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

Commit 8eebb5af authored by Evan Chen's avatar Evan Chen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "bullet_mapping"

* changes:
  Add strings for bullet permissions
  Mapping device profiles and resourceIds
parents ee732156 3379c749
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2022 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:viewportWidth="24"
        android:viewportHeight="24"
        android:width="24dp"
        android:height="24dp"
        android:tint="@android:color/system_accent1_200">
    <path android:pathData="M16.01 14.48L13.39 17.1C10.64 15.61 8.38 13.35 6.89 10.6L9.51 7.98C9.75 7.74 9.85 7.4 9.78 7.08L9.13 3.82C9.04 3.35 8.63 3.02 8.15 3.02L4 3.01c-0.56 0 -1.03 0.47 -1 1.03 0.17 2.91 1.04 5.63 2.43 8.01 1.57 2.69 3.81 4.93 6.5 6.5 2.38 1.39 5.1 2.26 8.01 2.43 0.56 0.03 1.03 -0.44 1.03 -1l0 -4.15c0 -0.48 -0.34 -0.89 -0.8 -0.98L16.91 14.2c-0.33 -0.06 -0.67 0.04 -0.9 0.28z"
          android:fillColor="#ffffff" />
    <path android:pathData="M12 8l10 0 0 -2 -10 0 0 2zm0 -4l10 0 0 -2 -10 0 0 2zm10 6l-10 0 0 2 10 0 0 -2z"
          android:fillColor="#ffffff" />
</vector>
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -18,6 +18,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="@android:color/system_accent1_100"/>
    <corners android:topLeftRadius="20dp" android:topRightRadius="20dp"
             android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/>
    <corners android:topLeftRadius="30dp" android:topRightRadius="30dp"
             android:bottomLeftRadius="30dp" android:bottomRightRadius="30dp"/>
</shape>
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2022 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:viewportWidth="24"
        android:viewportHeight="24"
        android:width="24dp"
        android:height="24dp"
        android:tint="@android:color/system_accent1_600">
    <path android:pathData="M16.01 14.48L13.39 17.1C10.64 15.61 8.38 13.35 6.89 10.6L9.51 7.98C9.75 7.74 9.85 7.4 9.78 7.08L9.13 3.82C9.04 3.35 8.63 3.02 8.15 3.02L4 3.01c-0.56 0 -1.03 0.47 -1 1.03 0.17 2.91 1.04 5.63 2.43 8.01 1.57 2.69 3.81 4.93 6.5 6.5 2.38 1.39 5.1 2.26 8.01 2.43 0.56 0.03 1.03 -0.44 1.03 -1l0 -4.15c0 -0.48 -0.34 -0.89 -0.8 -0.98L16.91 14.2c-0.33 -0.06 -0.67 0.04 -0.9 0.28z"
        android:fillColor="#ffffff" />
    <path android:pathData="M12 8l10 0 0 -2 -10 0 0 2zm0 -4l10 0 0 -2 -10 0 0 2zm10 6l-10 0 0 2 10 0 0 -2z"
        android:fillColor="#ffffff" />
</vector>
 No newline at end of file
+12 −9
Original line number Diff line number Diff line
@@ -143,7 +143,10 @@
    <!-- Microphone permission will be granted to corresponding profile [CHAR LIMIT=30] -->
    <string name="permission_microphone">Microphone</string>

    <!-- Nearby devices permission will be granted of corresponding profile [CHAR LIMIT=30] -->
    <!-- Call logs permission will be granted to the corresponding profile [CHAR LIMIT=30] -->
    <string name="permission_call_logs">Call logs</string>

    <!-- Nearby devices' permission will be granted of corresponding profile [CHAR LIMIT=30] -->
    <string name="permission_nearby_devices">Nearby devices</string>

    <!-- Storage permission will be granted of corresponding profile [CHAR LIMIT=30] -->
@@ -159,26 +162,26 @@
    <string name="permission_nearby_device_streaming">Nearby Device Streaming</string>

    <!-- Description of phone permission of corresponding profile [CHAR LIMIT=NONE] -->
    <string name="permission_phone_summary">Can access your phone number and network info. Required for making calls and VoIP, voicemail, call redirect, and editing call logs</string>
    <string name="permission_phone_summary">Can make and manage phone calls</string>

    <!-- Description of Call logs permission of corresponding profile [CHAR LIMIT=NONE] -->
    <string name="permission_call_logs_summary">Can read and write phone call log</string>

    <!-- Description of SMS permission of corresponding profile [CHAR LIMIT=NONE] -->
    <!-- TODO(b/253644212) Need the description for sms permission  -->
    <string name="permission_sms_summary"></string>
    <string name="permission_sms_summary">Can send and view SMS messages</string>

    <!-- Description of contacts permission of corresponding profile [CHAR LIMIT=NONE] -->
    <string name="permission_contacts_summary">Can read, create, or edit our contact list, as well as access the list of all accounts used on your device</string>
    <string name="permission_contacts_summary">Can access your contacts</string>

    <!-- Description of calendar permission of corresponding profile [CHAR LIMIT=NONE] -->
    <!-- TODO(b/253644212) Need the description for calendar permission  -->
    <string name="permission_calendar_summary"></string>
    <string name="permission_calendar_summary">Can access your calendar</string>

    <!-- Description of microphone permission of corresponding profile [CHAR LIMIT=NONE] -->
    <!-- TODO(b/256140614) Need the description for microphone permission  -->
    <string name="permission_microphone_summary">Can record audio using the microphone</string>

    <!-- Description of nearby devices' permission of corresponding profile [CHAR LIMIT=NONE] -->
    <!-- TODO(b/253644212) Need the description for nearby devices' permission  -->
    <string name="permission_nearby_devices_summary"></string>
    <string name="permission_nearby_devices_summary">Can find, connect to, and determine the relative position of nearby devices</string>

    <!-- Description of notification permission of corresponding profile [CHAR LIMIT=NONE] -->
    <string name="permission_notification_summary">Can read all notifications, including information like contacts, messages, and photos</string>
