author | yang.xu <yang.xu@amlogic.com> | 2018-03-06 11:12:42 (GMT) |
---|---|---|
committer | yang.xu <yang.xu@amlogic.com> | 2018-03-06 11:12:42 (GMT) |
commit | 02baa2500c6b9f752f1cc07408958a654932c6e1 (patch) | |
tree | 0e6aa0e1d8090e9242cba47c457b12e8028dd5c6 | |
parent | 04d9e06ed1a80b1b98bc9dbb8c4592da51993d3f (diff) | |
download | ampere-02baa2500c6b9f752f1cc07408958a654932c6e1.zip ampere-02baa2500c6b9f752f1cc07408958a654932c6e1.tar.gz ampere-02baa2500c6b9f752f1cc07408958a654932c6e1.tar.bz2 |
systemcontrol: add readUnifyKey & writeUnifyKey [2/2]
PD# 161103
add readUnifyKey & writeUnifyKey
Change-Id: I85e226e7e138b0b9c9019353755df6ddeeb27eba
7 files changed, 89 insertions, 0 deletions
diff --git a/frameworks/core/java/com/droidlogic/app/SystemControlManager.java b/frameworks/core/java/com/droidlogic/app/SystemControlManager.java index e7bd86d..63fb361 100644 --- a/frameworks/core/java/com/droidlogic/app/SystemControlManager.java +++ b/frameworks/core/java/com/droidlogic/app/SystemControlManager.java @@ -249,6 +249,34 @@ public class SystemControlManager { return true; } + public String readUnifyKey(String path) { + synchronized (mLock) { + Mutable<String> resultVal = new Mutable<>(); + try { + mProxy.readUnifyKey(path, (int ret, String v) -> { + if (Result.OK == ret) { + resultVal.value = v; + } + }); + return resultVal.value; + } catch (RemoteException e) { + Log.e(TAG, "readUnifyKey:" + e); + } + } + + return ""; + } + + public void writeUnifyKey(String prop, String val) { + synchronized (mLock) { + try { + mProxy.writeUnifyKey(prop, val); + } catch (RemoteException e) { + Log.e(TAG, "setBootenv:" + e); + } + } + } + public int readHdcpRX14Key(String val, int size) { /* synchronized (mLock) { diff --git a/frameworks/services/systemcontrol/SystemControlClient.cpp b/frameworks/services/systemcontrol/SystemControlClient.cpp index 681b4da..9506b28 100644 --- a/frameworks/services/systemcontrol/SystemControlClient.cpp +++ b/frameworks/services/systemcontrol/SystemControlClient.cpp @@ -135,6 +135,24 @@ bool SystemControlClient::writeSysfs(const std::string& path, const char *value, return false; } +bool SystemControlClient::writeUnifyKey(const std::string& key, const std::string& value) { + Result rtn = mSysCtrl->writeUnifyKey(key, value); + if (rtn == Result::OK) { + return true; + } + return false; +} + +bool SystemControlClient::readUnifyKey(const std::string& key, std::string& value) { + mSysCtrl->readUnifyKey(key, [&value](const Result &ret, const hidl_string& v) { + if (Result::OK == ret) { + value = v; + } + }); + + return true; +} + int32_t SystemControlClient::readHdcpRX22Key(char *value, int size) { std::string key; int32_t len; diff --git a/frameworks/services/systemcontrol/SystemControlClient.h b/frameworks/services/systemcontrol/SystemControlClient.h index 153f8dd..d59a8e6 100644 --- a/frameworks/services/systemcontrol/SystemControlClient.h +++ b/frameworks/services/systemcontrol/SystemControlClient.h @@ -63,6 +63,9 @@ public: bool writeHdcpRX14Key(const char *value, const int size); bool writeHdcpRXImg(const std::string& path); + bool readUnifyKey(const std::string& key, std::string& value); + bool writeUnifyKey(const std::string& key, const std::string& value); + void setBootEnv(const std::string& key, const std::string& value); bool getBootEnv(const std::string& key, std::string& value); void getDroidDisplayInfo(int &type, std::string& socType, std::string& defaultUI, diff --git a/frameworks/services/systemcontrol/SystemControlHal.cpp b/frameworks/services/systemcontrol/SystemControlHal.cpp index 7599e6a..29b2cae 100644 --- a/frameworks/services/systemcontrol/SystemControlHal.cpp +++ b/frameworks/services/systemcontrol/SystemControlHal.cpp @@ -219,6 +219,19 @@ Return<Result> SystemControlHal::writeHdcpRXImg(const hidl_string &path) { return mSysControl->writeHdcpRXImg(path)?Result::OK:Result::FAIL; } +Return<void> SystemControlHal::readUnifyKey(const hidl_string &key, readUnifyKey_cb _hidl_cb) { + std::string value; + mSysControl->readUnifyKey(key, value); + + ALOGI("readUnifyKey key :%s, value:%s", key.c_str(), value.c_str()); + _hidl_cb(Result::OK, value); + return Void(); +} +Return<Result> SystemControlHal::writeUnifyKey(const hidl_string &key, const hidl_string &value) { + ALOGI("writeUnifyKey key :%s, value:%s", key.c_str(), value.c_str()); + return mSysControl->writeUnifyKey(key, value)?Result::OK:Result::FAIL; +} + Return<void> SystemControlHal::getBootEnv(const hidl_string &key, getBootEnv_cb _hidl_cb) { std::string value; mSysControl->getBootEnv(key, value); diff --git a/frameworks/services/systemcontrol/SystemControlHal.h b/frameworks/services/systemcontrol/SystemControlHal.h index fe18cd3..047fbc7 100644 --- a/frameworks/services/systemcontrol/SystemControlHal.h +++ b/frameworks/services/systemcontrol/SystemControlHal.h @@ -67,6 +67,8 @@ class SystemControlHal : public ISystemControl, public SystemControlNotify { Return<void> readHdcpRX14Key(int32_t size, readHdcpRX14Key_cb _hidl_cb) override; Return<Result> writeHdcpRX14Key(const hidl_string &key) override; Return<Result> writeHdcpRXImg(const hidl_string &path) override; + Return<void> readUnifyKey(const hidl_string &key, readUnifyKey_cb _hidl_cb) override; + Return<Result> writeUnifyKey(const hidl_string &key, const hidl_string &value) override; Return<void> getBootEnv(const hidl_string &key, getBootEnv_cb _hidl_cb) override; Return<void> setBootEnv(const hidl_string &key, const hidl_string &value) override; Return<void> getDroidDisplayInfo(getDroidDisplayInfo_cb _hidl_cb) override; diff --git a/frameworks/services/systemcontrol/SystemControlService.cpp b/frameworks/services/systemcontrol/SystemControlService.cpp index 4d8d1c9..f3409e5 100644 --- a/frameworks/services/systemcontrol/SystemControlService.cpp +++ b/frameworks/services/systemcontrol/SystemControlService.cpp @@ -194,6 +194,29 @@ bool SystemControlService::writeSysfs(const std::string& path, const char *value return false; } +bool SystemControlService::writeUnifyKey(const std::string& key, const std::string& value) { + if (NO_ERROR == permissionCheck()) { + traceValue("writeUnifyKey", key, value); + + return pSysWrite->writeUnifyKey(key.c_str(), value.c_str()); + } + + return false; +} + +bool SystemControlService::readUnifyKey(const std::string& key, std::string& value) { + if (NO_ERROR == permissionCheck()) { + char buf[MAX_STR_LEN] = {0}; + bool ret = pSysWrite->readUnifyKey(key.c_str(), buf); + value = buf; + + traceValue("readUnifyKey", key, value); + return ret; + } + + return false; +} + int32_t SystemControlService::readHdcpRX22Key(char *value __attribute__((unused)), int size __attribute__((unused))) { /*if (NO_ERROR == permissionCheck()) { traceValue(String16("readHdcpRX22Key"), size); diff --git a/frameworks/services/systemcontrol/SystemControlService.h b/frameworks/services/systemcontrol/SystemControlService.h index 2efa074..cfdbd24 100644 --- a/frameworks/services/systemcontrol/SystemControlService.h +++ b/frameworks/services/systemcontrol/SystemControlService.h @@ -72,6 +72,8 @@ public: int32_t readHdcpRX14Key(char *value __attribute__((unused)), int size __attribute__((unused))); bool writeHdcpRX14Key(const char *value, const int size); bool writeHdcpRXImg(const std::string& path); + bool readUnifyKey(const std::string& key, std::string& value); + bool writeUnifyKey(const std::string& key, const std::string& value); //set or get uboot env bool getBootEnv(const std::string& key, std::string& value); void setBootEnv(const std::string& key, const std::string& value); |