1fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh/*
2fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * Copyright (C) 2011 The Android Open Source Project
3fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh *
4fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * Licensed under the Apache License, Version 2.0 (the "License");
5fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * you may not use this file except in compliance with the License.
6fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * You may obtain a copy of the License at
7fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh *
8fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh *      http://www.apache.org/licenses/LICENSE-2.0
9fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh *
10fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * Unless required by applicable law or agreed to in writing, software
11fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * distributed under the License is distributed on an "AS IS" BASIS,
12fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * See the License for the specific language governing permissions and
14fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh * limitations under the License.
15fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh */
16fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh
17fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh
18fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganeshpackage android.bluetooth;
19fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh
2083c6896cbf402623ef7d97f13ed65098df63429fTor Norbyeimport android.annotation.BinderThread;
21fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganeshimport android.os.ParcelFileDescriptor;
22fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganeshimport android.util.Log;
23fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh
24fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh/**
25eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh * This abstract class is used to implement {@link BluetoothHealth} callbacks.
26fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh */
27fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganeshpublic abstract class BluetoothHealthCallback {
28fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh    private static final String TAG = "BluetoothHealthCallback";
29fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh
30eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh    /**
31eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * Callback to inform change in registration state of the health
32eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * application.
33eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * <p> This callback is called on the binder thread (not on the UI thread)
34eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *
35eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param config Bluetooth Health app configuration
36eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param status Success or failure of the registration or unregistration
37eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *            calls. Can be one of
38eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *            {@link BluetoothHealth#APP_CONFIG_REGISTRATION_SUCCESS} or
39eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *            {@link BluetoothHealth#APP_CONFIG_REGISTRATION_FAILURE} or
40eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *            {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_SUCCESS} or
41eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *            {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_FAILURE}
42eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     */
4383c6896cbf402623ef7d97f13ed65098df63429fTor Norbye    @BinderThread
44fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh    public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
45eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh            int status) {
46eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh        Log.d(TAG, "onHealthAppConfigurationStatusChange: " + config + "Status: " + status);
47fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh    }
48fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh
49eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh    /**
50eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * Callback to inform change in channel state.
51eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * <p> Its the responsibility of the implementor of this callback to close the
52eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * parcel file descriptor when done. This callback is called on the Binder
53eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * thread (not the UI thread)
54eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *
55eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param config The Health app configutation
56eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param device The Bluetooth Device
57eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param prevState The previous state of the channel
58eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param newState The new state of the channel.
59eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param fd The Parcel File Descriptor when the channel state is connected.
60eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     * @param channelId The id associated with the channel. This id will be used
61eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     *            in future calls like when disconnecting the channel.
62eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh     */
6383c6896cbf402623ef7d97f13ed65098df63429fTor Norbye    @BinderThread
64fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh    public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
65eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh            BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
66eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh            int channelId) {
67eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh        Log.d(TAG, "onHealthChannelStateChange: " + config + "Device: " + device +
68eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh              "prevState:" + prevState + "newState:" + newState + "ParcelFd:" + fd +
69eb9d34630f74d0260690287f2df57c0cd3d7ba1dJaikumar Ganesh              "ChannelId:" + channelId);
70fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh    }
71fb658c72a3a76dac334c39070d1501a2575c1069Jaikumar Ganesh}
72