+38 −84
Original line number Diff line number Diff line
@@ -16,12 +16,6 @@

package com.android.companiondevicemanager;

import static android.companion.AssociationRequest.DEVICE_PROFILE_APP_STREAMING;
import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION;
import static android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER;
import static android.companion.AssociationRequest.DEVICE_PROFILE_GLASSES;
import static android.companion.AssociationRequest.DEVICE_PROFILE_NEARBY_DEVICE_STREAMING;
import static android.companion.AssociationRequest.DEVICE_PROFILE_WATCH;
import static android.companion.CompanionDeviceManager.REASON_CANCELED;
import static android.companion.CompanionDeviceManager.REASON_DISCOVERY_TIMEOUT;
import static android.companion.CompanionDeviceManager.REASON_INTERNAL_ERROR;
@@ -33,16 +27,14 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE

import static com.android.companiondevicemanager.CompanionDeviceDiscoveryService.DiscoveryState;
import static com.android.companiondevicemanager.CompanionDeviceDiscoveryService.DiscoveryState.FINISHED_TIMEOUT;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_APP_STREAMING;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_CALENDAR;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_CONTACTS;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_MICROPHONE;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_NEARBY_DEVICES;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_NEARBY_DEVICE_STREAMING;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_NOTIFICATION;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_PHONE;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_SMS;
import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_STORAGE;
import static com.android.companiondevicemanager.CompanionDeviceResources.MULTI_DEVICES_SUMMARIES;
import static com.android.companiondevicemanager.CompanionDeviceResources.PERMISSION_TYPES;
import static com.android.companiondevicemanager.CompanionDeviceResources.PROFILES_NAME;
import static com.android.companiondevicemanager.CompanionDeviceResources.PROFILE_ICON;
import static com.android.companiondevicemanager.CompanionDeviceResources.SUMMARIES;
import static com.android.companiondevicemanager.CompanionDeviceResources.SUPPORTED_PROFILES;
import static com.android.companiondevicemanager.CompanionDeviceResources.SUPPORTED_SELF_MANAGED_PROFILES;
import static com.android.companiondevicemanager.CompanionDeviceResources.TITLES;
import static com.android.companiondevicemanager.Utils.getApplicationLabel;
import static com.android.companiondevicemanager.Utils.getHtmlFromResources;
import static com.android.companiondevicemanager.Utils.getIcon;
@@ -92,7 +84,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
@@ -470,6 +461,10 @@ public class CompanionDeviceActivity extends FragmentActivity implements
        int nightModeFlags = getResources().getConfiguration().uiMode
                & Configuration.UI_MODE_NIGHT_MASK;

        if (!SUPPORTED_SELF_MANAGED_PROFILES.contains(deviceProfile)) {
            throw new RuntimeException("Unsupported profile " + deviceProfile);
        }

        mPermissionTypes = new ArrayList<>();

        try {
@@ -488,32 +483,8 @@ public class CompanionDeviceActivity extends FragmentActivity implements
            return;
        }

        // TODO(b/253644212): Add maps for profile -> title, summary, permissions
        switch (deviceProfile) {
            case DEVICE_PROFILE_APP_STREAMING:
                title = getHtmlFromResources(this, R.string.title_app_streaming, deviceName);
                mPermissionTypes.add(PERMISSION_APP_STREAMING);
                break;

            case DEVICE_PROFILE_AUTOMOTIVE_PROJECTION:
                title = getHtmlFromResources(
                        this, R.string.title_automotive_projection, deviceName);
                break;

            case DEVICE_PROFILE_COMPUTER:
                title = getHtmlFromResources(this, R.string.title_computer, deviceName);
                mPermissionTypes.addAll(Arrays.asList(PERMISSION_NOTIFICATION, PERMISSION_STORAGE));
                break;

            case DEVICE_PROFILE_NEARBY_DEVICE_STREAMING:
                title = getHtmlFromResources(this, R.string.title_nearby_device_streaming,
                        deviceName);
                mPermissionTypes.add(PERMISSION_NEARBY_DEVICE_STREAMING);
                break;

            default:
                throw new RuntimeException("Unsupported profile " + deviceProfile);
        }
        title = getHtmlFromResources(this, TITLES.get(deviceProfile), deviceName);
        mPermissionTypes.addAll(PERMISSION_TYPES.get(deviceProfile));

        // Summary is not needed for selfManaged dialog.
        mSummary.setVisibility(View.GONE);
