1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.companiondevicemanager;
18 
19 import static android.companion.AssociationRequest.DEVICE_PROFILE_APP_STREAMING;
20 import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION;
21 import static android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER;
22 import static android.companion.AssociationRequest.DEVICE_PROFILE_GLASSES;
23 import static android.companion.AssociationRequest.DEVICE_PROFILE_NEARBY_DEVICE_STREAMING;
24 import static android.companion.AssociationRequest.DEVICE_PROFILE_WATCH;
25 
26 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_APP_STREAMING;
27 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_CALENDAR;
28 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_CALL_LOGS;
29 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_CONTACTS;
30 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_MICROPHONE;
31 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_NEARBY_DEVICES;
32 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_NEARBY_DEVICE_STREAMING;
33 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_NOTIFICATION;
34 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_PHONE;
35 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_SMS;
36 import static com.android.companiondevicemanager.PermissionListAdapter.PERMISSION_STORAGE;
37 
38 import static java.util.Collections.unmodifiableMap;
39 import static java.util.Collections.unmodifiableSet;
40 
41 import android.util.ArrayMap;
42 import android.util.ArraySet;
43 
44 import java.util.Arrays;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.Set;
48 
49 /**
50  * A class contains maps that have deviceProfile as the key and resourceId as the value
51  * for the corresponding profile.
52  */
53 final class CompanionDeviceResources {
54     static final Map<String, Integer> TITLES;
55     static {
56         final Map<String, Integer> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_APP_STREAMING, R.string.title_app_streaming)57         map.put(DEVICE_PROFILE_APP_STREAMING, R.string.title_app_streaming);
map.put(DEVICE_PROFILE_AUTOMOTIVE_PROJECTION, R.string.title_automotive_projection)58         map.put(DEVICE_PROFILE_AUTOMOTIVE_PROJECTION, R.string.title_automotive_projection);
map.put(DEVICE_PROFILE_COMPUTER, R.string.title_computer)59         map.put(DEVICE_PROFILE_COMPUTER, R.string.title_computer);
map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING, R.string.title_nearby_device_streaming)60         map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING, R.string.title_nearby_device_streaming);
map.put(DEVICE_PROFILE_WATCH, R.string.confirmation_title)61         map.put(DEVICE_PROFILE_WATCH, R.string.confirmation_title);
map.put(DEVICE_PROFILE_GLASSES, R.string.confirmation_title_glasses)62         map.put(DEVICE_PROFILE_GLASSES, R.string.confirmation_title_glasses);
map.put(null, R.string.confirmation_title)63         map.put(null, R.string.confirmation_title);
64 
65         TITLES = unmodifiableMap(map);
66     }
67 
68     static final Map<String, List<Integer>> PERMISSION_TYPES;
69     static {
70         final Map<String, List<Integer>> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_APP_STREAMING, Arrays.asList(PERMISSION_APP_STREAMING))71         map.put(DEVICE_PROFILE_APP_STREAMING, Arrays.asList(PERMISSION_APP_STREAMING));
map.put(DEVICE_PROFILE_COMPUTER, Arrays.asList( PERMISSION_NOTIFICATION, PERMISSION_STORAGE))72         map.put(DEVICE_PROFILE_COMPUTER, Arrays.asList(
73                 PERMISSION_NOTIFICATION, PERMISSION_STORAGE));
map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING, Arrays.asList(PERMISSION_NEARBY_DEVICE_STREAMING))74         map.put(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
75                 Arrays.asList(PERMISSION_NEARBY_DEVICE_STREAMING));
map.put(DEVICE_PROFILE_WATCH, Arrays.asList(PERMISSION_NOTIFICATION, PERMISSION_PHONE, PERMISSION_CALL_LOGS, PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_CALENDAR, PERMISSION_NEARBY_DEVICES))76         map.put(DEVICE_PROFILE_WATCH, Arrays.asList(PERMISSION_NOTIFICATION, PERMISSION_PHONE,
77                 PERMISSION_CALL_LOGS, PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_CALENDAR,
78                 PERMISSION_NEARBY_DEVICES));
map.put(DEVICE_PROFILE_GLASSES, Arrays.asList(PERMISSION_NOTIFICATION, PERMISSION_PHONE, PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_MICROPHONE, PERMISSION_NEARBY_DEVICES))79         map.put(DEVICE_PROFILE_GLASSES, Arrays.asList(PERMISSION_NOTIFICATION, PERMISSION_PHONE,
80                 PERMISSION_SMS, PERMISSION_CONTACTS, PERMISSION_MICROPHONE,
81                 PERMISSION_NEARBY_DEVICES));
82 
83         PERMISSION_TYPES = unmodifiableMap(map);
84     }
85 
86     static final Map<String, Integer> SUMMARIES;
87     static {
88         final Map<String, Integer> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_WATCH, R.string.summary_watch)89         map.put(DEVICE_PROFILE_WATCH, R.string.summary_watch);
map.put(DEVICE_PROFILE_GLASSES, R.string.summary_glasses)90         map.put(DEVICE_PROFILE_GLASSES, R.string.summary_glasses);
map.put(null, R.string.summary_generic)91         map.put(null, R.string.summary_generic);
92 
93         SUMMARIES = unmodifiableMap(map);
94     }
95 
96     static final Map<String, Integer> PROFILES_NAME;
97     static {
98         final Map<String, Integer> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_WATCH, R.string.profile_name_watch)99         map.put(DEVICE_PROFILE_WATCH, R.string.profile_name_watch);
map.put(DEVICE_PROFILE_GLASSES, R.string.profile_name_glasses)100         map.put(DEVICE_PROFILE_GLASSES, R.string.profile_name_glasses);
map.put(null, R.string.profile_name_generic)101         map.put(null, R.string.profile_name_generic);
102 
103         PROFILES_NAME = unmodifiableMap(map);
104     }
105 
106     static final Map<String, Integer> PROFILES_NAME_MULTI;
107     static {
108         final Map<String, Integer> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_GLASSES, R.string.profile_name_generic)109         map.put(DEVICE_PROFILE_GLASSES, R.string.profile_name_generic);
map.put(DEVICE_PROFILE_WATCH, R.string.profile_name_watch)110         map.put(DEVICE_PROFILE_WATCH, R.string.profile_name_watch);
map.put(null, R.string.profile_name_generic)111         map.put(null, R.string.profile_name_generic);
112 
113         PROFILES_NAME_MULTI = unmodifiableMap(map);
114     }
115 
116     static final Map<String, Integer> PROFILE_ICON;
117     static {
118         final Map<String, Integer> map = new ArrayMap<>();
map.put(DEVICE_PROFILE_WATCH, R.drawable.ic_watch)119         map.put(DEVICE_PROFILE_WATCH, R.drawable.ic_watch);
map.put(DEVICE_PROFILE_GLASSES, R.drawable.ic_glasses)120         map.put(DEVICE_PROFILE_GLASSES, R.drawable.ic_glasses);
map.put(null, R.drawable.ic_device_other)121         map.put(null, R.drawable.ic_device_other);
122 
123         PROFILE_ICON = unmodifiableMap(map);
124     }
125 
126     static final Set<String> SUPPORTED_PROFILES;
127     static {
128         final Set<String> set = new ArraySet<>();
129         set.add(DEVICE_PROFILE_WATCH);
130         set.add(DEVICE_PROFILE_GLASSES);
131         set.add(null);
132 
133         SUPPORTED_PROFILES = unmodifiableSet(set);
134     }
135 
136     static final Set<String> SUPPORTED_SELF_MANAGED_PROFILES;
137     static {
138         final Set<String> set = new ArraySet<>();
139         set.add(DEVICE_PROFILE_APP_STREAMING);
140         set.add(DEVICE_PROFILE_COMPUTER);
141         set.add(DEVICE_PROFILE_AUTOMOTIVE_PROJECTION);
142         set.add(DEVICE_PROFILE_NEARBY_DEVICE_STREAMING);
143         set.add(null);
144 
145         SUPPORTED_SELF_MANAGED_PROFILES = unmodifiableSet(set);
146     }
147 }
148