OSDN Git Service

Use explicit .c_str() for hidl_string
authorScott Randolph <randolphs@google.com>
Mon, 3 Apr 2017 21:06:19 +0000 (14:06 -0700)
committerScott Randolph <randolphs@google.com>
Tue, 4 Apr 2017 17:53:26 +0000 (10:53 -0700)
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

automotive/evs/1.0/default/EvsEnumerator.cpp
drm/1.0/default/CryptoPlugin.cpp
drm/1.0/default/DrmPlugin.cpp
sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp

index 731e21b..b25d418 100644 (file)
@@ -99,7 +99,7 @@ Return<sp<IEvsCamera>> 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());
index 9c51b15..5e5b5a7 100644 (file)
@@ -35,7 +35,7 @@ namespace implementation {
     // Methods from ::android::hardware::drm::V1_0::ICryptoPlugin follow
     Return<bool> CryptoPlugin::requiresSecureDecoderComponent(
             const hidl_string& mime) {
-        return mLegacyPlugin->requiresSecureDecoderComponent(mime);
+        return mLegacyPlugin->requiresSecureDecoderComponent(mime.c_str());
     }
 
     Return<void> CryptoPlugin::notifyResolution(uint32_t width,
index c7428a5..bfe0646 100644 (file)
@@ -70,15 +70,15 @@ namespace implementation {
         if (status == android::OK) {
             android::KeyedVector<String8, String8> 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<uint8_t> 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<uint8_t> 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<Status> 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<Status> DrmPlugin::setPropertyByteArray(
             const hidl_string& propertyName, const hidl_vec<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t> 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();
index a65c7b8..14c4a2a 100644 (file)
@@ -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);