summaryrefslogtreecommitdiffstats
path: root/policy/com/android
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-04-29 13:28:56 -0700
committerDianne Hackborn <hackbod@google.com>2010-04-29 16:50:14 -0700
commit867ab64714afd080dcd6113ef57acab66e11863f (patch)
tree83a9422074d4ca06080d4b5c7b6642c2b38cbe38 /policy/com/android
parent8abcce1f7b29a4f759d85c72f3f9e5183a5fe902 (diff)
downloadframeworks_base-867ab64714afd080dcd6113ef57acab66e11863f.zip
frameworks_base-867ab64714afd080dcd6113ef57acab66e11863f.tar.gz
frameworks_base-867ab64714afd080dcd6113ef57acab66e11863f.tar.bz2
Integrate a bunch of stuff from Froyo:
Fix issue #2574016: Preferred activity setting is not persistent 14/48014/1 author Dianne Hackborn <hackbod@google.com> Wed, 7 Apr 2010 03:24:15 +0000 (20:24 -0700) committer Dianne Hackborn <hackbod@google.com> Wed, 7 Apr 2010 03:24:15 +0000 (20:24 -0700) commit 3cce600614c2a2643ae9a38c6ed87c06c7bab0b6 tree 394f330634ab83a97b244fbd214d5edbbd44fa52 tree | snapshot parent 7d8866f9ef026870d4735d6f2ede49525150e53e commit | diff Fix issue #2574016: Preferred activity setting is not persistent The recent tasks UI was trying to retrieve the current home activity in the wrong way, causing it to be a different match of activities and thus clearing any preferred activity that was set. In the future we should look at what the package manager is doing here and make it more robust in how it clears the list... but for now, this is the safest thing. Change-Id: Idc917dffa7d05d62671213414387e8bdb2e34bea Fix issue #2555171: Switching to app immediately after unmounting SD card causes... 28/48128/1 author Dianne Hackborn <hackbod@google.com> Thu, 8 Apr 2010 01:15:32 +0000 (18:15 -0700) committer Dianne Hackborn <hackbod@google.com> Thu, 8 Apr 2010 01:15:32 +0000 (18:15 -0700) commit 31abd7f677190edfa67cb96fb4ddb166e974cb3e tree 7cc1059c3c6689ba3f2af5161585b3e7241e0580 tree | snapshot parent 3cce600614c2a2643ae9a38c6ed87c06c7bab0b6 commit | diff Fix issue #2555171: Switching to app immediately after unmounting SD card causes reboot. Change-Id: I509162e136dd721fecfaabc45a046537b2d19077 Fix issue #2586349: Accelerometer is enabled when in car mode 61/48361/1 author Dianne Hackborn <hackbod@google.com> Fri, 9 Apr 2010 23:40:33 +0000 (16:40 -0700) committer Dianne Hackborn <hackbod@google.com> Fri, 9 Apr 2010 23:40:33 +0000 (16:40 -0700) commit b0d3a2371f92d19d01aa2ca8e4f382738273f2dd tree e134d055ce8efb4ef48a74c45da0325ed55852ea tree | snapshot parent eeb2497f92b8d1466918990d536e2d31b5a85c07 commit | diff Fix issue #2586349: Accelerometer is enabled when in car mode Change-Id: Iab5ca4ea9f69bd54f815fc7463df808d81c61ffd Fix issue #2555171: Switching to app immediately after unmounting... 65/48665/1 dalvik-dev froyo froyo-plus-aosp froyo-release stage-korg-froyo stage-korg-master author Dianne Hackborn <hackbod@google.com> Tue, 13 Apr 2010 19:48:30 +0000 (12:48 -0700) committer Dianne Hackborn <hackbod@google.com> Tue, 13 Apr 2010 19:52:10 +0000 (12:52 -0700) commit cddfd77b45662d7316aaed3d0159d0f42d284cfc tree c52d612ada1f85d3d38b3e776bc520b7a0b22256 tree | snapshot parent 5fa04b55a94b5cd98f1e6e1197cc4e6ef26a7061 commit | diff Fix issue #2555171: Switching to app immediately after unmounting... ...SD card causes reboot. Deal with unavailable apps in recent tasks UI. Change-Id: Ib85b773c5c6df7afb12db551b6cef63edbc6df64
Diffstat (limited to 'policy/com/android')
-rwxr-xr-xpolicy/com/android/internal/policy/impl/PhoneWindowManager.java151
-rw-r--r--policy/com/android/internal/policy/impl/RecentApplicationsDialog.java22
2 files changed, 100 insertions, 73 deletions
diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/com/android/internal/policy/impl/PhoneWindowManager.java
index cfdce5a..a7c278b 100755
--- a/policy/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -202,6 +202,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mSystemReady;
boolean mLidOpen;
int mUiMode = Configuration.UI_MODE_TYPE_NORMAL;
+ int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED;
int mLidOpenRotation;
int mCarDockRotation;
int mDeskDockRotation;
@@ -340,8 +341,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return true;
}
// We're in a dock that has a rotation affinity, an the app is willing to rotate.
- if ((mCarDockEnablesAccelerometer && mUiMode == Configuration.UI_MODE_TYPE_CAR)
- || (mDeskDockEnablesAccelerometer && mUiMode == Configuration.UI_MODE_TYPE_DESK)) {
+ if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR)
+ || (mDeskDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_DESK)) {
// Note we override the nosensor flag here.
if (appOrientation == ActivityInfo.SCREEN_ORIENTATION_USER
|| appOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
@@ -364,8 +365,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// orientation, then we need to turn the sensor or.
return true;
}
- if ((mCarDockEnablesAccelerometer && mUiMode == Configuration.UI_MODE_TYPE_CAR) ||
- (mDeskDockEnablesAccelerometer && mUiMode == Configuration.UI_MODE_TYPE_DESK)) {
+ if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) ||
+ (mDeskDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_DESK)) {
// enable accelerometer if we are docked in a dock that enables accelerometer
// orientation management,
return true;
@@ -526,7 +527,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE);
filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE);
filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE);
- context.registerReceiver(mDockReceiver, filter);
+ filter.addAction(Intent.ACTION_DOCK_EVENT);
+ Intent intent = context.registerReceiver(mDockReceiver, filter);
+ if (intent != null) {
+ // Retrieve current sticky dock event broadcast.
+ mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
+ Intent.EXTRA_DOCK_STATE_UNDOCKED);
+ }
mVibrator = new Vibrator();
mLongPressVibePattern = getLongIntArray(mContext.getResources(),
com.android.internal.R.array.config_longPressVibePattern);
@@ -829,59 +836,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;
- }
-
- 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);
+ 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);
- try {
WindowManagerImpl wm = (WindowManagerImpl)
context.getSystemService(Context.WINDOW_SERVICE);
View view = win.getDecorView();
@@ -909,6 +916,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;
@@ -1973,11 +1985,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
BroadcastReceiver mDockReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
- try {
- IUiModeManager uiModeService = IUiModeManager.Stub.asInterface(
- ServiceManager.getService(Context.UI_MODE_SERVICE));
- mUiMode = uiModeService.getCurrentModeType();
- } catch (RemoteException e) {
+ if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) {
+ mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
+ Intent.EXTRA_DOCK_STATE_UNDOCKED);
+ } else {
+ try {
+ IUiModeManager uiModeService = IUiModeManager.Stub.asInterface(
+ ServiceManager.getService(Context.UI_MODE_SERVICE));
+ mUiMode = uiModeService.getCurrentModeType();
+ } catch (RemoteException e) {
+ }
}
updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
updateOrientationListenerLp();
@@ -2106,9 +2123,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
//or case.unspecified
if (mLidOpen) {
return mLidOpenRotation;
- } else if (mUiMode == Configuration.UI_MODE_TYPE_CAR && mCarDockRotation >= 0) {
+ } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
return mCarDockRotation;
- } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK && mDeskDockRotation >= 0) {
+ } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
return mDeskDockRotation;
} else {
if (useSensorForOrientationLp(orientation)) {
@@ -2220,9 +2237,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int rotation = Surface.ROTATION_0;
if (mLidOpen) {
rotation = mLidOpenRotation;
- } else if (mUiMode == Configuration.UI_MODE_TYPE_CAR && mCarDockRotation >= 0) {
+ } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
rotation = mCarDockRotation;
- } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK && mDeskDockRotation >= 0) {
+ } else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
rotation = mDeskDockRotation;
}
//if lid is closed orientation will be portrait
@@ -2242,6 +2259,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
*/
Intent createHomeDockIntent() {
Intent intent;
+
+ // What home does is based on the mode, not the dock state. That
+ // is, when in car mode you should be taken to car home regardless
+ // of whether we are actually in a car dock.
if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
intent = mCarDockIntent;
} else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
diff --git a/policy/com/android/internal/policy/impl/RecentApplicationsDialog.java b/policy/com/android/internal/policy/impl/RecentApplicationsDialog.java
index 8287253..9608b9a 100644
--- a/policy/com/android/internal/policy/impl/RecentApplicationsDialog.java
+++ b/policy/com/android/internal/policy/impl/RecentApplicationsDialog.java
@@ -19,6 +19,7 @@ package com.android.internal.policy.impl;
import android.app.ActivityManager;
import android.app.Dialog;
import android.app.StatusBarManager;
+import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -29,6 +30,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
@@ -117,7 +119,11 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
Intent intent = (Intent)b.getTag();
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
- getContext().startActivity(intent);
+ try {
+ getContext().startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Log.w("Recent", "Unable to launch recent task", e);
+ }
}
break;
}
@@ -169,13 +175,13 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
final Context context = getContext();
final PackageManager pm = context.getPackageManager();
final ActivityManager am = (ActivityManager)
- context.getSystemService(Context.ACTIVITY_SERVICE);
+ context.getSystemService(Context.ACTIVITY_SERVICE);
final List<ActivityManager.RecentTaskInfo> recentTasks =
- am.getRecentTasks(MAX_RECENT_TASKS, 0);
+ am.getRecentTasks(MAX_RECENT_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
- ResolveInfo homeInfo = pm.resolveActivity(
- new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME),
- 0);
+ ActivityInfo homeInfo =
+ new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)
+ .resolveActivityInfo(pm, 0);
IconUtilities iconUtilities = new IconUtilities(getContext());
@@ -197,9 +203,9 @@ public class RecentApplicationsDialog extends Dialog implements OnClickListener
// Skip the current home activity.
if (homeInfo != null) {
- if (homeInfo.activityInfo.packageName.equals(
+ if (homeInfo.packageName.equals(
intent.getComponent().getPackageName())
- && homeInfo.activityInfo.name.equals(
+ && homeInfo.name.equals(
intent.getComponent().getClassName())) {
continue;
}