summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2011-08-03 14:17:22 -0700
committerJaikumar Ganesh <jaikumar@google.com>2011-08-03 15:00:07 -0700
commitf5fb6c8ce36a98da47f32f4142d372bd5f650bfa (patch)
tree6172decfbb4b028f78a5408406cfb4681299c0ed
parent62c7b37590b1a692384a55949d3b9eba221a3652 (diff)
downloadframeworks_base-f5fb6c8ce36a98da47f32f4142d372bd5f650bfa.zip
frameworks_base-f5fb6c8ce36a98da47f32f4142d372bd5f650bfa.tar.gz
frameworks_base-f5fb6c8ce36a98da47f32f4142d372bd5f650bfa.tar.bz2
Enforce permission for changeApplicationState function.
The ADMIN permission is for use cases where we want to manage BT connection at a deeper level. So just the Bluetooth permission is good enough here. Change-Id: Iddd038fe9f9a26f155b4edc9484ba1fe27b178ba
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java5
-rwxr-xr-xcore/java/android/server/BluetoothService.java2
2 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index ca6f085..28bc424 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -1163,7 +1163,10 @@ public final class BluetoothAdapter {
* <p> If this API returns true, it means the callback will be called.
* The callback will be called with the current state of Bluetooth.
* If the state is not what was requested, an internal error would be the
- * reason.
+ * reason. If Bluetooth is already on and if this function is called to turn
+ * it on, the api will return true and a callback will be called.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*
* @param on True for on, false for off.
* @param callback The callback to notify changes to the state.
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 28546dc..3029c9d 100755
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -1565,6 +1565,8 @@ public class BluetoothService extends IBluetooth.Stub {
@Override
public boolean changeApplicationBluetoothState(boolean on,
IBluetoothStateChangeCallback callback, IBinder binder) {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+
int pid = Binder.getCallingPid();
//mStateChangeTracker is a synchronized map
if (!mStateChangeTracker.containsKey(pid)) {