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

Commit 78a8dd11 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I838a8a65,I51112332 into main

* changes:
  SystemServer: remove avoid_static_loading_of_native
  SystemServer: remove fast_bind_to_app
parents 1add75f1 9237a1d0
Loading
Loading
Loading
Loading
+8 −52
Original line number Diff line number Diff line
@@ -369,17 +369,6 @@ public class AdapterService extends Service {
        }
    };

    static {
        if (!Flags.avoidStaticLoadingOfNative()) {
            Log.d(TAG, "Loading JNI Library");
            if (Utils.isInstrumentationTestMode()) {
                Log.w(TAG, "App is instrumented. Skip loading the native");
            } else {
                System.loadLibrary("bluetooth_jni");
            }
        }
    }

    // Keep a constructor for ActivityThread.handleCreateService
    AdapterService() {
        this(Looper.getMainLooper());
@@ -629,10 +618,6 @@ public class AdapterService extends Service {
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate()");
        if (!Flags.fastBindToApp()) {
            init();
            return;
        }
        // OnCreate must perform the minimum of infaillible and mandatory initialization
        mRemoteDevices = new RemoteDevices(this, mLooper);
        mAdapterProperties = new AdapterProperties(this, mRemoteDevices, mLooper);
@@ -652,27 +637,10 @@ public class AdapterService extends Service {
        Config.init(this);
        mDeviceConfigListener.start();

        if (!Flags.fastBindToApp()) {
            // Moved to OnCreate
            mUserManager = getNonNullSystemService(UserManager.class);
            mAppOps = getNonNullSystemService(AppOpsManager.class);
            mPowerManager = getNonNullSystemService(PowerManager.class);
            mBatteryStatsManager = getNonNullSystemService(BatteryStatsManager.class);
            mCompanionDeviceManager = getNonNullSystemService(CompanionDeviceManager.class);
            mRemoteDevices = new RemoteDevices(this, mLooper);
        }
        MetricsLogger.getInstance().init(this, mRemoteDevices);

        clearDiscoveringPackages();
        if (!Flags.fastBindToApp()) {
            mBinder = new AdapterServiceBinder(this);
        }
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        if (!Flags.fastBindToApp()) {
            // Moved to OnCreate
            mAdapterProperties = new AdapterProperties(this, mRemoteDevices, mLooper);
            mAdapterStateMachine = new AdapterState(this, mLooper);
        }
        boolean isCommonCriteriaMode =
                getNonNullSystemService(DevicePolicyManager.class)
                        .isCommonCriteriaModeEnabled(null);
@@ -690,14 +658,12 @@ public class AdapterService extends Service {
                getApplicationContext()
                        .getPackageManager()
                        .hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY);
        if (Flags.avoidStaticLoadingOfNative()) {
        if (Utils.isInstrumentationTestMode()) {
            Log.w(TAG, "This Bluetooth App is instrumented. ** Skip loading the native **");
        } else {
            Log.d(TAG, "Loading JNI Library");
            System.loadLibrary("bluetooth_jni");
        }
        }
        mNativeInterface.init(
                this,
                mAdapterProperties,
@@ -719,11 +685,7 @@ public class AdapterService extends Service {
                        "BluetoothQualityReportNativeInterface cannot be null when BQR starts");
        mBluetoothQualityReportNativeInterface.init();

        if (Flags.fastBindToApp()) {
        mSdpManager = new SdpManager(this, mLooper);
        } else {
            mSdpManager = new SdpManager(this);
        }

        mDatabaseManager.start(MetadataDatabase.createDatabase(this));

@@ -765,10 +727,6 @@ public class AdapterService extends Service {
                            mNativeInterface, mLooper, getSystemService(DisplayManager.class));
        }

        if (!Flags.fastBindToApp()) {
            setAdapterService(this);
        }

        invalidateBluetoothCaches();

        // First call to getSharedPreferences will result in a file read into
@@ -4683,10 +4641,8 @@ public class AdapterService extends Service {
            Log.d(TAG, "offToBleOn() called when Bluetooth was disallowed");
            return;
        }
        if (Flags.fastBindToApp()) {
        // The call to init must be done on the main thread
        mHandler.post(() -> init());
        }

        Log.i(TAG, "offToBleOn() - Enable called with quiet mode status =  " + quietMode);
        mQuietmode = quietMode;
+2 −6
Original line number Diff line number Diff line
@@ -410,9 +410,7 @@ public class AdapterServiceTest {
            IBluetoothCallback callback,
            AdapterNativeInterface nativeInterface) {
        adapter.offToBleOn(false);
        if (Flags.fastBindToApp()) {
            TestUtils.syncHandler(looper, 0); // when fastBindToApp is enable init need to be run
        }
        TestUtils.syncHandler(looper, 0); // `init` need to be run first
        TestUtils.syncHandler(looper, AdapterState.BLE_TURN_ON);
        verifyStateChange(callback, STATE_OFF, STATE_BLE_TURNING_ON);

@@ -625,9 +623,7 @@ public class AdapterServiceTest {
        assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF);

        mAdapterService.offToBleOn(false);
        if (Flags.fastBindToApp()) {
            syncHandler(0); // when fastBindToApp is enable init need to be run
        }
        syncHandler(0); // `init` need to be run first
        syncHandler(AdapterState.BLE_TURN_ON);
        verifyStateChange(STATE_OFF, STATE_BLE_TURNING_ON);
        assertThat(mAdapterService.getBluetoothGatt()).isNotNull();
+0 −17
Original line number Diff line number Diff line
package: "com.android.bluetooth.flags"
container: "com.android.btservices"

flag {
    name: "avoid_static_loading_of_native"
    namespace: "bluetooth"
    description: "Prevent loading native during static initialization and prefer doing it during init"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
    bug: "339554081"
}

flag {
    name: "enforce_resolve_system_service_behavior"
    namespace: "bluetooth"
@@ -21,13 +11,6 @@ flag {
    bug: "366273182"
}

flag {
    name: "fast_bind_to_app"
    namespace: "bluetooth"
    description: "Remove complexity and non necessary initialization when simply binding"
    bug: "328698375"
}

flag {
    name: "get_state_from_system_server"
    namespace: "bluetooth"
+1 −12
Original line number Diff line number Diff line
@@ -1570,23 +1570,15 @@ class BluetoothManagerService {
                        }
                    }

                    // Register callback object
                    try {
                        mAdapter.registerCallback(
                                mBluetoothCallback, mContext.getAttributionSource());
                    } catch (RemoteException e) {
                        Log.e(TAG, "Unable to register BluetoothCallback", e);
                    }
                    // Inform BluetoothAdapter instances that service is up
                    if (!Flags.fastBindToApp()) {
                        sendBluetoothServiceUpCallback();
                    }

                    // Do enable request
                    offToBleOn();
                    if (Flags.fastBindToApp()) {
                    sendBluetoothServiceUpCallback();
                    }

                    if (!mEnable) {
                        waitForState(STATE_ON);
@@ -1892,9 +1884,6 @@ class BluetoothManagerService {
    private void handleEnable() {
        if (mAdapter == null && !isBinding()) {
            bindToAdapter();
        } else if (!Flags.fastBindToApp() && mAdapter != null) {
            // Enable bluetooth
            offToBleOn();
        }
    }