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

Commit 0b90c194 authored by Biswarup Pal's avatar Biswarup Pal
Browse files

Updates in CDM dialogs for VDM screen mirroring

With the introduction of VDM interactive screen mirroring, the
message of the CDM dialog for app_streaming and device_streming
roles is being updated to inform the user regarding the potential
privacy implications.

App streaming dialog screenshots
Before - https://screenshot.googleplex.com/9ZoiLqj6GWEWkCN.png
After - https://screenshot.googleplex.com/4ufMdY9cVfAAtxx.png

Device streaming dialog screenshots
Before - https://screenshot.googleplex.com/BoRnT5ZwUwckSBQ.png
After - https://screenshot.googleplex.com/9syAMbBqBVKGqn2.png

Test: VirtualDeviceManager demo app
Bug: 292212199
Change-Id: I22bf148ed1aa24f79124c85a406ab381ae7aab46
parent 487d8fa9
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -52,12 +52,21 @@
    <!-- Confirmation for associating an application with a companion device of APP_STREAMING profile (type) [CHAR LIMIT=NONE] -->
    <!-- Confirmation for associating an application with a companion device of APP_STREAMING profile (type) [CHAR LIMIT=NONE] -->
    <string name="title_app_streaming">Allow &lt;strong&gt;<xliff:g id="app_name" example="Exo">%1$s</xliff:g>&lt;/strong&gt; to access this information from your phone</string>
    <string name="title_app_streaming">Allow &lt;strong&gt;<xliff:g id="app_name" example="Exo">%1$s</xliff:g>&lt;/strong&gt; to access this information from your phone</string>


    <!-- Confirmation for associating an application with a companion device of APP_STREAMING profile (type) with mirroring enabled [CHAR LIMIT=NONE] -->
    <string name="title_app_streaming_with_mirroring">Allow &lt;strong&gt;<xliff:g id="app_name" example="Exo">%1$s</xliff:g>&lt;/strong&gt; to stream your phone\u2019s apps?</string>

    <!-- Summary for associating an application with a companion device of APP_STREAMING profile [CHAR LIMIT=NONE] -->
    <string name="summary_app_streaming">%1$s will have access to anything that’s visible or played on the phone, including audio, photos, passwords, and messages.&lt;br/>&lt;br/>%1$s will be able to stream apps until you remove access to this permission.</string>

    <!-- Title of the helper dialog for APP_STREAMING profile [CHAR LIMIT=30]. -->
    <!-- Title of the helper dialog for APP_STREAMING profile [CHAR LIMIT=30]. -->
    <string name="helper_title_app_streaming">Cross-device services</string>
    <string name="helper_title_app_streaming">Cross-device services</string>


    <!-- Description of the helper dialog for APP_STREAMING profile. [CHAR LIMIT=NONE] -->
    <!-- Description of the helper dialog for APP_STREAMING profile. [CHAR LIMIT=NONE] -->
    <string name="helper_summary_app_streaming"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="display_name" example="Chromebook">%2$s</xliff:g> to stream apps between your devices</string>
    <string name="helper_summary_app_streaming"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="display_name" example="Chromebook">%2$s</xliff:g> to stream apps between your devices</string>


    <!-- Description of the helper dialog for APP_STREAMING profile with mirroring enabled. [CHAR LIMIT=NONE] -->
    <string name="helper_summary_app_streaming_with_mirroring"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="display_name" example="Chromebook">%2$s</xliff:g> to display and stream apps between your devices</string>

    <!-- ================= DEVICE_PROFILE_AUTOMOTIVE_PROJECTION ================= -->
    <!-- ================= DEVICE_PROFILE_AUTOMOTIVE_PROJECTION ================= -->


    <!-- Confirmation for associating an application with a companion device of AUTOMOTIVE_PROJECTION profile (type) [CHAR LIMIT=NONE] -->
    <!-- Confirmation for associating an application with a companion device of AUTOMOTIVE_PROJECTION profile (type) [CHAR LIMIT=NONE] -->
