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

Commit 08a90d71 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8920865 from 45f0bd67 to tm-qpr1-release

Change-Id: If6a94838407b403ccba9cb8b1188586b1b5a6e90
parents ddf424ff 45f0bd67
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

<resources xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="permlab_bluetoothShareManager" msgid="5297865456717871041">"ଡାଉନଲୋଡ୍‌ ମ୍ୟାନେଜର୍‌କୁ ଆକ୍ସେସ୍‌ କରନ୍ତୁ।"</string>
    <string name="permlab_bluetoothShareManager" msgid="5297865456717871041">"ଡାଉନଲୋଡ ମ୍ୟାନେଜର୍‌କୁ ଆକ୍ସେସ୍‌ କରନ୍ତୁ।"</string>
    <string name="permdesc_bluetoothShareManager" msgid="1588034776955941477">"BluetoothShare ମ୍ୟାନେଜର୍‌ ଆକ୍ସେସ୍‌ କରି ଫାଇଲ୍‌ଗୁଡ଼ିକ ଟ୍ରାନ୍ସଫର୍‌ କରିବାକୁ ବ୍ୟବହାର କରିବା ପାଇଁ ଆପ୍‌କୁ ଅନୁମତି ଦିଅନ୍ତୁ।"</string>
    <string name="permlab_bluetoothAcceptlist" msgid="5785922051395856524">"ବ୍ଲୁଟୁଥ୍ ଡିଭାଇସର ଆକ୍ସେସକୁ ଗ୍ରହଣ-ସୂଚୀରେ ରଖନ୍ତୁ।"</string>
    <string name="permdesc_bluetoothAcceptlist" msgid="259308920158011885">"ଏକ ବ୍ଲୁଟୁଥ୍ ଡିଭାଇସକୁ ଅସ୍ଥାୟୀ ଭାବେ ଗ୍ରହଣ-ସୂଚୀରେ ରଖିବାକୁ ଆପଟିକୁ ଅନୁମତି ଦେଇଥାଏ, ଯାହା ଦ୍ୱାରା ଉପଯୋଗକର୍ତ୍ତାଙ୍କ ସୁନିଶ୍ଚିତକରଣ ବିନା ଏହି ଡିଭାଇସକୁ ଫାଇଲ୍ ପଠାଇବା ପାଇଁ ସେହି ଡିଭାଇସକୁ ଅନୁମତି ମିଳିଥାଏ।"</string>
