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

Commit 3e0e9f8a authored by Xin Li's avatar Xin Li
Browse files

Merge commit 'ac5d7e74' from

oc-mr1-dev-plus-aosp into stage-aosp-master

Change-Id: I30866e08761de3375fbf589aeb84a5142838242c
parents 873d1d80 ac5d7e74
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -211,7 +211,8 @@
                  android:label=""
                  android:excludeFromRecents="true"
                  android:configChanges="orientation|keyboardHidden"
                  android:enabled="@bool/profile_supported_opp">
                  android:enabled="@bool/profile_supported_opp"
                  android:theme="@android:style/Theme.DeviceDefault.Settings">
            <intent-filter>
                <action android:name="com.android.bluetooth.action.TransferHistory" />
                <category android:name="android.intent.category.DEFAULT" />
+10 −2
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@ import java.util.UUID;
        /** Flag to signal that transport is congested */
        public Boolean isCongested = false;

        /** Whether the calling app has location permission */
        boolean hasLocationPermisson;

        /** Whether the calling app has peers mac address permission */
        boolean hasPeersMacAddressPermission;

        /** Internal callback info queue, waiting to be send on congestion clear */
        private List<CallbackInfo> mCongestionQueue = new ArrayList<CallbackInfo>();

@@ -154,7 +160,7 @@ import java.util.UUID;
    /**
     * Add an entry to the application context list.
     */
    void add(UUID uuid, WorkSource workSource, C callback, T info, GattService service) {
    App add(UUID uuid, WorkSource workSource, C callback, T info, GattService service) {
        int appUid = Binder.getCallingUid();
        String appName = service.getPackageManager().getNameForUid(appUid);
        if (appName == null) {
@@ -167,8 +173,10 @@ import java.util.UUID;
                appScanStats = new AppScanStats(appName, workSource, this, service);
                mAppScanStats.put(appUid, appScanStats);
            }
            mApps.add(new App(uuid, callback, info, appName, appScanStats));
            App app = new App(uuid, callback, info, appName, appScanStats);
            mApps.add(app);
            appScanStats.isRegistered = true;
            return app;
        }
    }

+24 −13
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.util.NumberUtils;
import com.android.internal.annotations.VisibleForTesting;

import java.security.Security;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -1037,7 +1038,7 @@ public class GattService extends ProfileService {
                if (cbApp.callback != null) {
                    cbApp.linkToDeath(new ScannerDeathRecipient(scannerId));
                } else {
                    continuePiStartScan(scannerId, cbApp.info);
                    continuePiStartScan(scannerId, cbApp);
                }
            } else {
                mScannerMap.remove(scannerId);
@@ -1919,26 +1920,36 @@ public class GattService extends ProfileService {
        piInfo.settings = settings;
        piInfo.filters = filters;
        piInfo.callingPackage = callingPackage;
        mScannerMap.add(uuid, null, null, piInfo, this);
        ScannerMap.App app = mScannerMap.add(uuid, null, null, piInfo, this);
        try {
            app.hasLocationPermisson =
                    Utils.checkCallerHasLocationPermission(this, mAppOps, callingPackage);
        } catch (SecurityException se) {
            // No need to throw here. Just mark as not granted.
            app.hasLocationPermisson = false;
        }
        try {
            app.hasPeersMacAddressPermission = Utils.checkCallerHasPeersMacAddressPermission(this);
        } catch (SecurityException se) {
            // No need to throw here. Just mark as not granted.
            app.hasPeersMacAddressPermission = false;
        }
        mScanManager.registerScanner(uuid);
    }

    void continuePiStartScan(int scannerId, PendingIntentInfo piInfo) {
    void continuePiStartScan(int scannerId, ScannerMap.App app) {
        final PendingIntentInfo piInfo = app.info;
        final ScanClient scanClient =
                new ScanClient(scannerId, piInfo.settings, piInfo.filters, null);
        scanClient.hasLocationPermission =
                true; // Utils.checkCallerHasLocationPermission(this, mAppOps,
        // piInfo.callingPackage);
        scanClient.hasPeersMacAddressPermission =
                true; // Utils.checkCallerHasPeersMacAddressPermission(
        // this);
        scanClient.hasLocationPermission = app.hasLocationPermisson;
        scanClient.hasPeersMacAddressPermission = app.hasPeersMacAddressPermission;
        scanClient.legacyForegroundApp = Utils.isLegacyForegroundApp(this, piInfo.callingPackage);

        AppScanStats app = mScannerMap.getAppScanStatsById(scannerId);
        if (app != null) {
            scanClient.stats = app;
        AppScanStats scanStats = mScannerMap.getAppScanStatsById(scannerId);
        if (scanStats != null) {
            scanClient.stats = scanStats;
            boolean isFilteredScan = (piInfo.filters != null) && !piInfo.filters.isEmpty();
            app.recordScanStart(piInfo.settings, isFilteredScan, scannerId);
            scanStats.recordScanStart(piInfo.settings, isFilteredScan, scannerId);
        }

        mScanManager.startScan(scanClient);