Home | History | Annotate | Download | only in btservice
      1 /*
      2  * Copyright (C) 2012-2014 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.bluetooth.btservice;
     18 
     19 final class JniCallbacks {
     20 
     21     private RemoteDevices mRemoteDevices;
     22     private AdapterProperties mAdapterProperties;
     23     private AdapterService mAdapterService;
     24     private BondStateMachine mBondStateMachine;
     25 
     26     JniCallbacks(AdapterService adapterService, AdapterProperties adapterProperties) {
     27         mAdapterService = adapterService;
     28         mAdapterProperties = adapterProperties;
     29     }
     30 
     31     void init(BondStateMachine bondStateMachine, RemoteDevices remoteDevices) {
     32         mRemoteDevices = remoteDevices;
     33         mBondStateMachine = bondStateMachine;
     34     }
     35 
     36     void cleanup() {
     37         mRemoteDevices = null;
     38         mAdapterProperties = null;
     39         mAdapterService = null;
     40         mBondStateMachine = null;
     41     }
     42 
     43     @Override
     44     public Object clone() throws CloneNotSupportedException {
     45         throw new CloneNotSupportedException();
     46     }
     47 
     48     void sspRequestCallback(byte[] address, byte[] name, int cod, int pairingVariant, int passkey) {
     49         mBondStateMachine.sspRequestCallback(address, name, cod, pairingVariant, passkey);
     50     }
     51 
     52     void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] val) {
     53         mRemoteDevices.devicePropertyChangedCallback(address, types, val);
     54     }
     55 
     56     void deviceFoundCallback(byte[] address) {
     57         mRemoteDevices.deviceFoundCallback(address);
     58     }
     59 
     60     void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) {
     61         mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits);
     62     }
     63 
     64     void bondStateChangeCallback(int status, byte[] address, int newState) {
     65         mBondStateMachine.bondStateChangeCallback(status, address, newState);
     66     }
     67 
     68     void aclStateChangeCallback(int status, byte[] address, int newState) {
     69         mRemoteDevices.aclStateChangeCallback(status, address, newState);
     70     }
     71 
     72     void stateChangeCallback(int status) {
     73         mAdapterService.stateChangeCallback(status);
     74     }
     75 
     76     void discoveryStateChangeCallback(int state) {
     77         mAdapterProperties.discoveryStateChangeCallback(state);
     78     }
     79 
     80     void adapterPropertyChangedCallback(int[] types, byte[][] val) {
     81         mAdapterProperties.adapterPropertyChangedCallback(types, val);
     82     }
     83 
     84 }
     85