diff options
| author | 2023-03-03 17:02:23 +0000 | |
|---|---|---|
| committer | 2023-03-03 17:02:23 +0000 | |
| commit | 706b1c46b1e7d945e5dbc583b1823bf48b7cba1c (patch) | |
| tree | b8d285796bfa89705599db6bdde0d8412a20a6d1 | |
| parent | 0adc576dec02619115fc3a9ea0e3d4664a50a3e2 (diff) | |
| parent | 96d4d20e8f01c0f44b6b9368900fd7c665abceca (diff) | |
Merge "Merge "Extend previously added limits for listeners" am: 875e6cc383 am: 5fb1885e8f" into tm-qpr-dev-plus-aosp
| -rw-r--r-- | services/core/java/com/android/server/TelephonyRegistry.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 7cc24fa5ea49..2652ebec5255 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -873,6 +873,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mContext.registerReceiver(mBroadcastReceiver, filter); } + //helper function to determine if limit on num listeners applies to callingUid + private boolean doesLimitApplyForListeners(int callingUid, int exemptUid) { + return (callingUid != Process.SYSTEM_UID + && callingUid != Process.PHONE_UID + && callingUid != exemptUid); + } + @Override public void addOnSubscriptionsChangedListener(String callingPackage, String callingFeatureId, IOnSubscriptionsChangedListener callback) { @@ -887,7 +894,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { // register IBinder b = callback.asBinder(); - Record r = add(b, Binder.getCallingUid(), Binder.getCallingPid(), false); + boolean doesLimitApply = doesLimitApplyForListeners(Binder.getCallingUid(), + Process.myUid()); + Record r = add(b, Binder.getCallingUid(), Binder.getCallingPid(), doesLimitApply); // if (r == null) { return; @@ -941,7 +950,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { // register IBinder b = callback.asBinder(); - Record r = add(b, Binder.getCallingUid(), Binder.getCallingPid(), false); + boolean doesLimitApply = doesLimitApplyForListeners(Binder.getCallingUid(), + Process.myUid()); + Record r = add(b, Binder.getCallingUid(), Binder.getCallingPid(), doesLimitApply); // if (r == null) { return; @@ -1070,10 +1081,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { // register IBinder b = callback.asBinder(); - boolean doesLimitApply = - Binder.getCallingUid() != Process.SYSTEM_UID - && Binder.getCallingUid() != Process.PHONE_UID - && Binder.getCallingUid() != Process.myUid(); + boolean doesLimitApply = doesLimitApplyForListeners(Binder.getCallingUid(), + Process.myUid()); Record r = add(b, Binder.getCallingUid(), Binder.getCallingPid(), doesLimitApply); if (r == null) { @@ -1417,7 +1426,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { .isRegistrationLimitEnabledInPlatformCompat(callingUid)) { throw new IllegalStateException(errorMsg); } - } else if (doesLimitApply && numRecordsForPid + } else if (numRecordsForPid >= TelephonyCallback.DEFAULT_PER_PID_REGISTRATION_LIMIT / 2) { // Log the warning independently of the dynamically set limit -- apps shouldn't be // doing this regardless of whether we're throwing them an exception for it. |