Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7479aa93 authored by Nino Jagar's avatar Nino Jagar Committed by Android (Google) Code Review
Browse files

Merge "Postpone checking for content protection permissions" into udc-qpr-dev

parents a86313f3 3ad1355d
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -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 */
@@ -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);
    }

+16 −13
Original line number Diff line number Diff line
@@ -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;
@@ -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());
    }

@@ -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);