OSDN Git Service

Nullpointer check on mAdapterService in ProfileService#onCreate
authorMatthew Xie <mattx@google.com>
Thu, 4 Dec 2014 00:52:37 +0000 (16:52 -0800)
committerMatthew Xie <mattx@google.com>
Thu, 4 Dec 2014 00:52:37 +0000 (16:52 -0800)
Bug: 18595130
Change-Id: I02d588dab94e1dc6c24402259e5b8cea2a98b482

src/com/android/bluetooth/btservice/ProfileService.java

index 1dcb7fb..d029249 100644 (file)
@@ -32,6 +32,8 @@ import android.util.Log;
 
 public abstract class ProfileService extends Service {
     private static final boolean DBG = false;
+    private static final String TAG = "BluetoothProfileService";
+
     //For Debugging only
     private static HashMap<String, Integer> sReferenceCount = new HashMap<String,Integer>();
 
@@ -108,7 +110,11 @@ public abstract class ProfileService extends Service {
         mAdapter = BluetoothAdapter.getDefaultAdapter();
         mBinder = initBinder();
         mAdapterService = AdapterService.getAdapterService();
-        mAdapterService.addProfile(this);
+        if (mAdapterService != null) {
+            mAdapterService.addProfile(this);
+        } else {
+            Log.w(TAG, "onCreate, null mAdapterService");
+        }
     }
 
     public int onStartCommand(Intent intent, int flags, int startId) {