@@ -85,6 +94,12 @@
    <!-- Confirmation for associating an application with a companion device of NEARBY_DEVICE_STREAMING profile (type) [CHAR LIMIT=NONE] -->
    <!-- Confirmation for associating an application with a companion device of NEARBY_DEVICE_STREAMING profile (type) [CHAR LIMIT=NONE] -->
    <string name="title_nearby_device_streaming">Allow &lt;strong&gt;<xliff:g id="device_name" example="NearbyStreamer">%1$s</xliff:g>&lt;/strong&gt; to take this action?</string>
    <string name="title_nearby_device_streaming">Allow &lt;strong&gt;<xliff:g id="device_name" example="NearbyStreamer">%1$s</xliff:g>&lt;/strong&gt; to take this action?</string>


    <!-- Confirmation for associating an application with a companion device of NEARBY_DEVICE_STREAMING profile (type) with mirroring enabled [CHAR LIMIT=NONE] -->
    <string name="title_nearby_device_streaming_with_mirroring">Allow &lt;strong&gt;<xliff:g id="device_name" example="NearbyStreamer">%1$s</xliff:g>&lt;/strong&gt; to stream your phone\u2019s apps and system features?</string>

    <!-- Summary for associating an application with a companion device of NEARBY_DEVICE_STREAMING profile [CHAR LIMIT=NONE] -->
    <string name="summary_nearby_device_streaming">%1$s will have access to anything that’s visible or played on your phone, including audio, photos, payment info, passwords, and messages.&lt;br/>&lt;br/>%1$s will be able to stream apps and system features until you remove access to this permission.</string>

    <!-- Description of the helper dialog for NEARBY_DEVICE_STREAMING profile. [CHAR LIMIT=NONE] -->
    <!-- Description of the helper dialog for NEARBY_DEVICE_STREAMING profile. [CHAR LIMIT=NONE] -->
    <string name="helper_summary_nearby_device_streaming"><xliff:g id="app_name" example="NearbyStreamerApp">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_name" example="NearbyDevice">%2$s</xliff:g> to stream apps and other system features to nearby devices</string>
    <string name="helper_summary_nearby_device_streaming"><xliff:g id="app_name" example="NearbyStreamerApp">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_name" example="NearbyDevice">%2$s</xliff:g> to stream apps and other system features to nearby devices</string>


+16 −3
Original line number Original line Diff line number Diff line
@@ -179,7 +179,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
    // onActivityResult() after the association is created.
    // onActivityResult() after the association is created.
    private @Nullable DeviceFilterPair<?> mSelectedDevice;
    private @Nullable DeviceFilterPair<?> mSelectedDevice;


    private LinearLayoutManager mPermissionsLayoutManager = new LinearLayoutManager(this);
    private final LinearLayoutManager mPermissionsLayoutManager = new LinearLayoutManager(this);


    @Override
    @Override
    public void onCreate(Bundle savedInstanceState) {
    public void onCreate(Bundle savedInstanceState) {
@@ -484,10 +484,18 @@ public class CompanionDeviceActivity extends FragmentActivity implements
        }
        }


        title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), deviceName);
        title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), deviceName);
        setupPermissionList(deviceProfile);


        // Summary is not needed for selfManaged dialog.
        if (PROFILE_SUMMARIES.containsKey(deviceProfile)) {
            final int summaryResourceId = PROFILE_SUMMARIES.get(deviceProfile);
            final Spanned summary = getHtmlFromResources(this, summaryResourceId,
                    deviceName);
            mSummary.setText(summary);
        } else {
            mSummary.setVisibility(View.GONE);
            mSummary.setVisibility(View.GONE);
        }

        setupPermissionList(deviceProfile);

        mTitle.setText(title);
        mTitle.setText(title);
        mVendorHeaderName.setText(vendorName);
        mVendorHeaderName.setText(vendorName);
        mVendorHeader.setVisibility(View.VISIBLE);
        mVendorHeader.setVisibility(View.VISIBLE);
