Put additional logs to check ResultReceiver created over limit
Bug: 376281558
Flag: com.android.internal.telephony.flags.geofence_enhancement_for_better_ux
Test: atest SatelliteControllerTest#testLoggingCodeForResultReceiverCount
Test: atest SatelliteAccessControllerTest
Change-Id: Id20172b0272177505bd744811cbcfa9fee507f38
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index bd90a9d..4a0f1ec 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -13204,11 +13204,14 @@
final long identity = Binder.clearCallingIdentity();
try {
if (enableSatellite) {
+ String caller = "PIM:requestSatelliteEnabled";
ResultReceiver resultReceiver = new ResultReceiver(mMainThreadHandler) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
Log.d(LOG_TAG, "Satellite access restriction resultCode=" + resultCode
+ ", resultData=" + resultData);
+ mSatelliteController.decrementResultReceiverCount(caller);
+
boolean isAllowed = false;
Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(
callback::accept);
@@ -13241,6 +13244,7 @@
};
mSatelliteAccessController.requestIsCommunicationAllowedForCurrentLocation(
resultReceiver, true);
+ mSatelliteController.incrementResultReceiverCount(caller);
} else {
// No need to check if satellite is allowed at current location when disabling
// satellite
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 49edf6a..be2e53b 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -425,6 +425,9 @@
handleIsSatelliteSupportedResult(resultCode, resultData);
}
};
+ mSatelliteController.incrementResultReceiverCount(
+ "SAC:mInternalSatelliteSupportedResultReceiver");
+
mInternalSatelliteProvisionedResultReceiver = new ResultReceiver(this) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
@@ -442,13 +445,16 @@
public void onSatelliteSupportedStateChanged(boolean isSupported) {
logd("onSatelliteSupportedStateChanged: isSupported=" + isSupported);
if (isSupported) {
+ final String caller = "SAC:onSatelliteSupportedStateChanged";
requestIsCommunicationAllowedForCurrentLocation(
new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
+ mSatelliteController.decrementResultReceiverCount(caller);
// do nothing
}
}, false);
+ mSatelliteController.incrementResultReceiverCount(caller);
if (mSatelliteDisallowedReasons.contains(
Integer.valueOf(SATELLITE_DISALLOWED_REASON_NOT_SUPPORTED))) {
mSatelliteDisallowedReasons.remove(
@@ -473,13 +479,16 @@
public void onSatelliteProvisionStateChanged(boolean isProvisioned) {
logd("onSatelliteProvisionStateChanged: isProvisioned=" + isProvisioned);
if (isProvisioned) {
+ final String caller = "SAC:onSatelliteProvisionStateChanged";
requestIsCommunicationAllowedForCurrentLocation(
new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
+ mSatelliteController.decrementResultReceiverCount(caller);
// do nothing
}
}, false);
+ mSatelliteController.incrementResultReceiverCount(caller);
if (mSatelliteDisallowedReasons.contains(
SATELLITE_DISALLOWED_REASON_NOT_PROVISIONED)) {
mSatelliteDisallowedReasons.remove(
@@ -591,6 +600,8 @@
mAccessControllerMetricsStats.setTriggeringEvent(TRIGGERING_EVENT_EXTERNAL_REQUEST);
sendRequestAsync(CMD_IS_SATELLITE_COMMUNICATION_ALLOWED,
new Pair<>(mSatelliteController.getSelectedSatelliteSubId(), result));
+ mSatelliteController.incrementResultReceiverCount(
+ "SAC:requestIsCommunicationAllowedForCurrentLocation");
}
/**
@@ -1180,6 +1191,8 @@
synchronized (mLock) {
for (ResultReceiver resultReceiver : mSatelliteAllowResultReceivers) {
resultReceiver.send(resultCode, resultData);
+ mSatelliteController.decrementResultReceiverCount(
+ "SAC:requestIsCommunicationAllowedForCurrentLocation");
}
mSatelliteAllowResultReceivers.clear();
}