Loading services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +10 −14 Original line number Diff line number Diff line Loading @@ -805,20 +805,7 @@ public class ContentCaptureManagerService extends @Nullable private ComponentName getContentProtectionServiceComponentName() { String flatComponentName = getContentProtectionServiceFlatComponentName(); ComponentName componentName = ComponentName.unflattenFromString(flatComponentName); if (componentName == null) { return null; } // Check permissions by trying to construct {@link ContentCaptureServiceInfo} try { createContentProtectionServiceInfo(componentName); } catch (Exception ex) { // Swallow, exception was already logged return null; } return componentName; return ComponentName.unflattenFromString(flatComponentName); } /** @hide */ Loading Loading @@ -853,6 +840,15 @@ public class ContentCaptureManagerService extends return null; } } // Check permissions by trying to construct {@link ContentCaptureServiceInfo} try { createContentProtectionServiceInfo(mContentProtectionServiceComponentName); } catch (Exception ex) { // Swallow, exception was already logged return null; } return createRemoteContentProtectionService(mContentProtectionServiceComponentName); } Loading services/tests/servicestests/src/com/android/server/contentcapture/ContentCaptureManagerServiceTest.java +16 −13 Original line number Diff line number Diff line Loading @@ -142,18 +142,6 @@ public class ContentCaptureManagerServiceTest { verifyZeroInteractions(mMockContentProtectionBlocklistManager); } @Test public void constructor_contentProtection_serviceInfoThrows_noBlocklistManager() { mDevCfgEnableContentProtectionReceiver = true; mContentProtectionServiceInfoConstructorShouldThrow = true; mContentCaptureManagerService = new TestContentCaptureManagerService(); assertThat(mContentProtectionBlocklistManagersCreated).isEqualTo(0); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(1); verifyZeroInteractions(mMockContentProtectionBlocklistManager); } @Test public void constructor_contentProtection_enabled_createsBlocklistManager() { mDevCfgEnableContentProtectionReceiver = true; Loading @@ -161,7 +149,7 @@ public class ContentCaptureManagerServiceTest { mContentCaptureManagerService = new TestContentCaptureManagerService(); assertThat(mContentProtectionBlocklistManagersCreated).isEqualTo(1); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(1); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(0); verify(mMockContentProtectionBlocklistManager).updateBlocklist(anyInt()); } Loading Loading @@ -357,6 +345,21 @@ public class ContentCaptureManagerServiceTest { mContentCaptureManagerService = new TestContentCaptureManagerService(); mContentCaptureManagerService.mDevCfgEnableContentProtectionReceiver = false; mContentCaptureManagerService .getContentCaptureManagerServiceStub() .onLoginDetected(PARCELED_EVENTS); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(0); assertThat(mRemoteContentProtectionServicesCreated).isEqualTo(0); verifyZeroInteractions(mMockRemoteContentProtectionService); } @Test public void onLoginDetected_invalidPermissions() { mDevCfgEnableContentProtectionReceiver = true; mContentProtectionServiceInfoConstructorShouldThrow = true; mContentCaptureManagerService = new TestContentCaptureManagerService(); mContentCaptureManagerService .getContentCaptureManagerServiceStub() .onLoginDetected(PARCELED_EVENTS); Loading Loading
services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +10 −14 Original line number Diff line number Diff line Loading @@ -805,20 +805,7 @@ public class ContentCaptureManagerService extends @Nullable private ComponentName getContentProtectionServiceComponentName() { String flatComponentName = getContentProtectionServiceFlatComponentName(); ComponentName componentName = ComponentName.unflattenFromString(flatComponentName); if (componentName == null) { return null; } // Check permissions by trying to construct {@link ContentCaptureServiceInfo} try { createContentProtectionServiceInfo(componentName); } catch (Exception ex) { // Swallow, exception was already logged return null; } return componentName; return ComponentName.unflattenFromString(flatComponentName); } /** @hide */ Loading Loading @@ -853,6 +840,15 @@ public class ContentCaptureManagerService extends return null; } } // Check permissions by trying to construct {@link ContentCaptureServiceInfo} try { createContentProtectionServiceInfo(mContentProtectionServiceComponentName); } catch (Exception ex) { // Swallow, exception was already logged return null; } return createRemoteContentProtectionService(mContentProtectionServiceComponentName); } Loading
services/tests/servicestests/src/com/android/server/contentcapture/ContentCaptureManagerServiceTest.java +16 −13 Original line number Diff line number Diff line Loading @@ -142,18 +142,6 @@ public class ContentCaptureManagerServiceTest { verifyZeroInteractions(mMockContentProtectionBlocklistManager); } @Test public void constructor_contentProtection_serviceInfoThrows_noBlocklistManager() { mDevCfgEnableContentProtectionReceiver = true; mContentProtectionServiceInfoConstructorShouldThrow = true; mContentCaptureManagerService = new TestContentCaptureManagerService(); assertThat(mContentProtectionBlocklistManagersCreated).isEqualTo(0); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(1); verifyZeroInteractions(mMockContentProtectionBlocklistManager); } @Test public void constructor_contentProtection_enabled_createsBlocklistManager() { mDevCfgEnableContentProtectionReceiver = true; Loading @@ -161,7 +149,7 @@ public class ContentCaptureManagerServiceTest { mContentCaptureManagerService = new TestContentCaptureManagerService(); assertThat(mContentProtectionBlocklistManagersCreated).isEqualTo(1); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(1); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(0); verify(mMockContentProtectionBlocklistManager).updateBlocklist(anyInt()); } Loading Loading @@ -357,6 +345,21 @@ public class ContentCaptureManagerServiceTest { mContentCaptureManagerService = new TestContentCaptureManagerService(); mContentCaptureManagerService.mDevCfgEnableContentProtectionReceiver = false; mContentCaptureManagerService .getContentCaptureManagerServiceStub() .onLoginDetected(PARCELED_EVENTS); assertThat(mContentProtectionServiceInfosCreated).isEqualTo(0); assertThat(mRemoteContentProtectionServicesCreated).isEqualTo(0); verifyZeroInteractions(mMockRemoteContentProtectionService); } @Test public void onLoginDetected_invalidPermissions() { mDevCfgEnableContentProtectionReceiver = true; mContentProtectionServiceInfoConstructorShouldThrow = true; mContentCaptureManagerService = new TestContentCaptureManagerService(); mContentCaptureManagerService .getContentCaptureManagerServiceStub() .onLoginDetected(PARCELED_EVENTS); Loading