@@ -692,6 +700,11 @@ public class CompanionDeviceActivity extends FragmentActivity implements
    private void setupPermissionList(String deviceProfile) {
    private void setupPermissionList(String deviceProfile) {
        final List<Integer> permissionTypes = new ArrayList<>(
        final List<Integer> permissionTypes = new ArrayList<>(
                PROFILE_PERMISSIONS.get(deviceProfile));
                PROFILE_PERMISSIONS.get(deviceProfile));
        if (permissionTypes.isEmpty()) {
            // Nothing to do if there are no permission types.
            return;
        }

        mPermissionListAdapter.setPermissionType(permissionTypes);
        mPermissionListAdapter.setPermissionType(permissionTypes);
        mPermissionListRecyclerView.setAdapter(mPermissionListAdapter);
        mPermissionListRecyclerView.setAdapter(mPermissionListAdapter);
        mPermissionListRecyclerView.setLayoutManager(mPermissionsLayoutManager);
        mPermissionListRecyclerView.setLayoutManager(mPermissionsLayoutManager);
+26 −5
Original line number Original line Diff line number Diff line
@@ -27,11 +27,13 @@ import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
import static java.util.Collections.unmodifiableSet;


import android.companion.virtual.flags.Flags;
import android.os.Build;
import android.os.Build;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.ArraySet;


import java.util.Arrays;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.Set;
import java.util.Set;
@@ -122,10 +124,19 @@ final class CompanionDeviceResources {
    static final Map<String, Integer> PROFILE_TITLES;
    static final Map<String, Integer> PROFILE_TITLES;
    static {
    static {
        final Map<String, Integer> map = new ArrayMap<>();
        final Map<String, Integer> map = new ArrayMap<>();
        if (Flags.interactiveScreenMirror()) {
            map.put(DEVICE_PROFILE_APP_STREAMING, R.string.title_app_streaming_with_mirroring);
        } else {
            map.put(DEVICE_PROFILE_APP_STREAMING, R.string.title_app_streaming);
            map.put(DEVICE_PROFILE_APP_STREAMING, R.string.title_app_streaming);
        }
        map.put(DEVICE_PROFILE_AUTOMOTIVE_PROJECTION, R.string.title_automotive_projection);
        map.put(DEVICE_PROFILE_AUTOMOTIVE_PROJECTION, R.string.title_automotive_projection);
        map.put(DEVICE_PROFILE_COMPUTER, R.string.title_computer);
        map.put(DEVICE_PROFILE_COMPUTER, R.string.title_computer);
        if (Flags.interactiveScreenMirror()) {
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
                    R.string.title_nearby_device_streaming_with_mirroring);
        } else {
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING, R.string.title_nearby_device_streaming);
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING, R.string.title_nearby_device_streaming);
        }
        map.put(DEVICE_PROFILE_WATCH, R.string.confirmation_title);
        map.put(DEVICE_PROFILE_WATCH, R.string.confirmation_title);
        map.put(DEVICE_PROFILE_GLASSES, R.string.confirmation_title_glasses);
        map.put(DEVICE_PROFILE_GLASSES, R.string.confirmation_title_glasses);
        map.put(null, R.string.confirmation_title);
        map.put(null, R.string.confirmation_title);
@@ -138,6 +149,11 @@ final class CompanionDeviceResources {
        final Map<String, Integer> map = new ArrayMap<>();
        final Map<String, Integer> map = new ArrayMap<>();
        map.put(DEVICE_PROFILE_WATCH, R.string.summary_watch);
        map.put(DEVICE_PROFILE_WATCH, R.string.summary_watch);
        map.put(DEVICE_PROFILE_GLASSES, R.string.summary_glasses);
        map.put(DEVICE_PROFILE_GLASSES, R.string.summary_glasses);
        if (Flags.interactiveScreenMirror()) {
            map.put(DEVICE_PROFILE_APP_STREAMING, R.string.summary_app_streaming);
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
                    R.string.summary_nearby_device_streaming);
        }
        map.put(null, R.string.summary_generic);
        map.put(null, R.string.summary_generic);


        PROFILE_SUMMARIES = unmodifiableMap(map);
        PROFILE_SUMMARIES = unmodifiableMap(map);
@@ -146,11 +162,16 @@ final class CompanionDeviceResources {
    static final Map<String, List<Integer>> PROFILE_PERMISSIONS;
    static final Map<String, List<Integer>> PROFILE_PERMISSIONS;
    static {
    static {
        final Map<String, List<Integer>> map = new ArrayMap<>();
        final Map<String, List<Integer>> map = new ArrayMap<>();
        map.put(DEVICE_PROFILE_APP_STREAMING, Arrays.asList(PERMISSION_APP_STREAMING));
        map.put(DEVICE_PROFILE_COMPUTER, Arrays.asList(
        map.put(DEVICE_PROFILE_COMPUTER, Arrays.asList(
                PERMISSION_NOTIFICATION_LISTENER_ACCESS, PERMISSION_STORAGE));
                PERMISSION_NOTIFICATION_LISTENER_ACCESS, PERMISSION_STORAGE));
        if (Flags.interactiveScreenMirror()) {
            map.put(DEVICE_PROFILE_APP_STREAMING, Collections.emptyList());
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING, Collections.emptyList());
        } else {
            map.put(DEVICE_PROFILE_APP_STREAMING, Arrays.asList(PERMISSION_APP_STREAMING));
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
            map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
                    Arrays.asList(PERMISSION_NEARBY_DEVICE_STREAMING));
                    Arrays.asList(PERMISSION_NEARBY_DEVICE_STREAMING));
        }
        if (Build.VERSION.SDK_INT > UPSIDE_DOWN_CAKE) {
        if (Build.VERSION.SDK_INT > UPSIDE_DOWN_CAKE) {
            map.put(DEVICE_PROFILE_WATCH, Arrays.asList(PERMISSION_NOTIFICATIONS, PERMISSION_PHONE,
            map.put(DEVICE_PROFILE_WATCH, Arrays.asList(PERMISSION_NOTIFICATIONS, PERMISSION_PHONE,
                    PERMISSION_CALL_LOGS, PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_CALENDAR,
                    PERMISSION_CALL_LOGS, PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_CALENDAR,
+4 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import static com.android.companiondevicemanager.Utils.getHtmlFromResources;


import android.annotation.Nullable;
import android.annotation.Nullable;
import android.companion.AssociationRequest;
import android.companion.AssociationRequest;
import android.companion.virtual.flags.Flags;
import android.content.DialogInterface;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
@@ -129,7 +130,9 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment {
            case DEVICE_PROFILE_APP_STREAMING:
            case DEVICE_PROFILE_APP_STREAMING:
                title = getHtmlFromResources(getContext(), R.string.helper_title_app_streaming);
                title = getHtmlFromResources(getContext(), R.string.helper_title_app_streaming);
                summary = getHtmlFromResources(
                summary = getHtmlFromResources(
                        getContext(), R.string.helper_summary_app_streaming, title, displayName);
                        getContext(), Flags.interactiveScreenMirror()
                                ? R.string.helper_summary_app_streaming_with_mirroring
                                : R.string.helper_summary_app_streaming, title, displayName);
                break;
                break;


            case DEVICE_PROFILE_COMPUTER:
            case DEVICE_PROFILE_COMPUTER: