1 package android.companion.cts.common
2 
3 import android.Manifest
4 import android.companion.AssociationRequest.DEVICE_PROFILE_APP_STREAMING
5 import android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION
6 import android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER
7 import android.companion.AssociationRequest.DEVICE_PROFILE_GLASSES
8 import android.companion.AssociationRequest.DEVICE_PROFILE_NEARBY_DEVICE_STREAMING
9 import android.companion.AssociationRequest.DEVICE_PROFILE_WATCH
10 import android.net.MacAddress
11 import android.os.Handler
12 import android.os.HandlerThread
13 import android.os.ParcelUuid
14 import java.util.concurrent.Executor
15 
16 /** Set of all supported CDM Device Profiles. */
17 val DEVICE_PROFILES = setOf(
18         DEVICE_PROFILE_WATCH,
19         DEVICE_PROFILE_GLASSES,
20         DEVICE_PROFILE_NEARBY_DEVICE_STREAMING,
21         DEVICE_PROFILE_COMPUTER,
22         DEVICE_PROFILE_APP_STREAMING,
23         DEVICE_PROFILE_AUTOMOTIVE_PROJECTION
24 )
25 
26 val DEVICE_PROFILE_TO_NAME = mapOf(
27         DEVICE_PROFILE_WATCH to "WATCH",
28         DEVICE_PROFILE_GLASSES to "GLASSES",
29         DEVICE_PROFILE_NEARBY_DEVICE_STREAMING to "NEARBY_DEVICE_STREAMING",
30         DEVICE_PROFILE_COMPUTER to "COMPUTER",
31         DEVICE_PROFILE_APP_STREAMING to "APP_STREAMING",
32         DEVICE_PROFILE_AUTOMOTIVE_PROJECTION to "AUTOMOTIVE_PROJECTION"
33 )
34 
35 val DEVICE_PROFILE_TO_PERMISSION = mapOf(
36         DEVICE_PROFILE_WATCH to Manifest.permission.REQUEST_COMPANION_PROFILE_WATCH,
37         DEVICE_PROFILE_APP_STREAMING to
38                 Manifest.permission.REQUEST_COMPANION_PROFILE_APP_STREAMING,
39         DEVICE_PROFILE_AUTOMOTIVE_PROJECTION to
40                 Manifest.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION,
41         DEVICE_PROFILE_GLASSES to
42                 Manifest.permission.REQUEST_COMPANION_PROFILE_GLASSES,
43         DEVICE_PROFILE_NEARBY_DEVICE_STREAMING to
44                 Manifest.permission.REQUEST_COMPANION_PROFILE_NEARBY_DEVICE_STREAMING,
45         DEVICE_PROFILE_COMPUTER to
46                 Manifest.permission.REQUEST_COMPANION_PROFILE_COMPUTER
47 )
48 
49 val MAC_ADDRESS_A = MacAddress.fromString("00:00:00:00:00:AA")
50 val MAC_ADDRESS_B = MacAddress.fromString("00:00:00:00:00:BB")
51 val MAC_ADDRESS_C = MacAddress.fromString("00:00:00:00:00:CC")
52 
53 val UUID_A: ParcelUuid = ParcelUuid.fromString("bc4990b9-698c-473d-8498-2a5c4119f73d")
54 val UUID_B: ParcelUuid = ParcelUuid.fromString("ba6d2f1e-9adc-11ee-b9d1-0242ac120002")
55 
56 const val ASSOCIATION_TAG = "00:00:00:00:00:AA"
57 var ASSOCIATION_TAG_INVALID = "A".repeat(1025)
58 
59 const val DEVICE_DISPLAY_NAME_A = "Device A"
60 const val DEVICE_DISPLAY_NAME_B = "Device B"
61 
<lambda>null62 val SIMPLE_EXECUTOR: Executor by lazy { Executor { it.run() } }
63 
<lambda>null64 val MAIN_THREAD_EXECUTOR: Executor by lazy {
65     Executor {
66         with(Handler.getMain()) { post(it) }
67     }
68 }
69 
<lambda>null70 val BACKGROUND_THREAD_EXECUTOR: Executor by lazy {
71     with(HandlerThread("CdmTestBackgroundThread")) {
72         start()
73         Executor { threadHandler.post(it) }
74     }
75 }
76 
77 val PRIMARY_PROCESS_NAME = ":primary"
78 val SECONDARY_PROCESS_NAME = ":secondary"
79