Merge changes I35c3ca3d,I5522ee84
* changes:
AvrcpController null pointer exceptions.
Update A2DP Sink Connect timeouts.
diff --git a/src/com/android/bluetooth/avrcp/AvrcpTargetService.java b/src/com/android/bluetooth/avrcp/AvrcpTargetService.java
index 4ff73ce..5ab3996 100644
--- a/src/com/android/bluetooth/avrcp/AvrcpTargetService.java
+++ b/src/com/android/bluetooth/avrcp/AvrcpTargetService.java
@@ -146,25 +146,25 @@
return true;
}
- mReceiver = new AvrcpBroadcastReceiver();
- IntentFilter filter = new IntentFilter();
- filter.addAction(BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED);
- registerReceiver(mReceiver, filter);
-
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
sDeviceMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mMediaPlayerList = new MediaPlayerList(Looper.myLooper(), this);
+ mNativeInterface = AvrcpNativeInterface.getInterface();
+ mNativeInterface.init(AvrcpTargetService.this);
+
+ mVolumeManager = new AvrcpVolumeManager(this, mAudioManager, mNativeInterface);
+
UserManager userManager = UserManager.get(getApplicationContext());
if (userManager.isUserUnlocked()) {
mMediaPlayerList.init(new ListCallback());
}
- mNativeInterface = AvrcpNativeInterface.getInterface();
- mNativeInterface.init(AvrcpTargetService.this);
-
- mVolumeManager = new AvrcpVolumeManager(this, mAudioManager, mNativeInterface);
+ mReceiver = new AvrcpBroadcastReceiver();
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED);
+ registerReceiver(mReceiver, filter);
// Only allow the service to be used once it is initialized
sInstance = this;
diff --git a/src/com/android/bluetooth/avrcp/AvrcpVolumeManager.java b/src/com/android/bluetooth/avrcp/AvrcpVolumeManager.java
index 09a6865..2eef2ba 100644
--- a/src/com/android/bluetooth/avrcp/AvrcpVolumeManager.java
+++ b/src/com/android/bluetooth/avrcp/AvrcpVolumeManager.java
@@ -195,7 +195,7 @@
mCurrentDevice = device;
}
- void deviceDisconnected(@NonNull BluetoothDevice device) {
+ synchronized void deviceDisconnected(@NonNull BluetoothDevice device) {
d("deviceDisconnected: device=" + device);
mDeviceMap.remove(device);
}
diff --git a/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java b/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java
index 99e3e69..4ef2c85 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java
@@ -75,6 +75,11 @@
Intent intent = getIntent();
String action = intent.getAction();
+ if (action == null) {
+ Log.w(TAG, " Received " + intent + " with null action");
+ finish();
+ return;
+ }
if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) {
//Check if Bluetooth is available in the beginning instead of at the end
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapActivity.java b/src/com/android/bluetooth/pbap/BluetoothPbapActivity.java
index f709cd5..5468a76 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapActivity.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapActivity.java
@@ -109,7 +109,7 @@
Intent i = getIntent();
String action = i.getAction();
mDevice = i.getParcelableExtra(BluetoothPbapService.EXTRA_DEVICE);
- if (action.equals(BluetoothPbapService.AUTH_CHALL_ACTION)) {
+ if (action != null && action.equals(BluetoothPbapService.AUTH_CHALL_ACTION)) {
showPbapDialog(DIALOG_YES_NO_AUTH);
mCurrentDialog = DIALOG_YES_NO_AUTH;
} else {
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
index e62c239..62c1aa0 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java
@@ -127,6 +127,7 @@
static final int CONTACTS_LOADED = 5;
static final int CHECK_SECONDARY_VERSION_COUNTER = 6;
static final int ROLLOVER_COUNTERS = 7;
+ static final int GET_LOCAL_TELEPHONY_DETAILS = 8;
static final int USER_CONFIRM_TIMEOUT_VALUE = 30000;
static final int RELEASE_WAKE_LOCK_DELAY = 10000;
@@ -408,6 +409,8 @@
mPbapStateMachineMap.remove(remoteDevice);
}
break;
+ case GET_LOCAL_TELEPHONY_DETAILS:
+ getLocalTelephonyDetails();
default:
break;
}
@@ -507,16 +510,10 @@
Log.e(TAG, "Illegal state exception, content observer is already registered");
}
- TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- if (tm != null) {
- sLocalPhoneNum = tm.getLine1Number();
- sLocalPhoneName = tm.getLine1AlphaTag();
- if (TextUtils.isEmpty(sLocalPhoneName)) {
- sLocalPhoneName = this.getString(R.string.localPhoneName);
- }
- }
-
setBluetoothPbapService(this);
+
+ mSessionStatusHandler.sendMessage(
+ mSessionStatusHandler.obtainMessage(GET_LOCAL_TELEPHONY_DETAILS));
mSessionStatusHandler.sendMessage(mSessionStatusHandler.obtainMessage(LOAD_CONTACTS));
mSessionStatusHandler.sendMessage(mSessionStatusHandler.obtainMessage(START_LISTENER));
return true;
@@ -775,4 +772,18 @@
mThreadUpdateSecVersionCounter.start();
}
}
+
+ private void getLocalTelephonyDetails() {
+ TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+ if (tm != null) {
+ sLocalPhoneNum = tm.getLine1Number();
+ sLocalPhoneName = tm.getLine1AlphaTag();
+ if (TextUtils.isEmpty(sLocalPhoneName)) {
+ sLocalPhoneName = this.getString(R.string.localPhoneName);
+ }
+ }
+ if (VERBOSE)
+ Log.v(TAG, "Local Phone Details- Number:" + sLocalPhoneNum
+ + ", Name:" + sLocalPhoneName);
+ }
}