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

Commit d84f0282 authored by Nino Jagar's avatar Nino Jagar Committed by Automerger Merge Worker
Browse files

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

Merge "Postpone checking for content protection permissions" into udc-qpr-dev am: 7479aa93 am: 78f54ae2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23574377



Change-Id: Ibb1ecfdfd6cfe34096648722403d277b4bda43db
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f475ce4f 78f54ae2
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);