Update property retrival method

[ Merge of http://go/wvgerrit/70203 ]

The earlier property_get() method had a limitation on property length.
Properties of some new devices exceed that length. An error message
is returned rather than a truncated string. Replace its use with
android::base::GetProperty() which does not have a length limitation.

Bug: 115358798
Test: WV unit/integration tests
Change-Id: I46ce9a7e77bcd031225d0082f83c57d484fe5405
This commit is contained in:
Rahul Frias
2019-01-11 00:57:32 -08:00
parent a4e66ac673
commit ef00d6ffa5
20 changed files with 49 additions and 38 deletions

View File

@@ -9,7 +9,7 @@
#include <sstream>
#include <string>
#include <cutils/properties.h>
#include <android-base/properties.h>
#include "log.h"
@@ -24,7 +24,6 @@ const char kFactoryKeyboxPath[] = "/factory/wv.keys";
const char kWVCdmVersion[] = "15.0.0";
bool GetAndroidProperty(const char* key, std::string* value) {
char val[PROPERTY_VALUE_MAX];
if (!key) {
LOGW("GetAndroidProperty: Invalid property key parameter");
return false;
@@ -35,10 +34,9 @@ bool GetAndroidProperty(const char* key, std::string* value) {
return false;
}
if (property_get(key, val, "Unknown") <= 0) return false;
*value = android::base::GetProperty(key, "");
*value = val;
return true;
return value->size() > 0;
}
} // namespace

View File

@@ -43,7 +43,7 @@ LOCAL_STATIC_LIBRARIES := \
libwvlevel3 \
LOCAL_SHARED_LIBRARIES := \
libcutils \
libbase \
libdl \
liblog \
libmedia_omx \

View File

@@ -5,7 +5,7 @@
#include <errno.h>
#include <sstream>
#include <cutils/properties.h>
#include <android-base/properties.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -4771,10 +4771,10 @@ INSTANTIATE_TEST_CASE_P(Cdm, WvCdmSessionSharingNoKeyTest,
&single_encrypted_sub_sample));
TEST(VersionNumberTest, VersionNumberChangeCanary) {
char release_number[PROPERTY_VALUE_MAX];
ASSERT_GT(property_get("ro.build.version.release", release_number, "Unknown"),
0);
EXPECT_STREQ("Q", release_number)
std::string release_number =
android::base::GetProperty("ro.build.version.release", "");
ASSERT_TRUE(release_number.size() > 0);
EXPECT_STREQ("Q", release_number.c_str())
<< "The Android version number has changed. You need to update this test "
"and also possibly update the Widevine version number in "
"properties_android.cpp.";

View File

@@ -43,7 +43,7 @@ LOCAL_STATIC_LIBRARIES := \
libwvlevel3 \
LOCAL_SHARED_LIBRARIES := \
libcutils \
libbase \
libdl \
liblog \
libmedia_omx \