+18 −21
Original line number Diff line number Diff line
@@ -5226,33 +5226,30 @@ public class AdapterService extends Service {
        }
    }

    public static int getScanQuotaCount() {
        if (sAdapterService == null) {
            return DeviceConfigListener.DEFAULT_SCAN_QUOTA_COUNT;
        }

        synchronized (sAdapterService.mDeviceConfigLock) {
            return sAdapterService.mScanQuotaCount;
        }
    /**
     * Returns scan quota count.
     */
    public int getScanQuotaCount() {
        synchronized (mDeviceConfigLock) {
            return mScanQuotaCount;
        }

    public static long getScanQuotaWindowMillis() {
        if (sAdapterService == null) {
            return DeviceConfigListener.DEFAULT_SCAN_QUOTA_WINDOW_MILLIS;
    }

        synchronized (sAdapterService.mDeviceConfigLock) {
            return sAdapterService.mScanQuotaWindowMillis;
        }
    /**
     * Returns scan quota window in millis.
     */
    public long getScanQuotaWindowMillis() {
        synchronized (mDeviceConfigLock) {
            return mScanQuotaWindowMillis;
        }

    public static long getScanTimeoutMillis() {
        if (sAdapterService == null) {
            return DeviceConfigListener.DEFAULT_SCAN_TIMEOUT_MILLIS;
    }

        synchronized (sAdapterService.mDeviceConfigLock) {
            return sAdapterService.mScanTimeoutMillis;
    /**
     * Returns scan timeout in millis.
     */
    public long getScanTimeoutMillis() {
        synchronized (mDeviceConfigLock) {
            return mScanTimeoutMillis;
        }
    }

+75 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.bluetooth.btservice;

import android.bluetooth.BluetoothAdapter;
import android.util.Log;

import com.android.bluetooth.Utils;
import com.android.internal.annotations.VisibleForTesting;

/**
 * A proxy class that facilitates testing of the ScanManager.
 *
 * This is necessary due to the "final" attribute of the BluetoothAdapter class. In order to
 * test the correct functioning of the ScanManager class, the final class must be put
 * into a container that can be mocked correctly.
 */
public class BluetoothAdapterProxy {
    private static final String TAG = BluetoothAdapterProxy.class.getSimpleName();
    private static BluetoothAdapterProxy sInstance;
    private static final Object INSTANCE_LOCK = new Object();

    private BluetoothAdapterProxy() {}

    /**
     * Get the singleton instance of proxy.
     *
     * @return the singleton instance, guaranteed not null
     */
    public static BluetoothAdapterProxy getInstance() {
        synchronized (INSTANCE_LOCK) {
            if (sInstance == null) {
                sInstance = new BluetoothAdapterProxy();
            }
            return sInstance;
        }
    }

    /**
     * Proxy function that calls {@link BluetoothAdapter#isOffloadedFilteringSupported()}.
     *
     * @return whether the offloaded scan filtering is supported
     */
    public boolean isOffloadedScanFilteringSupported() {
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        return adapter.isOffloadedFilteringSupported();
    }

    /**
     * Allow unit tests to substitute BluetoothAdapterProxy with a test instance
     *
     * @param proxy a test instance of the BluetoothAdapterProxy
     */
    @VisibleForTesting
    public static void setInstanceForTesting(BluetoothAdapterProxy proxy) {
        Utils.enforceInstrumentationTestMode();
        synchronized (INSTANCE_LOCK) {
            Log.d(TAG, "setInstanceForTesting(), set to " + proxy);
            sInstance = proxy;
        }
    }
}
+0 −23
Original line number Diff line number Diff line
@@ -105,29 +105,6 @@ import java.util.Objects;
            this.filterString = "";
        }
    }

    static int getNumScanDurationsKept() {
        return AdapterService.getScanQuotaCount();
    }

    // This constant defines the time window an app can scan multiple times.
    // Any single app can scan up to |NUM_SCAN_DURATIONS_KEPT| times during
    // this window. Once they reach this limit, they must wait until their
    // earliest recorded scan exits this window.
    static long getExcessiveScanningPeriodMillis() {
        return AdapterService.getScanQuotaWindowMillis();
    }

    // Maximum msec before scan gets downgraded to opportunistic
    static long getScanTimeoutMillis() {
        return AdapterService.getScanTimeoutMillis();
    }

    // Scan mode upgrade duration after scanStart()
    static long getScanUpgradeDurationMillis() {
        return AdapterService.getAdapterService().getScanUpgradeDurationMillis();
    }

    public String appName;
    public WorkSource mWorkSource; // Used for BatteryStatsManager
    public final WorkSourceUtil mWorkSourceUtil; // Used for BluetoothStatsLog
+13 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AbstractionLayer;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.BluetoothAdapterProxy;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.util.NumberUtils;
import com.android.internal.annotations.VisibleForTesting;
@@ -262,6 +263,7 @@ public class GattService extends ProfileService {
    private final HashMap<String, AtomicBoolean> mPermits = new HashMap<>();

    private AdapterService mAdapterService;
    private BluetoothAdapterProxy mBluetoothAdapterProxy;
    private AdvertiseManager mAdvertiseManager;
    private PeriodicScanManager mPeriodicScanManager;
    private ScanManager mScanManager;
@@ -319,12 +321,13 @@ public class GattService extends ProfileService {

        initializeNative();
        mAdapterService = AdapterService.getAdapterService();
        mBluetoothAdapterProxy = BluetoothAdapterProxy.getInstance();
        mCompanionManager = getSystemService(CompanionDeviceManager.class);
        mAppOps = getSystemService(AppOpsManager.class);
        mAdvertiseManager = new AdvertiseManager(this, mAdapterService);
        mAdvertiseManager.start();

        mScanManager = new ScanManager(this, mAdapterService);
        mScanManager = new ScanManager(this, mAdapterService, mBluetoothAdapterProxy);
        mScanManager.start();

        mPeriodicScanManager = new PeriodicScanManager(mAdapterService);
@@ -426,6 +429,15 @@ public class GattService extends ProfileService {
        return sGattService;
    }

    @VisibleForTesting
    ScanManager getScanManager() {
        if (mScanManager == null) {
            Log.w(TAG, "getScanManager(): scan manager is null");
            return null;
        }
        return mScanManager;
    }

    private static synchronized void setGattService(GattService instance) {
        if (DBG) {
            Log.d(TAG, "setGattService(): set to: " + instance);
Loading