protected boolean mStartError=false;
private boolean mCleaningUp = false;
- private AdapterService mAdapterService;
-
protected String getName() {
return getClass().getSimpleName();
}
super.onCreate();
mAdapter = BluetoothAdapter.getDefaultAdapter();
mBinder = initBinder();
- mAdapterService = AdapterService.getAdapterService();
- if (mAdapterService != null) {
- mAdapterService.addProfile(this);
- } else {
- Log.w(TAG, "onCreate, null mAdapterService");
- }
}
public int onStartCommand(Intent intent, int flags, int startId) {
if (DBG) log("onStartCommand()");
+ AdapterService adapterService = AdapterService.getAdapterService();
+ if (adapterService != null) {
+ adapterService.addProfile(this);
+ } else {
+ Log.w(TAG, "Could not add this profile because AdapterService is null.");
+ }
+
if (mStartError || mAdapter == null) {
Log.w(mName, "Stopping profile service: device does not have BT");
doStop(intent);
@Override
public void onDestroy() {
if (DBG) log("Destroying service.");
- if (mAdapterService != null) mAdapterService.removeProfile(this);
+ AdapterService adapterService = AdapterService.getAdapterService();
+ if (adapterService != null) adapterService.removeProfile(this);
if (mCleaningUp) {
if (DBG) log("Cleanup already started... Skipping cleanup()...");
protected void notifyProfileServiceStateChanged(int state) {
//Notify adapter service
- if (mAdapterService != null) {
- mAdapterService.onProfileServiceStateChanged(getClass().getName(), state);
+ AdapterService adapterService = AdapterService.getAdapterService();
+ if (adapterService != null) {
+ adapterService.onProfileServiceStateChanged(getClass().getName(), state);
}
}
public void notifyProfileConnectionStateChanged(BluetoothDevice device,
int profileId, int newState, int prevState) {
- if (mAdapterService != null) {
- mAdapterService.onProfileConnectionStateChanged(device, profileId, newState, prevState);
+ AdapterService adapterService = AdapterService.getAdapterService();
+ if (adapterService != null) {
+ adapterService.onProfileConnectionStateChanged(device, profileId, newState, prevState);
}
}