Add new Telephony APIs for Cell Broadcast
Bug: 256043136
Test: atest CtsTelephonyTestCases
Test: atest com.android.internal.telephony.GsmCdmaPhoneTest
Test: manual
Change-Id: I8a82e71f7f6f546cb59847a3b51890866153d7a5
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f1cff81..1ed6350 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -83,6 +83,7 @@
import android.telephony.CallForwardingInfo;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierRestrictionRules;
+import android.telephony.CellBroadcastIdRange;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityCdma;
import android.telephony.CellIdentityGsm;
@@ -11685,4 +11686,51 @@
}
return simState.ordinal();
}
-}
\ No newline at end of file
+
+ /**
+ * Get current cell broadcast ranges.
+ */
+ @Override
+ @RequiresPermission(android.Manifest.permission.MODIFY_CELL_BROADCASTS)
+ public List<CellBroadcastIdRange> getCellBroadcastIdRanges(int subId) {
+ mApp.enforceCallingPermission(android.Manifest.permission.MODIFY_CELL_BROADCASTS,
+ "getCellBroadcastIdRanges");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return getPhone(subId).getCellBroadcastIdRanges();
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ /**
+ * Set reception of cell broadcast messages with the list of the given ranges
+ *
+ * @param ranges the list of {@link CellBroadcastIdRange} to be enabled
+ */
+ @Override
+ @RequiresPermission(android.Manifest.permission.MODIFY_CELL_BROADCASTS)
+ public void setCellBroadcastIdRanges(int subId, @NonNull List<CellBroadcastIdRange> ranges,
+ @Nullable IIntegerConsumer callback) {
+ mApp.enforceCallingPermission(android.Manifest.permission.MODIFY_CELL_BROADCASTS,
+ "setCellBroadcastIdRanges");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Phone phone = getPhoneFromSubId(subId);
+ if (DBG) {
+ log("setCellBroadcastIdRanges for subId :" + subId + ", phone:" + phone);
+ }
+ phone.setCellBroadcastIdRanges(ranges, result -> {
+ if (callback != null) {
+ try {
+ callback.accept(result);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "setCellBroadcastIdRanges: callback not available.");
+ }
+ }
+ });
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+}