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

Commit 04878bed authored by William Escande's avatar William Escande
Browse files

Follow error prone recommendation

In bluetooth/Utils.java:
```
134: warning: Parameter name `testEnabled` is unknown.
     * @param testEnabled if the profile should enter or exit a testing mode
       ^
235: warning: Method setComponentAvailable() annotated [none] but too narrow;
invokes method requiring {allOf=[android.permission.CHANGE_COMPONENT_ENABLED_STATE]}
        setComponentAvailable(component, enable);
                             ^
255: warning: Method setComponentAvailable() annotated [none] but too narrow;
invokes method requiring {allOf=[android.permission.CHANGE_COMPONENT_ENABLED_STATE]}
        getPackageManager().setComponentEnabledSetting(
                                                      ^
355: warning:  Method doStart() annotated [none] but too narrow;
invokes method requiring {allOf=[] anyOf=[android.permission.INTERACT_ACROSS_USERS,
android.permission.MANAGE_USERS]}
        if (userManager.isUserUnlocked(UserHandle.of(currentUserId))) {
                                      ^
```

Bug: 236759221
Test: m RUN_ERROR_PRONE=true Bluetooth
Change-Id: I018b517a1cc7d9f2f2dd379b78ee320d62f2dc30
parent 35425c92
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.bluetooth.btservice;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Service;
@@ -131,7 +132,7 @@ public abstract class ProfileService extends Service {
    protected void setUserUnlocked(int userId) {}

    /**
     * @param testEnabled if the profile should enter or exit a testing mode
     * @param testModeEnabled if the profile should enter or exit a testing mode
     */
    // Suppressed since this is called from framework
    @SuppressLint("AndroidFrameworkRequiresPermission")
@@ -222,6 +223,7 @@ public abstract class ProfileService extends Service {
     * @param className The class name of the owned component residing in the Bluetooth package
     * @param enable True to enable the component, False to disable it
     */
    @RequiresPermission(android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE)
    protected void setComponentAvailable(String className, boolean enable) {
        if (DBG) {
            Log.d(mName, "setComponentAvailable(className=" + className + ", enable=" + enable
@@ -244,6 +246,7 @@ public abstract class ProfileService extends Service {
     * @param component The component name of owned component
     * @param enable True to enable the component, False to disable it
     */
    @RequiresPermission(android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE)
    protected void setComponentAvailable(ComponentName component, boolean enable) {
        if (DBG) {
            Log.d(mName, "setComponentAvailable(component=" + component + ", enable=" + enable
@@ -308,6 +311,10 @@ public abstract class ProfileService extends Service {
        super.onDestroy();
    }

    @RequiresPermission(anyOf = {
            android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.INTERACT_ACROSS_USERS
    })
    private void doStart() {
        if (mAdapter == null) {
            Log.w(mName, "Can't start profile service: device does not have BT");