diff options
author | 2023-08-22 14:02:27 +0000 | |
---|---|---|
committer | 2023-08-22 14:02:27 +0000 | |
commit | ae1151fb2c0608aa7794617b57a57e9c434a0006 (patch) | |
tree | 1f1f449aec0a8cc01bbfdbbc74c27e758adfbcb0 | |
parent | d6bfad2e5cad1ec56b4a5487766e24cafdf6e9bc (diff) | |
parent | fde494da8c0f5ea6726a6d55303f2d37d8456410 (diff) |
Merge "Use String8/16 c_str [sensors]" into main
-rw-r--r-- | libs/sensor/Sensor.cpp | 6 | ||||
-rw-r--r-- | services/sensorservice/RecentEventLogger.cpp | 2 | ||||
-rw-r--r-- | services/sensorservice/SensorDevice.cpp | 2 | ||||
-rw-r--r-- | services/sensorservice/SensorDirectConnection.cpp | 4 | ||||
-rw-r--r-- | services/sensorservice/SensorEventConnection.cpp | 8 | ||||
-rw-r--r-- | services/sensorservice/SensorList.cpp | 18 | ||||
-rw-r--r-- | services/sensorservice/SensorRegistrationInfo.h | 2 | ||||
-rw-r--r-- | services/sensorservice/SensorService.cpp | 40 | ||||
-rw-r--r-- | services/sensorservice/hidl/utils.cpp | 4 | ||||
-rw-r--r-- | services/sensorservice/tests/sensorservicetest.cpp | 2 |
10 files changed, 44 insertions, 44 deletions
diff --git a/libs/sensor/Sensor.cpp b/libs/sensor/Sensor.cpp index b865c4d5d6..f76d5cffcc 100644 --- a/libs/sensor/Sensor.cpp +++ b/libs/sensor/Sensor.cpp @@ -74,7 +74,7 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi if (hwSensor.maxDelay > INT_MAX) { // Max delay is declared as a 64 bit integer for 64 bit architectures. But it should // always fit in a 32 bit integer, log error and cap it to INT_MAX. - ALOGE("Sensor maxDelay overflow error %s %" PRId64, mName.string(), + ALOGE("Sensor maxDelay overflow error %s %" PRId64, mName.c_str(), static_cast<int64_t>(hwSensor.maxDelay)); mMaxDelay = INT_MAX; } else { @@ -339,7 +339,7 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi if (actualReportingMode != expectedReportingMode) { ALOGE("Reporting Mode incorrect: sensor %s handle=%#010" PRIx32 " type=%" PRId32 " " "actual=%d expected=%d", - mName.string(), mHandle, mType, actualReportingMode, expectedReportingMode); + mName.c_str(), mHandle, mType, actualReportingMode, expectedReportingMode); } } @@ -617,7 +617,7 @@ void Sensor::flattenString8(void*& buffer, size_t& size, const String8& string8) { uint32_t len = static_cast<uint32_t>(string8.length()); FlattenableUtils::write(buffer, size, len); - memcpy(static_cast<char*>(buffer), string8.string(), len); + memcpy(static_cast<char*>(buffer), string8.c_str(), len); FlattenableUtils::advance(buffer, size, len); size -= FlattenableUtils::align<4>(buffer); } diff --git a/services/sensorservice/RecentEventLogger.cpp b/services/sensorservice/RecentEventLogger.cpp index d7ca6e1dbf..47fa8b39ac 100644 --- a/services/sensorservice/RecentEventLogger.cpp +++ b/services/sensorservice/RecentEventLogger.cpp @@ -83,7 +83,7 @@ std::string RecentEventLogger::dump() const { } buffer.append("\n"); } - return std::string(buffer.string()); + return std::string(buffer.c_str()); } /** diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index de050e02d0..184fa7614d 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -299,7 +299,7 @@ std::string SensorDevice::dump() const { result.appendFormat("}, selected = %.2f ms\n", info.bestBatchParams.mTBatch / 1e6f); } - return result.string(); + return result.c_str(); } /** diff --git a/services/sensorservice/SensorDirectConnection.cpp b/services/sensorservice/SensorDirectConnection.cpp index 2dd12e9446..7548742e28 100644 --- a/services/sensorservice/SensorDirectConnection.cpp +++ b/services/sensorservice/SensorDirectConnection.cpp @@ -63,7 +63,7 @@ void SensorService::SensorDirectConnection::onFirstRef() { void SensorService::SensorDirectConnection::dump(String8& result) const { Mutex::Autolock _l(mConnectionLock); result.appendFormat("\tPackage %s, HAL channel handle %d, total sensor activated %zu\n", - String8(mOpPackageName).string(), getHalChannelHandle(), mActivated.size()); + String8(mOpPackageName).c_str(), getHalChannelHandle(), mActivated.size()); for (auto &i : mActivated) { result.appendFormat("\t\tSensor %#08x, rate %d\n", i.first, i.second); } @@ -79,7 +79,7 @@ void SensorService::SensorDirectConnection::dump(String8& result) const { void SensorService::SensorDirectConnection::dump(ProtoOutputStream* proto) const { using namespace service::SensorDirectConnectionProto; Mutex::Autolock _l(mConnectionLock); - proto->write(PACKAGE_NAME, std::string(String8(mOpPackageName).string())); + proto->write(PACKAGE_NAME, std::string(String8(mOpPackageName).c_str())); proto->write(HAL_CHANNEL_HANDLE, getHalChannelHandle()); proto->write(NUM_SENSOR_ACTIVATED, int(mActivated.size())); for (auto &i : mActivated) { diff --git a/services/sensorservice/SensorEventConnection.cpp b/services/sensorservice/SensorEventConnection.cpp index f06f9472bd..aa9637719f 100644 --- a/services/sensorservice/SensorEventConnection.cpp +++ b/services/sensorservice/SensorEventConnection.cpp @@ -90,12 +90,12 @@ void SensorService::SensorEventConnection::dump(String8& result) { result.append("NORMAL\n"); } result.appendFormat("\t %s | WakeLockRefCount %d | uid %d | cache size %d | " - "max cache size %d\n", mPackageName.string(), mWakeLockRefCount, mUid, mCacheSize, + "max cache size %d\n", mPackageName.c_str(), mWakeLockRefCount, mUid, mCacheSize, mMaxCacheSize); for (auto& it : mSensorInfo) { const FlushInfo& flushInfo = it.second; result.appendFormat("\t %s 0x%08x | status: %s | pending flush events %d \n", - mService->getSensorName(it.first).string(), + mService->getSensorName(it.first).c_str(), it.first, flushInfo.mFirstFlushPending ? "First flush pending" : "active", @@ -131,7 +131,7 @@ void SensorService::SensorEventConnection::dump(util::ProtoOutputStream* proto) } else { proto->write(OPERATING_MODE, OP_MODE_NORMAL); } - proto->write(PACKAGE_NAME, std::string(mPackageName.string())); + proto->write(PACKAGE_NAME, std::string(mPackageName.c_str())); proto->write(WAKE_LOCK_REF_COUNT, int32_t(mWakeLockRefCount)); proto->write(UID, int32_t(mUid)); proto->write(CACHE_SIZE, int32_t(mCacheSize)); @@ -846,7 +846,7 @@ int SensorService::SensorEventConnection::handleEvent(int fd, int events, void* if (numBytesRead == sizeof(sensors_event_t)) { if (!mDataInjectionMode) { ALOGE("Data injected in normal mode, dropping event" - "package=%s uid=%d", mPackageName.string(), mUid); + "package=%s uid=%d", mPackageName.c_str(), mUid); // Unregister call backs. return 0; } diff --git a/services/sensorservice/SensorList.cpp b/services/sensorservice/SensorList.cpp index 85ce0f0018..02f22c5c4a 100644 --- a/services/sensorservice/SensorList.cpp +++ b/services/sensorservice/SensorList.cpp @@ -134,12 +134,12 @@ std::string SensorList::dump() const { "%#010x) %-25s | %-15s | ver: %" PRId32 " | type: %20s(%" PRId32 ") | perm: %s | flags: 0x%08x\n", s.getHandle(), - s.getName().string(), - s.getVendor().string(), + s.getName().c_str(), + s.getVendor().c_str(), s.getVersion(), - s.getStringType().string(), + s.getStringType().c_str(), s.getType(), - s.getRequiredPermission().size() ? s.getRequiredPermission().string() : "n/a", + s.getRequiredPermission().size() ? s.getRequiredPermission().c_str() : "n/a", static_cast<int>(s.getFlags())); result.append("\t"); @@ -208,7 +208,7 @@ std::string SensorList::dump() const { } return true; }); - return std::string(result.string()); + return std::string(result.c_str()); } /** @@ -225,13 +225,13 @@ void SensorList::dump(util::ProtoOutputStream* proto) const { forEachSensor([&proto] (const Sensor& s) -> bool { const uint64_t token = proto->start(SENSORS); proto->write(HANDLE, s.getHandle()); - proto->write(NAME, std::string(s.getName().string())); - proto->write(VENDOR, std::string(s.getVendor().string())); + proto->write(NAME, std::string(s.getName().c_str())); + proto->write(VENDOR, std::string(s.getVendor().c_str())); proto->write(VERSION, s.getVersion()); - proto->write(STRING_TYPE, std::string(s.getStringType().string())); + proto->write(STRING_TYPE, std::string(s.getStringType().c_str())); proto->write(TYPE, s.getType()); proto->write(REQUIRED_PERMISSION, std::string(s.getRequiredPermission().size() ? - s.getRequiredPermission().string() : "")); + s.getRequiredPermission().c_str() : "")); proto->write(FLAGS, int(s.getFlags())); switch (s.getReportingMode()) { case AREPORTING_MODE_CONTINUOUS: diff --git a/services/sensorservice/SensorRegistrationInfo.h b/services/sensorservice/SensorRegistrationInfo.h index a34a65bbdd..dc9e8215e7 100644 --- a/services/sensorservice/SensorRegistrationInfo.h +++ b/services/sensorservice/SensorRegistrationInfo.h @@ -93,7 +93,7 @@ public: using namespace service::SensorRegistrationInfoProto; proto->write(TIMESTAMP_SEC, int64_t(mRealtimeSec)); proto->write(SENSOR_HANDLE, mSensorHandle); - proto->write(PACKAGE_NAME, std::string(mPackageName.string())); + proto->write(PACKAGE_NAME, std::string(mPackageName.c_str())); proto->write(PID, int32_t(mPid)); proto->write(UID, int32_t(mUid)); proto->write(SAMPLING_RATE_US, mSamplingRateUs); diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index e0a4f034cb..260e61a35d 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -537,7 +537,7 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) { i.second->setFormat("mask_data"); } // if there is events and sensor does not need special permission. - result.appendFormat("%s: ", s->getSensor().getName().string()); + result.appendFormat("%s: ", s->getSensor().getName().c_str()); result.append(i.second->dump().c_str()); } } @@ -548,7 +548,7 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) { int handle = mActiveSensors.keyAt(i); if (dev.isSensorActive(handle)) { result.appendFormat("%s (handle=0x%08x, connections=%zu)\n", - getSensorName(handle).string(), + getSensorName(handle).c_str(), handle, mActiveSensors.valueAt(i)->getNumConnections()); } @@ -564,10 +564,10 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) { result.appendFormat(" NORMAL\n"); break; case RESTRICTED: - result.appendFormat(" RESTRICTED : %s\n", mWhiteListedPackage.string()); + result.appendFormat(" RESTRICTED : %s\n", mWhiteListedPackage.c_str()); break; case DATA_INJECTION: - result.appendFormat(" DATA_INJECTION : %s\n", mWhiteListedPackage.string()); + result.appendFormat(" DATA_INJECTION : %s\n", mWhiteListedPackage.c_str()); } result.appendFormat("Sensor Privacy: %s\n", mSensorPrivacyPolicy->isSensorPrivacyEnabled() ? "enabled" : "disabled"); @@ -605,7 +605,7 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) { } while(startIndex != currentIndex); } } - write(fd, result.string(), result.size()); + write(fd, result.c_str(), result.size()); return NO_ERROR; } @@ -653,7 +653,7 @@ status_t SensorService::dumpProtoLocked(int fd, ConnectionSafeAutolock* connLock "normal" : "mask_data"); const uint64_t mToken = proto.start(service::SensorEventsProto::RECENT_EVENTS_LOGS); proto.write(service::SensorEventsProto::RecentEventsLog::NAME, - std::string(s->getSensor().getName().string())); + std::string(s->getSensor().getName().c_str())); i.second->dump(&proto); proto.end(mToken); } @@ -667,7 +667,7 @@ status_t SensorService::dumpProtoLocked(int fd, ConnectionSafeAutolock* connLock if (dev.isSensorActive(handle)) { token = proto.start(ACTIVE_SENSORS); proto.write(service::ActiveSensorProto::NAME, - std::string(getSensorName(handle).string())); + std::string(getSensorName(handle).c_str())); proto.write(service::ActiveSensorProto::HANDLE, handle); proto.write(service::ActiveSensorProto::NUM_CONNECTIONS, int(mActiveSensors.valueAt(i)->getNumConnections())); @@ -685,11 +685,11 @@ status_t SensorService::dumpProtoLocked(int fd, ConnectionSafeAutolock* connLock break; case RESTRICTED: proto.write(OPERATING_MODE, OP_MODE_RESTRICTED); - proto.write(WHITELISTED_PACKAGE, std::string(mWhiteListedPackage.string())); + proto.write(WHITELISTED_PACKAGE, std::string(mWhiteListedPackage.c_str())); break; case DATA_INJECTION: proto.write(OPERATING_MODE, OP_MODE_DATA_INJECTION); - proto.write(WHITELISTED_PACKAGE, std::string(mWhiteListedPackage.string())); + proto.write(WHITELISTED_PACKAGE, std::string(mWhiteListedPackage.c_str())); break; default: proto.write(OPERATING_MODE, OP_MODE_UNKNOWN); @@ -832,8 +832,8 @@ static status_t getUidForPackage(String16 packageName, int userId, /*inout*/uid_ PermissionController pc; uid = pc.getPackageUid(packageName, 0); if (uid <= 0) { - ALOGE("Unknown package: '%s'", String8(packageName).string()); - dprintf(err, "Unknown package: '%s'\n", String8(packageName).string()); + ALOGE("Unknown package: '%s'", String8(packageName).c_str()); + dprintf(err, "Unknown package: '%s'\n", String8(packageName).c_str()); return BAD_VALUE; } @@ -858,7 +858,7 @@ status_t SensorService::handleSetUidState(Vector<String16>& args, int err) { if (args[2] == String16("active")) { active = true; } else if ((args[2] != String16("idle"))) { - ALOGE("Expected active or idle but got: '%s'", String8(args[2]).string()); + ALOGE("Expected active or idle but got: '%s'", String8(args[2]).c_str()); return BAD_VALUE; } @@ -1351,8 +1351,8 @@ Vector<Sensor> SensorService::getDynamicSensorList(const String16& opPackageName accessibleSensorList.add(sensor); } else if (sensor.getType() != SENSOR_TYPE_HEAD_TRACKER) { ALOGI("Skipped sensor %s because it requires permission %s and app op %" PRId32, - sensor.getName().string(), - sensor.getRequiredPermission().string(), + sensor.getName().c_str(), + sensor.getRequiredPermission().c_str(), sensor.getRequiredAppOp()); } } @@ -1996,10 +1996,10 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, !isAudioServerOrSystemServerUid(IPCThreadState::self()->getCallingUid())) { if (!mHtRestricted) { ALOGI("Permitting access to HT sensor type outside system (%s)", - String8(opPackageName).string()); + String8(opPackageName).c_str()); } else { - ALOGW("%s %s a sensor (%s) as a non-system client", String8(opPackageName).string(), - operation, sensor.getName().string()); + ALOGW("%s %s a sensor (%s) as a non-system client", String8(opPackageName).c_str(), + operation, sensor.getName().c_str()); return false; } } @@ -2032,8 +2032,8 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, } if (!canAccess) { - ALOGE("%s %s a sensor (%s) without holding %s", String8(opPackageName).string(), - operation, sensor.getName().string(), sensor.getRequiredPermission().string()); + ALOGE("%s %s a sensor (%s) without holding %s", String8(opPackageName).c_str(), + operation, sensor.getName().c_str(), sensor.getRequiredPermission().c_str()); } return canAccess; @@ -2124,7 +2124,7 @@ void SensorService::sendEventsFromCache(const sp<SensorEventConnection>& connect } bool SensorService::isWhiteListedPackage(const String8& packageName) { - return (packageName.contains(mWhiteListedPackage.string())); + return (packageName.contains(mWhiteListedPackage.c_str())); } bool SensorService::isOperationRestrictedLocked(const String16& opPackageName) { diff --git a/services/sensorservice/hidl/utils.cpp b/services/sensorservice/hidl/utils.cpp index 5fa594d01d..d338d02675 100644 --- a/services/sensorservice/hidl/utils.cpp +++ b/services/sensorservice/hidl/utils.cpp @@ -32,8 +32,8 @@ SensorInfo convertSensor(const Sensor& src) { SensorInfo dst; const String8& name = src.getName(); const String8& vendor = src.getVendor(); - dst.name = hidl_string{name.string(), name.size()}; - dst.vendor = hidl_string{vendor.string(), vendor.size()}; + dst.name = hidl_string{name.c_str(), name.size()}; + dst.vendor = hidl_string{vendor.c_str(), vendor.size()}; dst.version = src.getVersion(); dst.sensorHandle = src.getHandle(); dst.type = static_cast<::android::hardware::sensors::V1_0::SensorType>( diff --git a/services/sensorservice/tests/sensorservicetest.cpp b/services/sensorservice/tests/sensorservicetest.cpp index 1406bb38e7..8b4b3f61b0 100644 --- a/services/sensorservice/tests/sensorservicetest.cpp +++ b/services/sensorservice/tests/sensorservicetest.cpp @@ -105,7 +105,7 @@ int main() { Sensor const* accelerometer = mgr.getDefaultSensor(Sensor::TYPE_ACCELEROMETER); printf("accelerometer=%p (%s)\n", - accelerometer, accelerometer->getName().string()); + accelerometer, accelerometer->getName().c_str()); sStartTime = systemTime(); |