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

Commit cc02efa4 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6622447 from 1deb14b0 to mainline-release

Change-Id: I2dd3192dca0062a6be688ce9783aadb811ea79d0
parents 1d45a8a1 1deb14b0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <uses-permission android:name="android.permission.MANAGE_COMPANION_DEVICES"/>

    <uses-sdk android:minSdkVersion="14"/>

+10 −6
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ class PhonePolicy {
                || ArrayUtils.contains(uuids, BluetoothUuid.HOGP)) && (
                hidService.getConnectionPolicy(device)
                        == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            hidService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                    BluetoothProfile.HID_HOST, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        }

        // If we do not have a stored priority for HFP/A2DP (all roles) then default to on.
@@ -269,14 +270,16 @@ class PhonePolicy {
                || ArrayUtils.contains(uuids, BluetoothUuid.HFP)) && (
                headsetService.getConnectionPolicy(device)
                        == BluetoothProfile.CONNECTION_POLICY_UNKNOWN))) {
            headsetService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                    BluetoothProfile.HEADSET, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        }

        if ((a2dpService != null) && (ArrayUtils.contains(uuids, BluetoothUuid.A2DP_SINK)
                || ArrayUtils.contains(uuids, BluetoothUuid.ADV_AUDIO_DIST)) && (
                a2dpService.getConnectionPolicy(device)
                        == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            a2dpService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                    BluetoothProfile.A2DP, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        }

        if ((panService != null) && (ArrayUtils.contains(uuids, BluetoothUuid.PANU) && (
@@ -284,15 +287,16 @@ class PhonePolicy {
                        == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)
                && mAdapterService.getResources()
                .getBoolean(R.bool.config_bluetooth_pan_enable_autoconnect))) {
            panService.setConnectionPolicy(device, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                    BluetoothProfile.PAN, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        }

        if ((hearingAidService != null) && ArrayUtils.contains(uuids,
                BluetoothUuid.HEARING_AID) && (hearingAidService.getConnectionPolicy(device)
                == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) {
            debugLog("setting hearing aid profile priority for device " + device);
            hearingAidService.setConnectionPolicy(device,
                    BluetoothProfile.CONNECTION_POLICY_ALLOWED);
            mAdapterService.getDatabase().setProfileConnectionPolicy(device,
                    BluetoothProfile.HEARING_AID, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ import java.util.UUID;
        /** Whether the calling app has the network setup wizard permission */
        boolean mHasScanWithoutLocationPermission;

        public List<String> mAssociatedDevices;

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

+39 −2
Original line number Diff line number Diff line
@@ -45,11 +45,14 @@ import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanRecord;
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.companion.ICompanionDeviceManager;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.WorkSource;
@@ -181,6 +184,7 @@ public class GattService extends ProfileService {
    private PeriodicScanManager mPeriodicScanManager;
    private ScanManager mScanManager;
    private AppOpsManager mAppOps;
    private ICompanionDeviceManager mCompanionManager;

    private static GattService sGattService;

@@ -205,6 +209,8 @@ public class GattService extends ProfileService {
        }
        initializeNative();
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mCompanionManager = ICompanionDeviceManager.Stub.asInterface(
                ServiceManager.getService(Context.COMPANION_DEVICE_SERVICE));
        mAppOps = getSystemService(AppOpsManager.class);
        mAdvertiseManager = new AdvertiseManager(this, AdapterService.getAdapterService());
        mAdvertiseManager.start();
@@ -1012,8 +1018,16 @@ public class GattService extends ProfileService {
                            txPower, rssi, periodicAdvInt,
                            ScanRecord.parseFromBytes(scanRecordData),
                            SystemClock.elapsedRealtimeNanos());
            // Do not report if location mode is OFF or the client has no location permission
            if (!hasScanResultPermission(client) || !matchesFilters(client, result)) {
            boolean hasPermission = hasScanResultPermission(client);
            if (!hasPermission) {
                for (String associatedDevice : client.associatedDevices) {
                    if (associatedDevice.equalsIgnoreCase(address)) {
                        hasPermission = true;
                        break;
                    }
                }
            }
            if (!hasPermission || !matchesFilters(client, result)) {
                continue;
            }

@@ -1938,6 +1952,26 @@ public class GattService extends ProfileService {
        mScanManager.unregisterScanner(scannerId);
    }

    private List<String> getAssociatedDevices(String callingPackage, UserHandle userHandle) {
        if (mCompanionManager == null) {
            return new ArrayList<String>();
        }
        long identity = Binder.clearCallingIdentity();
        try {
            return mCompanionManager.getAssociations(
                    callingPackage, userHandle.getIdentifier());
        } catch (SecurityException se) {
            // Not an app with associated devices
        } catch (RemoteException re) {
            Log.e(TAG, "Cannot reach companion device service", re);
        } catch (Exception e) {
            Log.e(TAG, "Cannot check device associations for " + callingPackage, e);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
        return new ArrayList<String>();
    }

    void startScan(int scannerId, ScanSettings settings, List<ScanFilter> filters,
            List<List<ResultStorageDescriptor>> storages, String callingPackage,
            @Nullable String callingFeatureId) {
@@ -1966,6 +2000,7 @@ public class GattService extends ProfileService {
                Utils.checkCallerHasNetworkSetupWizardPermission(this);
        scanClient.hasScanWithoutLocationPermission =
                Utils.checkCallerHasScanWithoutLocationPermission(this);
        scanClient.associatedDevices = getAssociatedDevices(callingPackage, scanClient.userHandle);

        AppScanStats app = mScannerMap.getAppScanStatsById(scannerId);
        ScannerMap.App cbApp = mScannerMap.getById(scannerId);
@@ -2030,6 +2065,7 @@ public class GattService extends ProfileService {
                Utils.checkCallerHasNetworkSetupWizardPermission(this);
        app.mHasScanWithoutLocationPermission =
                Utils.checkCallerHasScanWithoutLocationPermission(this);
        app.mAssociatedDevices = getAssociatedDevices(callingPackage, app.mUserHandle);
        mScanManager.registerScanner(uuid);
    }

@@ -2043,6 +2079,7 @@ public class GattService extends ProfileService {
        scanClient.hasNetworkSettingsPermission = app.mHasNetworkSettingsPermission;
        scanClient.hasNetworkSetupWizardPermission = app.mHasNetworkSetupWizardPermission;
        scanClient.hasScanWithoutLocationPermission = app.mHasScanWithoutLocationPermission;
        scanClient.associatedDevices = app.mAssociatedDevices;

        AppScanStats scanStats = mScannerMap.getAppScanStatsById(scannerId);
        if (scanStats != null) {
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import java.util.UUID;
    public boolean hasNetworkSettingsPermission;
    public boolean hasNetworkSetupWizardPermission;
    public boolean hasScanWithoutLocationPermission;
    public List<String> associatedDevices;

    public AppScanStats stats = null;

Loading