summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Komsiyski <vladokom@google.com> 2024-07-31 14:20:52 +0200
committer Vladimir Komsiyski <vladokom@google.com> 2024-08-02 14:20:06 +0200
commitd7ce40a68c135c901c010836bffa31491375752b (patch)
treead635d0f86b0d8b7c7f44b1cf571a18f251035b3
parent73a1f20925aaeae873c3d239b2e41840e50d3c52 (diff)
Fix several issues with the CDM association dialog:
Affecting only self-managed associations. Dialog title and summary: - Fix the app name resource in self-managed profiles titles and summaries. The resources are defined correctly, they expect the app name to be passed, but the substitution is actually done with the device name, which is wrong. Also, add the device name to the title and summary string resources to make the message Helper dialog: - The helper title is hardcoded "Cross-Device Services". It needs to be the name of the app requesting the association. - Remove the now obsolete helper title string resources. - Make the message of APP_STREAMING profile consistent with the one for NEARBY_DEVICE_STREAMING - Add a map of profile to helper summary, similarly to the rest of the CDM resources. Clean up: - Clean up launched VDM flag interactiveScreenMirror. It's low-risk, has no API changes and has been in Nextfood for months. - Remove the now obsolete string resources after the mirroring flag is cleaned up. - Remove the unused permission constants, string and drawable resources for APP_STREAMING and NEARBY_DEVICE_STREAMING profiles. They are obsolete after the mirroring flag is cleaned up because there are no "permissions" associated with these profiles. Fix: 338973982 Flag: EXEMPT bugfix Test: presubmit, manual with VDM demo app Change-Id: I8c9e404a77b9e74fc813b3c3c9effc85050d15bc
-rw-r--r--packages/CompanionDeviceManager/res/values/strings.xml53
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionAssociationActivity.java10
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceResources.java69
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java46
4 files changed, 59 insertions, 119 deletions
diff --git a/packages/CompanionDeviceManager/res/values/strings.xml b/packages/CompanionDeviceManager/res/values/strings.xml
index 42d0cc403372..a57d6eb11927 100644
--- a/packages/CompanionDeviceManager/res/values/strings.xml
+++ b/packages/CompanionDeviceManager/res/values/strings.xml
@@ -34,7 +34,7 @@
<string name="chooser_title">Choose a <xliff:g id="profile_name" example="watch">%1$s</xliff:g> to set up</string>
<!-- Description of the privileges the application will get if associated with the companion device of WATCH profile [CHAR LIMIT=NONE] -->
- <string name="summary_watch">This app will be allowed to sync info, like the name of someone calling, and access these permissions on your <xliff:g id="device_name" example="phone">%1$s</xliff:g></string>
+ <string name="summary_watch">This app will be allowed to sync info, like the name of someone calling, and access these permissions on your <xliff:g id="device_type" example="phone">%1$s</xliff:g></string>
<!-- ================= DEVICE_PROFILE_GLASSES ================= -->
@@ -45,27 +45,18 @@
<string name="profile_name_glasses">device</string>
<!-- Description of the privileges the application will get if associated with the companion device of GLASSES profile [CHAR LIMIT=NONE] -->
- <string name="summary_glasses">This app will be allowed to access these permissions on your <xliff:g id="device_name" example="phone">%1$s</xliff:g></string>
+ <string name="summary_glasses">This app will be allowed to access these permissions on your <xliff:g id="device_type" example="phone">%1$s</xliff:g></string>
<!-- ================= DEVICE_PROFILE_APP_STREAMING ================= -->
<!-- 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>
-
- <!-- 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>
+ <string name="title_app_streaming">Allow &lt;strong&gt;<xliff:g id="app_name" example="Exo">%1$s</xliff:g>&lt;/strong&gt; to stream your <xliff:g id="device_type" example="phone">%2$s</xliff:g>\u2019s apps to &lt;strong&gt;<xliff:g id="device_name" example="Chromebook">%3$s</xliff:g>&lt;/strong&gt;?</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]. -->
- <string name="helper_title_app_streaming">Cross-device services</string>
+ <string name="summary_app_streaming"><xliff:g id="app_name" example="Exo">%1$s</xliff:g> will have access to anything that’s visible or played on the <xliff:g id="device_type" example="phone">%2$s</xliff:g>, including audio, photos, passwords, and messages.&lt;br/>&lt;br/><xliff:g id="app_name" example="Exo">%1$s</xliff:g> will be able to stream apps to <xliff:g id="device_name" example="Chromebook">%3$s</xliff:g> until you remove access to this permission.</string>
<!-- 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>
-
- <!-- 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>
+ <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="device_name" example="Chromebook">%2$s</xliff:g> to display and stream apps between your devices</string>
<!-- ================= DEVICE_PROFILE_AUTOMOTIVE_PROJECTION ================= -->
@@ -78,30 +69,24 @@
<!-- ================= DEVICE_PROFILE_COMPUTER ================= -->
<!-- Confirmation for associating an application with a companion device of COMPUTER profile (type) [CHAR LIMIT=NONE] -->
- <string name="title_computer">Allow &lt;strong&gt;<xliff:g id="app_name" example="GMS">%1$s</xliff:g>&lt;/strong&gt; to access this information from your phone</string>
+ <string name="title_computer">Allow &lt;strong&gt;<xliff:g id="app_name" example="GMS">%1$s</xliff:g>&lt;/strong&gt; to access this information from your <xliff:g id="device_type" example="phone">%2$s</xliff:g></string>
<!-- Description of the privileges the application will get if associated with the companion device of COMPUTER profile (type) [CHAR LIMIT=NONE] -->
<string name="summary_computer"></string>
- <!-- Title of the helper dialog for COMPUTER profile [CHAR LIMIT=30]. -->
- <string name="helper_title_computer">Google Play services</string>
-
<!-- Description of the helper dialog for COMPUTER profile. [CHAR LIMIT=NONE] -->
- <string name="helper_summary_computer"><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 access your phone\u2019s photos, media, and notifications</string>
+ <string name="helper_summary_computer"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_name" example="Chromebook">%2$s</xliff:g> to access your <xliff:g id="device_type" example="phone">%3$s</xliff:g>\u2019s photos, media, and notifications</string>
<!-- ================= DEVICE_PROFILE_NEARBY_DEVICE_STREAMING ================= -->
<!-- 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>
-
- <!-- 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>
+ <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 stream your <xliff:g id="device_type" example="phone">%2$s</xliff:g>\u2019s apps and system features to &lt;strong&gt;<xliff:g id="device_name" example="Chromebook">%3$s</xliff:g>&lt;/strong&gt;?</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>
+ <string name="summary_nearby_device_streaming"><xliff:g id="app_name" example="Exo">%1$s</xliff:g> will have access to anything that’s visible or played on your <xliff:g id="device_type" example="phone">%2$s</xliff:g>, including audio, photos, payment info, passwords, and messages.&lt;br/>&lt;br/><xliff:g id="app_name" example="Exo">%1$s</xliff:g> will be able to stream apps and system features to <xliff:g id="device_name" example="Chromebook">%3$s</xliff:g> until you remove access to this permission.</string>
<!-- 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 between your devices</string>
<!-- ================= null profile ================= -->
@@ -173,12 +158,6 @@
<!-- Notification permission will be granted of corresponding profile [CHAR LIMIT=30] -->
<string name="permission_notifications">Notifications</string>
- <!-- Apps permission will be granted of corresponding profile [CHAR LIMIT=30] -->
- <string name="permission_app_streaming">Apps</string>
-
- <!-- Nearby_device_streaming permission will be granted to the corresponding profile [CHAR LIMIT=45] -->
- <string name="permission_nearby_device_streaming">Streaming</string>
-
<!-- Description of phone permission of corresponding profile [CHAR LIMIT=NONE] -->
<string name="permission_phone_summary">Make and manage phone calls</string>
@@ -206,15 +185,9 @@
<!-- Description of NLA & POST_NOTIFICATION of corresponding profile [CHAR LIMIT=NONE] -->
<string name="permission_notifications_summary">\u2022 Read all notifications, including info like contacts, messages, and photos&lt;br/>\u2022 Send notifications&lt;br/>&lt;br/>You can manage this app\'s ability to read and send notifications anytime in Settings > Notifications.</string>
- <!-- Description of app streaming permission of corresponding profile [CHAR LIMIT=NONE] -->
- <string name="permission_app_streaming_summary">Stream your phone\u2019s apps</string>
-
<!-- Description of storage permission of corresponding profile [CHAR LIMIT=NONE] -->
<string name="permission_storage_summary"></string>
- <!-- Description of nearby_device_streaming permission of corresponding profile [CHAR LIMIT=NONE] -->
- <string name="permission_nearby_device_streaming_summary">Stream apps and other system features from your phone</string>
-
<!-- Description of change media output permission to be granted to the corresponding profile [CHAR LIMIT=NONE] -->
<string name="permission_media_routing_control_summary">Access a list of available devices and control which one streams or casts audio or video from other apps</string>
@@ -224,4 +197,10 @@
<!-- The type of the device for tablet [CHAR LIMIT=30] -->
<string name="device_type" product="tablet">tablet</string>
+ <!-- The type of the device for TV [CHAR LIMIT=30] -->
+ <string name="device_type" product="tv">tv</string>
+
+ <!-- The type of the device for other device [CHAR LIMIT=30] -->
+ <string name="device_type" product="device">device</string>
+
</resources>
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionAssociationActivity.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionAssociationActivity.java
index e00533422072..61173306180e 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionAssociationActivity.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionAssociationActivity.java
@@ -440,12 +440,13 @@ public class CompanionAssociationActivity extends FragmentActivity implements
return;
}
- title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), deviceName);
+ title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), mAppLabel,
+ getString(R.string.device_type), deviceName);
if (PROFILE_SUMMARIES.containsKey(deviceProfile)) {
final int summaryResourceId = PROFILE_SUMMARIES.get(deviceProfile);
final Spanned summary = getHtmlFromResources(this, summaryResourceId,
- deviceName);
+ mAppLabel, getString(R.string.device_type), deviceName);
mSummary.setText(summary);
} else {
mSummary.setVisibility(View.GONE);
@@ -646,6 +647,11 @@ public class CompanionAssociationActivity extends FragmentActivity implements
// and when mPermissionListRecyclerView is fully populated.
// Lastly, disable the Allow and Don't allow buttons.
private void setupPermissionList(String deviceProfile) {
+ if (!PROFILE_PERMISSIONS.containsKey(deviceProfile)) {
+ // Nothing to do if there are no permission types.
+ return;
+ }
+
final List<Integer> permissionTypes = new ArrayList<>(
PROFILE_PERMISSIONS.get(deviceProfile));
if (permissionTypes.isEmpty()) {
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceResources.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceResources.java
index dc68bccc8f0a..37b1f297f90b 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceResources.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceResources.java
@@ -27,13 +27,11 @@ import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
-import android.companion.virtual.flags.Flags;
import android.os.Build;
import android.util.ArrayMap;
import android.util.ArraySet;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -47,31 +45,27 @@ final class CompanionDeviceResources {
// Permission resources
private static final int PERMISSION_NOTIFICATION_LISTENER_ACCESS = 0;
private static final int PERMISSION_STORAGE = 1;
- private static final int PERMISSION_APP_STREAMING = 2;
- private static final int PERMISSION_PHONE = 3;
- private static final int PERMISSION_SMS = 4;
- private static final int PERMISSION_CONTACTS = 5;
- private static final int PERMISSION_CALENDAR = 6;
- private static final int PERMISSION_NEARBY_DEVICES = 7;
- private static final int PERMISSION_NEARBY_DEVICE_STREAMING = 8;
- private static final int PERMISSION_MICROPHONE = 9;
- private static final int PERMISSION_CALL_LOGS = 10;
+ private static final int PERMISSION_PHONE = 2;
+ private static final int PERMISSION_SMS = 3;
+ private static final int PERMISSION_CONTACTS = 4;
+ private static final int PERMISSION_CALENDAR = 5;
+ private static final int PERMISSION_NEARBY_DEVICES = 6;
+ private static final int PERMISSION_MICROPHONE = 7;
+ private static final int PERMISSION_CALL_LOGS = 8;
// Notification Listener Access & POST_NOTIFICATION permission
- private static final int PERMISSION_NOTIFICATIONS = 11;
- private static final int PERMISSION_CHANGE_MEDIA_OUTPUT = 12;
+ private static final int PERMISSION_NOTIFICATIONS = 9;
+ private static final int PERMISSION_CHANGE_MEDIA_OUTPUT = 10;
static final Map<Integer, Integer> PERMISSION_TITLES;
static {
final Map<Integer, Integer> map = new ArrayMap<>();
map.put(PERMISSION_NOTIFICATION_LISTENER_ACCESS, R.string.permission_notifications);
map.put(PERMISSION_STORAGE, R.string.permission_storage);
- map.put(PERMISSION_APP_STREAMING, R.string.permission_app_streaming);
map.put(PERMISSION_PHONE, R.string.permission_phone);
map.put(PERMISSION_SMS, R.string.permission_sms);
map.put(PERMISSION_CONTACTS, R.string.permission_contacts);
map.put(PERMISSION_CALENDAR, R.string.permission_calendar);
map.put(PERMISSION_NEARBY_DEVICES, R.string.permission_nearby_devices);
- map.put(PERMISSION_NEARBY_DEVICE_STREAMING, R.string.permission_nearby_device_streaming);
map.put(PERMISSION_MICROPHONE, R.string.permission_microphone);
map.put(PERMISSION_CALL_LOGS, R.string.permission_call_logs);
map.put(PERMISSION_NOTIFICATIONS, R.string.permission_notifications);
@@ -85,14 +79,11 @@ final class CompanionDeviceResources {
map.put(PERMISSION_NOTIFICATION_LISTENER_ACCESS,
R.string.permission_notification_listener_access_summary);
map.put(PERMISSION_STORAGE, R.string.permission_storage_summary);
- map.put(PERMISSION_APP_STREAMING, R.string.permission_app_streaming_summary);
map.put(PERMISSION_PHONE, R.string.permission_phone_summary);
map.put(PERMISSION_SMS, R.string.permission_sms_summary);
map.put(PERMISSION_CONTACTS, R.string.permission_contacts_summary);
map.put(PERMISSION_CALENDAR, R.string.permission_calendar_summary);
map.put(PERMISSION_NEARBY_DEVICES, R.string.permission_nearby_devices_summary);
- map.put(PERMISSION_NEARBY_DEVICE_STREAMING,
- R.string.permission_nearby_device_streaming_summary);
map.put(PERMISSION_MICROPHONE, R.string.permission_microphone_summary);
map.put(PERMISSION_CALL_LOGS, R.string.permission_call_logs_summary);
map.put(PERMISSION_NOTIFICATIONS, R.string.permission_notifications_summary);
@@ -105,14 +96,11 @@ final class CompanionDeviceResources {
final Map<Integer, Integer> map = new ArrayMap<>();
map.put(PERMISSION_NOTIFICATION_LISTENER_ACCESS, R.drawable.ic_permission_notifications);
map.put(PERMISSION_STORAGE, R.drawable.ic_permission_storage);
- map.put(PERMISSION_APP_STREAMING, R.drawable.ic_permission_app_streaming);
map.put(PERMISSION_PHONE, R.drawable.ic_permission_phone);
map.put(PERMISSION_SMS, R.drawable.ic_permission_sms);
map.put(PERMISSION_CONTACTS, R.drawable.ic_permission_contacts);
map.put(PERMISSION_CALENDAR, R.drawable.ic_permission_calendar);
map.put(PERMISSION_NEARBY_DEVICES, R.drawable.ic_permission_nearby_devices);
- map.put(PERMISSION_NEARBY_DEVICE_STREAMING,
- R.drawable.ic_permission_nearby_device_streaming);
map.put(PERMISSION_MICROPHONE, R.drawable.ic_permission_microphone);
map.put(PERMISSION_CALL_LOGS, R.drawable.ic_permission_call_logs);
map.put(PERMISSION_NOTIFICATIONS, R.drawable.ic_permission_notifications);
@@ -124,19 +112,10 @@ final class CompanionDeviceResources {
static final Map<String, Integer> PROFILE_TITLES;
static {
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_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_GLASSES, R.string.confirmation_title_glasses);
map.put(null, R.string.confirmation_title);
@@ -149,29 +128,29 @@ final class CompanionDeviceResources {
final Map<String, Integer> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_WATCH, R.string.summary_watch);
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(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);
PROFILE_SUMMARIES = unmodifiableMap(map);
}
+ static final Map<String, Integer> PROFILE_HELPER_SUMMARIES;
+ static {
+ final Map<String, Integer> map = new ArrayMap<>();
+ map.put(DEVICE_PROFILE_APP_STREAMING, R.string.helper_summary_app_streaming);
+ map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
+ R.string.helper_summary_nearby_device_streaming);
+ map.put(DEVICE_PROFILE_COMPUTER, R.string.helper_summary_computer);
+
+ PROFILE_HELPER_SUMMARIES = unmodifiableMap(map);
+ }
+
static final Map<String, List<Integer>> PROFILE_PERMISSIONS;
static {
final Map<String, List<Integer>> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_COMPUTER, Arrays.asList(
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,
- Arrays.asList(PERMISSION_NEARBY_DEVICE_STREAMING));
- }
if (Build.VERSION.SDK_INT > UPSIDE_DOWN_CAKE) {
map.put(DEVICE_PROFILE_WATCH, Arrays.asList(PERMISSION_NOTIFICATIONS, PERMISSION_PHONE,
PERMISSION_CALL_LOGS, PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_CALENDAR,
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java
index fe0e021b363c..ec92987e7e87 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java
@@ -16,17 +16,13 @@
package com.android.companiondevicemanager;
-import static android.companion.AssociationRequest.DEVICE_PROFILE_APP_STREAMING;
-import static android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER;
-import static android.companion.AssociationRequest.DEVICE_PROFILE_NEARBY_DEVICE_STREAMING;
-
+import static com.android.companiondevicemanager.CompanionDeviceResources.PROFILE_HELPER_SUMMARIES;
import static com.android.companiondevicemanager.Utils.getApplicationIcon;
import static com.android.companiondevicemanager.Utils.getApplicationLabel;
import static com.android.companiondevicemanager.Utils.getHtmlFromResources;
import android.annotation.Nullable;
import android.companion.AssociationRequest;
-import android.companion.virtual.flags.Flags;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
@@ -105,7 +101,7 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment {
final String deviceProfile = request.getDeviceProfile();
final String packageName = request.getPackageName();
- final CharSequence displayName = request.getDisplayName();
+ final CharSequence deviceName = request.getDisplayName();
final int userId = request.getUserId();
final CharSequence appLabel;
@@ -123,37 +119,17 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment {
mAppIcon = view.findViewById(R.id.app_icon);
mButton = view.findViewById(R.id.btn_back);
- final CharSequence title;
- final Spanned summary;
-
- switch (deviceProfile) {
- case DEVICE_PROFILE_APP_STREAMING:
- title = getHtmlFromResources(getContext(), R.string.helper_title_app_streaming);
- summary = getHtmlFromResources(
- getContext(), Flags.interactiveScreenMirror()
- ? R.string.helper_summary_app_streaming_with_mirroring
- : R.string.helper_summary_app_streaming, title, displayName);
- break;
-
- case DEVICE_PROFILE_COMPUTER:
- title = getHtmlFromResources(getContext(), R.string.helper_title_computer);
- summary = getHtmlFromResources(
- getContext(), R.string.helper_summary_computer, title, displayName);
- break;
-
- case DEVICE_PROFILE_NEARBY_DEVICE_STREAMING:
- title = appLabel;
- summary = getHtmlFromResources(
- getContext(), R.string.helper_summary_nearby_device_streaming, title,
- displayName);
- break;
-
- default:
- throw new RuntimeException("Unsupported profile " + deviceProfile);
+ if (PROFILE_HELPER_SUMMARIES.containsKey(deviceProfile)) {
+ final int summaryResourceId = PROFILE_HELPER_SUMMARIES.get(deviceProfile);
+ final Spanned summary = getHtmlFromResources(
+ getContext(), summaryResourceId, appLabel, deviceName,
+ getString(R.string.device_type));
+ mSummary.setText(summary);
+ } else {
+ throw new RuntimeException("Unsupported profile " + deviceProfile);
}
- mTitle.setText(title);
- mSummary.setText(summary);
+ mTitle.setText(appLabel);
mAppIcon.setImageDrawable(applicationIcon);
mButton.setOnClickListener(v -> {