Merge "no-op: Remove checkAndNotifyCommonError with ResultReceiver" into main am: 67055ed7a8

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3512872

Change-Id: I3db2bf384d70ad9172e9531730c5fd341198cfab
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Quang Luong 2025-03-15 00:39:27 -07:00 • committed by Automerger Merge Worker
commit 16ad4737c7

View file

@ -173,7 +173,21 @@ public class TetheringService extends Service {
@Override
public void requestLatestTetheringEntitlementResult(int type, ResultReceiver receiver,
boolean showEntitlementUi, String callerPkg, String callingAttributionTag) {
if (checkAndNotifyCommonError(callerPkg, callingAttributionTag, receiver)) return;
// Wrap the app-provided ResultReceiver in an IIntResultListener in order to call
// checkAndNotifyCommonError with it.
IIntResultListener listener = new IIntResultListener() {
@Override
public void onResult(int i) {
receiver.send(i, null);
}
@Override
public IBinder asBinder() {
throw new UnsupportedOperationException("asBinder unexpectedly called on"
+ " internal-only listener");
}
};
if (checkAndNotifyCommonError(callerPkg, callingAttributionTag, listener)) return;
mTethering.requestLatestTetheringEntitlementResult(type, receiver, showEntitlementUi);
}
@ -277,27 +291,6 @@ public class TetheringService extends Service {
return false;
}
private boolean checkAndNotifyCommonError(final String callerPkg,
final String callingAttributionTag, final ResultReceiver receiver) {
if (!checkPackageNameMatchesUid(getBinderCallingUid(), callerPkg)) {
Log.e(TAG, "Package name " + callerPkg + " does not match UID "
+ getBinderCallingUid());
receiver.send(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION, null);
return true;
}
if (!hasTetherChangePermission(callerPkg, callingAttributionTag,
false /* onlyAllowPrivileged */)) {
receiver.send(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION, null);
return true;
}
if (!mTethering.isTetheringSupported() || !mTethering.isTetheringAllowed()) {
receiver.send(TETHER_ERROR_UNSUPPORTED, null);
return true;
}
return false;
}
private boolean hasNetworkSettingsPermission() {
return checkCallingOrSelfPermission(NETWORK_SETTINGS);
}