1 /*
2  * Copyright (C) 2017 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 android.companion;
18 
19 import android.app.PendingIntent;
20 import android.companion.IAssociationRequestCallback;
21 import android.companion.IOnAssociationsChangedListener;
22 import android.companion.IOnMessageReceivedListener;
23 import android.companion.IOnTransportsChangedListener;
24 import android.companion.ISystemDataTransferCallback;
25 import android.companion.AssociationInfo;
26 import android.companion.AssociationRequest;
27 import android.companion.ObservingDevicePresenceRequest;
28 import android.companion.datatransfer.PermissionSyncRequest;
29 import android.content.ComponentName;
30 import android.os.ParcelUuid;
31 
32 
33 /**
34  * Interface for communication with the core companion device manager service.
35  *
36  * @hide
37  */
38 interface ICompanionDeviceManager {
associate(in AssociationRequest request, in IAssociationRequestCallback callback, in String callingPackage, int userId)39     void associate(in AssociationRequest request, in IAssociationRequestCallback callback,
40         in String callingPackage, int userId);
41 
getAssociations(String callingPackage, int userId)42     List<AssociationInfo> getAssociations(String callingPackage, int userId);
43 
44     @EnforcePermission("MANAGE_COMPANION_DEVICES")
getAllAssociationsForUser(int userId)45     List<AssociationInfo> getAllAssociationsForUser(int userId);
46 
47     /** @deprecated */
legacyDisassociate(String deviceMacAddress, String callingPackage, int userId)48     void legacyDisassociate(String deviceMacAddress, String callingPackage, int userId);
49 
disassociate(int associationId)50     void disassociate(int associationId);
51 
52     /** @deprecated */
hasNotificationAccess(in ComponentName component)53     boolean hasNotificationAccess(in ComponentName component);
54 
requestNotificationAccess(in ComponentName component, int userId)55     PendingIntent requestNotificationAccess(in ComponentName component, int userId);
56 
57     @EnforcePermission("MANAGE_COMPANION_DEVICES")
isDeviceAssociatedForWifiConnection(in String packageName, in String macAddress, int userId)58     boolean isDeviceAssociatedForWifiConnection(in String packageName, in String macAddress,
59         int userId);
60 
61     @EnforcePermission("REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE")
legacyStartObservingDevicePresence(in String deviceAddress, in String callingPackage, int userId)62     void legacyStartObservingDevicePresence(in String deviceAddress, in String callingPackage, int userId);
63 
64     @EnforcePermission("REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE")
legacyStopObservingDevicePresence(in String deviceAddress, in String callingPackage, int userId)65     void legacyStopObservingDevicePresence(in String deviceAddress, in String callingPackage, int userId);
66 
67     @EnforcePermission("REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE")
startObservingDevicePresence(in ObservingDevicePresenceRequest request, in String packageName, int userId)68     void startObservingDevicePresence(in ObservingDevicePresenceRequest request, in String packageName, int userId);
69 
70     @EnforcePermission("REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE")
stopObservingDevicePresence(in ObservingDevicePresenceRequest request, in String packageName, int userId)71     void stopObservingDevicePresence(in ObservingDevicePresenceRequest request, in String packageName, int userId);
72 
canPairWithoutPrompt(in String packageName, in String deviceMacAddress, int userId)73     boolean canPairWithoutPrompt(in String packageName, in String deviceMacAddress, int userId);
74 
75     @EnforcePermission("ASSOCIATE_COMPANION_DEVICES")
createAssociation(in String packageName, in String macAddress, int userId, in byte[] certificate)76     void createAssociation(in String packageName, in String macAddress, int userId,
77         in byte[] certificate);
78 
79     @EnforcePermission("MANAGE_COMPANION_DEVICES")
addOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId)80     void addOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId);
81 
82     @EnforcePermission("MANAGE_COMPANION_DEVICES")
removeOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId)83     void removeOnAssociationsChangedListener(IOnAssociationsChangedListener listener, int userId);
84 
85     @EnforcePermission("USE_COMPANION_TRANSPORTS")
addOnTransportsChangedListener(IOnTransportsChangedListener listener)86     void addOnTransportsChangedListener(IOnTransportsChangedListener listener);
87 
88     @EnforcePermission("USE_COMPANION_TRANSPORTS")
removeOnTransportsChangedListener(IOnTransportsChangedListener listener)89     void removeOnTransportsChangedListener(IOnTransportsChangedListener listener);
90 
91     @EnforcePermission("USE_COMPANION_TRANSPORTS")
sendMessage(int messageType, in byte[] data, in int[] associationIds)92     void sendMessage(int messageType, in byte[] data, in int[] associationIds);
93 
94     @EnforcePermission("USE_COMPANION_TRANSPORTS")
addOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener)95     void addOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener);
96 
97     @EnforcePermission("USE_COMPANION_TRANSPORTS")
removeOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener)98     void removeOnMessageReceivedListener(int messageType, IOnMessageReceivedListener listener);
99 
100     @EnforcePermission("REQUEST_COMPANION_SELF_MANAGED")
notifySelfManagedDeviceAppeared(int associationId)101     void notifySelfManagedDeviceAppeared(int associationId);
102 
103     @EnforcePermission("REQUEST_COMPANION_SELF_MANAGED")
notifySelfManagedDeviceDisappeared(int associationId)104     void notifySelfManagedDeviceDisappeared(int associationId);
105 
buildPermissionTransferUserConsentIntent(String callingPackage, int userId, int associationId)106     PendingIntent buildPermissionTransferUserConsentIntent(String callingPackage, int userId,
107         int associationId);
108 
isPermissionTransferUserConsented(String callingPackage, int userId, int associationId)109     boolean isPermissionTransferUserConsented(String callingPackage, int userId, int associationId);
110 
startSystemDataTransfer(String packageName, int userId, int associationId, in ISystemDataTransferCallback callback)111     void startSystemDataTransfer(String packageName, int userId, int associationId,
112         in ISystemDataTransferCallback callback);
113 
114     @EnforcePermission("DELIVER_COMPANION_MESSAGES")
attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd)115     void attachSystemDataTransport(String packageName, int userId, int associationId, in ParcelFileDescriptor fd);
116 
117     @EnforcePermission("DELIVER_COMPANION_MESSAGES")
detachSystemDataTransport(String packageName, int userId, int associationId)118     void detachSystemDataTransport(String packageName, int userId, int associationId);
119 
isCompanionApplicationBound(String packageName, int userId)120     boolean isCompanionApplicationBound(String packageName, int userId);
121 
buildAssociationCancellationIntent(in String callingPackage, int userId)122     PendingIntent buildAssociationCancellationIntent(in String callingPackage, int userId);
123 
enableSystemDataSync(int associationId, int flags)124     void enableSystemDataSync(int associationId, int flags);
125 
disableSystemDataSync(int associationId, int flags)126     void disableSystemDataSync(int associationId, int flags);
127 
enablePermissionsSync(int associationId)128     void enablePermissionsSync(int associationId);
129 
disablePermissionsSync(int associationId)130     void disablePermissionsSync(int associationId);
131 
getPermissionSyncRequest(int associationId)132     PermissionSyncRequest getPermissionSyncRequest(int associationId);
133 
134     @EnforcePermission("MANAGE_COMPANION_DEVICES")
enableSecureTransport(boolean enabled)135     void enableSecureTransport(boolean enabled);
136 
setAssociationTag(int associationId, String tag)137     void setAssociationTag(int associationId, String tag);
138 
clearAssociationTag(int associationId)139     void clearAssociationTag(int associationId);
140 
getBackupPayload(int userId)141     byte[] getBackupPayload(int userId);
142 
applyRestoredPayload(in byte[] payload, int userId)143     void applyRestoredPayload(in byte[] payload, int userId);
144 
145     @EnforcePermission("BLUETOOTH_CONNECT")
removeBond(int associationId, in String packageName, int userId)146     boolean removeBond(int associationId, in String packageName, int userId);
147 }
148