Integrate the machinism of always reporting signal strength
in Telephony service
Test: WIP (Have this CL out to try to catch up the API deadline)
Bug: 147322848
Change-Id: I3d6465088b239d9fd62585f7477db448a142bf66
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ae6ec1a..ae4b130 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -49,6 +49,7 @@
import android.os.ParcelFileDescriptor;
import android.os.ParcelUuid;
import android.os.PersistableBundle;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceSpecificException;
@@ -2455,6 +2456,17 @@
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE, null);
}
+ /**
+ * Make sure the caller is system.
+ *
+ * @throws SecurityException if the caller is not system.
+ */
+ private void enforceSystemCaller() {
+ if (Binder.getCallingUid() != Process.SYSTEM_UID) {
+ throw new SecurityException("Caller must be system");
+ }
+ }
+
private void enforceActiveEmergencySessionPermission() {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION, null);
@@ -5135,6 +5147,34 @@
}
/**
+ * Enable or disable always reporting signal strength changes from radio.
+ *
+ * @param isEnable {@code true} for enabling; {@code false} for disabling.
+ */
+ @Override
+ public void setAlwaysReportSignalStrength(int subId, boolean isEnable) {
+ enforceModifyPermission();
+ enforceSystemCaller();
+
+ final long identity = Binder.clearCallingIdentity();
+ final Phone phone = getPhone(subId);
+ try {
+ if (phone != null) {
+ if (DBG) {
+ log("setAlwaysReportSignalStrength: subId=" + subId
+ + " isEnable=" + isEnable);
+ }
+ phone.setAlwaysReportSignalStrength(isEnable);
+ } else {
+ loge("setAlwaysReportSignalStrength: no phone found for subId="
+ + subId);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ /**
* Get the user enabled state of Mobile Data.
*
* TODO: remove and use isUserDataEnabled.