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

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

Merge "BluetoothApp: Enforce more error prone" into main

parents e30b2fbe 68abe535
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -323,23 +323,31 @@ android_app {
        enabled: true,
        javacflags: [
            "-Xep:AlmostJavadoc:ERROR",
            "-Xep:AndroidFrameworkBinderIdentity:ERROR",
            "-Xep:AndroidFrameworkEfficientStrings:ERROR",
            "-Xep:AndroidFrameworkRequiresPermission:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:DateFormatConstant:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:HidingField:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:MissingCasesInEnumSwitch:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:UnnecessaryStringBuilder:ERROR",
            "-Xep:UnusedMethod:ERROR",
            "-Xep:UnusedNestedClass:ERROR",
            "-Xep:UnusedVariable:ERROR",
            "-Xep:WaitNotInLoop:ERROR",
            "-XepExcludedPaths:.*/srcjars/.*", // Exclude generated files
        ],
    },
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class BluetoothEventLogger {
        }

        public String toString() {
            return (new StringBuilder(mTimeStamp).append(" ").append(mMsg).toString());
            return mTimeStamp + " " + mMsg;
        }
    }

+19 −16
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ public class BassClientStateMachine extends StateMachine {
            AdapterService adapterService,
            Looper looper,
            int connectTimeoutMs) {
        super(TAG + "(" + device.toString() + ")", looper);
        super(TAG + "(" + device + ")", looper);
        mDevice = device;
        mService = svc;
        mAdapterService = adapterService;
@@ -182,7 +182,8 @@ public class BassClientStateMachine extends StateMachine {
        addState(mConnectedProcessing);
        setInitialState(mDisconnected);
        mFirstTimeBisDiscoveryMap = new HashMap<Integer, Boolean>();
        long token = Binder.clearCallingIdentity();
        final long token = Binder.clearCallingIdentity();
        try {
            mIsAllowedList =
                    DeviceConfig.getBoolean(
                            DeviceConfig.NAMESPACE_BLUETOOTH, "persist.vendor.service.bt.wl", true);
@@ -196,8 +197,10 @@ public class BassClientStateMachine extends StateMachine {
                            DeviceConfig.NAMESPACE_BLUETOOTH,
                            "persist.vendor.service.bt.forceSB",
                            false);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    static BassClientStateMachine make(
            BluetoothDevice device,
+5 −4
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class AudioRoutingManager extends ActiveDeviceManager {
    private AudioRoutingHandler mHandler = null;
    private final AudioManager mAudioManager;
    private final MediaSessionManager mSessionManager;
    private final AudioManagerAudioDeviceCallback mAudioManagerAudioDeviceCallback;
    private final AudioManagerAudioDeviceCallback mAudioRoutingManagerAudioDeviceCallback;

    @Override
    public void onBluetoothStateChange(int prevState, int newState) {
@@ -144,7 +144,7 @@ public class AudioRoutingManager extends ActiveDeviceManager {
        mFactory = factory;
        mAudioManager = service.getSystemService(AudioManager.class);
        mSessionManager = service.getSystemService(MediaSessionManager.class);
        mAudioManagerAudioDeviceCallback = new AudioManagerAudioDeviceCallback();
        mAudioRoutingManagerAudioDeviceCallback = new AudioManagerAudioDeviceCallback();
    }

    @Override
@@ -157,7 +157,8 @@ public class AudioRoutingManager extends ActiveDeviceManager {
        mHandler = new AudioRoutingHandler(mp.handlerThreadGetLooper(mHandlerThread));

        mAudioManager.addOnModeChangedListener(cmd -> mHandler.post(cmd), mHandler);
        mAudioManager.registerAudioDeviceCallback(mAudioManagerAudioDeviceCallback, mHandler);
        mAudioManager.registerAudioDeviceCallback(
                mAudioRoutingManagerAudioDeviceCallback, mHandler);
        mAdapterService.registerBluetoothStateCallback((command) -> mHandler.post(command), this);
    }

@@ -166,7 +167,7 @@ public class AudioRoutingManager extends ActiveDeviceManager {
        Log.d(TAG, "cleanup()");

        mAudioManager.removeOnModeChangedListener(mHandler);
        mAudioManager.unregisterAudioDeviceCallback(mAudioManagerAudioDeviceCallback);
        mAudioManager.unregisterAudioDeviceCallback(mAudioRoutingManagerAudioDeviceCallback);
        mAdapterService.unregisterBluetoothStateCallback(this);
        if (mHandlerThread != null) {
            mHandlerThread.quit();
+4 −3
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ import java.util.Objects;
public class AppScanStats {
    private static final String TAG = AppScanStats.class.getSimpleName();

    static final DateFormat DATE_FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss");
    private static final ThreadLocal<DateFormat> DATE_FORMAT =
            ThreadLocal.withInitial(() -> new SimpleDateFormat("MM-dd HH:mm:ss"));

    // Weight is the duty cycle of the scan mode
    static final int OPPORTUNISTIC_WEIGHT = 0;
@@ -1031,7 +1032,7 @@ public class AppScanStats {
            for (int i = 0; i < mLastScans.size(); i++) {
                LastScan scan = mLastScans.get(i);
                Date timestamp = new Date(currentTime - currTime + scan.timestamp);
                sb.append("\n    ").append(DATE_FORMAT.format(timestamp)).append(" - ");
                sb.append("\n    ").append(DATE_FORMAT.get().format(timestamp)).append(" - ");
                sb.append(scan.duration).append("ms ");
                if (scan.isOpportunisticScan) {
                    sb.append("Opp ");
@@ -1084,7 +1085,7 @@ public class AppScanStats {
            for (Integer key : mOngoingScans.keySet()) {
                LastScan scan = mOngoingScans.get(key);
                Date timestamp = new Date(currentTime - currTime + scan.timestamp);
                sb.append("\n    ").append(DATE_FORMAT.format(timestamp)).append(" - ");
                sb.append("\n    ").append(DATE_FORMAT.get().format(timestamp)).append(" - ");
                sb.append((currTime - scan.timestamp)).append("ms ");
                if (scan.isOpportunisticScan) {
                    sb.append("Opp ");
Loading