Merge "Allow UiMode adb shell command to override night mode custom type. Add night mode custom type information in UiMode dumpsys." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5128c76995
@@ -1302,7 +1302,7 @@ final class UiModeManagerService extends SystemService {
|
|||||||
pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState);
|
pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState);
|
||||||
|
|
||||||
pw.print(" mNightMode="); pw.print(mNightMode); pw.print(" (");
|
pw.print(" mNightMode="); pw.print(mNightMode); pw.print(" (");
|
||||||
pw.print(Shell.nightModeToStr(mNightMode)); pw.print(") ");
|
pw.print(Shell.nightModeToStr(mNightMode, mNightModeCustomType)); pw.print(") ");
|
||||||
pw.print(" mOverrideOn/Off="); pw.print(mOverrideNightModeOn);
|
pw.print(" mOverrideOn/Off="); pw.print(mOverrideNightModeOn);
|
||||||
pw.print("/"); pw.print(mOverrideNightModeOff);
|
pw.print("/"); pw.print(mOverrideNightModeOff);
|
||||||
|
|
||||||
@@ -1917,7 +1917,8 @@ final class UiModeManagerService extends SystemService {
|
|||||||
public static final String NIGHT_MODE_STR_YES = "yes";
|
public static final String NIGHT_MODE_STR_YES = "yes";
|
||||||
public static final String NIGHT_MODE_STR_NO = "no";
|
public static final String NIGHT_MODE_STR_NO = "no";
|
||||||
public static final String NIGHT_MODE_STR_AUTO = "auto";
|
public static final String NIGHT_MODE_STR_AUTO = "auto";
|
||||||
public static final String NIGHT_MODE_STR_CUSTOM = "custom";
|
public static final String NIGHT_MODE_STR_CUSTOM_SCHEDULE = "custom_schedule";
|
||||||
|
public static final String NIGHT_MODE_STR_CUSTOM_BEDTIME = "custom_bedtime";
|
||||||
public static final String NIGHT_MODE_STR_UNKNOWN = "unknown";
|
public static final String NIGHT_MODE_STR_UNKNOWN = "unknown";
|
||||||
private final IUiModeManager mInterface;
|
private final IUiModeManager mInterface;
|
||||||
|
|
||||||
@@ -1931,7 +1932,7 @@ final class UiModeManagerService extends SystemService {
|
|||||||
pw.println("UiModeManager service (uimode) commands:");
|
pw.println("UiModeManager service (uimode) commands:");
|
||||||
pw.println(" help");
|
pw.println(" help");
|
||||||
pw.println(" Print this help text.");
|
pw.println(" Print this help text.");
|
||||||
pw.println(" night [yes|no|auto|custom]");
|
pw.println(" night [yes|no|auto|custom_schedule|custom_bedtime]");
|
||||||
pw.println(" Set or read night mode.");
|
pw.println(" Set or read night mode.");
|
||||||
pw.println(" car [yes|no]");
|
pw.println(" car [yes|no]");
|
||||||
pw.println(" Set or read car mode.");
|
pw.println(" Set or read car mode.");
|
||||||
@@ -2001,14 +2002,19 @@ final class UiModeManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int mode = strToNightMode(modeStr);
|
final int mode = strToNightMode(modeStr);
|
||||||
|
final int customType = strToNightModeCustomType(modeStr);
|
||||||
if (mode >= 0) {
|
if (mode >= 0) {
|
||||||
mInterface.setNightMode(mode);
|
mInterface.setNightMode(mode);
|
||||||
|
if (mode == UiModeManager.MODE_NIGHT_CUSTOM) {
|
||||||
|
mInterface.setNightModeCustomType(customType);
|
||||||
|
}
|
||||||
printCurrentNightMode();
|
printCurrentNightMode();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
err.println("Error: mode must be '" + NIGHT_MODE_STR_YES + "', '"
|
err.println("Error: mode must be '" + NIGHT_MODE_STR_YES + "', '"
|
||||||
+ NIGHT_MODE_STR_NO + "', or '" + NIGHT_MODE_STR_AUTO
|
+ NIGHT_MODE_STR_NO + "', or '" + NIGHT_MODE_STR_AUTO
|
||||||
+ "', or '" + NIGHT_MODE_STR_CUSTOM + "'");
|
+ "', or '" + NIGHT_MODE_STR_CUSTOM_SCHEDULE + "', or '"
|
||||||
|
+ NIGHT_MODE_STR_CUSTOM_BEDTIME + "'");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2016,11 +2022,12 @@ final class UiModeManagerService extends SystemService {
|
|||||||
private void printCurrentNightMode() throws RemoteException {
|
private void printCurrentNightMode() throws RemoteException {
|
||||||
final PrintWriter pw = getOutPrintWriter();
|
final PrintWriter pw = getOutPrintWriter();
|
||||||
final int currMode = mInterface.getNightMode();
|
final int currMode = mInterface.getNightMode();
|
||||||
final String currModeStr = nightModeToStr(currMode);
|
final int customType = mInterface.getNightModeCustomType();
|
||||||
|
final String currModeStr = nightModeToStr(currMode, customType);
|
||||||
pw.println("Night mode: " + currModeStr);
|
pw.println("Night mode: " + currModeStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String nightModeToStr(int mode) {
|
private static String nightModeToStr(int mode, int customType) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case UiModeManager.MODE_NIGHT_YES:
|
case UiModeManager.MODE_NIGHT_YES:
|
||||||
return NIGHT_MODE_STR_YES;
|
return NIGHT_MODE_STR_YES;
|
||||||
@@ -2029,7 +2036,12 @@ final class UiModeManagerService extends SystemService {
|
|||||||
case UiModeManager.MODE_NIGHT_AUTO:
|
case UiModeManager.MODE_NIGHT_AUTO:
|
||||||
return NIGHT_MODE_STR_AUTO;
|
return NIGHT_MODE_STR_AUTO;
|
||||||
case MODE_NIGHT_CUSTOM:
|
case MODE_NIGHT_CUSTOM:
|
||||||
return NIGHT_MODE_STR_CUSTOM;
|
if (customType == UiModeManager.MODE_NIGHT_CUSTOM_TYPE_SCHEDULE) {
|
||||||
|
return NIGHT_MODE_STR_CUSTOM_SCHEDULE;
|
||||||
|
}
|
||||||
|
if (customType == UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME) {
|
||||||
|
return NIGHT_MODE_STR_CUSTOM_BEDTIME;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return NIGHT_MODE_STR_UNKNOWN;
|
return NIGHT_MODE_STR_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -2043,13 +2055,25 @@ final class UiModeManagerService extends SystemService {
|
|||||||
return UiModeManager.MODE_NIGHT_NO;
|
return UiModeManager.MODE_NIGHT_NO;
|
||||||
case NIGHT_MODE_STR_AUTO:
|
case NIGHT_MODE_STR_AUTO:
|
||||||
return UiModeManager.MODE_NIGHT_AUTO;
|
return UiModeManager.MODE_NIGHT_AUTO;
|
||||||
case NIGHT_MODE_STR_CUSTOM:
|
case NIGHT_MODE_STR_CUSTOM_SCHEDULE:
|
||||||
|
case NIGHT_MODE_STR_CUSTOM_BEDTIME:
|
||||||
return UiModeManager.MODE_NIGHT_CUSTOM;
|
return UiModeManager.MODE_NIGHT_CUSTOM;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int strToNightModeCustomType(String customTypeStr) {
|
||||||
|
switch (customTypeStr) {
|
||||||
|
case NIGHT_MODE_STR_CUSTOM_BEDTIME:
|
||||||
|
return UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME;
|
||||||
|
case NIGHT_MODE_STR_CUSTOM_SCHEDULE:
|
||||||
|
return UiModeManager.MODE_NIGHT_CUSTOM_TYPE_SCHEDULE;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int handleCarMode() throws RemoteException {
|
private int handleCarMode() throws RemoteException {
|
||||||
final PrintWriter err = getErrPrintWriter();
|
final PrintWriter err = getErrPrintWriter();
|
||||||
final String modeStr = getNextArg();
|
final String modeStr = getNextArg();
|
||||||
|
|||||||
Reference in New Issue
Block a user