summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth
diff options
context:
space:
mode:
authorZhihai Xu <zhihaixu@google.com>2012-10-17 10:01:03 -0700
committerZhihai Xu <zhihaixu@google.com>2012-10-17 11:07:21 -0700
commitbd704c741b8c523ad747214f6f0520ac3e2caf8f (patch)
tree507ddd4e55bf1f46c341310897f8f153f009ef20 /src/com/android/bluetooth
parenta595fcc57e7f0be9cf57913cd665dc99e4001b16 (diff)
downloadandroid_packages_apps_Bluetooth-bd704c741b8c523ad747214f6f0520ac3e2caf8f.tar.gz
android_packages_apps_Bluetooth-bd704c741b8c523ad747214f6f0520ac3e2caf8f.tar.bz2
android_packages_apps_Bluetooth-bd704c741b8c523ad747214f6f0520ac3e2caf8f.zip
BT connection notification in not updated in status bar for second user
It is due to the system UI is always running as the first user. It can't receive broadcast intent ACTION_CONNECTION_STATE_CHANGED and ACTION_BOND_STATE_CHANGED from bluetooth service when We switch to second user. Also the system UI also is running as uid 10055, which will also call function isEnabled, getState, getBondedDevices, getAdapterConnectionState and getBondState in bluetooth service. I allow these functions to be called by all the users. I forget remove check for getBondState in my first patch set bug 7333382 Change-Id: I57f39a722e78d6d2453ebfecaab043637fef4d9c
Diffstat (limited to 'src/com/android/bluetooth')
-rwxr-xr-xsrc/com/android/bluetooth/btservice/AdapterProperties.java4
-rwxr-xr-xsrc/com/android/bluetooth/btservice/AdapterService.java32
-rwxr-xr-xsrc/com/android/bluetooth/btservice/BondStateMachine.java4
3 files changed, 11 insertions, 29 deletions
diff --git a/src/com/android/bluetooth/btservice/AdapterProperties.java b/src/com/android/bluetooth/btservice/AdapterProperties.java
index 9b7b2a633..837c446d0 100755
--- a/src/com/android/bluetooth/btservice/AdapterProperties.java
+++ b/src/com/android/bluetooth/btservice/AdapterProperties.java
@@ -10,6 +10,7 @@ import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.os.ParcelUuid;
+import android.os.UserHandle;
import android.util.Log;
import android.util.Pair;
@@ -299,7 +300,8 @@ class AdapterProperties {
intent.putExtra(BluetoothAdapter.EXTRA_PREVIOUS_CONNECTION_STATE,
convertToAdapterState(prevState));
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- mService.sendBroadcast(intent, mService.BLUETOOTH_PERM);
+ mService.sendBroadcastAsUser(intent, UserHandle.ALL,
+ mService.BLUETOOTH_PERM);
Log.d(TAG, "CONNECTION_STATE_CHANGE: " + device + ": "
+ prevState + " -> " + state);
}
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index e32c8c57c..988f0ecd6 100755
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -483,24 +483,14 @@ public class AdapterService extends Service {
return null;
}
public boolean isEnabled() {
- if ((Binder.getCallingUid() != Process.SYSTEM_UID) &&
- (!Utils.checkCaller())) {
- Log.w(TAG,"isEnabled(): not allowed for non-active user and non system user");
- return false;
- }
-
+ // don't check caller, may be called from system UI
AdapterService service = getService();
if (service == null) return false;
return service.isEnabled();
}
public int getState() {
- if ((Binder.getCallingUid() != Process.SYSTEM_UID) &&
- (!Utils.checkCaller())) {
- Log.w(TAG,"getState(): not allowed for non-active user and non system user");
- return BluetoothAdapter.STATE_OFF;
- }
-
+ // don't check caller, may be called from system UI
AdapterService service = getService();
if (service == null) return BluetoothAdapter.STATE_OFF;
return service.getState();
@@ -665,22 +655,14 @@ public class AdapterService extends Service {
}
public BluetoothDevice[] getBondedDevices() {
- if (!Utils.checkCaller()) {
- Log.w(TAG,"getBondedDevices: not allowed for non-active user");
- return new BluetoothDevice[0];
- }
-
+ // don't check caller, may be called from system UI
AdapterService service = getService();
if (service == null) return new BluetoothDevice[0];
return service.getBondedDevices();
}
public int getAdapterConnectionState() {
- if (!Utils.checkCaller()) {
- Log.w(TAG,"getAdapterConnectionState: not allowed for non-active user");
- return BluetoothAdapter.STATE_DISCONNECTED;
- }
-
+ // don't check caller, may be called from system UI
AdapterService service = getService();
if (service == null) return BluetoothAdapter.STATE_DISCONNECTED;
return service.getAdapterConnectionState();
@@ -731,11 +713,7 @@ public class AdapterService extends Service {
}
public int getBondState(BluetoothDevice device) {
- if (!Utils.checkCaller()) {
- Log.w(TAG,"getBondState(): not allowed for non-active user");
- return BluetoothDevice.BOND_NONE;
- }
-
+ // don't check caller, may be called from system UI
AdapterService service = getService();
if (service == null) return BluetoothDevice.BOND_NONE;
return service.getBondState(device);
diff --git a/src/com/android/bluetooth/btservice/BondStateMachine.java b/src/com/android/bluetooth/btservice/BondStateMachine.java
index d192ddc83..ffdfab1ca 100755
--- a/src/com/android/bluetooth/btservice/BondStateMachine.java
+++ b/src/com/android/bluetooth/btservice/BondStateMachine.java
@@ -13,6 +13,7 @@ import com.android.bluetooth.hfp.HeadsetService;
import android.content.Context;
import android.content.Intent;
import android.os.Message;
+import android.os.UserHandle;
import android.util.Log;
import com.android.bluetooth.Utils;
@@ -252,7 +253,8 @@ final class BondStateMachine extends StateMachine {
intent.putExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, oldState);
if (newState == BluetoothDevice.BOND_NONE)
intent.putExtra(BluetoothDevice.EXTRA_REASON, reason);
- mAdapterService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM);
+ mAdapterService.sendBroadcastAsUser(intent, UserHandle.ALL,
+ AdapterService.BLUETOOTH_PERM);
infoLog("Bond State Change Intent:" + device + " OldState: " + oldState
+ " NewState: " + newState);
}