Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +1 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,7 @@ open class ClockRegistry( { str1 = id }, { "Clock Id conflict on load: $str1 is double registered" } ) manager.unloadPlugin() continue } Loading packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginActionManager.java +12 −11 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public class PluginActionManager<T extends Plugin> { /** Load all plugins matching this instance's action. */ public void loadAll() { if (DEBUG) Log.d(TAG, "startListening"); mBgExecutor.execute(this::queryAll); mBgExecutor.execute(() -> queryAll()); } /** Unload all plugins managed by this instance. */ Loading Loading @@ -255,17 +255,18 @@ public class PluginActionManager<T extends Plugin> { intent.setPackage(pkgName); } List<ResolveInfo> result = mPm.queryIntentServices(intent, 0); if (DEBUG) Log.d(TAG, "Found " + result.size() + " plugins"); if (result.size() > 1 && !mAllowMultiple) { // TODO: Show warning. Log.w(TAG, "Multiple plugins found for " + mAction); if (DEBUG) { Log.d(TAG, "Found " + result.size() + " plugins"); for (ResolveInfo info : result) { ComponentName name = new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name); Log.w(TAG, " " + name); Log.d(TAG, " " + name); } } if (result.size() > 1 && !mAllowMultiple) { // TODO: Show warning. Log.w(TAG, "Multiple plugins found for " + mAction); return; } for (ResolveInfo info : result) { Loading Loading @@ -307,7 +308,7 @@ public class PluginActionManager<T extends Plugin> { // TODO: Only create the plugin before version check if we need it for // legacy version check. if (DEBUG) { Log.d(TAG, "createPlugin"); Log.d(TAG, "createPlugin: " + component); } try { return mPluginInstanceFactory.create( Loading @@ -317,7 +318,7 @@ public class PluginActionManager<T extends Plugin> { reportInvalidVersion(component, component.getClassName(), e); } } catch (Throwable e) { Log.w(TAG, "Couldn't load plugin: " + packageName, e); Log.w(TAG, "Couldn't load plugin: " + component, e); return null; } Loading packages/SystemUI/tests/src/com/android/systemui/shared/clocks/ClockRegistryTest.kt +5 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.Mockito.`when` as whenever import org.mockito.junit.MockitoJUnit Loading Loading @@ -172,7 +174,7 @@ class ClockRegistryTest : SysuiTestCase() { } @Test fun clockIdConflict_ErrorWithoutCrash() { fun clockIdConflict_ErrorWithoutCrash_unloadDuplicate() { val mockPluginLifecycle1 = mock<PluginLifecycleManager<ClockProviderPlugin>>() val plugin1 = FakeClockPlugin() .addClock("clock_1", "clock 1", { mockClock }, { mockThumbnail }) Loading @@ -199,6 +201,8 @@ class ClockRegistryTest : SysuiTestCase() { assertEquals(registry.createExampleClock("clock_2"), mockClock) assertEquals(registry.getClockThumbnail("clock_1"), mockThumbnail) assertEquals(registry.getClockThumbnail("clock_2"), mockThumbnail) verify(mockPluginLifecycle1, never()).unloadPlugin() verify(mockPluginLifecycle2, times(2)).unloadPlugin() } @Test Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +1 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,7 @@ open class ClockRegistry( { str1 = id }, { "Clock Id conflict on load: $str1 is double registered" } ) manager.unloadPlugin() continue } Loading
packages/SystemUI/shared/src/com/android/systemui/shared/plugins/PluginActionManager.java +12 −11 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public class PluginActionManager<T extends Plugin> { /** Load all plugins matching this instance's action. */ public void loadAll() { if (DEBUG) Log.d(TAG, "startListening"); mBgExecutor.execute(this::queryAll); mBgExecutor.execute(() -> queryAll()); } /** Unload all plugins managed by this instance. */ Loading Loading @@ -255,17 +255,18 @@ public class PluginActionManager<T extends Plugin> { intent.setPackage(pkgName); } List<ResolveInfo> result = mPm.queryIntentServices(intent, 0); if (DEBUG) Log.d(TAG, "Found " + result.size() + " plugins"); if (result.size() > 1 && !mAllowMultiple) { // TODO: Show warning. Log.w(TAG, "Multiple plugins found for " + mAction); if (DEBUG) { Log.d(TAG, "Found " + result.size() + " plugins"); for (ResolveInfo info : result) { ComponentName name = new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name); Log.w(TAG, " " + name); Log.d(TAG, " " + name); } } if (result.size() > 1 && !mAllowMultiple) { // TODO: Show warning. Log.w(TAG, "Multiple plugins found for " + mAction); return; } for (ResolveInfo info : result) { Loading Loading @@ -307,7 +308,7 @@ public class PluginActionManager<T extends Plugin> { // TODO: Only create the plugin before version check if we need it for // legacy version check. if (DEBUG) { Log.d(TAG, "createPlugin"); Log.d(TAG, "createPlugin: " + component); } try { return mPluginInstanceFactory.create( Loading @@ -317,7 +318,7 @@ public class PluginActionManager<T extends Plugin> { reportInvalidVersion(component, component.getClassName(), e); } } catch (Throwable e) { Log.w(TAG, "Couldn't load plugin: " + packageName, e); Log.w(TAG, "Couldn't load plugin: " + component, e); return null; } Loading
packages/SystemUI/tests/src/com/android/systemui/shared/clocks/ClockRegistryTest.kt +5 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.Mockito.`when` as whenever import org.mockito.junit.MockitoJUnit Loading Loading @@ -172,7 +174,7 @@ class ClockRegistryTest : SysuiTestCase() { } @Test fun clockIdConflict_ErrorWithoutCrash() { fun clockIdConflict_ErrorWithoutCrash_unloadDuplicate() { val mockPluginLifecycle1 = mock<PluginLifecycleManager<ClockProviderPlugin>>() val plugin1 = FakeClockPlugin() .addClock("clock_1", "clock 1", { mockClock }, { mockThumbnail }) Loading @@ -199,6 +201,8 @@ class ClockRegistryTest : SysuiTestCase() { assertEquals(registry.createExampleClock("clock_2"), mockClock) assertEquals(registry.getClockThumbnail("clock_1"), mockThumbnail) assertEquals(registry.getClockThumbnail("clock_2"), mockThumbnail) verify(mockPluginLifecycle1, never()).unloadPlugin() verify(mockPluginLifecycle2, times(2)).unloadPlugin() } @Test Loading