diff options
author | 2024-07-31 14:20:52 +0200 | |
---|---|---|
committer | 2024-08-02 14:20:06 +0200 | |
commit | d7ce40a68c135c901c010836bffa31491375752b (patch) | |
tree | ad635d0f86b0d8b7c7f44b1cf571a18f251035b3 /packages/CompanionDeviceManager/src | |
parent | 73a1f20925aaeae873c3d239b2e41840e50d3c52 (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
Diffstat (limited to 'packages/CompanionDeviceManager/src')
3 files changed, 43 insertions, 82 deletions
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 -> { |