JniCallbacks.java revision ff4f17bf64978d0738c66e1b6dd70be8664efc24
1/* 2 * Copyright (C) 2012 Google Inc. 3 */ 4 5package com.android.bluetooth.btservice; 6 7final class JniCallbacks { 8 9 private static JniCallbacks sInstance; 10 private RemoteDevices mRemoteDevices; 11 private AdapterProperties mAdapterProperties; 12 private AdapterState mAdapterStateMachine; 13 private BondStateMachine mBondStateMachine; 14 15 JniCallbacks(RemoteDevices remoteDevices, AdapterProperties adapterProperties, 16 AdapterState adapterStateMachine, BondStateMachine bondStateMachine) { 17 mRemoteDevices = remoteDevices; 18 mAdapterProperties = adapterProperties; 19 mAdapterStateMachine = adapterStateMachine; 20 mBondStateMachine = bondStateMachine; 21 } 22 23 static synchronized JniCallbacks getInstance(RemoteDevices remoteDevices, 24 AdapterProperties adapterProperties, AdapterState adapterStateMachine, 25 BondStateMachine bondStateMachine) { 26 if (sInstance == null) sInstance = 27 new JniCallbacks(remoteDevices, adapterProperties, adapterStateMachine, 28 bondStateMachine); 29 return sInstance; 30 } 31 32 public Object Clone() throws CloneNotSupportedException { 33 throw new CloneNotSupportedException(); 34 } 35 36 void sspRequestCallback(byte[] address, byte[] name, int cod, int pairingVariant, 37 int passkey) { 38 mRemoteDevices.sspRequestCallback(address, name, cod, pairingVariant, 39 passkey); 40 } 41 void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] val) { 42 mRemoteDevices.devicePropertyChangedCallback(address, types, val); 43 } 44 45 void deviceFoundCallback(byte[] address) { 46 mRemoteDevices.deviceFoundCallback(address); 47 } 48 49 void pinRequestCallback(byte[] address, byte[] name, int cod) { 50 mRemoteDevices.pinRequestCallback(address, name, cod); 51 } 52 53 void passkeyRequestCallback(byte[] address, byte[] name, int cod) { 54 mRemoteDevices.passkeyRequestCallback(address, name, cod); 55 } 56 57 void bondStateChangeCallback(int status, byte[] address, int newState) { 58 mBondStateMachine.bondStateChangeCallback(status, address, newState); 59 } 60 61 void stateChangeCallback(int status) { 62 mAdapterStateMachine.stateChangeCallback(status); 63 } 64 65 void discoveryStateChangeCallback(int state) { 66 mAdapterProperties.discoveryStateChangeCallback(state); 67 } 68 69 void adapterPropertyChangedCallback(int[] types, byte[][] val) { 70 mAdapterProperties.adapterPropertyChangedCallback(types, val); 71 } 72} 73