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

Commit b91788b3 authored by dianlujitao's avatar dianlujitao Committed by Luca Stefani
Browse files

adb_root: Restart adbd when turning off root

 * The running adbd session remains rooted after turning off from UI.

Change-Id: Iedd5282b4e3c11ef6c0959ae6867448521cb2c78
parent 43ab18e6
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <private/android_filesystem_config.h>

@@ -60,8 +61,18 @@ binder::Status ADBRootService::setEnabled(bool enabled) {
    }

    AutoMutex _l(lock_);

    if (enabled_ != enabled) {
        enabled_ = enabled;
        WriteStringToFile(std::to_string(enabled), kStoragePath + kEnabled);

        // Turning off adb root, restart adbd.
        if (!enabled) {
            base::SetProperty("lineage.service.adb.root", "0");
            base::SetProperty("ctl.restart", "adbd");
        }
    }

    return binder::Status::ok();
}