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

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

Merge changes I955631da,I7de3daa8,Iaf258db0,Ib9b31756,If5b59f95 into main

* changes:
  Dumpsys: fix native flag output
  SystemServer: shell cmd Add enableBle & DisableBle
  update coverage script
  SystemServer: Prevent BLE_ON when Airplane mode on
  Airplane mode rename isOn to isOnOverrode
parents f132c029 d86cb3e7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -185,6 +185,8 @@ android_robolectric_test {
    static_libs: [
        "androidx.test.core",
        "androidx.test.ext.truth",
        "bluetooth_flags_java_lib",
        "flag-junit",
        "kotlin-test",
        "kotlinx_coroutines",
        "kotlinx_coroutines_test",
+2 −1
Original line number Diff line number Diff line
@@ -27,7 +27,8 @@ rm ${COVERAGE_TMP_FOLDER}/ServiceBluetoothRobo_unzip/com/android/server/bluetoot
rm ${COVERAGE_TMP_FOLDER}/ServiceBluetoothRobo_unzip/com/android/server/bluetooth/R.class

# Generate report:
java -jar "${ANDROID_BUILD_TOP}"/out/dist/jacoco-cli.jar report "${COVERAGE_COLLECTED}"/invocation_*/inv_*/coverage_*.ec --classfiles ${COVERAGE_TMP_FOLDER}/ServiceBluetoothRobo_unzip --html ${COVERAGE_TMP_FOLDER}/coverage --name coverage.html --sourcefiles ${COVERAGE_TMP_FOLDER}
# You may want to run "m jacoco-cli" if above command failed
java -jar "${ANDROID_BUILD_TOP}"/out/host/linux-x86/framework/jacoco-cli.jar report "${COVERAGE_COLLECTED}"/invocation_*/inv_*/coverage_*.ec --classfiles ${COVERAGE_TMP_FOLDER}/ServiceBluetoothRobo_unzip --html ${COVERAGE_TMP_FOLDER}/coverage --name coverage.html --sourcefiles ${COVERAGE_TMP_FOLDER}

# Start python server and expose URL
printf "Url to connect to the coverage \033[32m http://%s:8000 \033[0m\n" "$(hostname)"
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import androidx.annotation.RequiresApi
import androidx.annotation.VisibleForTesting
import com.android.modules.expresslog.Counter
import com.android.server.bluetooth.airplane.hasUserToggledApm as hasUserToggledApm
import com.android.server.bluetooth.airplane.isOn as isAirplaneModeOn
import com.android.server.bluetooth.airplane.isOnOverrode as isAirplaneModeOn
import com.android.server.bluetooth.satellite.isOn as isSatelliteModeOn
import java.time.LocalDateTime
import java.time.LocalTime
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import com.android.server.bluetooth.BluetoothAdapterState
import com.android.server.bluetooth.Log
import com.android.server.bluetooth.Timer
import com.android.server.bluetooth.USER_SETTINGS_KEY
import com.android.server.bluetooth.airplane.isOn as isAirplaneModeOn
import com.android.server.bluetooth.airplane.isOnOverrode as isAirplaneModeOn
import com.android.server.bluetooth.airplane.test.ModeListenerTest as AirplaneListener
import com.android.server.bluetooth.isUserEnabled
import com.android.server.bluetooth.isUserSupported
+29 −10
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Looper
import android.provider.Settings
import android.widget.Toast
import com.android.bluetooth.BluetoothStatsLog
import com.android.bluetooth.flags.Flags
import com.android.server.bluetooth.BluetoothAdapterState
import com.android.server.bluetooth.Log
import com.android.server.bluetooth.initializeRadioModeListener
@@ -36,7 +37,16 @@ import kotlin.time.TimeSource

private const val TAG = "AirplaneModeListener"

/** @return true if Bluetooth state is impacted by airplane mode */
/** @return true if Bluetooth state is currently impacted by airplane mode */
public var isOnOverrode = false
    private set

/**
 * @return true if airplane is ON on the device.
 *
 * This need to be used instead of reading the settings properties to avoid race condition from
 * within the BluetoothManagerService thread
 */
public var isOn = false
    private set

@@ -80,11 +90,12 @@ public fun initialize(
            Settings.Global.AIRPLANE_MODE_RADIOS,
            Settings.Global.AIRPLANE_MODE_ON,
            fun(newMode: Boolean) {
                val previousMode = isOn
                isOn = newMode
                val previousMode = isOnOverrode
                val isBluetoothOn = state.oneOf(STATE_ON, STATE_TURNING_ON, STATE_TURNING_OFF)
                val isMediaConnected = isBluetoothOn && mediaCallback()

                isOn =
                isOnOverrode =
                    airplaneModeValueOverride(
                        systemResolver,
                        newMode,
@@ -103,17 +114,25 @@ public fun initialize(
                    timeSource.markNow(),
                )

                if (previousMode == isOn) {
                    Log.d(TAG, "Ignore airplane mode change because is already: $isOn")
                val description = "isOn=$isOn, isOnOverrode=$isOnOverrode"

                if (previousMode == isOnOverrode) {
                    Log.d(TAG, "Ignore mode change to same state. $description")
                    return
                } else if (
                    Flags.airplaneModeXBleOn() && isOnOverrode == false && state.oneOf(STATE_ON)
                ) {
                    Log.d(TAG, "Ignore mode change as Bluetooth is ON. $description")
                    return
                }

                Log.i(TAG, "Trigger callback with state: $isOn")
                modeCallback(isOn)
                Log.i(TAG, "Trigger callback. $description")
                modeCallback(isOnOverrode)
            }
        )

    isOn =
    isOn = airplaneModeAtBoot
    isOnOverrode =
        airplaneModeValueOverride(
            systemResolver,
            airplaneModeAtBoot,
@@ -132,7 +151,7 @@ public fun initialize(
        false,
        timeSource.markNow(),
    )
    Log.i(TAG, "Initialized successfully with state: $isOn")
    Log.i(TAG, "Init completed. isOn=$isOn, isOnOverrode=$isOnOverrode")
}

@kotlin.time.ExperimentalTime
@@ -263,7 +282,7 @@ private class AirplaneMetricSession(
        }
    }

    private val isBluetoothOnAfterApmToggle = !isOn
    private val isBluetoothOnAfterApmToggle = !isOnOverrode
    private var userToggledBluetoothDuringApm = false
    private var userToggledBluetoothDuringApmWithinMinute = false

Loading