Loading core/java/android/provider/Settings.java +11 −7 Original line number Diff line number Diff line Loading @@ -2790,13 +2790,12 @@ public final class Settings { // Settings.Global and is not annotated as @Readable. // Notice that a key string that is not defined in any of the Settings.* classes will // still be regarded as readable. // TODO(b/175024829): provide a register method. if (!Settings.isInSystemServer() && !isSystemOrPrivilegedApp() if (!isCallerExemptFromReadableRestriction() && mAllFields.contains(name) && !mReadableFields.contains(name)) { throw new SecurityException( "Settings key: <" + name + "> is not readable. From S+, new public " + "settings keys need to be annotated with @Readable unless they are " + "annotated with @hide."); "Settings key: <" + name + "> is not readable. From S+, settings keys " + "annotated with @hide are restricted to system_server and system " + "apps only, unless they are annotated with @Readable."); } final boolean isSelf = (userHandle == UserHandle.myUserId()); int currentGeneration = -1; Loading Loading @@ -2972,7 +2971,10 @@ public final class Settings { } } private static boolean isSystemOrPrivilegedApp() { private static boolean isCallerExemptFromReadableRestriction() { if (Settings.isInSystemServer()) { return true; } if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) { return true; } Loading @@ -2981,7 +2983,9 @@ public final class Settings { return false; } final ApplicationInfo applicationInfo = application.getApplicationInfo(); return applicationInfo.isSystemApp() || applicationInfo.isPrivilegedApp() final boolean isTestOnly = (applicationInfo.flags & ApplicationInfo.FLAG_TEST_ONLY) != 0; return isTestOnly || applicationInfo.isSystemApp() || applicationInfo.isPrivilegedApp() || applicationInfo.isSignedWithPlatformKey(); } Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +7 −4 Original line number Diff line number Diff line Loading @@ -1941,7 +1941,10 @@ public class SettingsProvider extends ContentProvider { if (ai.isSystemApp() || ai.isSignedWithPlatformKey()) { return; } if ((ai.flags & ApplicationInfo.FLAG_TEST_ONLY) == 0) { // Skip checking readable annotations for test_only apps checkReadableAnnotation(settingsType, settingName); } if (!ai.isInstantApp()) { return; } Loading Loading @@ -1983,9 +1986,9 @@ public class SettingsProvider extends ContentProvider { if (allFields.contains(settingName) && !readableFields.contains(settingName)) { throw new SecurityException( "Settings key: <" + settingName + "> is not readable. From S+, new public " + "settings keys need to be annotated with @Readable unless they are " + "annotated with @hide."); "Settings key: <" + settingName + "> is not readable. From S+, settings keys " + "annotated with @hide are restricted to system_server and system " + "apps only, unless they are annotated with @Readable."); } } Loading Loading
core/java/android/provider/Settings.java +11 −7 Original line number Diff line number Diff line Loading @@ -2790,13 +2790,12 @@ public final class Settings { // Settings.Global and is not annotated as @Readable. // Notice that a key string that is not defined in any of the Settings.* classes will // still be regarded as readable. // TODO(b/175024829): provide a register method. if (!Settings.isInSystemServer() && !isSystemOrPrivilegedApp() if (!isCallerExemptFromReadableRestriction() && mAllFields.contains(name) && !mReadableFields.contains(name)) { throw new SecurityException( "Settings key: <" + name + "> is not readable. From S+, new public " + "settings keys need to be annotated with @Readable unless they are " + "annotated with @hide."); "Settings key: <" + name + "> is not readable. From S+, settings keys " + "annotated with @hide are restricted to system_server and system " + "apps only, unless they are annotated with @Readable."); } final boolean isSelf = (userHandle == UserHandle.myUserId()); int currentGeneration = -1; Loading Loading @@ -2972,7 +2971,10 @@ public final class Settings { } } private static boolean isSystemOrPrivilegedApp() { private static boolean isCallerExemptFromReadableRestriction() { if (Settings.isInSystemServer()) { return true; } if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) { return true; } Loading @@ -2981,7 +2983,9 @@ public final class Settings { return false; } final ApplicationInfo applicationInfo = application.getApplicationInfo(); return applicationInfo.isSystemApp() || applicationInfo.isPrivilegedApp() final boolean isTestOnly = (applicationInfo.flags & ApplicationInfo.FLAG_TEST_ONLY) != 0; return isTestOnly || applicationInfo.isSystemApp() || applicationInfo.isPrivilegedApp() || applicationInfo.isSignedWithPlatformKey(); } Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +7 −4 Original line number Diff line number Diff line Loading @@ -1941,7 +1941,10 @@ public class SettingsProvider extends ContentProvider { if (ai.isSystemApp() || ai.isSignedWithPlatformKey()) { return; } if ((ai.flags & ApplicationInfo.FLAG_TEST_ONLY) == 0) { // Skip checking readable annotations for test_only apps checkReadableAnnotation(settingsType, settingName); } if (!ai.isInstantApp()) { return; } Loading Loading @@ -1983,9 +1986,9 @@ public class SettingsProvider extends ContentProvider { if (allFields.contains(settingName) && !readableFields.contains(settingName)) { throw new SecurityException( "Settings key: <" + settingName + "> is not readable. From S+, new public " + "settings keys need to be annotated with @Readable unless they are " + "annotated with @hide."); "Settings key: <" + settingName + "> is not readable. From S+, settings keys " + "annotated with @hide are restricted to system_server and system " + "apps only, unless they are annotated with @Readable."); } } Loading