Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +93 −2 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.policy.impl; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.ActivityManagerNative; import android.app.AppOpsManager; import android.app.AppOpsManager; import android.app.IUiModeManager; import android.app.ProgressDialog; import android.app.ProgressDialog; import android.app.SearchManager; import android.app.SearchManager; import android.app.UiModeManager; import android.app.UiModeManager; Loading @@ -31,6 +32,7 @@ import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.ServiceConnection; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.CompatibilityInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources; Loading Loading @@ -125,6 +127,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean SHOW_STARTING_ANIMATIONS = true; static final boolean SHOW_STARTING_ANIMATIONS = true; static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. // No longer recommended for desk docks; still useful in car docks. static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; static final int LONG_PRESS_POWER_NOTHING = 0; static final int LONG_PRESS_POWER_NOTHING = 0; static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; static final int LONG_PRESS_POWER_SHUT_OFF = 2; static final int LONG_PRESS_POWER_SHUT_OFF = 2; Loading Loading @@ -247,6 +254,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mSystemReady; boolean mSystemReady; boolean mSystemBooted; boolean mSystemBooted; boolean mHdmiPlugged; boolean mHdmiPlugged; int mUiMode; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; int mLidOpenRotation; int mLidOpenRotation; int mCarDockRotation; int mCarDockRotation; Loading Loading @@ -832,6 +840,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mSettingsObserver.observe(); mSettingsObserver.observe(); mShortcutManager = new ShortcutManager(context, mHandler); mShortcutManager = new ShortcutManager(context, mHandler); mShortcutManager.observe(); mShortcutManager.observe(); mUiMode = context.getResources().getInteger( com.android.internal.R.integer.config_defaultUiModeType); mHomeIntent = new Intent(Intent.ACTION_MAIN, null); mHomeIntent = new Intent(Intent.ACTION_MAIN, null); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK Loading Loading @@ -3951,6 +3961,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED); 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(true); updateRotation(true); synchronized (mLock) { synchronized (mLock) { Loading Loading @@ -4587,9 +4604,70 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } /** * Return an Intent to launch the currently active dock app as home. Returns * null if the standard home should be launched, which is the case if any of the following is * true: * <ul> * <li>The device is not in either car mode or desk mode * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME * </ul> * @return */ Intent createHomeDockIntent() { Intent intent = null; // 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) { if (ENABLE_CAR_DOCK_HOME_CAPTURE) { intent = mCarDockIntent; } } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { if (ENABLE_DESK_DOCK_HOME_CAPTURE) { intent = mDeskDockIntent; } } if (intent == null) { return null; } ActivityInfo ai = null; ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( intent, PackageManager.MATCH_DEFAULT_ONLY, UserHandle.USER_CURRENT); if (info != null) { ai = info.activityInfo; } if (ai != null && ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { intent = new Intent(intent); intent.setClassName(ai.packageName, ai.name); return intent; } return null; } void startDockOrHome() { void startDockOrHome() { awakenDreams(); awakenDreams(); // We don't have dock home anymore. Home is home. If you lived here, you'd be home by now. Intent dock = createHomeDockIntent(); if (dock != null) { try { mContext.startActivityAsUser(dock, UserHandle.CURRENT); return; } catch (ActivityNotFoundException e) { } } mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); } } Loading @@ -4616,6 +4694,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { } else { ActivityManagerNative.getDefault().stopAppSwitches(); ActivityManagerNative.getDefault().stopAppSwitches(); sendCloseSystemWindows(); sendCloseSystemWindows(); Intent dock = createHomeDockIntent(); if (dock != null) { int result = ActivityManagerNative.getDefault() .startActivityAsUser(null, null, dock, dock.resolveTypeIfNeeded(mContext.getContentResolver()), null, null, 0, ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null, null, UserHandle.USER_CURRENT); if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { return false; } } } } int result = ActivityManagerNative.getDefault() int result = ActivityManagerNative.getDefault() .startActivityAsUser(null, null, mHomeIntent, .startActivityAsUser(null, null, mHomeIntent, Loading Loading @@ -4844,7 +4934,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.println(mLastFocusNeedsMenu); pw.println(mLastFocusNeedsMenu); } } pw.print(prefix); pw.print("mDockMode="); pw.print(mDockMode); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); Loading Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +93 −2 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.policy.impl; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.ActivityManagerNative; import android.app.AppOpsManager; import android.app.AppOpsManager; import android.app.IUiModeManager; import android.app.ProgressDialog; import android.app.ProgressDialog; import android.app.SearchManager; import android.app.SearchManager; import android.app.UiModeManager; import android.app.UiModeManager; Loading @@ -31,6 +32,7 @@ import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.ServiceConnection; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.CompatibilityInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources; Loading Loading @@ -125,6 +127,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean SHOW_STARTING_ANIMATIONS = true; static final boolean SHOW_STARTING_ANIMATIONS = true; static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. // No longer recommended for desk docks; still useful in car docks. static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; static final int LONG_PRESS_POWER_NOTHING = 0; static final int LONG_PRESS_POWER_NOTHING = 0; static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; static final int LONG_PRESS_POWER_SHUT_OFF = 2; static final int LONG_PRESS_POWER_SHUT_OFF = 2; Loading Loading @@ -247,6 +254,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mSystemReady; boolean mSystemReady; boolean mSystemBooted; boolean mSystemBooted; boolean mHdmiPlugged; boolean mHdmiPlugged; int mUiMode; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; int mLidOpenRotation; int mLidOpenRotation; int mCarDockRotation; int mCarDockRotation; Loading Loading @@ -832,6 +840,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mSettingsObserver.observe(); mSettingsObserver.observe(); mShortcutManager = new ShortcutManager(context, mHandler); mShortcutManager = new ShortcutManager(context, mHandler); mShortcutManager.observe(); mShortcutManager.observe(); mUiMode = context.getResources().getInteger( com.android.internal.R.integer.config_defaultUiModeType); mHomeIntent = new Intent(Intent.ACTION_MAIN, null); mHomeIntent = new Intent(Intent.ACTION_MAIN, null); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK Loading Loading @@ -3951,6 +3961,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED); 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(true); updateRotation(true); synchronized (mLock) { synchronized (mLock) { Loading Loading @@ -4587,9 +4604,70 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } /** * Return an Intent to launch the currently active dock app as home. Returns * null if the standard home should be launched, which is the case if any of the following is * true: * <ul> * <li>The device is not in either car mode or desk mode * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME * </ul> * @return */ Intent createHomeDockIntent() { Intent intent = null; // 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) { if (ENABLE_CAR_DOCK_HOME_CAPTURE) { intent = mCarDockIntent; } } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { if (ENABLE_DESK_DOCK_HOME_CAPTURE) { intent = mDeskDockIntent; } } if (intent == null) { return null; } ActivityInfo ai = null; ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( intent, PackageManager.MATCH_DEFAULT_ONLY, UserHandle.USER_CURRENT); if (info != null) { ai = info.activityInfo; } if (ai != null && ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { intent = new Intent(intent); intent.setClassName(ai.packageName, ai.name); return intent; } return null; } void startDockOrHome() { void startDockOrHome() { awakenDreams(); awakenDreams(); // We don't have dock home anymore. Home is home. If you lived here, you'd be home by now. Intent dock = createHomeDockIntent(); if (dock != null) { try { mContext.startActivityAsUser(dock, UserHandle.CURRENT); return; } catch (ActivityNotFoundException e) { } } mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); } } Loading @@ -4616,6 +4694,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { } else { ActivityManagerNative.getDefault().stopAppSwitches(); ActivityManagerNative.getDefault().stopAppSwitches(); sendCloseSystemWindows(); sendCloseSystemWindows(); Intent dock = createHomeDockIntent(); if (dock != null) { int result = ActivityManagerNative.getDefault() .startActivityAsUser(null, null, dock, dock.resolveTypeIfNeeded(mContext.getContentResolver()), null, null, 0, ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null, null, UserHandle.USER_CURRENT); if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { return false; } } } } int result = ActivityManagerNative.getDefault() int result = ActivityManagerNative.getDefault() .startActivityAsUser(null, null, mHomeIntent, .startActivityAsUser(null, null, mHomeIntent, Loading Loading @@ -4844,7 +4934,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.print(prefix); pw.print("mLastFocusNeedsMenu="); pw.println(mLastFocusNeedsMenu); pw.println(mLastFocusNeedsMenu); } } pw.print(prefix); pw.print("mDockMode="); pw.print(mDockMode); pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); pw.print(" mDockMode="); pw.print(mDockMode); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); Loading