Add MODIFY_PHONE_STATE permission to access Bluetooth service in Phone app
Enforce MODIFY_PHONE_STATE permission for some HeadsetService APIs that
only provided for Phone app for phone stat change notifications
bug 7115021
Change-Id: I62e3f429f4205feb50e123ee94b4c468999804a6
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c73d92f..e139859 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -43,6 +43,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
+ <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<!-- For PBAP Owner Vcard Info -->
<uses-permission android:name="android.permission.READ_PROFILE"/>
<application
diff --git a/src/com/android/bluetooth/hfp/HeadsetService.java b/src/com/android/bluetooth/hfp/HeadsetService.java
index f147078..b603e02 100755
--- a/src/com/android/bluetooth/hfp/HeadsetService.java
+++ b/src/com/android/bluetooth/hfp/HeadsetService.java
@@ -33,6 +33,8 @@
public class HeadsetService extends ProfileService {
private static final boolean DBG = true;
private static final String TAG = "HeadsetService";
+ private static final String MODIFY_PHONE_STATE = android.Manifest.permission.MODIFY_PHONE_STATE;
+
private HeadsetStateMachine mStateMachine;
private static HeadsetService sHeadsetService;
@@ -452,6 +454,7 @@
private void phoneStateChanged(int numActive, int numHeld, int callState,
String number, int type) {
+ enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, null);
Message msg = mStateMachine.obtainMessage(HeadsetStateMachine.CALL_STATE_CHANGED);
msg.obj = new HeadsetCallState(numActive, numHeld, callState, number, type);
msg.arg1 = 0; // false
@@ -459,11 +462,13 @@
}
private void roamChanged(boolean roam) {
+ enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, null);
mStateMachine.sendMessage(HeadsetStateMachine.ROAM_CHANGED, roam);
}
private void clccResponse(int index, int direction, int status, int mode, boolean mpty,
String number, int type) {
+ enforceCallingOrSelfPermission(MODIFY_PHONE_STATE, null);
mStateMachine.sendMessage(HeadsetStateMachine.SEND_CCLC_RESPONSE,
new HeadsetClccResponse(index, direction, status, mode, mpty, number, type));
}