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

Commit e942c479 authored by Lucas Silva's avatar Lucas Silva
Browse files

Temporarily allow all activies to run on SLS.

Enforcing the restriction has broken Dreams and some assistant
functionality. Those apps need to be updated before we start
enforcement.

Test: atest FrameworksMockingServicesTests:CommunalManagerServiceTest
Change-Id: I644a8bea72ca0286a3eb7eb05e06bd1df1836d0a
Bug: 203692863
Bug: 203684016
parent df08d493
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -129,17 +129,19 @@ public final class CommunalManagerService extends SystemService {
    }
    }


    private boolean isActivityAllowed(ActivityInfo activityInfo) {
    private boolean isActivityAllowed(ActivityInfo activityInfo) {
        if (!mCommunalViewIsShowing.get() || !mKeyguardManager.isKeyguardLocked()) return true;
        return true;

        // TODO(b/191994709): Uncomment the lines below once Dreams and Assistant have been fixed.
        // If the activity doesn't have showWhenLocked enabled, disallow the activity.
//        if (!mCommunalViewIsShowing.get() || !mKeyguardManager.isKeyguardLocked()) return true;
        final boolean showWhenLocked =
//
                (activityInfo.flags & ActivityInfo.FLAG_SHOW_WHEN_LOCKED) != 0;
//        // If the activity doesn't have showWhenLocked enabled, disallow the activity.
        if (!showWhenLocked) {
//        final boolean showWhenLocked =
            return false;
//                (activityInfo.flags & ActivityInfo.FLAG_SHOW_WHEN_LOCKED) != 0;
        }
//        if (!showWhenLocked) {

//            return false;
        // Check the cached user preferences to see if the user has allowed this app.
//        }
        return mEnabledApps.contains(activityInfo.applicationInfo.packageName);
//
//        // Check the cached user preferences to see if the user has allowed this app.
//        return mEnabledApps.contains(activityInfo.applicationInfo.packageName);
    }
    }


    private final class SettingsObserver extends ContentObserver {
    private final class SettingsObserver extends ContentObserver {
+6 −3
Original line number Original line Diff line number Diff line
@@ -191,7 +191,8 @@ public class CommunalManagerServiceTest {
        mBinder.setCommunalViewShowing(true);
        mBinder.setCommunalViewShowing(true);
        when(mKeyguardManager.isKeyguardLocked()).thenReturn(true);
        when(mKeyguardManager.isKeyguardLocked()).thenReturn(true);
        mAInfo.flags = 0;
        mAInfo.flags = 0;
        assertThat(mActivityInterceptorCallback.intercept(buildActivityInfo(intent))).isNotNull();
        // TODO(b/191994709): Fix this assertion once we properly intercept activities.
        assertThat(mActivityInterceptorCallback.intercept(buildActivityInfo(intent))).isNull();
    }
    }


    @Test
    @Test
@@ -203,7 +204,8 @@ public class CommunalManagerServiceTest {
        mAInfo.flags = FLAG_SHOW_WHEN_LOCKED;
        mAInfo.flags = FLAG_SHOW_WHEN_LOCKED;


        allowPackages("package1,package2");
        allowPackages("package1,package2");
        assertThat(mActivityInterceptorCallback.intercept(buildActivityInfo(intent))).isNotNull();
        // TODO(b/191994709): Fix this assertion once we properly intercept activities.
        assertThat(mActivityInterceptorCallback.intercept(buildActivityInfo(intent))).isNull();
    }
    }


    @Test
    @Test
@@ -215,7 +217,8 @@ public class CommunalManagerServiceTest {
        mAInfo.flags = 0;
        mAInfo.flags = 0;


        allowPackages(TEST_PACKAGE_NAME);
        allowPackages(TEST_PACKAGE_NAME);
        assertThat(mActivityInterceptorCallback.intercept(buildActivityInfo(intent))).isNotNull();
        // TODO(b/191994709): Fix this assertion once we properly intercept activities.
        assertThat(mActivityInterceptorCallback.intercept(buildActivityInfo(intent))).isNull();
    }
    }


    @Test
    @Test