Loading core/java/android/companion/virtual/computercontrol/ComputerControlSession.java +1 −3 Original line number Diff line number Diff line Loading @@ -159,9 +159,7 @@ public final class ComputerControlSession implements AutoCloseable { /** * Launches an application's launcher activity in the computer control session. * * <p>The application with the given package name must have a launcher activity and the * package name must have been declared during the session creation.</p> * * @throws IllegalArgumentException if the package does not have a launcher activity. * @see ComputerControlSessionParams#getTargetPackageNames() */ public void launchApplication(@NonNull String packageName) { Loading libs/computercontrol/src/com/android/extensions/computercontrol/ComputerControlSession.java +1 −3 Original line number Diff line number Diff line Loading @@ -106,9 +106,7 @@ public final class ComputerControlSession implements AutoCloseable { /** * Launches an application's launcher activity in the computer control session. * * <p>The application with the given package name must have a launcher activity and the * package name must have been included during the session creation.</p> * * @throws IllegalArgumentException if the package does not have a launcher activity. * @see Params#getTargetPackageNames() */ public void launchApplication(@NonNull String packageName) { Loading services/companion/java/com/android/server/companion/virtual/computercontrol/ComputerControlSessionImpl.java +7 −4 Original line number Diff line number Diff line Loading @@ -320,10 +320,13 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub return mOwnerPackageName; } public void launchApplication(@NonNull String packageName) { if (!mParams.getTargetPackageNames().contains(Objects.requireNonNull(packageName))) { throw new IllegalArgumentException( "Package " + packageName + " is not allowed to be launched in this session."); @Override public void launchApplication(@NonNull String packageName) throws RemoteException { if (Flags.computerControlActivityPolicyStrict()) { // TODO(b/444600407): Remove this once the consent model is per-target app. While the // consent is general, the caller can extend the list of target packages dynamically. mVirtualDevice.addActivityPolicyExemption( new ActivityPolicyExemption.Builder().setPackageName(packageName).build()); } final UserHandle user = UserHandle.of(UserHandle.getUserId(Binder.getCallingUid())); Binder.withCleanCallingIdentity(() -> mInjector.launchApplicationOnDisplayAsUser( Loading services/tests/servicestests/src/com/android/server/companion/virtual/computercontrol/ComputerControlSessionTest.java +17 −4 Original line number Diff line number Diff line Loading @@ -271,7 +271,7 @@ public class ComputerControlSessionTest { } @Test public void launchApplication_launchesApplication() { public void launchApplication_launchesApplication() throws RemoteException { createComputerControlSession(mDefaultParams); mSession.launchApplication(TARGET_PACKAGE_1); verify(mInjector).launchApplicationOnDisplayAsUser( Loading @@ -279,10 +279,23 @@ public class ComputerControlSessionTest { } @Test public void launchApplication_undeclaredPackage_throws() { @DisableFlags(Flags.FLAG_COMPUTER_CONTROL_ACTIVITY_POLICY_STRICT) public void launchApplication_noActivityPolicy_launchesApplication() throws RemoteException { createComputerControlSession(mDefaultParams); assertThrows(IllegalArgumentException.class, () -> mSession.launchApplication(UNDECLARED_TARGET_PACKAGE)); mSession.launchApplication(UNDECLARED_TARGET_PACKAGE); verify(mInjector).launchApplicationOnDisplayAsUser( eq(UNDECLARED_TARGET_PACKAGE), eq(VIRTUAL_DISPLAY_ID), any()); } @Test @EnableFlags(Flags.FLAG_COMPUTER_CONTROL_ACTIVITY_POLICY_STRICT) public void launchApplication_strictActivityPolicy_addsExemption() throws RemoteException { createComputerControlSession(mDefaultParams); mSession.launchApplication(UNDECLARED_TARGET_PACKAGE); verify(mVirtualDevice).addActivityPolicyExemption( argThat(new MatchesActivityPolicyExcemption(UNDECLARED_TARGET_PACKAGE))); verify(mInjector).launchApplicationOnDisplayAsUser( eq(UNDECLARED_TARGET_PACKAGE), eq(VIRTUAL_DISPLAY_ID), any()); } @Test Loading Loading
core/java/android/companion/virtual/computercontrol/ComputerControlSession.java +1 −3 Original line number Diff line number Diff line Loading @@ -159,9 +159,7 @@ public final class ComputerControlSession implements AutoCloseable { /** * Launches an application's launcher activity in the computer control session. * * <p>The application with the given package name must have a launcher activity and the * package name must have been declared during the session creation.</p> * * @throws IllegalArgumentException if the package does not have a launcher activity. * @see ComputerControlSessionParams#getTargetPackageNames() */ public void launchApplication(@NonNull String packageName) { Loading
libs/computercontrol/src/com/android/extensions/computercontrol/ComputerControlSession.java +1 −3 Original line number Diff line number Diff line Loading @@ -106,9 +106,7 @@ public final class ComputerControlSession implements AutoCloseable { /** * Launches an application's launcher activity in the computer control session. * * <p>The application with the given package name must have a launcher activity and the * package name must have been included during the session creation.</p> * * @throws IllegalArgumentException if the package does not have a launcher activity. * @see Params#getTargetPackageNames() */ public void launchApplication(@NonNull String packageName) { Loading
services/companion/java/com/android/server/companion/virtual/computercontrol/ComputerControlSessionImpl.java +7 −4 Original line number Diff line number Diff line Loading @@ -320,10 +320,13 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub return mOwnerPackageName; } public void launchApplication(@NonNull String packageName) { if (!mParams.getTargetPackageNames().contains(Objects.requireNonNull(packageName))) { throw new IllegalArgumentException( "Package " + packageName + " is not allowed to be launched in this session."); @Override public void launchApplication(@NonNull String packageName) throws RemoteException { if (Flags.computerControlActivityPolicyStrict()) { // TODO(b/444600407): Remove this once the consent model is per-target app. While the // consent is general, the caller can extend the list of target packages dynamically. mVirtualDevice.addActivityPolicyExemption( new ActivityPolicyExemption.Builder().setPackageName(packageName).build()); } final UserHandle user = UserHandle.of(UserHandle.getUserId(Binder.getCallingUid())); Binder.withCleanCallingIdentity(() -> mInjector.launchApplicationOnDisplayAsUser( Loading
services/tests/servicestests/src/com/android/server/companion/virtual/computercontrol/ComputerControlSessionTest.java +17 −4 Original line number Diff line number Diff line Loading @@ -271,7 +271,7 @@ public class ComputerControlSessionTest { } @Test public void launchApplication_launchesApplication() { public void launchApplication_launchesApplication() throws RemoteException { createComputerControlSession(mDefaultParams); mSession.launchApplication(TARGET_PACKAGE_1); verify(mInjector).launchApplicationOnDisplayAsUser( Loading @@ -279,10 +279,23 @@ public class ComputerControlSessionTest { } @Test public void launchApplication_undeclaredPackage_throws() { @DisableFlags(Flags.FLAG_COMPUTER_CONTROL_ACTIVITY_POLICY_STRICT) public void launchApplication_noActivityPolicy_launchesApplication() throws RemoteException { createComputerControlSession(mDefaultParams); assertThrows(IllegalArgumentException.class, () -> mSession.launchApplication(UNDECLARED_TARGET_PACKAGE)); mSession.launchApplication(UNDECLARED_TARGET_PACKAGE); verify(mInjector).launchApplicationOnDisplayAsUser( eq(UNDECLARED_TARGET_PACKAGE), eq(VIRTUAL_DISPLAY_ID), any()); } @Test @EnableFlags(Flags.FLAG_COMPUTER_CONTROL_ACTIVITY_POLICY_STRICT) public void launchApplication_strictActivityPolicy_addsExemption() throws RemoteException { createComputerControlSession(mDefaultParams); mSession.launchApplication(UNDECLARED_TARGET_PACKAGE); verify(mVirtualDevice).addActivityPolicyExemption( argThat(new MatchesActivityPolicyExcemption(UNDECLARED_TARGET_PACKAGE))); verify(mInjector).launchApplicationOnDisplayAsUser( eq(UNDECLARED_TARGET_PACKAGE), eq(VIRTUAL_DISPLAY_ID), any()); } @Test Loading