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

Commit afeced01 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes from topic "shutdown_latency" into main

* changes:
  SystemServer: Add more situational log for sleep
  SystemServer: remove lint baseline
  SystemServer: Metrics on shutdown latency
parents cd8e9af1 c05e7ca1
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ java_defaults {
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:LongFloatConversion:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
@@ -110,10 +111,6 @@ java_library {
        "modules-utils-shell-command-handler",
    ],

    lint: {
        baseline_filename: "lint-baseline.xml",
    },

    optimize: {
        enabled: true,
        shrink: true,

service/lint-baseline.xml

deleted100644 → 0
+0 −52
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.4.0-alpha01" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha01">

    <issue
        id="NotificationPermission"
        message="When targeting Android 13 or higher, posting a permission requires holding the `POST_NOTIFICATIONS` permission">
        <location
            file="packages/modules/Bluetooth/service/src/com/android/server/bluetooth/BluetoothNotificationManager.java"
            line="125"/>
    </issue>

    <issue
        id="VisibleForTests"
        message="This method should only be accessed from tests or within private scope">
        <location
            file="packages/modules/Bluetooth/service/src/com/android/server/bluetooth/BluetoothAirplaneModeListener.java"
            line="239"/>
    </issue>

    <issue
        id="VisibleForTests"
        message="This method should only be accessed from tests or within private scope">
        <location
            file="packages/modules/Bluetooth/service/src/com/android/server/bluetooth/BluetoothAirplaneModeListener.java"
            line="247"/>
    </issue>

    <issue
        id="VisibleForTests"
        message="This method should only be accessed from tests or within private scope">
        <location
            file="packages/modules/Bluetooth/service/src/com/android/server/bluetooth/BluetoothManagerService.java"
            line="1532"/>
    </issue>

    <issue
        id="VisibleForTests"
        message="This method should only be accessed from tests or within private scope">
        <location
            file="packages/modules/Bluetooth/service/src/com/android/server/bluetooth/BluetoothSatelliteModeListener.java"
            line="48"/>
    </issue>

    <issue
        id="VisibleForTests"
        message="This method should only be accessed from tests or within private scope">
        <location
            file="packages/modules/Bluetooth/service/src/com/android/server/bluetooth/BluetoothSatelliteModeListener.java"
            line="51"/>
    </issue>

</issues>
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.modules.expresslog.Counter;
import com.android.modules.expresslog.Histogram;
import com.android.server.BluetoothManagerServiceDumpProto;
import com.android.server.bluetooth.airplane.AirplaneModeListener;
import com.android.server.bluetooth.satellite.SatelliteModeListener;
@@ -563,6 +564,10 @@ class BluetoothManagerService {
                }
            };

    private final Histogram mShutdownLatencyHistogram =
            new Histogram(
                    "bluetooth.value_shutdown_latency", new Histogram.UniformOptions(50, 0, 3000));

    BluetoothManagerService(@NonNull Context context, @NonNull Looper looper) {
        mContext = requireNonNull(context, "Context cannot be null");
        mContentResolver = requireNonNull(mContext.getContentResolver(), "Resolver cannot be null");
@@ -1194,6 +1199,7 @@ class BluetoothManagerService {
            if (mAdapter == null) {
                return;
            }
            long currentTimeMs = System.currentTimeMillis();

            try {
                mAdapter.unregisterCallback(mBluetoothCallback, mContext.getAttributionSource());
@@ -1236,7 +1242,11 @@ class BluetoothManagerService {
                Log.e(TAG, "Bluetooth death not received correctly after > 2000ms", e);
            }

            long timeSpentForShutdown = System.currentTimeMillis() - currentTimeMs;
            mShutdownLatencyHistogram.logSample((float) timeSpentForShutdown);

            // TODO: b/356931756 - Remove sleep
            Log.d(TAG, "Force sleep 100 ms for propagating Bluetooth app death");
            SystemClock.sleep(100); // required to let the ActivityManager be notified of BT death

            mAdapter = null;
@@ -1831,8 +1841,10 @@ class BluetoothManagerService {
            // shut down completely before attempting to restart.
            //
            if (didDisableTimeout) {
                Log.d(TAG, "Force sleep 3000 ms for user switch that timed out");
                SystemClock.sleep(3000);
            } else {
                Log.d(TAG, "Force sleep 100 ms for");
                SystemClock.sleep(100);
            }

@@ -2107,6 +2119,7 @@ class BluetoothManagerService {
    }

    private boolean waitForState(int... states) {
        Log.d(TAG, "Waiting " + STATE_TIMEOUT + " for state: " + Arrays.toString(states));
        return mState.waitForState(STATE_TIMEOUT, states);
    }

@@ -2164,6 +2177,7 @@ class BluetoothManagerService {
            mAdapterLock.readLock().unlock();
        }

        Log.d(TAG, "Force sleep 500 ms for recovering from error");
        SystemClock.sleep(500);

        // disable