1 /**
2  * Copyright (C) 2019 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.car.companiondevicesupport.api.internal.trust;
18 
19 import com.android.car.companiondevicesupport.api.external.CompanionDevice;
20 import com.android.car.companiondevicesupport.api.external.IDeviceAssociationCallback;
21 import com.android.car.companiondevicesupport.api.internal.trust.ITrustedDeviceAgentDelegate;
22 import com.android.car.companiondevicesupport.api.internal.trust.ITrustedDeviceCallback;
23 import com.android.car.companiondevicesupport.api.internal.trust.ITrustedDeviceEnrollmentCallback;
24 import com.android.car.companiondevicesupport.api.internal.trust.TrustedDevice;
25 
26 /**
27  * Manager of trusted devices with the car to be used by any service/activity that needs to interact
28  * with trusted devices.
29  */
30 interface ITrustedDeviceManager {
31 
32     /** Indicate the escrow token has been added for a user and corresponding handle. */
onEscrowTokenAdded(in int userId, in long handle)33     void onEscrowTokenAdded(in int userId, in long handle);
34 
35     /** Indicate the escrow token has been activated for a user and corresponding handle. */
onEscrowTokenActivated(in int userId, in long handle)36     void onEscrowTokenActivated(in int userId, in long handle);
37 
38     /** Register a new callback for trusted device events. */
registerTrustedDeviceCallback(in ITrustedDeviceCallback callback)39     void registerTrustedDeviceCallback(in ITrustedDeviceCallback callback);
40 
41     /** Remove a previously registered callback. */
unregisterTrustedDeviceCallback(in ITrustedDeviceCallback callback)42     void unregisterTrustedDeviceCallback(in ITrustedDeviceCallback callback);
43 
44     /** Register a new callback for enrollment triggered events. */
registerTrustedDeviceEnrollmentCallback(in ITrustedDeviceEnrollmentCallback callback)45     void registerTrustedDeviceEnrollmentCallback(in ITrustedDeviceEnrollmentCallback callback);
46 
47     /** Remove a previously registered callback. */
unregisterTrustedDeviceEnrollmentCallback(in ITrustedDeviceEnrollmentCallback callback)48     void unregisterTrustedDeviceEnrollmentCallback(in ITrustedDeviceEnrollmentCallback callback);
49 
50     /** Set a delegate for TrustAgent operation calls. */
setTrustedDeviceAgentDelegate(in ITrustedDeviceAgentDelegate trustAgentDelegate)51     void setTrustedDeviceAgentDelegate(in ITrustedDeviceAgentDelegate trustAgentDelegate);
52 
53     /** Remove a prevoiusly set delegate. */
clearTrustedDeviceAgentDelegate(in ITrustedDeviceAgentDelegate trustAgentDelegate)54     void clearTrustedDeviceAgentDelegate(in ITrustedDeviceAgentDelegate trustAgentDelegate);
55 
56     /** Returns a list of trusted devices for user. */
getTrustedDevicesForActiveUser()57     List<TrustedDevice> getTrustedDevicesForActiveUser();
58 
59     /** Remove a trusted device and invalidate any credentials associated with it. */
removeTrustedDevice(in TrustedDevice trustedDevice)60     void removeTrustedDevice(in TrustedDevice trustedDevice);
61 
62     /** Returns {@link List<CompanionDevice>} of devices currently connected. */
getActiveUserConnectedDevices()63     List<CompanionDevice> getActiveUserConnectedDevices();
64 
65     /** Register a new callback for associated device events. */
registerAssociatedDeviceCallback(in IDeviceAssociationCallback callback)66     void registerAssociatedDeviceCallback(in IDeviceAssociationCallback callback);
67 
68     /** Remove a previously registered callback. */
unregisterAssociatedDeviceCallback(IDeviceAssociationCallback callback)69     void unregisterAssociatedDeviceCallback(IDeviceAssociationCallback callback);
70 
71     /** Attempts to initiate trusted device enrollment on the phone with the given device id. */
initiateEnrollment(in String deviceId)72     void initiateEnrollment(in String deviceId);
73 }
74