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

Commit ccf3bb8e authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Intercept automated app launches and show a warning

 - ActivityStartInterceptor logic to replace the intent
 - Detection and warning dialog intent logic in VDM
 - New warning dialog in the VDM app

Bug: 442627126
Flag: android.companion.virtualdevice.flags.automated_app_launch_interception
Test: manual & atest
Change-Id: Ia8bbf51c0d7ff3ecf2e84f0f1a05255dab5a37e5
parent bd85660e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ public final class ComputerControlSession implements AutoCloseable {
    public static final String ACTION_REQUEST_ACCESS =
            "android.companion.virtual.computercontrol.action.REQUEST_ACCESS";

    /** @hide */
    public static final String EXTRA_AUTOMATING_PACKAGE_NAME =
            "android.companion.virtual.computercontrol.extra.AUTOMATING_PACKAGE_NAME";

    /**
     * Error code indicating that a new session cannot be created because the maximum number of
     * allowed concurrent sessions has been reached.
+10 −0
Original line number Diff line number Diff line
@@ -257,6 +257,16 @@ flag {
    }
}

flag {
    name: "automated_app_launch_interception"
    namespace: "virtual_devices"
    description: "Show a warning dialog when launching an automated app"
    bug: "442627126"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "computer_control_activity_policy_strict"
    namespace: "virtual_devices"
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,14 @@
            android:launchMode="singleTop">
        </activity>

        <activity
            android:name=".AutomatedAppLaunchWarningActivity"
            android:theme="@style/Theme.AutomatedAppLaunchWarningActivity.FilterTouches"
            android:excludeFromRecents="true"
            android:exported="true"
            android:launchMode="singleTop">
        </activity>

    </application>

</manifest>
+52 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/AutomatedAppLaunchWarningDialogScrollView">
    <LinearLayout
        style="@style/AutomatedAppLaunchWarningDialogContent">
        <LinearLayout
            style="@style/AutomatedAppLaunchWarningDialogIconBar">
            <ImageView
                android:id="@+id/agent_icon"
                style="@style/AutomatedAppLaunchWarningDialogAgentIcon" />
            <ImageView
                android:id="@+id/target_icon"
                style="@style/AutomatedAppLaunchWarningDialogTargetIcon" />
        </LinearLayout>
        <TextView
            android:id="@+id/title"
            android:text="@string/automated_app_launch_warning_dialog_title"
            style="@style/AutomatedAppLaunchWarningDialogTitle" />
        <TextView
            android:id="@+id/description"
            android:text="@string/automated_app_launch_warning_dialog_description"
            style="@style/AutomatedAppLaunchWarningDialogDescription" />
        <LinearLayout
            style="@style/AutomatedAppLaunchWarningDialogButtonBar">
            <Button
                android:id="@+id/stop_button"
                android:text="@string/automated_app_launch_warning_dialog_stop"
                style="@style/AutomatedAppLaunchWarningDialogStopButton" />
            <Button
                android:id="@+id/wait_button"
                android:text="@string/automated_app_launch_warning_dialog_wait"
                style="@style/AutomatedAppLaunchWarningDialogWaitButton" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>
+16 −0
Original line number Diff line number Diff line
@@ -52,4 +52,20 @@

    <!-- END NOTIFY COMPUTER CONTROL BLOCKED ACTIVITY DIALOG -->

    <!-- START AUTOMATED APP LAUNCH WARNING ACTIVITY DIALOG -->

    <!-- Label for the title of automated app launch warning dialog [CHAR LIMIT=70] -->
    <string name="automated_app_launch_warning_dialog_title"><xliff:g id="agent_app_name" example="Example Agent App">%1$s</xliff:g> is using <xliff:g id="target_app_name" example="Example Target App">%2$s</xliff:g></string>

    <!-- Label for the description of automated app launch warning dialog [CHAR LIMIT=NONE] -->
    <string name="automated_app_launch_warning_dialog_description">You can use <xliff:g id="target_app_name" example="Example Target App">%2$s</xliff:g> when <xliff:g id="agent_app_name" example="Example Agent App">%1$s</xliff:g> is done, or you can stop <xliff:g id="agent_app_name" example="Example Agent App">%1$s</xliff:g> to open <xliff:g id="target_app_name" example="Example Target App">%2$s</xliff:g> now</string>

    <!-- Label for the stop button for automated app launch warning dialog. [CHAR LIMIT=40] -->
    <string name="automated_app_launch_warning_dialog_stop">Stop task</string>

    <!-- Label for the wait button for automated app launch warning dialog. [CHAR LIMIT=40] -->
    <string name="automated_app_launch_warning_dialog_wait">I\u2019ll wait</string>

    <!-- END AUTOMATED APP LAUNCH WARNING ACTIVITY DIALOG -->

</resources>
Loading