property: fix prop value parsing error if includes = [1/1]
PD#SWPL-172618
Problem:
fix prop value parsing error if includes '='
Solution:
fix prop value parsing error if includes '='
Verify:
local
Change-Id: I46d8d5549313ea30c7abfc80c59940172ce37154
Signed-off-by: Daogao Xu <daogao.xu@amlogic.com>
diff --git a/aml_property_server/property-db/property-db.cpp b/aml_property_server/property-db/property-db.cpp
index 962e433..e6e3401 100644
--- a/aml_property_server/property-db/property-db.cpp
+++ b/aml_property_server/property-db/property-db.cpp
@@ -305,15 +305,15 @@
leveldb::WriteBatch batch;
string linebuf;
while (getline(fin, linebuf)) {
- auto kvs = split(linebuf, '=');
- if (kvs.size() > 1) {
- string key(kvs.at(0));
- string value(kvs.at(1));
+ int idx = linebuf.find('=');
+ if (idx != std::string::npos) {
+ string key(linebuf, 0, idx);
+ string value(linebuf, idx + 1, linebuf.size() - idx - 1);
trim(key), trim(value);
DataAttr attr = get_attribute(key);
if (attr == ATTR_RO) {
// load ro properties into memory map
- gs_ro_device_properties[key] = kvs.at(1);
+ gs_ro_device_properties[key] = value;
continue;
}
@@ -324,7 +324,7 @@
leveldb::Status s =
gs_persist_db->Get(leveldb::ReadOptions(), key, &old_value);
if (!s.ok()) {
- batch.Put(kvs.at(0), kvs.at(1));
+ batch.Put(key, value);
}
}
}