Loading packages/SettingsProvider/src/com/android/providers/settings/GenerationRegistry.java +3 −3 Original line number Diff line number Diff line Loading @@ -45,7 +45,8 @@ final class GenerationRegistry { private static final boolean DEBUG = false; private final Object mLock; // This lock is not the same lock used in SettingsProvider and SettingsState private final Object mLock = new Object(); // Key -> backingStore mapping @GuardedBy("mLock") Loading Loading @@ -74,8 +75,7 @@ final class GenerationRegistry { private final int mMaxNumBackingStore; GenerationRegistry(Object lock, int maxNumUsers) { mLock = lock; GenerationRegistry(int maxNumUsers) { // Add some buffer to maxNumUsers to accommodate corner cases when the actual number of // users in the system exceeds the limit maxNumUsers = maxNumUsers + 2; Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -2884,7 +2884,7 @@ public class SettingsProvider extends ContentProvider { public SettingsRegistry() { mHandler = new MyHandler(getContext().getMainLooper()); mGenerationRegistry = new GenerationRegistry(mLock, UserManager.getMaxSupportedUsers()); mGenerationRegistry = new GenerationRegistry(UserManager.getMaxSupportedUsers()); mBackupManager = new BackupManager(getContext()); } Loading packages/SettingsProvider/test/src/com/android/providers/settings/GenerationRegistryTest.java +8 −8 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ import java.io.IOException; public class GenerationRegistryTest { @Test public void testGenerationsWithRegularSetting() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 2); final GenerationRegistry generationRegistry = new GenerationRegistry(2); final int secureKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_SECURE, 0); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); Loading Loading @@ -93,7 +93,7 @@ public class GenerationRegistryTest { @Test public void testGenerationsWithConfigSetting() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 1); final GenerationRegistry generationRegistry = new GenerationRegistry(1); final String prefix = "test_namespace/"; final int configKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_CONFIG, 0); Loading @@ -110,7 +110,7 @@ public class GenerationRegistryTest { @Test public void testMaxNumBackingStores() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 2); final GenerationRegistry generationRegistry = new GenerationRegistry(2); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); for (int i = 0; i < generationRegistry.getMaxNumBackingStores(); i++) { Loading @@ -133,7 +133,7 @@ public class GenerationRegistryTest { @Test public void testMaxSizeBackingStore() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 1); final GenerationRegistry generationRegistry = new GenerationRegistry(1); final int secureKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_SECURE, 0); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); Loading @@ -153,7 +153,7 @@ public class GenerationRegistryTest { @Test public void testUnsetSettings() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 1); final GenerationRegistry generationRegistry = new GenerationRegistry(1); final int secureKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_SECURE, 0); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); Loading @@ -172,7 +172,7 @@ public class GenerationRegistryTest { @Test public void testGlobalSettings() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 2); final GenerationRegistry generationRegistry = new GenerationRegistry(2); final int globalKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_GLOBAL, 0); final String testGlobalSetting = "test_global_setting"; final Bundle b = new Bundle(); Loading @@ -190,11 +190,11 @@ public class GenerationRegistryTest { @Test public void testNumberOfBackingStores() { GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 0); GenerationRegistry generationRegistry = new GenerationRegistry(0); // Test that the capacity of the backing stores is always valid assertThat(generationRegistry.getMaxNumBackingStores()).isEqualTo( GenerationRegistry.MIN_NUM_BACKING_STORE); generationRegistry = new GenerationRegistry(new Object(), 100); generationRegistry = new GenerationRegistry(100); // Test that the capacity of the backing stores is always valid assertThat(generationRegistry.getMaxNumBackingStores()).isEqualTo( GenerationRegistry.MAX_NUM_BACKING_STORE); Loading Loading
packages/SettingsProvider/src/com/android/providers/settings/GenerationRegistry.java +3 −3 Original line number Diff line number Diff line Loading @@ -45,7 +45,8 @@ final class GenerationRegistry { private static final boolean DEBUG = false; private final Object mLock; // This lock is not the same lock used in SettingsProvider and SettingsState private final Object mLock = new Object(); // Key -> backingStore mapping @GuardedBy("mLock") Loading Loading @@ -74,8 +75,7 @@ final class GenerationRegistry { private final int mMaxNumBackingStore; GenerationRegistry(Object lock, int maxNumUsers) { mLock = lock; GenerationRegistry(int maxNumUsers) { // Add some buffer to maxNumUsers to accommodate corner cases when the actual number of // users in the system exceeds the limit maxNumUsers = maxNumUsers + 2; Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -2884,7 +2884,7 @@ public class SettingsProvider extends ContentProvider { public SettingsRegistry() { mHandler = new MyHandler(getContext().getMainLooper()); mGenerationRegistry = new GenerationRegistry(mLock, UserManager.getMaxSupportedUsers()); mGenerationRegistry = new GenerationRegistry(UserManager.getMaxSupportedUsers()); mBackupManager = new BackupManager(getContext()); } Loading
packages/SettingsProvider/test/src/com/android/providers/settings/GenerationRegistryTest.java +8 −8 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ import java.io.IOException; public class GenerationRegistryTest { @Test public void testGenerationsWithRegularSetting() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 2); final GenerationRegistry generationRegistry = new GenerationRegistry(2); final int secureKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_SECURE, 0); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); Loading Loading @@ -93,7 +93,7 @@ public class GenerationRegistryTest { @Test public void testGenerationsWithConfigSetting() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 1); final GenerationRegistry generationRegistry = new GenerationRegistry(1); final String prefix = "test_namespace/"; final int configKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_CONFIG, 0); Loading @@ -110,7 +110,7 @@ public class GenerationRegistryTest { @Test public void testMaxNumBackingStores() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 2); final GenerationRegistry generationRegistry = new GenerationRegistry(2); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); for (int i = 0; i < generationRegistry.getMaxNumBackingStores(); i++) { Loading @@ -133,7 +133,7 @@ public class GenerationRegistryTest { @Test public void testMaxSizeBackingStore() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 1); final GenerationRegistry generationRegistry = new GenerationRegistry(1); final int secureKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_SECURE, 0); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); Loading @@ -153,7 +153,7 @@ public class GenerationRegistryTest { @Test public void testUnsetSettings() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 1); final GenerationRegistry generationRegistry = new GenerationRegistry(1); final int secureKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_SECURE, 0); final String testSecureSetting = "test_secure_setting"; Bundle b = new Bundle(); Loading @@ -172,7 +172,7 @@ public class GenerationRegistryTest { @Test public void testGlobalSettings() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 2); final GenerationRegistry generationRegistry = new GenerationRegistry(2); final int globalKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_GLOBAL, 0); final String testGlobalSetting = "test_global_setting"; final Bundle b = new Bundle(); Loading @@ -190,11 +190,11 @@ public class GenerationRegistryTest { @Test public void testNumberOfBackingStores() { GenerationRegistry generationRegistry = new GenerationRegistry(new Object(), 0); GenerationRegistry generationRegistry = new GenerationRegistry(0); // Test that the capacity of the backing stores is always valid assertThat(generationRegistry.getMaxNumBackingStores()).isEqualTo( GenerationRegistry.MIN_NUM_BACKING_STORE); generationRegistry = new GenerationRegistry(new Object(), 100); generationRegistry = new GenerationRegistry(100); // Test that the capacity of the backing stores is always valid assertThat(generationRegistry.getMaxNumBackingStores()).isEqualTo( GenerationRegistry.MAX_NUM_BACKING_STORE); Loading