summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-04-07 18:15:32 -0700
committerDianne Hackborn <hackbod@google.com>2010-04-07 18:15:32 -0700
commit31abd7f677190edfa67cb96fb4ddb166e974cb3e (patch)
tree7cc1059c3c6689ba3f2af5161585b3e7241e0580
parent3cce600614c2a2643ae9a38c6ed87c06c7bab0b6 (diff)
downloadbase-31abd7f677190edfa67cb96fb4ddb166e974cb3e.tar.gz
Fix issue #2555171: Switching to app immediately after unmounting SD card causes reboot.
Change-Id: I509162e136dd721fecfaabc45a046537b2d19077
-rwxr-xr-xphone/com/android/internal/policy/impl/PhoneWindowManager.java107
1 files changed, 56 insertions, 51 deletions
diff --git a/phone/com/android/internal/policy/impl/PhoneWindowManager.java b/phone/com/android/internal/policy/impl/PhoneWindowManager.java
index cfdce5a..ac09744 100755
--- a/phone/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/phone/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -829,59 +829,59 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return null;
}
- Context context = mContext;
- boolean setTheme = false;
- //Log.i(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel="
- // + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
- if (theme != 0 || labelRes != 0) {
- try {
- context = context.createPackageContext(packageName, 0);
- if (theme != 0) {
- context.setTheme(theme);
- setTheme = true;
- }
- } catch (PackageManager.NameNotFoundException e) {
- // Ignore
+ try {
+ Context context = mContext;
+ boolean setTheme = false;
+ //Log.i(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel="
+ // + nonLocalizedLabel + " theme=" + Integer.toHexString(theme));
+ if (theme != 0 || labelRes != 0) {
+ try {
+ context = context.createPackageContext(packageName, 0);
+ if (theme != 0) {
+ context.setTheme(theme);
+ setTheme = true;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ // Ignore
+ }
+ }
+ if (!setTheme) {
+ context.setTheme(com.android.internal.R.style.Theme);
+ }
+
+ Window win = PolicyManager.makeNewWindow(context);
+ if (win.getWindowStyle().getBoolean(
+ com.android.internal.R.styleable.Window_windowDisablePreview, false)) {
+ return null;
}
- }
- if (!setTheme) {
- context.setTheme(com.android.internal.R.style.Theme);
- }
-
- Window win = PolicyManager.makeNewWindow(context);
- if (win.getWindowStyle().getBoolean(
- com.android.internal.R.styleable.Window_windowDisablePreview, false)) {
- return null;
- }
-
- Resources r = context.getResources();
- win.setTitle(r.getText(labelRes, nonLocalizedLabel));
-
- win.setType(
- WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
- // Force the window flags: this is a fake window, so it is not really
- // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM
- // flag because we do know that the next window will take input
- // focus, so we want to get the IME window up on top of us right away.
- win.setFlags(
- WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
- WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
- WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
- WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
- WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
- WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
-
- win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
- WindowManager.LayoutParams.MATCH_PARENT);
-
- final WindowManager.LayoutParams params = win.getAttributes();
- params.token = appToken;
- params.packageName = packageName;
- params.windowAnimations = win.getWindowStyle().getResourceId(
- com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
- params.setTitle("Starting " + packageName);
+
+ Resources r = context.getResources();
+ win.setTitle(r.getText(labelRes, nonLocalizedLabel));
+
+ win.setType(
+ WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
+ // Force the window flags: this is a fake window, so it is not really
+ // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM
+ // flag because we do know that the next window will take input
+ // focus, so we want to get the IME window up on top of us right away.
+ win.setFlags(
+ WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
+ WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
+ WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
+ WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
+
+ win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.MATCH_PARENT);
+
+ final WindowManager.LayoutParams params = win.getAttributes();
+ params.token = appToken;
+ params.packageName = packageName;
+ params.windowAnimations = win.getWindowStyle().getResourceId(
+ com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
+ params.setTitle("Starting " + packageName);
- try {
WindowManagerImpl wm = (WindowManagerImpl)
context.getSystemService(Context.WINDOW_SERVICE);
View view = win.getDecorView();
@@ -909,6 +909,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} catch (WindowManagerImpl.BadTokenException e) {
// ignore
Log.w(TAG, appToken + " already running, starting window not displayed");
+ } catch (RuntimeException e) {
+ // don't crash if something else bad happens, for example a
+ // failure loading resources because we are loading from an app
+ // on external storage that has been unmounted.
+ Log.w(TAG, appToken + " failed creating starting window", e);
}
return null;