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

Commit fa3cbdf5 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Implement Bluetooth settings factory reset (1/5)

Implemented the factory reset function to be used to reset all bluetooth
settings on device to factory default

Bug: 16161518
parent 5d0d1da2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1123,6 +1123,13 @@ static void dumpNative(JNIEnv *env, jobject obj, jobject fdObj)
    sBluetoothInterface->dump(fd);
}

static jboolean factoryResetNative(JNIEnv *env, jobject obj) {
    ALOGV("%s:", __FUNCTION__);
    if (!sBluetoothInterface) return JNI_FALSE;
    int ret = sBluetoothInterface->config_clear();
    return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static JNINativeMethod sMethods[] = {
    /* name, signature, funcPtr */
    {"classInitNative", "()V", (void *) classInitNative},
@@ -1151,6 +1158,7 @@ static JNINativeMethod sMethods[] = {
    {"alarmFiredNative", "()V", (void *) alarmFiredNative},
    {"readEnergyInfo", "()I", (void*) readEnergyInfo},
    {"dumpNative", "(Ljava/io/FileDescriptor;)V", (void*) dumpNative},
    {"factoryResetNative", "()Z", (void*)factoryResetNative}
};

int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env)
+14 −0
Original line number Diff line number Diff line
@@ -1212,6 +1212,14 @@ public class AdapterService extends Service {
            return service.configHciSnoopLog(enable);
        }

        public boolean factoryReset() {
            AdapterService service = getService();
            if (service == null) return false;
            service.disable();
            return service.factoryReset();

        }

        public void registerCallback(IBluetoothCallback cb) {
            AdapterService service = getService();
            if (service == null) return ;
@@ -1821,6 +1829,11 @@ public class AdapterService extends Service {
        return configHciSnoopLogNative(enable);
    }

    boolean factoryReset() {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH permission");
        return factoryResetNative();
    }

     void registerCallback(IBluetoothCallback cb) {
         mCallbacks.register(cb);
      }
@@ -2121,6 +2134,7 @@ public class AdapterService extends Service {
                                                 byte[] uuid, int port, int flag);

    /*package*/ native boolean configHciSnoopLogNative(boolean enable);
    /*package*/ native boolean factoryResetNative();

    private native void alarmFiredNative();
    private native void dumpNative(FileDescriptor fd);