diff options
author | jt1134 <jt1134@gmail.com> | 2013-02-15 22:36:27 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-03-06 00:13:35 -0800 |
commit | 45a13a4c7369e85537275515597a5d20e82ec9e7 (patch) | |
tree | 3f180cc9d6fb1272b4d444eaddca2fc25544a650 /policy | |
parent | d5c23fe5f24d239920b9a59ceed00a78de4de0c6 (diff) | |
download | frameworks_base-45a13a4c7369e85537275515597a5d20e82ec9e7.zip frameworks_base-45a13a4c7369e85537275515597a5d20e82ec9e7.tar.gz frameworks_base-45a13a4c7369e85537275515597a5d20e82ec9e7.tar.bz2 |
Revert "Remove dock home support."
This reverts commit 7c135205f2f4c192299ad0215276e9e481bccaa5.
Conflicts:
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Change-Id: I9b2c4eebaab87a669b42681e70ec5324dadf7f6d
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 88 |
1 files changed, 86 insertions, 2 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 0504b6d..635d1ec 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -21,6 +21,7 @@ import android.app.ActivityManager; import android.app.ActivityManager.RunningAppProcessInfo; import android.app.ActivityManagerNative; import android.app.IActivityManager; +import android.app.IUiModeManager; import android.app.ProgressDialog; import android.app.SearchManager; import android.app.UiModeManager; @@ -188,6 +189,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean SHOW_STARTING_ANIMATIONS = true; 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_GLOBAL_ACTIONS = 1; static final int LONG_PRESS_POWER_SHUT_OFF = 2; @@ -333,6 +339,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mSystemBooted; boolean mHdmiPlugged; boolean mWifiDisplayConnected; + int mUiMode; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; int mLidOpenRotation; boolean mHasRemovableLid; @@ -1112,6 +1119,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mSettingsObserver.observe(); mShortcutManager = new ShortcutManager(context, mHandler); mShortcutManager.observe(); + mUiMode = context.getResources().getInteger( + com.android.internal.R.integer.config_defaultUiModeType); mHomeIntent = new Intent(Intent.ACTION_MAIN, null); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK @@ -4253,6 +4262,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { 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(true); updateOrientationListenerLp(); @@ -4915,8 +4931,63 @@ 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 = intent.resolveActivityInfo( + mContext.getPackageManager(), PackageManager.GET_META_DATA); + if (ai == null) { + return null; + } + + if (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() { - // 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.startActivity(dock); + return; + } catch (ActivityNotFoundException e) { + } + } mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); } @@ -4943,6 +5014,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { ActivityManagerNative.getDefault().stopAppSwitches(); sendCloseSystemWindows(); + Intent dock = createHomeDockIntent(); + if (dock != null) { + int result = ActivityManagerNative.getDefault() + .startActivityAsUser(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() .startActivityAsUser(null, mHomeIntent, @@ -5153,7 +5236,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(prefix); pw.print("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(" mDeskDockRotation="); pw.println(mDeskDockRotation); pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |