Add multi user support for bluetooth
Create a BLUETOOTH_STACK permission to share between all users of
Bluetooth apk. Bluetooth Manager binds to apk of current user
bug 6925422
Change-Id: I2df5546e977c2d77bc66d97d12479d933826922a
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index c794c51..aa67ec2 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -620,6 +620,13 @@
android:description="@string/permdesc_bluetoothAdmin"
android:label="@string/permlab_bluetoothAdmin" />
+ <!-- Allows bluetooth stack to access files
+ @hide This should only be used by Bluetooth apk.
+ -->
+ <permission android:name="android.permission.BLUETOOTH_STACK"
+ android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
+ android:protectionLevel="signature" />
+
<!-- Allows applications to perform I/O operations over NFC -->
<permission android:name="android.permission.NFC"
android:permissionGroup="android.permission-group.NETWORK"
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index a19b9b4..13d1791 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -42,6 +42,10 @@
<group gid="net_bt" />
</permission>
+ <permission name="android.permission.BLUETOOTH_STACK" >
+ <group gid="net_bt_stack" />
+ </permission>
+
<permission name="android.permission.NET_TUNNELING" >
<group gid="vpn" />
</permission>
@@ -176,6 +180,7 @@
<assign-permission name="android.permission.INTERACT_ACROSS_USERS" uid="shell" />
<assign-permission name="android.permission.INTERACT_ACROSS_USERS_FULL" uid="shell" />
<assign-permission name="android.permission.MANAGE_USERS" uid="shell" />
+ <assign-permission name="android.permission.BLUETOOTH_STACK" uid="shell" />
<assign-permission name="android.permission.MODIFY_AUDIO_SETTINGS" uid="media" />
<assign-permission name="android.permission.ACCESS_DRM" uid="media" />
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java
index ce75e35..e7cd279 100755
--- a/services/java/com/android/server/BluetoothManagerService.java
+++ b/services/java/com/android/server/BluetoothManagerService.java
@@ -481,7 +481,7 @@
mHandler.sendMessageDelayed(timeoutMsg,TIMEOUT_BIND_MS);
Intent i = new Intent(IBluetooth.class.getName());
if (!mContext.bindService(i, mConnection,
- Context.BIND_AUTO_CREATE)) {
+ Context.BIND_AUTO_CREATE, UserHandle.USER_CURRENT)) {
mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);
Log.e(TAG, "fail to bind to: " + IBluetooth.class.getName());
}
@@ -717,7 +717,8 @@
mHandler.sendMessageDelayed(timeoutMsg,TIMEOUT_BIND_MS);
mConnection.setGetNameAddressOnly(false);
Intent i = new Intent(IBluetooth.class.getName());
- if (!mContext.bindService(i, mConnection,Context.BIND_AUTO_CREATE)) {
+ if (!mContext.bindService(i, mConnection, Context.BIND_AUTO_CREATE,
+ UserHandle.USER_CURRENT)) {
mHandler.removeMessages(MESSAGE_TIMEOUT_BIND);
Log.e(TAG, "Fail to bind to: " + IBluetooth.class.getName());
}