Loading camera/camera_platform.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -257,3 +257,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { namespace: "camera_platform" name: "bump_preview_frame_space_priority" description: "Increase the PreviewFrameSpacer thread priority" bug: "355665306" metadata { purpose: PURPOSE_BUGFIX } } camera/ndk/impl/ACameraManager.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -177,14 +177,11 @@ sp<hardware::ICameraService> CameraManagerGlobal::getCameraServiceLocked() { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; do { binder = sm->getService(toString16(kCameraServiceName)); if (binder != nullptr) { break; binder = sm->checkService(String16(kCameraServiceName)); if (binder == nullptr) { ALOGE("%s: Could not get CameraService instance.", __FUNCTION__); return nullptr; } ALOGW("CameraService not published, waiting..."); usleep(kCameraServicePollDelay); } while(true); if (mDeathNotifier == nullptr) { mDeathNotifier = new DeathNotifier(this); } Loading camera/ndk/impl/ACameraManager.h +0 −1 Original line number Diff line number Diff line Loading @@ -99,7 +99,6 @@ class CameraManagerGlobal final : public RefBase { private: sp<hardware::ICameraService> mCameraService; const int kCameraServicePollDelay = 500000; // 0.5s const char* kCameraServiceName = "media.camera"; Mutex mLock; Loading media/psh_utils/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ package { // libraries that are included whole_static for test apps ndk_libs = [ "android.hardware.health-V3-ndk", "android.hardware.power.stats-V1-ndk", ] Loading @@ -18,6 +19,8 @@ cc_library { local_include_dirs: ["include"], export_include_dirs: ["include"], srcs: [ "HealthStats.cpp", "HealthStatsProvider.cpp", "PowerStats.cpp", "PowerStatsCollector.cpp", "PowerStatsProvider.cpp", Loading media/psh_utils/HealthStats.cpp 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <android-base/logging.h> #include <psh_utils/HealthStats.h> namespace android::media::psh_utils { template <typename T> const T& choose_voltage(const T& a, const T& b) { return std::max(a, b); // we use max here, could use avg. } std::string HealthStats::toString() const { std::string result; const float batteryVoltage = batteryVoltageMillivolts * 1e-3f; // Volts const float charge = batteryChargeCounterUah * (3600 * 1e-6); // Joules = Amp-Second result.append(" battery_voltage: ") .append(std::to_string(batteryVoltage)) .append(" charge: ") .append(std::to_string(charge)); return result; } std::string HealthStats::normalizedEnergy(double timeSec) const { std::string result; const float batteryVoltage = batteryVoltageMillivolts * 1e-3f; // Volts const float charge = -batteryChargeCounterUah * (3600 * 1e-6f); // Joules = Amp-Second const float watts = charge * batteryVoltage / timeSec; result.append(" battery_voltage: ") .append(std::to_string(batteryVoltage)) .append(" J: ") .append(std::to_string(charge)) .append(" W: ") .append(std::to_string(watts)); return result; } HealthStats HealthStats::operator+=(const HealthStats& other) { batteryVoltageMillivolts = choose_voltage( batteryVoltageMillivolts, other.batteryVoltageMillivolts); batteryFullChargeUah = std::max(batteryFullChargeUah, other.batteryFullChargeUah); batteryChargeCounterUah += other.batteryChargeCounterUah; return *this; } HealthStats HealthStats::operator-=(const HealthStats& other) { batteryVoltageMillivolts = choose_voltage( batteryVoltageMillivolts, other.batteryVoltageMillivolts); batteryFullChargeUah = std::max(batteryFullChargeUah, other.batteryFullChargeUah); batteryChargeCounterUah -= other.batteryChargeCounterUah; return *this; } HealthStats HealthStats::operator+(const HealthStats& other) const { HealthStats result = *this; result += other; return result; } HealthStats HealthStats::operator-(const HealthStats& other) const { HealthStats result = *this; result -= other; return result; } } // namespace android::media::psh_utils Loading
camera/camera_platform.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -257,3 +257,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { namespace: "camera_platform" name: "bump_preview_frame_space_priority" description: "Increase the PreviewFrameSpacer thread priority" bug: "355665306" metadata { purpose: PURPOSE_BUGFIX } }
camera/ndk/impl/ACameraManager.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -177,14 +177,11 @@ sp<hardware::ICameraService> CameraManagerGlobal::getCameraServiceLocked() { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; do { binder = sm->getService(toString16(kCameraServiceName)); if (binder != nullptr) { break; binder = sm->checkService(String16(kCameraServiceName)); if (binder == nullptr) { ALOGE("%s: Could not get CameraService instance.", __FUNCTION__); return nullptr; } ALOGW("CameraService not published, waiting..."); usleep(kCameraServicePollDelay); } while(true); if (mDeathNotifier == nullptr) { mDeathNotifier = new DeathNotifier(this); } Loading
camera/ndk/impl/ACameraManager.h +0 −1 Original line number Diff line number Diff line Loading @@ -99,7 +99,6 @@ class CameraManagerGlobal final : public RefBase { private: sp<hardware::ICameraService> mCameraService; const int kCameraServicePollDelay = 500000; // 0.5s const char* kCameraServiceName = "media.camera"; Mutex mLock; Loading
media/psh_utils/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ package { // libraries that are included whole_static for test apps ndk_libs = [ "android.hardware.health-V3-ndk", "android.hardware.power.stats-V1-ndk", ] Loading @@ -18,6 +19,8 @@ cc_library { local_include_dirs: ["include"], export_include_dirs: ["include"], srcs: [ "HealthStats.cpp", "HealthStatsProvider.cpp", "PowerStats.cpp", "PowerStatsCollector.cpp", "PowerStatsProvider.cpp", Loading
media/psh_utils/HealthStats.cpp 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <android-base/logging.h> #include <psh_utils/HealthStats.h> namespace android::media::psh_utils { template <typename T> const T& choose_voltage(const T& a, const T& b) { return std::max(a, b); // we use max here, could use avg. } std::string HealthStats::toString() const { std::string result; const float batteryVoltage = batteryVoltageMillivolts * 1e-3f; // Volts const float charge = batteryChargeCounterUah * (3600 * 1e-6); // Joules = Amp-Second result.append(" battery_voltage: ") .append(std::to_string(batteryVoltage)) .append(" charge: ") .append(std::to_string(charge)); return result; } std::string HealthStats::normalizedEnergy(double timeSec) const { std::string result; const float batteryVoltage = batteryVoltageMillivolts * 1e-3f; // Volts const float charge = -batteryChargeCounterUah * (3600 * 1e-6f); // Joules = Amp-Second const float watts = charge * batteryVoltage / timeSec; result.append(" battery_voltage: ") .append(std::to_string(batteryVoltage)) .append(" J: ") .append(std::to_string(charge)) .append(" W: ") .append(std::to_string(watts)); return result; } HealthStats HealthStats::operator+=(const HealthStats& other) { batteryVoltageMillivolts = choose_voltage( batteryVoltageMillivolts, other.batteryVoltageMillivolts); batteryFullChargeUah = std::max(batteryFullChargeUah, other.batteryFullChargeUah); batteryChargeCounterUah += other.batteryChargeCounterUah; return *this; } HealthStats HealthStats::operator-=(const HealthStats& other) { batteryVoltageMillivolts = choose_voltage( batteryVoltageMillivolts, other.batteryVoltageMillivolts); batteryFullChargeUah = std::max(batteryFullChargeUah, other.batteryFullChargeUah); batteryChargeCounterUah -= other.batteryChargeCounterUah; return *this; } HealthStats HealthStats::operator+(const HealthStats& other) const { HealthStats result = *this; result += other; return result; } HealthStats HealthStats::operator-(const HealthStats& other) const { HealthStats result = *this; result -= other; return result; } } // namespace android::media::psh_utils