Java Code Examples for android.app.UiModeManager#DISABLE_CAR_MODE_GO_HOME
The following examples show how to use
android.app.UiModeManager#DISABLE_CAR_MODE_GO_HOME .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UiModeManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void updateAfterBroadcastLocked(String action, int enableFlags, int disableFlags) { // Launch a dock activity String category = null; if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(action)) { // Only launch car home when car mode is enabled and the caller // has asked us to switch to it. if (mEnableCarDockLaunch && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { category = Intent.CATEGORY_CAR_DOCK; } } else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(action)) { // Only launch car home when desk mode is enabled and the caller // has asked us to switch to it. Currently re-using the car // mode flag since we don't have a formal API for "desk mode". if (ENABLE_LAUNCH_DESK_DOCK_APP && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { category = Intent.CATEGORY_DESK_DOCK; } } else { // Launch the standard home app if requested. if ((disableFlags & UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { category = Intent.CATEGORY_HOME; } } if (LOG) { Slog.v(TAG, String.format( "Handling broadcast result for action %s: enable=0x%08x, disable=0x%08x, " + "category=%s", action, enableFlags, disableFlags, category)); } sendConfigurationAndStartDreamOrDockAppLocked(category); }
Example 2
Source File: UiModeManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void updateLocked(int enableFlags, int disableFlags) { String action = null; String oldAction = null; if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_CAR) { adjustStatusBarCarModeLocked(); oldAction = UiModeManager.ACTION_EXIT_CAR_MODE; } else if (isDeskDockState(mLastBroadcastState)) { oldAction = UiModeManager.ACTION_EXIT_DESK_MODE; } if (mCarModeEnabled) { if (mLastBroadcastState != Intent.EXTRA_DOCK_STATE_CAR) { adjustStatusBarCarModeLocked(); if (oldAction != null) { sendForegroundBroadcastToAllUsers(oldAction); } mLastBroadcastState = Intent.EXTRA_DOCK_STATE_CAR; action = UiModeManager.ACTION_ENTER_CAR_MODE; } } else if (isDeskDockState(mDockState)) { if (!isDeskDockState(mLastBroadcastState)) { if (oldAction != null) { sendForegroundBroadcastToAllUsers(oldAction); } mLastBroadcastState = mDockState; action = UiModeManager.ACTION_ENTER_DESK_MODE; } } else { mLastBroadcastState = Intent.EXTRA_DOCK_STATE_UNDOCKED; action = oldAction; } if (action != null) { if (LOG) { Slog.v(TAG, String.format( "updateLocked: preparing broadcast: action=%s enable=0x%08x disable=0x%08x", action, enableFlags, disableFlags)); } // Send the ordered broadcast; the result receiver will receive after all // broadcasts have been sent. If any broadcast receiver changes the result // code from the initial value of RESULT_OK, then the result receiver will // not launch the corresponding dock application. This gives apps a chance // to override the behavior and stay in their app even when the device is // placed into a dock. Intent intent = new Intent(action); intent.putExtra("enableFlags", enableFlags); intent.putExtra("disableFlags", disableFlags); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); getContext().sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null, mResultReceiver, null, Activity.RESULT_OK, null, null); // Attempting to make this transition a little more clean, we are going // to hold off on doing a configuration change until we have finished // the broadcast and started the home activity. mHoldingConfiguration = true; updateConfigurationLocked(); } else { String category = null; if (mCarModeEnabled) { if (mEnableCarDockLaunch && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { category = Intent.CATEGORY_CAR_DOCK; } } else if (isDeskDockState(mDockState)) { if (ENABLE_LAUNCH_DESK_DOCK_APP && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { category = Intent.CATEGORY_DESK_DOCK; } } else { if ((disableFlags & UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { category = Intent.CATEGORY_HOME; } } if (LOG) { Slog.v(TAG, "updateLocked: null action, mDockState=" + mDockState +", category=" + category); } sendConfigurationAndStartDreamOrDockAppLocked(category); } // keep screen on when charging and in car mode boolean keepScreenOn = mCharging && ((mCarModeEnabled && mCarModeKeepsScreenOn && (mCarModeEnableFlags & UiModeManager.ENABLE_CAR_MODE_ALLOW_SLEEP) == 0) || (mCurUiMode == Configuration.UI_MODE_TYPE_DESK && mDeskModeKeepsScreenOn)); if (keepScreenOn != mWakeLock.isHeld()) { if (keepScreenOn) { mWakeLock.acquire(); } else { mWakeLock.release(); } } }