Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b5e9120 authored by Etienne Ruffieux's avatar Etienne Ruffieux
Browse files

Replaced hidden APIs usage by new SystemApi.

Replaced hidden calls to registerCancelListener and
unregisterCancelListener by new public SystemApis. Also
moved the PendingIntent.addCancelListener to be after
scan setup.

Tag: #feature
Bug: 195146423
Test: Manual
Ignore-AOSP-First: Merge conflict
Change-Id: Ifbfb4af6e946492be892ad2ba80742c044455826
parent aea67d4b
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2381,8 +2381,6 @@ public class GattService extends ProfileService {

        ScannerMap.App app = mScannerMap.add(uuid, null, null, piInfo, this);

        pendingIntent.registerCancelListener(mScanIntentCancelListener);

        app.mUserHandle = UserHandle.getUserHandleForUid(Binder.getCallingUid());
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
        app.mEligibleForSanitizedExposureNotification =
@@ -2414,6 +2412,12 @@ public class GattService extends ProfileService {
                Utils.checkCallerHasScanWithoutLocationPermission(this);
        app.mAssociatedDevices = getAssociatedDevices(callingPackage, app.mUserHandle);
        mScanManager.registerScanner(uuid);

        // If this fails, we should stop the scan immediately.
        if (!pendingIntent.addCancelListener(Runnable::run, mScanIntentCancelListener)) {
            Log.d(TAG, "scanning PendingIntent is already cancelled, stopping scan.");
            stopScan(pendingIntent, attributionSource);
        }
    }

    void continuePiStartScan(int scannerId, ScannerMap.App app) {
@@ -2488,7 +2492,7 @@ public class GattService extends ProfileService {
            Log.d(TAG, "stopScan(PendingIntent): app found = " + app);
        }
        if (app != null) {
            intent.unregisterCancelListener(mScanIntentCancelListener);
            intent.removeCancelListener(mScanIntentCancelListener);
            final int scannerId = app.id;
            stopScan(scannerId, attributionSource);
            // Also unregister the scanner