CMSettings: intercept Settings calls to DEV_FORCE_SHOW_NAVBAR

Because DEV_FORCE_SHOW_NAVBAR has lived in Settings.System,
Settings.Secure, and now in CMSettings.Secure, we need to return the
proper value no matter which place an app might query.

Ticket: CYNGNOS-2480

Change-Id: Ie84df9763aa3714ec4ce4d033dc73be4de3f1f00
Signed-off-by: Roman Birg <roman@cyngn.com>
This commit is contained in:
Roman Birg 2016-04-29 15:25:13 -07:00 committed by Gerrit Code Review
parent 94dd91a34c
commit fd4b383b71
1 changed files with 29 additions and 2 deletions

View File

@ -438,6 +438,12 @@ public final class CMSettings {
CALL_METHOD_GET_SYSTEM,
CALL_METHOD_PUT_SYSTEM);
protected static final ArraySet<String> MOVED_TO_SECURE;
static {
MOVED_TO_SECURE = new ArraySet<>(1);
MOVED_TO_SECURE.add(Secure.DEV_FORCE_SHOW_NAVBAR);
}
// region Methods
/**
@ -501,6 +507,11 @@ public final class CMSettings {
/** @hide */
public static String getStringForUser(ContentResolver resolver, String name,
int userId) {
if (MOVED_TO_SECURE.contains(name)) {
Log.w(TAG, "Setting " + name + " has moved from CMSettings.System"
+ " to CMSettings.Secure, value is unchanged.");
return CMSettings.Secure.getStringForUser(resolver, name, userId);
}
return sNameValueCache.getStringForUser(resolver, name, userId);
}
@ -1914,7 +1925,15 @@ public final class CMSettings {
* @hide
*/
public static boolean shouldInterceptSystemProvider(String key) {
return key.equals(System.SYSTEM_PROFILES_ENABLED);
switch (key) {
case System.SYSTEM_PROFILES_ENABLED:
// some apps still query Settings.System.DEV_FORCE_SHOW_NAVBAR;
// we intercept the call, and return CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR's value
case Secure.DEV_FORCE_SHOW_NAVBAR:
return true;
default:
return false;
}
}
/**
@ -2853,7 +2872,15 @@ public final class CMSettings {
* @hide
*/
public static boolean shouldInterceptSystemProvider(String key) {
return false;
switch (key) {
// some apps still query Settings.System.DEV_FORCE_SHOW_NAVBAR, and it was moved to
// Settings.Secure, then CMSettings.Secure. Forward queries from Settings.Secure
// to CMSettings.Secure here just in case an app stuck with the Settings.Secure call
case DEV_FORCE_SHOW_NAVBAR:
return true;
default:
return false;
}
}
}