1 /*
2  * Copyright (C) 2015 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.google.android.auto.mapservice;
18 
19 import com.google.android.auto.mapservice.BluetoothMapEventReport;
20 import com.google.android.auto.mapservice.BluetoothMapMessage;
21 import com.google.android.auto.mapservice.BluetoothMapMessagesListing;
22 
23 /**
24  * Any binder to IBluetoothMapService will have to provide this class as the callbacks so that
25  * it can listen to various events that happen in the inbox of the phone such as new messages or
26  * message delivery reports (see BluetoothMapEventReport above). Additionally it also informs the
27  * binder about the state of service connection (see onConnect and onDisconnect functions below).
28  *
29  * NOTE: Callbacks which are initiated by client i.e. callbacks in response to any of the API
30  * functions defined in IBluetoothMapService will be executed in order of functions called. i.e.
31  * if getMessage(handle1) is called followed by getMessage(handle2) then the reply of handle1 will
32  * be received before handle2. Hence there's synchronization in order of callbacks. Although there
33  * is no order for onEvent calls because they are not initiated by client in
34  * IBluetoothMapService.
35  * @hide
36  */
37 oneway interface IBluetoothMapServiceCallbacks {
38     // Notifies the client binding to the service if the callback has been registered successfully.
onConnect()39     void onConnect();
40 
41     // Notifies the client binding to the service if the callback is registered but not connected to
42     // external Map profile via any device. The client should wait until it receives onConnect()
43     // again before using the API.
onConnectFailed()44     void onConnectFailed();
45 
46     // Callback for notification registration.
47     // @status - The final status of the notifications.
onEnableNotifications()48     void onEnableNotifications();
49 
50     // Returns the string handle for a pushMessage request.
onPushMessage(String handle)51     void onPushMessage(String handle);
52 
53     // Callback for getMessage().
54     // @message - The message.
onGetMessage(in BluetoothMapMessage message)55     void onGetMessage(in BluetoothMapMessage message);
56 
57     // Callback for getMessagesListing().
onGetMessagesListing(in List<BluetoothMapMessagesListing> msgsListing)58     void onGetMessagesListing(in List<BluetoothMapMessagesListing> msgsListing);
59 
60     // Whenever there is an event (see list of events on top of BluetoothMapEventReport) this
61     // callback will be executed with the event report. Client can take subsequent action on each
62     // such report.
63     //
64     // Eg. If the report is NEW_MESSAGE then the client should grab the handle from the event report
65     // and send a getMessage request to fetch the message.
66     // @eventReport - The event report which contains details of how to proceed with notification.
onEvent(in BluetoothMapEventReport eventReport)67     void onEvent(in BluetoothMapEventReport eventReport);
68 }
69