@@ -566,46 +537,28 @@ public class CompanionDeviceActivity extends FragmentActivity implements
        }

        final String deviceName = mSelectedDevice.getDisplayName();
        final String profileName;
        final Spanned title;
        final Spanned summary;
        final Drawable profileIcon;

        if (!SUPPORTED_PROFILES.contains(deviceProfile)) {
            throw new RuntimeException("Unsupported profile " + deviceProfile);
        }

        if (deviceProfile == null) {
            title = getHtmlFromResources(this, R.string.confirmation_title, appLabel, deviceName);
            summary = getHtmlFromResources(this, R.string.summary_generic);
            profileIcon = getIcon(this, R.drawable.ic_device_other);
            // Summary is not needed for null profile.
            mSummary.setVisibility(View.GONE);
            mConstraintList.setVisibility(View.GONE);
        } else if (deviceProfile.equals(DEVICE_PROFILE_WATCH)) {
            profileName = getString(R.string.profile_name_watch);
            title = getHtmlFromResources(this, R.string.confirmation_title, appLabel, deviceName);
            summary = getHtmlFromResources(
                    this, R.string.summary_watch_single_device, profileName, appLabel);
            profileIcon = getIcon(this, R.drawable.ic_watch);

            mPermissionTypes.addAll(Arrays.asList(
                    PERMISSION_NOTIFICATION, PERMISSION_PHONE, PERMISSION_SMS, PERMISSION_CONTACTS,
                    PERMISSION_CALENDAR, PERMISSION_NEARBY_DEVICES));

            setupPermissionList();
        } else if (deviceProfile.equals(DEVICE_PROFILE_GLASSES)) {
            profileName = getString(R.string.profile_name_glasses);
            title = getHtmlFromResources(this, R.string.confirmation_title, appLabel, deviceName);
            summary = getHtmlFromResources(
                    this, R.string.summary_glasses_single_device, profileName, appLabel);
            profileIcon = getIcon(this, R.drawable.ic_glasses);

            mPermissionTypes.addAll(Arrays.asList(
                    PERMISSION_NOTIFICATION, PERMISSION_PHONE, PERMISSION_SMS, PERMISSION_CONTACTS,
                    PERMISSION_MICROPHONE, PERMISSION_NEARBY_DEVICES));

            setupPermissionList();
        } else {
            throw new RuntimeException("Unsupported profile " + deviceProfile);
            mPermissionTypes.addAll(PERMISSION_TYPES.get(deviceProfile));
            setupPermissionList();
        }

        title = getHtmlFromResources(this, TITLES.get(deviceProfile), appLabel, deviceName);
        summary = getHtmlFromResources(this, SUMMARIES.get(deviceProfile),
                getString(PROFILES_NAME.get(deviceProfile)), appLabel);
        profileIcon = getIcon(this, PROFILE_ICON.get(deviceProfile));

        mTitle.setText(title);
        mSummary.setText(summary);
        mProfileIcon.setImageDrawable(profileIcon);
@@ -621,22 +574,23 @@ public class CompanionDeviceActivity extends FragmentActivity implements
        final String profileName;
        final Spanned summary;
        final Drawable profileIcon;
        final int summaryResourceId;

        if (!SUPPORTED_PROFILES.contains(deviceProfile)) {
            throw new RuntimeException("Unsupported profile " + deviceProfile);
        }

        profileName = getString(PROFILES_NAME.get(deviceProfile));
        profileIcon = getIcon(this, PROFILE_ICON.get(deviceProfile));
        summaryResourceId = MULTI_DEVICES_SUMMARIES.get(deviceProfile);

        if (deviceProfile == null) {
            profileName = getString(R.string.profile_name_generic);
            summary = getHtmlFromResources(this, R.string.summary_generic);
            profileIcon = getIcon(this, R.drawable.ic_device_other);
            summary = getHtmlFromResources(this, summaryResourceId);
            mSummary.setVisibility(View.GONE);
        } else if (deviceProfile.equals(DEVICE_PROFILE_WATCH)) {
            profileName = getString(R.string.profile_name_watch);
            summary = getHtmlFromResources(this, R.string.summary_watch, profileName, appLabel);
            profileIcon = getIcon(this, R.drawable.ic_watch);
        } else if (deviceProfile.equals(DEVICE_PROFILE_GLASSES)) {
            profileName = getString(R.string.profile_name_glasses);
            summary = getHtmlFromResources(this, R.string.summary_glasses, profileName, appLabel);
            profileIcon = getIcon(this, R.drawable.ic_glasses);
        } else {
            throw new RuntimeException("Unsupported profile " + deviceProfile);
            summary = getHtmlFromResources(this, summaryResourceId, profileName, appLabel);
        }

        final Spanned title = getHtmlFromResources(
                this, R.string.chooser_title, profileName, appLabel);

Loading