From fd4b383b71cd21b5bfc03e782573a938b8abe505 Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Fri, 29 Apr 2016 15:25:13 -0700 Subject: [PATCH] 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 --- .../cyanogenmod/providers/CMSettings.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/sdk/src/java/cyanogenmod/providers/CMSettings.java b/sdk/src/java/cyanogenmod/providers/CMSettings.java index b6ed449..f739d42 100644 --- a/sdk/src/java/cyanogenmod/providers/CMSettings.java +++ b/sdk/src/java/cyanogenmod/providers/CMSettings.java @@ -438,6 +438,12 @@ public final class CMSettings { CALL_METHOD_GET_SYSTEM, CALL_METHOD_PUT_SYSTEM); + protected static final ArraySet 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; + } } }