summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nathan <nharold@google.com> 2022-10-12 17:36:36 -0700
committer Nathan <nharold@google.com> 2022-10-14 15:04:09 -0700
commit5af91fbe5af8f350d936ae8401d3584a9e8f48e2 (patch)
tree7613e632ed43df5bf9d7b2c0c280c91ce8aa74cc
parent8314a3e51bd31e9c11a9b61e4bef88b2ad65803d (diff)
Fixups for Barring Info
-Ensure that phoneId is valid before doing fixup for null barring info (shouldn't happen, but it's validated elsewhere). -Move write of mBarringInfo into the synchronized block. -Dedupe BarringInfo to ensure that registrants aren't spammed due to screen off/on. Bug: 242633342 Test: atest TelephonyRegistryTest#testBarringInfoChanged Change-Id: I1f83709beb44d65bb36d49dcf71bce5ae382c2d1
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java50
1 files changed, 28 insertions, 22 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index c5c45534d338..7cc24fa5ea49 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -2572,33 +2572,39 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (!checkNotifyPermission("notifyBarringInfo()")) {
return;
}
- if (barringInfo == null) {
- log("Received null BarringInfo for subId=" + subId + ", phoneId=" + phoneId);
- mBarringInfo.set(phoneId, new BarringInfo());
+ if (!validatePhoneId(phoneId)) {
+ loge("Received invalid phoneId for BarringInfo = " + phoneId);
return;
}
synchronized (mRecords) {
- if (validatePhoneId(phoneId)) {
- mBarringInfo.set(phoneId, barringInfo);
- // Barring info is non-null
- BarringInfo biNoLocation = barringInfo.createLocationInfoSanitizedCopy();
- if (VDBG) log("listen: call onBarringInfoChanged=" + barringInfo);
- for (Record r : mRecords) {
- if (r.matchTelephonyCallbackEvent(
- TelephonyCallback.EVENT_BARRING_INFO_CHANGED)
- && idMatch(r, subId, phoneId)) {
- try {
- if (DBG_LOC) {
- log("notifyBarringInfo: mBarringInfo="
- + barringInfo + " r=" + r);
- }
- r.callback.onBarringInfoChanged(
- checkFineLocationAccess(r, Build.VERSION_CODES.BASE)
- ? barringInfo : biNoLocation);
- } catch (RemoteException ex) {
- mRemoveList.add(r.binder);
+ if (barringInfo == null) {
+ loge("Received null BarringInfo for subId=" + subId + ", phoneId=" + phoneId);
+ mBarringInfo.set(phoneId, new BarringInfo());
+ return;
+ }
+ if (barringInfo.equals(mBarringInfo.get(phoneId))) {
+ if (VDBG) log("Ignoring duplicate barring info.");
+ return;
+ }
+ mBarringInfo.set(phoneId, barringInfo);
+ // Barring info is non-null
+ BarringInfo biNoLocation = barringInfo.createLocationInfoSanitizedCopy();
+ if (VDBG) log("listen: call onBarringInfoChanged=" + barringInfo);
+ for (Record r : mRecords) {
+ if (r.matchTelephonyCallbackEvent(
+ TelephonyCallback.EVENT_BARRING_INFO_CHANGED)
+ && idMatch(r, subId, phoneId)) {
+ try {
+ if (DBG_LOC) {
+ log("notifyBarringInfo: mBarringInfo="
+ + barringInfo + " r=" + r);
}
+ r.callback.onBarringInfoChanged(
+ checkFineLocationAccess(r, Build.VERSION_CODES.BASE)
+ ? barringInfo : biNoLocation);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
}
}
}