Merge "Revert "allow locking UI mode and block launching car dock for automotive""
This commit is contained in:
committed by
Android (Google) Code Review
commit
aa8b1c35ad
@@ -5529,8 +5529,6 @@ package android.app {
|
||||
method public void enableCarMode(int);
|
||||
method public int getCurrentModeType();
|
||||
method public int getNightMode();
|
||||
method public boolean isNightModeLocked();
|
||||
method public boolean isUiModeLocked();
|
||||
method public void setNightMode(int);
|
||||
field public static java.lang.String ACTION_ENTER_CAR_MODE;
|
||||
field public static java.lang.String ACTION_ENTER_DESK_MODE;
|
||||
|
||||
@@ -133,7 +133,6 @@ package android {
|
||||
field public static final java.lang.String MODIFY_AUDIO_ROUTING = "android.permission.MODIFY_AUDIO_ROUTING";
|
||||
field public static final java.lang.String MODIFY_AUDIO_SETTINGS = "android.permission.MODIFY_AUDIO_SETTINGS";
|
||||
field public static final java.lang.String MODIFY_CELL_BROADCASTS = "android.permission.MODIFY_CELL_BROADCASTS";
|
||||
field public static final java.lang.String MODIFY_DAY_NIGHT_MODE = "android.permission.MODIFY_DAY_NIGHT_MODE";
|
||||
field public static final java.lang.String MODIFY_NETWORK_ACCOUNTING = "android.permission.MODIFY_NETWORK_ACCOUNTING";
|
||||
field public static final java.lang.String MODIFY_PARENTAL_CONTROLS = "android.permission.MODIFY_PARENTAL_CONTROLS";
|
||||
field public static final java.lang.String MODIFY_PHONE_STATE = "android.permission.MODIFY_PHONE_STATE";
|
||||
@@ -5649,8 +5648,6 @@ package android.app {
|
||||
method public void enableCarMode(int);
|
||||
method public int getCurrentModeType();
|
||||
method public int getNightMode();
|
||||
method public boolean isNightModeLocked();
|
||||
method public boolean isUiModeLocked();
|
||||
method public void setNightMode(int);
|
||||
field public static java.lang.String ACTION_ENTER_CAR_MODE;
|
||||
field public static java.lang.String ACTION_ENTER_DESK_MODE;
|
||||
|
||||
@@ -51,14 +51,4 @@ interface IUiModeManager {
|
||||
* 2 for night, and 3 for automatic mode switching.
|
||||
*/
|
||||
int getNightMode();
|
||||
|
||||
/**
|
||||
* Tells if UI mode is locked or not.
|
||||
*/
|
||||
boolean isUiModeLocked();
|
||||
|
||||
/**
|
||||
* Tells if Night mode is locked or not.
|
||||
*/
|
||||
boolean isNightModeLocked();
|
||||
}
|
||||
|
||||
@@ -233,35 +233,4 @@ public class UiModeManager {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If UI mode is locked or not. When UI mode is locked, calls to change UI mode
|
||||
* like {@link #enableCarMode(int)} will silently fail.
|
||||
*/
|
||||
public boolean isUiModeLocked() {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.isUiModeLocked();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "isUiModeLocked: RemoteException", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If Night mode is locked or not. When Night mode is locked, changing Night mode
|
||||
* is only allowed to privileged system components and normal application's call
|
||||
* to change Night mode using {@link #setNightMode(int)} will silently fail.
|
||||
*/
|
||||
public boolean isNightModeLocked() {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.isNightModeLocked();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "isNightModeLocked: RemoteException", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2712,13 +2712,6 @@
|
||||
<permission android:name="android.permission.DISPATCH_NFC_MESSAGE"
|
||||
android:protectionLevel="signature|privileged" />
|
||||
|
||||
<!-- @SystemApi Allows changing day / night mode when system is configured with
|
||||
config_lockDayNightMode set to true. If requesting app does not have permission,
|
||||
it will be ignored.
|
||||
@hide -->
|
||||
<permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"
|
||||
android:protectionLevel="signature|privileged" />
|
||||
|
||||
<!-- The system process is explicitly the only one allowed to launch the
|
||||
confirmation UI for full backup/restore -->
|
||||
<uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>
|
||||
|
||||
@@ -716,13 +716,6 @@
|
||||
|
||||
<bool name="config_carDockEnablesAccelerometer">true</bool>
|
||||
|
||||
<!-- Control whether to launch Car dock home app when user presses home button or when
|
||||
car dock intent is fired.
|
||||
In mobile device, usually separate home app is expected in car mode, and this should be
|
||||
enabled. But in environments like real car, default home app may be enough, and in that
|
||||
case, this can be disabled (set to false). -->
|
||||
<bool name="config_enableCarDockHomeLaunch">true</bool>
|
||||
|
||||
<!-- HDMI behavior -->
|
||||
|
||||
<!-- The number of degrees to rotate the display when the device has HDMI connected
|
||||
@@ -740,15 +733,6 @@
|
||||
Any other values will have surprising consequences. -->
|
||||
<integer name="config_defaultUiModeType">1</integer>
|
||||
|
||||
<!-- Control whether to lock UI mode to what is selected from config_defaultUiModeType.
|
||||
Once UI mode is locked, applications cannot change it anymore. -->
|
||||
<bool name="config_lockUiMode">false</bool>
|
||||
|
||||
<!-- Control whether to lock day/night mode change from normal application. When it is
|
||||
true, day / night mode change is only allowed to apps with MODIFY_DAY_NIGHT_MODE
|
||||
permission. -->
|
||||
<bool name="config_lockDayNightMode">false</bool>
|
||||
|
||||
<!-- Control the default night mode to use when there is no other mode override set.
|
||||
One of the following values (see UiModeManager.java):
|
||||
0 - MODE_NIGHT_AUTO
|
||||
|
||||
@@ -1476,14 +1476,11 @@
|
||||
<java-symbol type="bool" name="config_carDockEnablesAccelerometer" />
|
||||
<java-symbol type="bool" name="config_deskDockEnablesAccelerometer" />
|
||||
<java-symbol type="bool" name="config_disableMenuKeyInLockScreen" />
|
||||
<java-symbol type="bool" name="config_enableCarDockHomeLaunch" />
|
||||
<java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
|
||||
<java-symbol type="bool" name="config_enableLockScreenRotation" />
|
||||
<java-symbol type="bool" name="config_enableLockScreenTranslucentDecor" />
|
||||
<java-symbol type="bool" name="config_enableTranslucentDecor" />
|
||||
<java-symbol type="bool" name="config_lidControlsSleep" />
|
||||
<java-symbol type="bool" name="config_lockDayNightMode" />
|
||||
<java-symbol type="bool" name="config_lockUiMode" />
|
||||
<java-symbol type="bool" name="config_reverseDefaultRotation" />
|
||||
<java-symbol type="bool" name="config_showNavigationBar" />
|
||||
<java-symbol type="bool" name="config_supportAutoRotation" />
|
||||
|
||||
@@ -57,6 +57,7 @@ final class UiModeManagerService extends SystemService {
|
||||
private static final boolean LOG = false;
|
||||
|
||||
// Enable launching of applications when entering the dock.
|
||||
private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true;
|
||||
private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = true;
|
||||
|
||||
final Object mLock = new Object();
|
||||
@@ -75,13 +76,6 @@ final class UiModeManagerService extends SystemService {
|
||||
private boolean mComputedNightMode;
|
||||
private int mCarModeEnableFlags;
|
||||
|
||||
// flag set by resource, whether to enable Car dock launch when starting car mode.
|
||||
private boolean mEnableCarDockLaunch = true;
|
||||
// flag set by resource, whether to lock UI mode to the default one or not.
|
||||
private boolean mUiModeLocked = false;
|
||||
// flag set by resource, whether to night mode change for normal all or not.
|
||||
private boolean mNightModeLocked = false;
|
||||
|
||||
int mCurUiMode = 0;
|
||||
private int mSetUiMode = 0;
|
||||
private boolean mHoldingConfiguration = false;
|
||||
@@ -182,10 +176,6 @@ final class UiModeManagerService extends SystemService {
|
||||
com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1);
|
||||
mDeskModeKeepsScreenOn = (res.getInteger(
|
||||
com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1);
|
||||
mEnableCarDockLaunch = res.getBoolean(
|
||||
com.android.internal.R.bool.config_enableCarDockHomeLaunch);
|
||||
mUiModeLocked = res.getBoolean(com.android.internal.R.bool.config_lockUiMode);
|
||||
mNightModeLocked = res.getBoolean(com.android.internal.R.bool.config_lockDayNightMode);
|
||||
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
mTelevision = pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
|
||||
@@ -209,10 +199,6 @@ final class UiModeManagerService extends SystemService {
|
||||
private final IBinder mService = new IUiModeManager.Stub() {
|
||||
@Override
|
||||
public void enableCarMode(int flags) {
|
||||
if (isUiModeLocked()) {
|
||||
Slog.e(TAG, "enableCarMode while UI mode is locked");
|
||||
return;
|
||||
}
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
@@ -228,10 +214,6 @@ final class UiModeManagerService extends SystemService {
|
||||
|
||||
@Override
|
||||
public void disableCarMode(int flags) {
|
||||
if (isUiModeLocked()) {
|
||||
Slog.e(TAG, "disableCarMode while UI mode is locked");
|
||||
return;
|
||||
}
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
@@ -259,13 +241,6 @@ final class UiModeManagerService extends SystemService {
|
||||
|
||||
@Override
|
||||
public void setNightMode(int mode) {
|
||||
if (isNightModeLocked() && (getContext().checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)
|
||||
!= PackageManager.PERMISSION_GRANTED)) {
|
||||
Slog.e(TAG,
|
||||
"Night mode locked, requires MODIFY_DAY_NIGHT_MODE permission");
|
||||
return;
|
||||
}
|
||||
switch (mode) {
|
||||
case UiModeManager.MODE_NIGHT_NO:
|
||||
case UiModeManager.MODE_NIGHT_YES:
|
||||
@@ -297,20 +272,6 @@ final class UiModeManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUiModeLocked() {
|
||||
synchronized (mLock) {
|
||||
return mUiModeLocked;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNightModeLocked() {
|
||||
synchronized (mLock) {
|
||||
return mNightModeLocked;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
if (getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
||||
@@ -332,13 +293,10 @@ final class UiModeManagerService extends SystemService {
|
||||
pw.print(" mDockState="); pw.print(mDockState);
|
||||
pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState);
|
||||
pw.print(" mNightMode="); pw.print(mNightMode);
|
||||
pw.print(" mNightModeLocked="); pw.print(mNightModeLocked);
|
||||
pw.print(" mCarModeEnabled="); pw.print(mCarModeEnabled);
|
||||
pw.print(" mComputedNightMode="); pw.print(mComputedNightMode);
|
||||
pw.print(" mCarModeEnableFlags="); pw.print(mCarModeEnableFlags);
|
||||
pw.print(" mEnableCarDockLaunch="); pw.println(mEnableCarDockLaunch);
|
||||
pw.print(" mCarModeEnableFlags="); pw.println(mCarModeEnableFlags);
|
||||
pw.print(" mCurUiMode=0x"); pw.print(Integer.toHexString(mCurUiMode));
|
||||
pw.print(" mUiModeLocked="); pw.print(mUiModeLocked);
|
||||
pw.print(" mSetUiMode=0x"); pw.println(Integer.toHexString(mSetUiMode));
|
||||
pw.print(" mHoldingConfiguration="); pw.print(mHoldingConfiguration);
|
||||
pw.print(" mSystemReady="); pw.println(mSystemReady);
|
||||
@@ -398,9 +356,7 @@ final class UiModeManagerService extends SystemService {
|
||||
|
||||
private void updateConfigurationLocked() {
|
||||
int uiMode = mDefaultUiModeType;
|
||||
if (mUiModeLocked) {
|
||||
// no-op, keeps default one
|
||||
} else if (mTelevision) {
|
||||
if (mTelevision) {
|
||||
uiMode = Configuration.UI_MODE_TYPE_TELEVISION;
|
||||
} else if (mWatch) {
|
||||
uiMode = Configuration.UI_MODE_TYPE_WATCH;
|
||||
@@ -504,7 +460,7 @@ final class UiModeManagerService extends SystemService {
|
||||
} else {
|
||||
String category = null;
|
||||
if (mCarModeEnabled) {
|
||||
if (mEnableCarDockLaunch
|
||||
if (ENABLE_LAUNCH_CAR_DOCK_APP
|
||||
&& (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
|
||||
category = Intent.CATEGORY_CAR_DOCK;
|
||||
}
|
||||
@@ -547,7 +503,7 @@ final class UiModeManagerService extends SystemService {
|
||||
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
|
||||
if (ENABLE_LAUNCH_CAR_DOCK_APP
|
||||
&& (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
|
||||
category = Intent.CATEGORY_CAR_DOCK;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
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;
|
||||
// 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 SHORT_PRESS_POWER_NOTHING = 0;
|
||||
@@ -316,10 +317,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
int[] mNavigationBarHeightForRotation = new int[4];
|
||||
int[] mNavigationBarWidthForRotation = new int[4];
|
||||
|
||||
// Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key.
|
||||
// This is for car dock and this is updated from resource.
|
||||
private boolean mEnableCarDockHomeCapture = true;
|
||||
|
||||
boolean mBootMessageNeedsHiding;
|
||||
KeyguardServiceDelegate mKeyguardDelegate;
|
||||
final Runnable mWindowManagerDrawCallback = new Runnable() {
|
||||
@@ -1402,8 +1399,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mHomeIntent.addCategory(Intent.CATEGORY_HOME);
|
||||
mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
mEnableCarDockHomeCapture = context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_enableCarDockHomeLaunch);
|
||||
mCarDockIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK);
|
||||
mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
@@ -6407,7 +6402,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
* true:
|
||||
* <ul>
|
||||
* <li>The device is not in either car mode or desk mode
|
||||
* <li>The device is in car mode but mEnableCarDockHomeCapture is false
|
||||
* <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
|
||||
@@ -6421,7 +6416,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
// 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 (mEnableCarDockHomeCapture) {
|
||||
if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
|
||||
intent = mCarDockIntent;
|
||||
}
|
||||
} else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
|
||||
@@ -6941,7 +6936,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation);
|
||||
pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode);
|
||||
pw.print(" mDockMode="); pw.print(mDockMode);
|
||||
pw.print(" mEnableCarDockHomeCapture="); pw.print(mEnableCarDockHomeCapture);
|
||||
pw.print(" mCarDockRotation="); pw.print(mCarDockRotation);
|
||||
pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation);
|
||||
pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode);
|
||||
|
||||
Reference in New Issue
Block a user