}
protected boolean start() {
- mStateMachine = new A2dpStateMachine(this,this);
- mStateMachine.start();
+ mStateMachine = A2dpStateMachine.make(this, this);
setA2dpService(this);
return true;
}
classInitNative();
}
- A2dpStateMachine(A2dpService svc, Context context) {
+ private A2dpStateMachine(A2dpService svc, Context context) {
super(TAG);
mService = svc;
mContext = context;
}
+ static A2dpStateMachine make(A2dpService svc, Context context) {
+ Log.d(TAG, "make");
+ A2dpStateMachine a2dpSm = new A2dpStateMachine(svc, context);
+ a2dpSm.start();
+ return a2dpSm;
+ }
+
public void doQuit() {
quitNow();
}
if (DBG) debugLog("onCreate");
mBinder = new AdapterServiceBinder(this);
mAdapterProperties = new AdapterProperties(this);
- mAdapterStateMachine = new AdapterState(this, mAdapterProperties);
+ mAdapterStateMachine = AdapterState.make(this, mAdapterProperties);
mJniCallbacks = new JniCallbacks(mAdapterStateMachine, mAdapterProperties);
initNative();
mNativeAvailable=true;
- mAdapterStateMachine.start();
mCallbacks = new RemoteCallbackList<IBluetoothCallback>();
//Load the name and address
getAdapterPropertyNative(AbstractionLayer.BT_PROPERTY_BDADDR);
mProfileServicesState.put(supportedProfileServices[i].getName(),BluetoothAdapter.STATE_OFF);
}
mRemoteDevices = new RemoteDevices(this);
- mBondStateMachine = new BondStateMachine(this, mAdapterProperties, mRemoteDevices);
mAdapterProperties.init(mRemoteDevices);
- mJniCallbacks.init(mBondStateMachine,mRemoteDevices);
- //Start Bond State Machine
- if (DBG) {debugLog("processStart(): Starting Bond State Machine");}
- mBondStateMachine.start();
+ if (DBG) {debugLog("processStart(): Make Bond State Machine");}
+ mBondStateMachine = BondStateMachine.make(this, mAdapterProperties, mRemoteDevices);
+
+ mJniCallbacks.init(mBondStateMachine,mRemoteDevices);
//FIXME: Set static instance here???
setAdapterService(this);
return isTurningOff;
}
- public AdapterState(AdapterService service,AdapterProperties adapterProperties) {
+ private AdapterState(AdapterService service, AdapterProperties adapterProperties) {
super("BluetoothAdapterState:");
addState(mOnState);
addState(mOffState);
setInitialState(mOffState);
}
+ public static AdapterState make(AdapterService service, AdapterProperties adapterProperties) {
+ Log.d(TAG, "make");
+ AdapterState as = new AdapterState(service, adapterProperties);
+ as.start();
+ return as;
+ }
public void doQuit() {
quitNow();
private PendingCommandState mPendingCommandState = new PendingCommandState();
private StableState mStableState = new StableState();
- public BondStateMachine(AdapterService service,
+ private BondStateMachine(AdapterService service,
AdapterProperties prop, RemoteDevices remoteDevices) {
super("BondStateMachine:");
addState(mStableState);
setInitialState(mStableState);
}
+ public static BondStateMachine make(AdapterService service,
+ AdapterProperties prop, RemoteDevices remoteDevices) {
+ Log.d(TAG, "make");
+ BondStateMachine bsm = new BondStateMachine(service, prop, remoteDevices);
+ bsm.start();
+ return bsm;
+ }
+
public void doQuit() {
quitNow();
}
}
protected boolean start() {
- mStateMachine = new HeadsetStateMachine(this);
- mStateMachine.start();
+ mStateMachine = HeadsetStateMachine.make(this);
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
filter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
filter.addAction(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
classInitNative();
}
- HeadsetStateMachine(HeadsetService context) {
+ private HeadsetStateMachine(HeadsetService context) {
super(TAG);
mService = context;
mVoiceRecognitionStarted = false;
setInitialState(mDisconnected);
}
+ static HeadsetStateMachine make(HeadsetService context) {
+ Log.d(TAG, "make");
+ HeadsetStateMachine hssm = new HeadsetStateMachine(context);
+ hssm.start();
+ return hssm;
+ }
+
public void doQuit() {
quitNow();