diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2010-03-24 10:36:06 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2010-03-24 10:43:06 -0700 |
commit | 0bd5f7b5c36a60687ffe895368fd8df6df38acab (patch) | |
tree | 68ef30e92e48a4b9fcd2e7e495804ee0b0a274a9 | |
parent | 20b5a93b6e18cd441065edfdf676ad612affc507 (diff) | |
download | android_packages_apps_Bluetooth-0bd5f7b5c36a60687ffe895368fd8df6df38acab.tar.gz android_packages_apps_Bluetooth-0bd5f7b5c36a60687ffe895368fd8df6df38acab.tar.bz2 android_packages_apps_Bluetooth-0bd5f7b5c36a60687ffe895368fd8df6df38acab.zip |
Fix pbap and opp running bluetooth in phone process problems.
1. Use the right context instead of application context.
2. Make PbapActivity run in the same process as PbapService as they
share state.
Change-Id: Ib50c63c271dd8b30108f22734c47ee8645cd4839
-rw-r--r-- | AndroidManifest.xml | 1 | ||||
-rw-r--r-- | AndroidManifest_test.xml | 1 | ||||
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppManager.java | 3 | ||||
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppPreference.java | 3 | ||||
-rw-r--r-- | src/com/android/bluetooth/pbap/BluetoothPbapService.java | 39 |
5 files changed, 23 insertions, 24 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c78e9714c..fabdf02bd 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -108,6 +108,7 @@ android:configChanges="orientation|keyboardHidden"> </activity> <activity android:name=".pbap.BluetoothPbapActivity" + android:process="@string/process" android:excludeFromRecents="true" android:theme="@*android:style/Theme.Dialog.Alert"> <intent-filter> diff --git a/AndroidManifest_test.xml b/AndroidManifest_test.xml index 593682cc6..de55b5f46 100644 --- a/AndroidManifest_test.xml +++ b/AndroidManifest_test.xml @@ -84,6 +84,7 @@ </intent-filter> </activity> <activity android:name=".pbap.BluetoothPbapActivity" + android:process="@string/process" android:label=" " android:theme="@*android:style/Theme.Dialog.Alert"> <intent-filter> diff --git a/src/com/android/bluetooth/opp/BluetoothOppManager.java b/src/com/android/bluetooth/opp/BluetoothOppManager.java index 2dd0acb8e..73411d926 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppManager.java +++ b/src/com/android/bluetooth/opp/BluetoothOppManager.java @@ -127,8 +127,7 @@ public class BluetoothOppManager { return true; mInitialized = true; - // This will be around as long as this process is - mContext = context.getApplicationContext(); + mContext = context; mAdapter = BluetoothAdapter.getDefaultAdapter(); if (mAdapter == null) { diff --git a/src/com/android/bluetooth/opp/BluetoothOppPreference.java b/src/com/android/bluetooth/opp/BluetoothOppPreference.java index 3a83cb35b..787422293 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppPreference.java +++ b/src/com/android/bluetooth/opp/BluetoothOppPreference.java @@ -83,8 +83,7 @@ public class BluetoothOppPreference { return true; mInitialized = true; - // This will be around as long as this process is - mContext = context.getApplicationContext(); + mContext = context; mNamePreference = mContext.getSharedPreferences(Constants.BLUETOOTHOPP_NAME_PREFERENCE, Context.MODE_PRIVATE); diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java index 26ac61a90..e0a705f0d 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java @@ -617,57 +617,56 @@ public class BluetoothPbapService extends Service { } private void createPbapNotification(String action) { - Context context = getApplicationContext(); - NotificationManager nm = (NotificationManager)context - .getSystemService(Context.NOTIFICATION_SERVICE); + NotificationManager nm = (NotificationManager) + getSystemService(Context.NOTIFICATION_SERVICE); // Create an intent triggered by clicking on the status icon. Intent clickIntent = new Intent(); - clickIntent.setClass(context, BluetoothPbapActivity.class); + clickIntent.setClass(this, BluetoothPbapActivity.class); clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); clickIntent.setAction(action); // Create an intent triggered by clicking on the // "Clear All Notifications" button Intent deleteIntent = new Intent(); - deleteIntent.setClass(context, BluetoothPbapReceiver.class); + deleteIntent.setClass(this, BluetoothPbapReceiver.class); Notification notification = null; String name = getRemoteDeviceName(); + if (action.equals(ACCESS_REQUEST_ACTION)) { deleteIntent.setAction(ACCESS_DISALLOWED_ACTION); - notification = new Notification(android.R.drawable.stat_sys_data_bluetooth, context - .getString(R.string.pbap_notif_ticker), System.currentTimeMillis()); - notification.setLatestEventInfo(context, context.getString(R.string.pbap_notif_title), - context.getString(R.string.pbap_notif_message, name), PendingIntent - .getActivity(context, 0, clickIntent, 0)); + notification = new Notification(android.R.drawable.stat_sys_data_bluetooth, + getString(R.string.pbap_notif_ticker), System.currentTimeMillis()); + notification.setLatestEventInfo(this, getString(R.string.pbap_notif_title), + getString(R.string.pbap_notif_message, name), PendingIntent + .getActivity(this, 0, clickIntent, 0)); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE; notification.defaults = Notification.DEFAULT_SOUND; - notification.deleteIntent = PendingIntent.getBroadcast(context, 0, deleteIntent, 0); + notification.deleteIntent = PendingIntent.getBroadcast(this, 0, deleteIntent, 0); nm.notify(NOTIFICATION_ID_ACCESS, notification); } else if (action.equals(AUTH_CHALL_ACTION)) { deleteIntent.setAction(AUTH_CANCELLED_ACTION); - notification = new Notification(android.R.drawable.stat_sys_data_bluetooth, context - .getString(R.string.auth_notif_ticker), System.currentTimeMillis()); - notification.setLatestEventInfo(context, context.getString(R.string.auth_notif_title), - context.getString(R.string.auth_notif_message, name), PendingIntent - .getActivity(context, 0, clickIntent, 0)); + notification = new Notification(android.R.drawable.stat_sys_data_bluetooth, + getString(R.string.auth_notif_ticker), System.currentTimeMillis()); + notification.setLatestEventInfo(this, getString(R.string.auth_notif_title), + getString(R.string.auth_notif_message, name), PendingIntent + .getActivity(this, 0, clickIntent, 0)); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE; notification.defaults = Notification.DEFAULT_SOUND; - notification.deleteIntent = PendingIntent.getBroadcast(context, 0, deleteIntent, 0); + notification.deleteIntent = PendingIntent.getBroadcast(this, 0, deleteIntent, 0); nm.notify(NOTIFICATION_ID_AUTH, notification); } } private void removePbapNotification(int id) { - Context context = getApplicationContext(); - NotificationManager nm = (NotificationManager)context - .getSystemService(Context.NOTIFICATION_SERVICE); + NotificationManager nm = (NotificationManager) + getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(id); } |