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

Commit 8721b387 authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I980a1f05,I896d25aa,I7db26b74,Ie2f6c15e,I9df627ef, ...

* changes:
  Simplify more discovery functions
  Simplify handling discoverable timeout
  Simplify scan mode handling
  Move more permission checks into the binder stub
  Simplify IO capability handling
  Simplify checking for system or active or managed users
parents 6062a2d0 985121e7
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -286,7 +286,15 @@ public final class Utils {

    public static boolean callerIsSystemOrActiveUser(String tag, String method) {
        if (!checkCaller()) {
          Log.w(TAG, method + "() - Not allowed for non-active user and non system user");
          Log.w(TAG, method + "() - Not allowed for non-active user and non-system user");
          return false;
        }
        return true;
    }

    public static boolean callerIsSystemOrActiveOrManagedUser(Context context, String tag, String method) {
        if (!checkCallerAllowManagedProfiles(context)) {
          Log.w(TAG, method + "() - Not allowed for non-active user and non-system and non-managed user");
          return false;
        }
        return true;
+0 −9
Original line number Diff line number Diff line
@@ -916,15 +916,6 @@ class AdapterProperties {
        setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE);
    }

    void onBluetoothDisable() {
        // From STATE_ON to BLE_ON
        debugLog("onBluetoothDisable()");
        // Turn off any Device Search/Inquiry
        mService.cancelDiscovery();
        // Set the scan_mode to NONE (no incoming connections).
        setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE);
    }

    void discoveryStateChangeCallback(int state) {
        infoLog("Callback:discoveryStateChangeCallback with state:" + state);
        synchronized (mObject) {
+92 −167

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public class AdapterServiceTest {
    private static final String TAG = AdapterServiceTest.class.getSimpleName();

    private AdapterService mAdapterService;
    private AdapterService.AdapterServiceBinder mServiceBinder;

    private @Mock Context mMockContext;
    private @Mock ApplicationInfo mMockApplicationInfo;
@@ -119,6 +120,7 @@ public class AdapterServiceTest {

        InstrumentationRegistry.getInstrumentation().runOnMainSync(
                () -> mAdapterService = new AdapterService());
        mServiceBinder = new AdapterService.AdapterServiceBinder(mAdapterService);
        mMockPackageManager = mock(PackageManager.class);
        mMockContentResolver = new MockContentResolver(mMockContext);
        MockitoAnnotations.initMocks(this);
@@ -220,7 +222,7 @@ public class AdapterServiceTest {

        verify(mMockContext, timeout(CONTEXT_SWITCH_MS).times(2 * invocationNumber + 2))
                .sendBroadcast(any(), eq(android.Manifest.permission.BLUETOOTH));
        final int scanMode = mAdapterService.getScanMode();
        final int scanMode = mServiceBinder.getScanMode();
        Assert.assertTrue(scanMode == BluetoothAdapter.SCAN_MODE_CONNECTABLE
                || scanMode == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
        Assert.assertTrue(mAdapterService.getState() == BluetoothAdapter.STATE_ON);