From: Scott Randolph Date: Mon, 3 Apr 2017 21:06:19 +0000 (-0700) Subject: Use explicit .c_str() for hidl_string X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8997880087d14e8a8ee7cf13682f457dbb7f5292;p=android-x86%2Fhardware-interfaces.git Use explicit .c_str() for hidl_string hidl_string no longer will provide an implicit cast to const char* as it interfers with other expected behaviors of the class. It now emulated std::string in requiring a call to .c_str() to get the same behavior. Bug: 36532780 Test: Build the tree Change-Id: I265590c7c18f425e44863df062a56b67519a932a --- diff --git a/automotive/evs/1.0/default/EvsEnumerator.cpp b/automotive/evs/1.0/default/EvsEnumerator.cpp index 731e21bd..b25d418f 100644 --- a/automotive/evs/1.0/default/EvsEnumerator.cpp +++ b/automotive/evs/1.0/default/EvsEnumerator.cpp @@ -99,7 +99,7 @@ Return> EvsEnumerator::openCamera(const hidl_string& cameraId) { } // Construct a camera instance for the caller - pActiveCamera = new EvsCamera(cameraId); + pActiveCamera = new EvsCamera(cameraId.c_str()); pRecord->activeInstance = pActiveCamera; if (pActiveCamera == nullptr) { ALOGE("Failed to allocate new EvsCamera object for %s\n", cameraId.c_str()); diff --git a/drm/1.0/default/CryptoPlugin.cpp b/drm/1.0/default/CryptoPlugin.cpp index 9c51b15d..5e5b5a7f 100644 --- a/drm/1.0/default/CryptoPlugin.cpp +++ b/drm/1.0/default/CryptoPlugin.cpp @@ -35,7 +35,7 @@ namespace implementation { // Methods from ::android::hardware::drm::V1_0::ICryptoPlugin follow Return CryptoPlugin::requiresSecureDecoderComponent( const hidl_string& mime) { - return mLegacyPlugin->requiresSecureDecoderComponent(mime); + return mLegacyPlugin->requiresSecureDecoderComponent(mime.c_str()); } Return CryptoPlugin::notifyResolution(uint32_t width, diff --git a/drm/1.0/default/DrmPlugin.cpp b/drm/1.0/default/DrmPlugin.cpp index c7428a5c..bfe06462 100644 --- a/drm/1.0/default/DrmPlugin.cpp +++ b/drm/1.0/default/DrmPlugin.cpp @@ -70,15 +70,15 @@ namespace implementation { if (status == android::OK) { android::KeyedVector legacyOptionalParameters; for (size_t i = 0; i < optionalParameters.size(); i++) { - legacyOptionalParameters.add(String8(optionalParameters[i].key), - String8(optionalParameters[i].value)); + legacyOptionalParameters.add(String8(optionalParameters[i].key.c_str()), + String8(optionalParameters[i].value.c_str())); } android::DrmPlugin::KeyRequestType legacyRequestType = android::DrmPlugin::kKeyRequestType_Unknown; status = mLegacyPlugin->getKeyRequest(toVector(scope), - toVector(initData), String8(mimeType), legacyKeyType, + toVector(initData), String8(mimeType.c_str()), legacyKeyType, legacyOptionalParameters, legacyRequest, defaultUrl, &legacyRequestType); @@ -149,7 +149,7 @@ namespace implementation { Vector legacyRequest; String8 legacyDefaultUrl; status_t status = mLegacyPlugin->getProvisionRequest( - String8(certificateType), String8(certificateAuthority), + String8(certificateType.c_str()), String8(certificateAuthority.c_str()), legacyRequest, legacyDefaultUrl); _hidl_cb(toStatus(status), toHidlVec(legacyRequest), @@ -217,7 +217,7 @@ namespace implementation { getPropertyString_cb _hidl_cb) { String8 legacyValue; status_t status = mLegacyPlugin->getPropertyString( - String8(propertyName), legacyValue); + String8(propertyName.c_str()), legacyValue); _hidl_cb(toStatus(status), legacyValue.string()); return Void(); } @@ -226,7 +226,7 @@ namespace implementation { getPropertyByteArray_cb _hidl_cb) { Vector legacyValue; status_t status = mLegacyPlugin->getPropertyByteArray( - String8(propertyName), legacyValue); + String8(propertyName.c_str()), legacyValue); _hidl_cb(toStatus(status), toHidlVec(legacyValue)); return Void(); } @@ -234,15 +234,15 @@ namespace implementation { Return DrmPlugin::setPropertyString(const hidl_string& propertyName, const hidl_string& value) { status_t legacyStatus = - mLegacyPlugin->setPropertyString(String8(propertyName), - String8(value)); + mLegacyPlugin->setPropertyString(String8(propertyName.c_str()), + String8(value.c_str())); return toStatus(legacyStatus); } Return DrmPlugin::setPropertyByteArray( const hidl_string& propertyName, const hidl_vec& value) { status_t legacyStatus = - mLegacyPlugin->setPropertyByteArray(String8(propertyName), + mLegacyPlugin->setPropertyByteArray(String8(propertyName.c_str()), toVector(value)); return toStatus(legacyStatus); } @@ -251,7 +251,7 @@ namespace implementation { const hidl_vec& sessionId, const hidl_string& algorithm) { status_t legacyStatus = mLegacyPlugin->setCipherAlgorithm(toVector(sessionId), - String8(algorithm)); + String8(algorithm.c_str())); return toStatus(legacyStatus); } @@ -259,7 +259,7 @@ namespace implementation { const hidl_vec& sessionId, const hidl_string& algorithm) { status_t legacyStatus = mLegacyPlugin->setMacAlgorithm(toVector(sessionId), - String8(algorithm)); + String8(algorithm.c_str())); return toStatus(legacyStatus); } @@ -313,7 +313,7 @@ namespace implementation { Vector legacySignature; status_t status = mLegacyPlugin->signRSA(toVector(sessionId), - String8(algorithm), toVector(message), toVector(wrappedKey), + String8(algorithm.c_str()), toVector(message), toVector(wrappedKey), legacySignature); _hidl_cb(toStatus(status), toHidlVec(legacySignature)); return Void(); diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp index a65c7b86..14c4a2a3 100644 --- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp @@ -616,7 +616,7 @@ void SensorsHidlTest::assertTypeMatchStringType(SensorType type, const hidl_stri switch (type) { #define CHECK_TYPE_STRING_FOR_SENSOR_TYPE(type) \ - case SensorType::type: ASSERT_STREQ(SENSOR_STRING_TYPE_ ## type, stringType); break; + case SensorType::type: ASSERT_STREQ(SENSOR_STRING_TYPE_ ## type, stringType.c_str()); break; CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ACCELEROMETER); CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ACCELEROMETER_UNCALIBRATED); CHECK_TYPE_STRING_FOR_SENSOR_TYPE(ADDITIONAL_INFO);