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

Commit 96910f7d authored by Haijie Hong's avatar Haijie Hong
Browse files

Add method to get bluetooth key missing count

Bug: 388018781
Test: local build and tested. I didn't find a good way to add unit test for reflection
Flag: EXEMPT add utils
Change-Id: I79bb15984cb1ac4085d1b04f26e5d8e88717545f
parent 40aa32b3
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ import com.android.settingslib.widget.AdaptiveOutlineDrawable;
import com.google.common.collect.ImmutableSet;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
@@ -1268,4 +1270,15 @@ public class BluetoothUtils {

        return false;
    }

    /** Gets key missing count of the device. This is a workaround before the API is rolled out. */
    public static Integer getKeyMissingCount(BluetoothDevice device) {
        try {
            Method m = BluetoothDevice.class.getDeclaredMethod("getKeyMissingCount");
            return (int) m.invoke(device);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            Log.w(TAG, "error happens when getKeyMissingCount.");
            return null;
        }
    }
}