Loading services/core/java/com/android/server/communal/CommunalManagerService.java +13 −11 Original line number Diff line number Diff line Loading @@ -129,17 +129,19 @@ public final class CommunalManagerService extends SystemService { } private boolean isActivityAllowed(ActivityInfo activityInfo) { if (!mCommunalViewIsShowing.get() || !mKeyguardManager.isKeyguardLocked()) return true; // If the activity doesn't have showWhenLocked enabled, disallow the activity. final boolean showWhenLocked = (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); return true; // TODO(b/191994709): Uncomment the lines below once Dreams and Assistant have been fixed. // if (!mCommunalViewIsShowing.get() || !mKeyguardManager.isKeyguardLocked()) return true; // // // If the activity doesn't have showWhenLocked enabled, disallow the activity. // final boolean showWhenLocked = // (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); } private final class SettingsObserver extends ContentObserver { Loading services/tests/mockingservicestests/src/com/android/server/communal/CommunalManagerServiceTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -191,7 +191,8 @@ public class CommunalManagerServiceTest { mBinder.setCommunalViewShowing(true); when(mKeyguardManager.isKeyguardLocked()).thenReturn(true); 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 Loading @@ -203,7 +204,8 @@ public class CommunalManagerServiceTest { mAInfo.flags = FLAG_SHOW_WHEN_LOCKED; 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 Loading @@ -215,7 +217,8 @@ public class CommunalManagerServiceTest { mAInfo.flags = 0; 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 Loading Loading
services/core/java/com/android/server/communal/CommunalManagerService.java +13 −11 Original line number Diff line number Diff line Loading @@ -129,17 +129,19 @@ public final class CommunalManagerService extends SystemService { } private boolean isActivityAllowed(ActivityInfo activityInfo) { if (!mCommunalViewIsShowing.get() || !mKeyguardManager.isKeyguardLocked()) return true; // If the activity doesn't have showWhenLocked enabled, disallow the activity. final boolean showWhenLocked = (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); return true; // TODO(b/191994709): Uncomment the lines below once Dreams and Assistant have been fixed. // if (!mCommunalViewIsShowing.get() || !mKeyguardManager.isKeyguardLocked()) return true; // // // If the activity doesn't have showWhenLocked enabled, disallow the activity. // final boolean showWhenLocked = // (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); } private final class SettingsObserver extends ContentObserver { Loading
services/tests/mockingservicestests/src/com/android/server/communal/CommunalManagerServiceTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -191,7 +191,8 @@ public class CommunalManagerServiceTest { mBinder.setCommunalViewShowing(true); when(mKeyguardManager.isKeyguardLocked()).thenReturn(true); 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 Loading @@ -203,7 +204,8 @@ public class CommunalManagerServiceTest { mAInfo.flags = FLAG_SHOW_WHEN_LOCKED; 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 Loading @@ -215,7 +217,8 @@ public class CommunalManagerServiceTest { mAInfo.flags = 0; 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 Loading