author | xiaoliang.wang <xiaoliang.wang@amlogic.com> | 2017-11-16 11:55:47 (GMT) |
---|---|---|
committer | xiaoliang.wang <xiaoliang.wang@amlogic.com> | 2017-11-16 11:55:47 (GMT) |
commit | 0c06030684b291b8984068021e1af7ab9c44dd10 (patch) | |
tree | 82a38c777ba269c8513e98e5e04a56f40fa824fe | |
parent | 22f7ae967c343b3df2b9103a610df2c8b396c22c (diff) | |
download | SubTitle-0c06030684b291b8984068021e1af7ab9c44dd10.zip SubTitle-0c06030684b291b8984068021e1af7ab9c44dd10.tar.gz SubTitle-0c06030684b291b8984068021e1af7ab9c44dd10.tar.bz2 |
Subtitle: change for full treble mode[1/1]
PD#154817
change for full treble mode
Change-Id: Iee0d2c35bbb061ee21e5825b816e2efcb2197243
-rw-r--r-- | jni/subtitle/Amsyswrite.cpp | 145 | ||||
-rw-r--r-- | jni/subtitle/Amsyswrite.h | 6 | ||||
-rw-r--r-- | jni/subtitle/Android.mk | 2 | ||||
-rw-r--r-- | jni/subtitle/amsysfsutils.c | 4 |
4 files changed, 57 insertions, 100 deletions
diff --git a/jni/subtitle/Amsyswrite.cpp b/jni/subtitle/Amsyswrite.cpp index 90acc16..e93a16e 100644 --- a/jni/subtitle/Amsyswrite.cpp +++ b/jni/subtitle/Amsyswrite.cpp @@ -1,7 +1,5 @@ #define LOG_TAG "amSystemControl" -#include <../../../../../vendor/amlogic/frameworks/services/systemcontrol/ISystemControlService.h> - #include <binder/Binder.h> #include <binder/IServiceManager.h> #include <utils/Atomic.h> @@ -16,6 +14,8 @@ #include <MemoryLeakTrackUtilTmp.h> #include <fcntl.h> +#include <../../../../../vendor/amlogic/frameworks/services/systemcontrol/SystemControlClient.h> + using namespace android; class DeathNotifier: public IBinder::DeathRecipient @@ -29,94 +29,62 @@ class DeathNotifier: public IBinder::DeathRecipient } }; -static sp < ISystemControlService > amSystemControlService; static sp < DeathNotifier > amDeathNotifier; static Mutex amLock; static Mutex amgLock; +static SystemControlClient *mScc = new SystemControlClient(); -const sp < ISystemControlService > &getSystemControlService() -{ - Mutex::Autolock _l(amgLock); - if (amSystemControlService.get() == 0) - { - sp < IServiceManager > sm = defaultServiceManager(); - sp < IBinder > binder; - do - { - binder = sm->getService(String16("system_control")); - if (binder != 0) - break; - ALOGW("SystemControl not published, waiting..."); - usleep(500000); // 0.5 s - } - while (true); - if (amDeathNotifier == NULL) - { - amDeathNotifier = new DeathNotifier(); - } - binder->linkToDeath(amDeathNotifier); - amSystemControlService = - interface_cast < ISystemControlService > (binder); - } - ALOGE_IF(amSystemControlService == 0, "no System Control Service!?"); - return amSystemControlService; -} - -int amSystemControlGetProperty(const char *key, char *value) +int amSystemControlGetProperty(const char* key, char* value) { - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - String16 v; - if (scs->getProperty(String16(key), v)) + const std::string stdKey(key); + std::string stdValue(value); + if (mScc->getProperty(stdKey, stdValue)) { - strcpy(value, String8(v).string()); return 0; } } return -1; } -int amSystemControlGetPropertyStr(const char *key, char *def, char *value) +int amSystemControlGetPropertyStr(const char* key, char* def, char* value) { - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) - { - String16 v; - String16 d(def); - scs->getPropertyString(String16(key), v, d); - strcpy(value, String8(v).string()); + if (mScc != NULL) { + const std::string stdKey(key); + std::string stdDef(def); + std::string stdValue(value); + mScc->getPropertyString(stdKey, stdValue, stdDef); } - strcpy(value, def); return -1; } -int amSystemControlGetPropertyInt(const char *key, int def) +int amSystemControlGetPropertyInt(const char* key, int def) { - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - return scs->getPropertyInt(String16(key), def); + const std::string stdKey(key); + return mScc->getPropertyInt(stdKey, def); } return def; } -long amSystemControlGetPropertyLong(const char *key, long def) +long amSystemControlGetPropertyLong(const char* key, long def) { - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - return scs->getPropertyLong(String16(key), def); + const std::string stdKey(key); + return mScc->getPropertyLong(stdKey, (int64_t)def); } return def; } -int amSystemControlGetPropertyBool(const char *key, int def) +int amSystemControlGetPropertyBool(const char* key, int def) { - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - if (scs->getPropertyBoolean(String16(key), def)) + const std::string stdKey(key); + if (mScc->getPropertyBoolean(stdKey, def)) { return 1; } @@ -128,76 +96,65 @@ int amSystemControlGetPropertyBool(const char *key, int def) return def; } -void amSystemControlSetProperty(const char *key, const char *value) +void amSystemControlSetProperty(const char* key, const char* value) { - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - scs->setProperty(String16(key), String16(value)); + const std::string stdKey(key); + const std::string stdValue(value); + mScc->setProperty(stdKey, stdValue); } } -int amSystemControlReadSysfs(const char *path, char *value) +int amSystemControlReadSysfs(const char* path, char* value) { - //ALOGD("amSystemControlReadNumSysfs:%s",path); - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - String16 v; - if (scs->readSysfs(String16(path), v)) + const std::string stdPath(path); + std::string stdValue(value); + if (mScc->readSysfs(stdPath, stdValue)) { - strcpy(value, String8(v).string()); + ALOGE("amSystemControlReadSysfs stdValue:%s", stdValue.c_str()); return 0; } } return -1; } -int amSystemControlReadNumSysfs(const char *path, char *value, int size) +int amSystemControlReadNumSysfs(const char* path, char* value, int32_t size) { //ALOGD("amSystemControlReadNumSysfs:%s",path); - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0 && value != NULL && access(path, 0) != -1) + //const sp < ISystemControlService > &scs = getSystemControlService(); + if (mScc != NULL /*&& value != NULL && access(path, 0) != -1*/) { - String16 v; - if (scs->readSysfs(String16(path), v)) + //String16 v; + /*if (mScc->readSysfs(path, value)) { - if (v.size() != 0) + if (value.size() != 0) { - //ALOGD("readSysfs ok:%s,%s,%d", path, String8(v).string(), String8(v).size()); - memset(value, 0, size); - if (size <= String8(v).size() + 1) - { - memcpy(value, String8(v).string(), - size - 1); - value[strlen(value)] = '\0'; - } - else + if (size <= value.size() + 1) { - strcpy(value, String8(v).string()); + value[size] = '\0'; } return 0; } - } + }*/ } //ALOGD("[false]amSystemControlReadNumSysfs%s,",path); return -1; } -int amSystemControlWriteSysfs(const char *path, char *value) +int amSystemControlWriteSysfs(const char* path, char* value) { - //ALOGD("amSystemControlWriteSysfs:%s",path); - const sp < ISystemControlService > &scs = getSystemControlService(); - if (scs != 0) + if (mScc != NULL) { - String16 v(value); - if (scs->writeSysfs(String16(path), v)) + const std::string stdPath(path); + std::string stdValue(value); + if (mScc->writeSysfs(stdPath, stdValue)) { - //ALOGD("writeSysfs ok"); return 0; } } - //ALOGD("[false]amSystemControlWriteSysfs%s,",path); return -1; } diff --git a/jni/subtitle/Amsyswrite.h b/jni/subtitle/Amsyswrite.h index 822ac34..9a3e27f 100644 --- a/jni/subtitle/Amsyswrite.h +++ b/jni/subtitle/Amsyswrite.h @@ -5,15 +5,13 @@ extern "C" { #endif int amSystemControlGetProperty(const char *key, char *value); - int amSystemControlGetPropertyStr(const char *key, char *def, - char *value); + int amSystemControlGetPropertyStr(const char *key, char *def, char *value); int amSystemControlGetPropertyInt(const char *key, int def); long amSystemControlGetPropertyLong(const char *key, long def); int amSystemControlGetPropertyBool(const char *key, int def); void amSystemControlSetProperty(const char *key, const char *value); int amSystemControlReadSysfs(const char *path, char *value); - int amSystemControlReadNumSysfs(const char *path, char *value, - int size); + int amSystemControlReadNumSysfs(const char *path, char *value, int size); int amSystemControlWriteSysfs(const char *path, char *value); void amDumpMemoryAddresses(int fd); diff --git a/jni/subtitle/Android.mk b/jni/subtitle/Android.mk index 9479d27..9a18fe1 100644 --- a/jni/subtitle/Android.mk +++ b/jni/subtitle/Android.mk @@ -10,7 +10,7 @@ LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) \ $(TOP)/frameworks/native/services \ $(TOP)/frameworks/native/include -LOCAL_SHARED_LIBRARIES += libutils libmedia libcutils libbinder libsystemcontrolservice liblog +LOCAL_SHARED_LIBRARIES += libutils libmedia libcutils libbinder libsystemcontrolservice liblog vendor.amlogic.hardware.systemcontrol@1.0_vendor LOCAL_PRELINK_MODULE := false diff --git a/jni/subtitle/amsysfsutils.c b/jni/subtitle/amsysfsutils.c index cc1f5f4..13ec3ce 100644 --- a/jni/subtitle/amsysfsutils.c +++ b/jni/subtitle/amsysfsutils.c @@ -186,7 +186,9 @@ int amsysfs_get_sysfs_int(const char *path) int val = 0; if (amSystemControlReadSysfs(path, bcmd) == 0) { - val = strtol(bcmd, NULL, 10); + if (strlen(bcmd) > 0) { + val = strtol(bcmd, NULL, 10); + } } return val; } |