Skip to content

Commit 7c0fda8

Browse files
committed
Merge branch '5.1' of https://github.com/Team-Radium/frameworks_base into 5.1
Signed-off-by: W4TCH0UT <[email protected]> Conflicts: packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
2 parents da30bb6 + 6e61e9f commit 7c0fda8

File tree

75 files changed

+1339
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1339
-44
lines changed

api/current.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9166,6 +9166,10 @@ package android.content.res {
91669166
field public static final int UI_MODE_TYPE_TELEVISION = 4; // 0x4
91679167
field public static final int UI_MODE_TYPE_UNDEFINED = 0; // 0x0
91689168
field public static final int UI_MODE_TYPE_WATCH = 6; // 0x6
9169+
field public static final int UI_THEME_MODE_UNDEFINED = 0; // 0x0
9170+
field public static final int UI_THEME_MODE_NORMAL = 1; // 0x1
9171+
field public static final int UI_THEME_MODE_HOLO_DARK = 2; // 0x2
9172+
field public static final int UI_THEME_MODE_HOLO_LIGHT = 3; // 0x3
91699173
field public int densityDpi;
91709174
field public float fontScale;
91719175
field public int hardKeyboardHidden;
@@ -9182,6 +9186,7 @@ package android.content.res {
91829186
field public int screenWidthDp;
91839187
field public int smallestScreenWidthDp;
91849188
field public int touchscreen;
9189+
field public int uiThemeMode;
91859190
field public int uiMode;
91869191
}
91879192

core/java/android/app/IUiModeManager.aidl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ interface IUiModeManager {
5151
* 2 for night, and 3 for automatic mode switching.
5252
*/
5353
int getNightMode();
54+
55+
/**
56+
* Sets the system ui theme mode. Only the system can do this.
57+
*
58+
* possible theme modes @link Configuration
59+
* {@link #UI_THEME_MODE_NORMAL},
60+
* {@link #UI_THEME_MODE_HOLO_DARK}, {@link #UI_THEME_MODE_HOLO_LIGHT}
61+
*
62+
* @hide
63+
*/
64+
void setUiThemeMode(int mode);
65+
5466
}

core/java/android/app/ResourcesManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ public final boolean applyConfigurationToResourcesLocked(Configuration config,
456456
DisplayMetrics dm = defaultDisplayMetrics;
457457
final boolean hasOverrideConfiguration = key.hasOverrideConfiguration();
458458
boolean themeChanged = (changes & ActivityInfo.CONFIG_THEME_RESOURCE) != 0;
459+
final boolean themeChanged2 = (changes & ActivityInfo.CONFIG_UI_THEME_MODE) != 0;
459460
if (themeChanged) {
460461
AssetManager am = r.getAssets();
461462
if (am.hasThemeSupport()) {
@@ -487,7 +488,7 @@ public final boolean applyConfigurationToResourcesLocked(Configuration config,
487488
} else {
488489
r.updateConfiguration(config, dm, compat);
489490
}
490-
if (themeChanged) {
491+
if (themeChanged || themeChanged2) {
491492
r.updateStringCache();
492493
}
493494
//Slog.i(TAG, "Updated app resources " + v.getKey()

core/java/android/app/UiModeManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,23 @@ public int getNightMode() {
234234
}
235235
return -1;
236236
}
237+
238+
/**
239+
* Set system ui theme mode.
240+
*
241+
* possible theme modes @link Configuration
242+
* {@link #UI_THEME_MODE_NORMAL},
243+
* {@link #UI_THEME_MODE_HOLO_DARK}, {@link #UI_THEME_MODE_HOLO_LIGHT}
244+
*
245+
* @hide
246+
*/
247+
public void setUiThemeMode(int mode) {
248+
if (mService != null) {
249+
try {
250+
mService.setUiThemeMode(mode);
251+
} catch (RemoteException e) {
252+
Log.e(TAG, "setUiThemeMode: RemoteException", e);
253+
}
254+
}
255+
}
237256
}

core/java/android/content/pm/ActivityInfo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ public class ActivityInfo extends ComponentInfo
504504
* {@link android.R.attr#configChanges} attribute.
505505
*/
506506
public static final int CONFIG_UI_MODE = 0x0200;
507+
/**
508+
* Bit in {@link #configChanges} that indicates that the activity
509+
* can itself handle the inverted ui mode. Set from the
510+
* {@link android.R.attr#configChanges} attribute.
511+
* @hide
512+
*/
513+
public static final int CONFIG_UI_THEME_MODE = 0x0300;
507514
/**
508515
* Bit in {@link #configChanges} that indicates that the activity
509516
* can itself handle the screen size. Set from the
@@ -574,6 +581,7 @@ public class ActivityInfo extends ComponentInfo
574581
Configuration.NATIVE_CONFIG_NAVIGATION, // NAVIGATION
575582
Configuration.NATIVE_CONFIG_ORIENTATION, // ORIENTATION
576583
Configuration.NATIVE_CONFIG_SCREEN_LAYOUT, // SCREEN LAYOUT
584+
Configuration.NATIVE_CONFIG_UI_THEME_MODE, // UI THEME MODE
577585
Configuration.NATIVE_CONFIG_UI_MODE, // UI MODE
578586
Configuration.NATIVE_CONFIG_SCREEN_SIZE, // SCREEN SIZE
579587
Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE, // SMALLEST SCREEN SIZE

core/java/android/content/pm/PackageParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ private Package parseBaseApk(File apkFile, AssetManager assets, int flags)
907907
XmlResourceParser parser = null;
908908
try {
909909
res = new Resources(assets, mMetrics, null);
910-
assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
910+
assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
911911
Build.VERSION.RESOURCES_SDK_INT);
912912
parser = assets.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
913913

@@ -961,7 +961,7 @@ private void parseSplitApk(Package pkg, int splitIndex, AssetManager assets, int
961961
XmlResourceParser parser = null;
962962
try {
963963
res = new Resources(assets, mMetrics, null);
964-
assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
964+
assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
965965
Build.VERSION.RESOURCES_SDK_INT);
966966
parser = assets.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
967967

@@ -1258,7 +1258,7 @@ public static ApkLite parseApkLite(File apkFile, int flags)
12581258
XmlResourceParser parser = null;
12591259
try {
12601260
assets = new AssetManager();
1261-
assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1261+
assets.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12621262
Build.VERSION.RESOURCES_SDK_INT);
12631263

12641264
int cookie = assets.addAssetPath(apkPath);

core/java/android/content/res/AssetManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ public native final void setConfiguration(int mcc, int mnc, String locale,
887887
int orientation, int touchscreen, int density, int keyboard,
888888
int keyboardHidden, int navigation, int screenWidth, int screenHeight,
889889
int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp,
890-
int screenLayout, int uiMode, int majorVersion);
890+
int screenLayout, int uiThemeMode, int uiMode, int majorVersion);
891891

892892
/**
893893
* Retrieve the resource identifier for the given resource name.

core/java/android/content/res/Configuration.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,45 @@ public boolean isLayoutSizeAtLeast(int size) {
465465
*/
466466
public int orientation;
467467

468+
/** Constant for {@link #uiThemeMode}
469+
* value that corresponds to the
470+
* ui theme mode framework
471+
* resource qualifier.
472+
* value indicating that no mode has been set.
473+
* @hide
474+
*/
475+
public static final int UI_THEME_MODE_UNDEFINED = 0;
476+
/** Constant for {@link #uiThemeMode}
477+
* value that corresponds to the
478+
* stock themed framework
479+
* resource qualifier.
480+
* @hide
481+
*/
482+
public static final int UI_THEME_MODE_NORMAL = 1;
483+
/** Constant for {@link #uiThemeMode}
484+
* value that corresponds to the
485+
* dark themed framework
486+
* resource qualifier.
487+
* @hide
488+
*/
489+
public static final int UI_THEME_MODE_HOLO_DARK = 2;
490+
/** Constant for {@link #uiThemeMode}
491+
* value that corresponds to the
492+
* light themed framework
493+
* resource qualifier.
494+
* @hide
495+
*/
496+
public static final int UI_THEME_MODE_HOLO_LIGHT = 3;
497+
498+
/**
499+
* Bit for the ui theme mode.
500+
* This may be one of {@link #UI_THEME_MODE_UNDEFINED},
501+
* {@link #UI_THEME_MODE_NORMAL},
502+
* {@link #UI_THEME_MODE_HOLO_DARK}, {@link #UI_THEME_MODE_HOLO_LIGHT},
503+
* @hide
504+
*/
505+
public int uiThemeMode;
506+
468507
/** Constant for {@link #uiMode}: bits that encode the mode type. */
469508
public static final int UI_MODE_TYPE_MASK = 0x0f;
470509
/** Constant for {@link #uiMode}: a {@link #UI_MODE_TYPE_MASK}
@@ -642,6 +681,8 @@ public boolean isLayoutSizeAtLeast(int size) {
642681
public static final int NATIVE_CONFIG_VERSION = 0x0400;
643682
/** @hide Native-specific bit mask for SCREEN_LAYOUT config; DO NOT USE UNLESS YOU ARE SURE. */
644683
public static final int NATIVE_CONFIG_SCREEN_LAYOUT = 0x0800;
684+
/** @hide Native-specific bit mask for UI_THEME_MODE config; DO NOT USE UNLESS YOU ARE SURE. */
685+
public static final int NATIVE_CONFIG_UI_THEME_MODE = 0x0900;
645686
/** @hide Native-specific bit mask for UI_MODE config; DO NOT USE UNLESS YOU ARE SURE. */
646687
public static final int NATIVE_CONFIG_UI_MODE = 0x1000;
647688
/** @hide Native-specific bit mask for SMALLEST_SCREEN_SIZE config; DO NOT USE UNLESS YOU
@@ -681,6 +722,7 @@ public void setTo(Configuration o) {
681722
navigationHidden = o.navigationHidden;
682723
orientation = o.orientation;
683724
screenLayout = o.screenLayout;
725+
uiThemeMode = o.uiThemeMode;
684726
uiMode = o.uiMode;
685727
screenWidthDp = o.screenWidthDp;
686728
screenHeightDp = o.screenHeightDp;
@@ -768,6 +810,14 @@ public String toString() {
768810
case ORIENTATION_PORTRAIT: sb.append(" port"); break;
769811
default: sb.append(" orien="); sb.append(orientation); break;
770812
}
813+
switch (uiThemeMode) {
814+
case UI_THEME_MODE_UNDEFINED: sb.append(" ?uithememode"); break;
815+
/* normal is not interesting to print it is default behaviour*/
816+
case UI_THEME_MODE_NORMAL: break;
817+
case UI_THEME_MODE_HOLO_DARK: sb.append(" darktheme"); break;
818+
case UI_THEME_MODE_HOLO_LIGHT: sb.append(" lighttheme"); break;
819+
default: sb.append(" uiThemeMode="); sb.append(uiThemeMode); break;
820+
}
771821
switch ((uiMode&UI_MODE_TYPE_MASK)) {
772822
case UI_MODE_TYPE_UNDEFINED: sb.append(" ?uimode"); break;
773823
case UI_MODE_TYPE_NORMAL: /* normal is not interesting to print */ break;
@@ -851,6 +901,7 @@ public void setToDefaults() {
851901
navigationHidden = NAVIGATIONHIDDEN_UNDEFINED;
852902
orientation = ORIENTATION_UNDEFINED;
853903
screenLayout = SCREENLAYOUT_UNDEFINED;
904+
uiThemeMode = UI_THEME_MODE_UNDEFINED;
854905
uiMode = UI_MODE_TYPE_UNDEFINED;
855906
screenWidthDp = compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
856907
screenHeightDp = compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
@@ -956,6 +1007,11 @@ public int updateFrom(Configuration delta) {
9561007
screenLayout = delta.screenLayout;
9571008
}
9581009
}
1010+
if (delta.uiThemeMode != UI_THEME_MODE_UNDEFINED
1011+
&& uiThemeMode != delta.uiThemeMode) {
1012+
changed |= ActivityInfo.CONFIG_UI_THEME_MODE;
1013+
uiThemeMode = delta.uiThemeMode;
1014+
}
9591015
if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED)
9601016
&& uiMode != delta.uiMode) {
9611017
changed |= ActivityInfo.CONFIG_UI_MODE;
@@ -1101,6 +1157,10 @@ && getScreenLayoutNoDirection(screenLayout) !=
11011157
getScreenLayoutNoDirection(delta.screenLayout)) {
11021158
changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT;
11031159
}
1160+
if (delta.uiThemeMode != UI_THEME_MODE_UNDEFINED
1161+
&& uiThemeMode != delta.uiThemeMode) {
1162+
changed |= ActivityInfo.CONFIG_UI_THEME_MODE;
1163+
}
11041164
if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED|UI_MODE_NIGHT_UNDEFINED)
11051165
&& uiMode != delta.uiMode) {
11061166
changed |= ActivityInfo.CONFIG_UI_MODE;
@@ -1211,6 +1271,7 @@ public void writeToParcel(Parcel dest, int flags) {
12111271
dest.writeInt(navigationHidden);
12121272
dest.writeInt(orientation);
12131273
dest.writeInt(screenLayout);
1274+
dest.writeInt(uiThemeMode);
12141275
dest.writeInt(uiMode);
12151276
dest.writeInt(screenWidthDp);
12161277
dest.writeInt(screenHeightDp);
@@ -1240,6 +1301,7 @@ public void readFromParcel(Parcel source) {
12401301
navigationHidden = source.readInt();
12411302
orientation = source.readInt();
12421303
screenLayout = source.readInt();
1304+
uiThemeMode = source.readInt();
12431305
uiMode = source.readInt();
12441306
screenWidthDp = source.readInt();
12451307
screenHeightDp = source.readInt();
@@ -1308,6 +1370,8 @@ public int compareTo(Configuration that) {
13081370
if (n != 0) return n;
13091371
n = this.screenLayout - that.screenLayout;
13101372
if (n != 0) return n;
1373+
n = this.uiThemeMode - that.uiThemeMode;
1374+
if (n != 0) return n;
13111375
n = this.uiMode - that.uiMode;
13121376
if (n != 0) return n;
13131377
n = this.screenWidthDp - that.screenWidthDp;
@@ -1354,6 +1418,7 @@ public int hashCode() {
13541418
result = 31 * result + navigationHidden;
13551419
result = 31 * result + orientation;
13561420
result = 31 * result + screenLayout;
1421+
result = 31 * result + uiThemeMode;
13571422
result = 31 * result + uiMode;
13581423
result = 31 * result + screenWidthDp;
13591424
result = 31 * result + screenHeightDp;

core/java/android/content/res/Resources.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,8 @@ public void updateConfiguration(Configuration config,
19511951
keyboardHidden, mConfiguration.navigation, width, height,
19521952
mConfiguration.smallestScreenWidthDp,
19531953
mConfiguration.screenWidthDp, mConfiguration.screenHeightDp,
1954-
mConfiguration.screenLayout, mConfiguration.uiMode,
1954+
mConfiguration.screenLayout,
1955+
mConfiguration.uiThemeMode, mConfiguration.uiMode,
19551956
Build.VERSION.RESOURCES_SDK_INT);
19561957

19571958
if (DEBUG_CONFIG) {
@@ -2018,10 +2019,21 @@ private void clearDrawableCachesLocked(
20182019

20192020
private void clearDrawableCacheLocked(
20202021
LongSparseArray<WeakReference<ConstantState>> cache, int configChanges) {
2022+
20212023
/*
20222024
* Quick test to find out if the config change that occurred should
20232025
* trigger a full cache wipe.
20242026
*/
2027+
2028+
if (Configuration.needNewResources(configChanges, ActivityInfo.CONFIG_UI_THEME_MODE)) {
2029+
if (DEBUG_CONFIG) {
2030+
Log.d(TAG, "Clear drawable cache from config changes: 0x"
2031+
+ Integer.toHexString(configChanges));
2032+
}
2033+
cache.clear();
2034+
return;
2035+
}
2036+
20252037
if (Configuration.needNewResources(configChanges, 0)) {
20262038
if (DEBUG_CONFIG) {
20272039
Log.d(TAG, "Clear drawable cache from config changes: 0x"
@@ -2465,6 +2477,11 @@ private boolean verifyPreloadConfig(int changingConfigurations, int allowVarying
24652477
public final void updateStringCache() {
24662478
synchronized (mAccessLock) {
24672479
mAssets.recreateStringBlocks();
2480+
}
2481+
if (mTmpValue != null) {
2482+
synchronized (mTmpValue) {
2483+
mAssets.recreateStringBlocks();
2484+
}
24682485
}
24692486
}
24702487

core/java/android/provider/Settings.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4481,6 +4481,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
44814481
*/
44824482
public static final String LOCK_SCREEN_MAX_NOTIFICATIONS = "lock_screen_max_notifications";
44834483

4484+
/**
4485+
* TRDS: Override custom notification and qs colors on theme change
4486+
* @hide
4487+
*/
4488+
public static final String OVERRIDE_CUSTOM_COLORS = "override_custom_colors";
4489+
44844490
/**
44854491
* Settings to backup. This is here so that it's in the same place as the settings
44864492
* keys and easy to update.
@@ -6709,6 +6715,21 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
67096715
*/
67106716
public static final String UI_NIGHT_MODE = "ui_night_mode";
67116717

6718+
/**
6719+
* The current theme mode that has been selected by the user. Owned
6720+
* and controlled by UiModeManagerService.
6721+
* @hide
6722+
*/
6723+
public static final String UI_THEME_MODE = "ui_theme_mode";
6724+
6725+
/**
6726+
* Auto theme mode which switches either based on daytime or lightsensor
6727+
* values: 0 = manual (default), 1 = auto twilight (based on daytime)
6728+
* 2 = auto lightsensor (based on light conditions)
6729+
* @hide
6730+
*/
6731+
public static final String UI_THEME_AUTO_MODE = "ui_theme_auto_mode";
6732+
67126733
/**
67136734
* Whether screensavers are enabled.
67146735
* @hide

0 commit comments

Comments
 (0)