Sync up to v304
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,10 @@
|
||||
From 04ada322124eca94d2e354f10c45d80d1ad522e3 Mon Sep 17 00:00:00 2001
|
||||
From bff763fb4b54c97fbb3535ea68a093acf81969bc Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Sun, 24 Mar 2019 23:05:14 +0100
|
||||
Subject: [PATCH] Support new samsung Pie and Q light hal and Samsung Power
|
||||
HALs
|
||||
|
||||
Change-Id: I37dc7af3fbc6f9bfa2a4822d4dfba817e803945e
|
||||
---
|
||||
services/core/jni/Android.bp | 3 ++
|
||||
...om_android_server_lights_LightsService.cpp | 51 +++++++++++++++++++
|
||||
@@ -11,13 +12,13 @@ Subject: [PATCH] Support new samsung Pie and Q light hal and Samsung Power
|
||||
3 files changed, 76 insertions(+)
|
||||
|
||||
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
|
||||
index eaa3c66fe0d..74f5b8667c4 100644
|
||||
index 0b085d65e4c..36315e951e3 100644
|
||||
--- a/services/core/jni/Android.bp
|
||||
+++ b/services/core/jni/Android.bp
|
||||
@@ -167,6 +167,9 @@ cc_defaults {
|
||||
"service.incremental",
|
||||
@@ -169,6 +169,9 @@ cc_defaults {
|
||||
"suspend_control_aidl_interface-cpp",
|
||||
"vendor.lineage.power@1.0",
|
||||
"vendor.lineage.power-cpp",
|
||||
+ "vendor.samsung.hardware.miscpower@2.0",
|
||||
+ "vendor.samsung.hardware.light@2.0",
|
||||
+ "vendor.samsung.hardware.light@3.0",
|
||||
@@ -103,7 +104,7 @@ index 35d8219651d..b45b2137d0e 100644
|
||||
LightState state = constructState(
|
||||
colorARGB, flashMode, onMS, offMS, brightnessMode);
|
||||
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
index 33b3bad2b33..47fdcc9a87b 100644
|
||||
index 61d53351af5..dcd33366a35 100644
|
||||
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
@@ -24,6 +24,7 @@
|
||||
@@ -113,25 +114,25 @@ index 33b3bad2b33..47fdcc9a87b 100644
|
||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
#include <vendor/lineage/power/1.0/ILineagePower.h>
|
||||
#include "jni.h"
|
||||
@@ -64,6 +65,7 @@ using IPowerV1_0 = android::hardware::power::V1_0::IPower;
|
||||
using IPowerAidl = android::hardware::power::IPower;
|
||||
using ILineagePowerV1_0 = vendor::lineage::power::V1_0::ILineagePower;
|
||||
using vendor::lineage::power::V1_0::LineageFeature;
|
||||
#include <vendor/lineage/power/IPower.h>
|
||||
@@ -69,6 +70,7 @@ using LineageBoostAidl = vendor::lineage::power::Boost;
|
||||
using LineageFeatureV1_0 = vendor::lineage::power::V1_0::LineageFeature;
|
||||
using LineageFeatureAidl = vendor::lineage::power::Feature;
|
||||
using LineagePowerHint1_0 = vendor::lineage::power::V1_0::LineagePowerHint;
|
||||
+using ISehMiscPower = vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower;
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -80,6 +82,8 @@ static sp<IPowerV1_0> gPowerHalHidlV1_0_ = nullptr;
|
||||
static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
|
||||
@@ -86,6 +88,8 @@ static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
|
||||
static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
||||
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
||||
static sp<ILineagePowerAidl> gLineagePowerHalAidl_ = nullptr;
|
||||
+static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
||||
+static bool gPowerHalExists = true;
|
||||
static std::mutex gPowerHalMutex;
|
||||
static std::mutex gLineagePowerHalMutex;
|
||||
|
||||
enum class HalVersion {
|
||||
@@ -125,6 +129,10 @@ static HalVersion connectPowerHalLocked() {
|
||||
@@ -132,6 +136,10 @@ static HalVersion connectPowerHalLocked() {
|
||||
gPowerHalAidlExists = false;
|
||||
}
|
||||
}
|
||||
@@ -142,8 +143,8 @@ index 33b3bad2b33..47fdcc9a87b 100644
|
||||
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
||||
if (gPowerHalHidlV1_0_) {
|
||||
@@ -163,6 +171,12 @@ void connectLineagePowerHalLocked() {
|
||||
}
|
||||
@@ -190,6 +198,12 @@ static HalVersion connectLineagePowerHalLocked() {
|
||||
return HalVersion::NONE;
|
||||
}
|
||||
|
||||
+sp<ISehMiscPower> getSehMiscPower() {
|
||||
@@ -155,7 +156,7 @@ index 33b3bad2b33..47fdcc9a87b 100644
|
||||
// Retrieve a copy of PowerHAL HIDL V1_0
|
||||
sp<IPowerV1_0> getPowerHalHidlV1_0() {
|
||||
std::lock_guard<std::mutex> lock(gPowerHalMutex);
|
||||
@@ -498,6 +512,14 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
|
||||
@@ -559,6 +573,14 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 8bd0f8e1905ed0ecf275d383e816afb480feae30 Mon Sep 17 00:00:00 2001
|
||||
From 014ba558076692fb0009b0100c4f18a6800e30ac Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Sun, 6 Dec 2020 12:20:08 +0100
|
||||
Subject: [PATCH] Make rounded corners padding overridable with
|
||||
@@ -6,12 +6,10 @@ Subject: [PATCH] Make rounded corners padding overridable with
|
||||
|
||||
Change-Id: Id5d73b06b9a2cb2da95ff31f204c1984555872ff
|
||||
---
|
||||
.../systemui/qs/QuickStatusBarHeader.java | 6 +-
|
||||
.../phone/KeyguardStatusBarView.java | 6 +-
|
||||
.../statusbar/phone/PhoneStatusBarView.java | 6 +-
|
||||
..._server_power_PowerManagerService.cpp.orig | 641 ++++++++++++++++++
|
||||
4 files changed, 656 insertions(+), 3 deletions(-)
|
||||
create mode 100644 services/core/jni/com_android_server_power_PowerManagerService.cpp.orig
|
||||
.../src/com/android/systemui/qs/QuickStatusBarHeader.java | 6 +++++-
|
||||
.../systemui/statusbar/phone/KeyguardStatusBarView.java | 6 +++++-
|
||||
.../systemui/statusbar/phone/PhoneStatusBarView.java | 6 +++++-
|
||||
3 files changed, 15 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
|
||||
index 7533f2ac1db..94fd996d085 100644
|
||||
@@ -88,653 +86,6 @@ index 1c6c7db6a69..f0e5c7bb3d2 100644
|
||||
|
||||
updateStatusBarHeight();
|
||||
}
|
||||
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp.orig b/services/core/jni/com_android_server_power_PowerManagerService.cpp.orig
|
||||
new file mode 100644
|
||||
index 00000000000..47fdcc9a87b
|
||||
--- /dev/null
|
||||
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp.orig
|
||||
@@ -0,0 +1,641 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2010 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.
|
||||
+ */
|
||||
+
|
||||
+#define LOG_TAG "PowerManagerService-JNI"
|
||||
+
|
||||
+//#define LOG_NDEBUG 0
|
||||
+
|
||||
+#include <android/hardware/power/1.1/IPower.h>
|
||||
+#include <android/hardware/power/Boost.h>
|
||||
+#include <android/hardware/power/IPower.h>
|
||||
+#include <android/hardware/power/Mode.h>
|
||||
+#include <android/system/suspend/1.0/ISystemSuspend.h>
|
||||
+#include <android/system/suspend/ISuspendControlService.h>
|
||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
||||
+#include <nativehelper/JNIHelp.h>
|
||||
+#include <vendor/lineage/power/1.0/ILineagePower.h>
|
||||
+#include "jni.h"
|
||||
+
|
||||
+#include <nativehelper/ScopedUtfChars.h>
|
||||
+
|
||||
+#include <limits.h>
|
||||
+
|
||||
+#include <android-base/chrono_utils.h>
|
||||
+#include <android_runtime/AndroidRuntime.h>
|
||||
+#include <android_runtime/Log.h>
|
||||
+#include <binder/IServiceManager.h>
|
||||
+#include <gui/SurfaceComposerClient.h>
|
||||
+#include <hardware/power.h>
|
||||
+#include <hardware_legacy/power.h>
|
||||
+#include <hidl/ServiceManagement.h>
|
||||
+#include <utils/Timers.h>
|
||||
+#include <utils/misc.h>
|
||||
+#include <utils/String8.h>
|
||||
+#include <utils/Log.h>
|
||||
+#include <android/keycodes.h>
|
||||
+
|
||||
+#include "com_android_server_power_PowerManagerService.h"
|
||||
+
|
||||
+using android::hardware::Return;
|
||||
+using android::hardware::Void;
|
||||
+using android::hardware::power::Boost;
|
||||
+using android::hardware::power::Mode;
|
||||
+using android::hardware::power::V1_0::PowerHint;
|
||||
+using android::hardware::power::V1_0::Feature;
|
||||
+using android::String8;
|
||||
+using android::system::suspend::V1_0::ISystemSuspend;
|
||||
+using android::system::suspend::V1_0::IWakeLock;
|
||||
+using android::system::suspend::V1_0::WakeLockType;
|
||||
+using android::system::suspend::ISuspendControlService;
|
||||
+using IPowerV1_1 = android::hardware::power::V1_1::IPower;
|
||||
+using IPowerV1_0 = android::hardware::power::V1_0::IPower;
|
||||
+using IPowerAidl = android::hardware::power::IPower;
|
||||
+using ILineagePowerV1_0 = vendor::lineage::power::V1_0::ILineagePower;
|
||||
+using vendor::lineage::power::V1_0::LineageFeature;
|
||||
+using ISehMiscPower = vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower;
|
||||
+
|
||||
+namespace android {
|
||||
+
|
||||
+// ----------------------------------------------------------------------------
|
||||
+
|
||||
+static struct {
|
||||
+ jmethodID userActivityFromNative;
|
||||
+} gPowerManagerServiceClassInfo;
|
||||
+
|
||||
+// ----------------------------------------------------------------------------
|
||||
+
|
||||
+static jobject gPowerManagerServiceObj;
|
||||
+static sp<IPowerV1_0> gPowerHalHidlV1_0_ = nullptr;
|
||||
+static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
|
||||
+static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
||||
+static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
||||
+static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
||||
+static bool gPowerHalExists = true;
|
||||
+static std::mutex gPowerHalMutex;
|
||||
+
|
||||
+enum class HalVersion {
|
||||
+ NONE,
|
||||
+ HIDL_1_0,
|
||||
+ HIDL_1_1,
|
||||
+ AIDL,
|
||||
+};
|
||||
+
|
||||
+static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1];
|
||||
+
|
||||
+// Throttling interval for user activity calls.
|
||||
+static const nsecs_t MIN_TIME_BETWEEN_USERACTIVITIES = 100 * 1000000L; // 100ms
|
||||
+
|
||||
+// ----------------------------------------------------------------------------
|
||||
+
|
||||
+static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
|
||||
+ if (env->ExceptionCheck()) {
|
||||
+ ALOGE("An exception was thrown by callback '%s'.", methodName);
|
||||
+ LOGE_EX(env);
|
||||
+ env->ExceptionClear();
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+// Check validity of current handle to the power HAL service, and connect to it if necessary.
|
||||
+// The caller must be holding gPowerHalMutex.
|
||||
+static HalVersion connectPowerHalLocked() {
|
||||
+ static bool gPowerHalHidlExists = true;
|
||||
+ static bool gPowerHalAidlExists = true;
|
||||
+ if (!gPowerHalHidlExists && !gPowerHalAidlExists) {
|
||||
+ return HalVersion::NONE;
|
||||
+ }
|
||||
+ if (gPowerHalAidlExists) {
|
||||
+ if (!gPowerHalAidl_) {
|
||||
+ gPowerHalAidl_ = waitForVintfService<IPowerAidl>();
|
||||
+ }
|
||||
+ if (gPowerHalAidl_) {
|
||||
+ ALOGV("Successfully connected to Power HAL AIDL service.");
|
||||
+ return HalVersion::AIDL;
|
||||
+ } else {
|
||||
+ gPowerHalAidlExists = false;
|
||||
+ }
|
||||
+ }
|
||||
+ if (gPowerHalExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||
+ gSehMiscPower = ISehMiscPower::getService();
|
||||
+ gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
|
||||
+ }
|
||||
+ if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||
+ gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
||||
+ if (gPowerHalHidlV1_0_) {
|
||||
+ ALOGV("Successfully connected to Power HAL HIDL 1.0 service.");
|
||||
+ // Try cast to powerHAL HIDL V1_1
|
||||
+ gPowerHalHidlV1_1_ = IPowerV1_1::castFrom(gPowerHalHidlV1_0_);
|
||||
+ if (gPowerHalHidlV1_1_) {
|
||||
+ ALOGV("Successfully connected to Power HAL HIDL 1.1 service.");
|
||||
+ }
|
||||
+ } else {
|
||||
+ ALOGV("Couldn't load power HAL HIDL service");
|
||||
+ gPowerHalHidlExists = false;
|
||||
+ return HalVersion::NONE;
|
||||
+ }
|
||||
+ }
|
||||
+ if (gPowerHalHidlV1_1_) {
|
||||
+ return HalVersion::HIDL_1_1;
|
||||
+ } else if (gPowerHalHidlV1_0_) {
|
||||
+ return HalVersion::HIDL_1_0;
|
||||
+ }
|
||||
+ return HalVersion::NONE;
|
||||
+}
|
||||
+
|
||||
+// Check validity of current handle to the Lineage power HAL service, and call getService() if necessary.
|
||||
+// The caller must be holding gPowerHalMutex.
|
||||
+void connectLineagePowerHalLocked() {
|
||||
+ static bool gLineagePowerHalExists = true;
|
||||
+ if (gLineagePowerHalExists && gLineagePowerHalV1_0_ == nullptr) {
|
||||
+ gLineagePowerHalV1_0_ = ILineagePowerV1_0::getService();
|
||||
+ if (gLineagePowerHalV1_0_ != nullptr) {
|
||||
+ ALOGI("Loaded power HAL service");
|
||||
+ } else {
|
||||
+ ALOGI("Couldn't load power HAL service");
|
||||
+ gLineagePowerHalExists = false;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+sp<ISehMiscPower> getSehMiscPower() {
|
||||
+ std::lock_guard<std::mutex> lock(gPowerHalMutex);
|
||||
+ connectPowerHalLocked();
|
||||
+ return gSehMiscPower;
|
||||
+}
|
||||
+
|
||||
+// Retrieve a copy of PowerHAL HIDL V1_0
|
||||
+sp<IPowerV1_0> getPowerHalHidlV1_0() {
|
||||
+ std::lock_guard<std::mutex> lock(gPowerHalMutex);
|
||||
+ HalVersion halVersion = connectPowerHalLocked();
|
||||
+ if (halVersion == HalVersion::HIDL_1_0 || halVersion == HalVersion::HIDL_1_1) {
|
||||
+ return gPowerHalHidlV1_0_;
|
||||
+ }
|
||||
+
|
||||
+ return nullptr;
|
||||
+}
|
||||
+
|
||||
+// Retrieve a copy of PowerHAL HIDL V1_1
|
||||
+sp<IPowerV1_1> getPowerHalHidlV1_1() {
|
||||
+ std::lock_guard<std::mutex> lock(gPowerHalMutex);
|
||||
+ if (connectPowerHalLocked() == HalVersion::HIDL_1_1) {
|
||||
+ return gPowerHalHidlV1_1_;
|
||||
+ }
|
||||
+
|
||||
+ return nullptr;
|
||||
+}
|
||||
+
|
||||
+// Retrieve a copy of LineagePowerHAL V1_0
|
||||
+sp<ILineagePowerV1_0> getLineagePowerHalV1_0() {
|
||||
+ std::lock_guard<std::mutex> lock(gPowerHalMutex);
|
||||
+ connectLineagePowerHalLocked();
|
||||
+ return gLineagePowerHalV1_0_;
|
||||
+}
|
||||
+
|
||||
+// Check if a call to a power HAL function failed; if so, log the failure and invalidate the
|
||||
+// current handle to the power HAL service.
|
||||
+bool processPowerHalReturn(bool isOk, const char* functionName) {
|
||||
+ if (!isOk) {
|
||||
+ ALOGE("%s() failed: power HAL service not available.", functionName);
|
||||
+ gPowerHalMutex.lock();
|
||||
+ gPowerHalHidlV1_0_ = nullptr;
|
||||
+ gPowerHalHidlV1_1_ = nullptr;
|
||||
+ gPowerHalAidl_ = nullptr;
|
||||
+ gPowerHalMutex.unlock();
|
||||
+ }
|
||||
+ return isOk;
|
||||
+}
|
||||
+
|
||||
+enum class HalSupport {
|
||||
+ UNKNOWN = 0,
|
||||
+ ON,
|
||||
+ OFF,
|
||||
+};
|
||||
+
|
||||
+static void setPowerBoostWithHandle(sp<IPowerAidl> handle, Boost boost, int32_t durationMs) {
|
||||
+ // Android framework only sends boost upto DISPLAY_UPDATE_IMMINENT.
|
||||
+ // Need to increase the array size if more boost supported.
|
||||
+ static std::array<std::atomic<HalSupport>,
|
||||
+ static_cast<int32_t>(Boost::DISPLAY_UPDATE_IMMINENT) + 1>
|
||||
+ boostSupportedArray = {HalSupport::UNKNOWN};
|
||||
+
|
||||
+ // Quick return if boost is not supported by HAL
|
||||
+ if (boost > Boost::DISPLAY_UPDATE_IMMINENT ||
|
||||
+ boostSupportedArray[static_cast<int32_t>(boost)] == HalSupport::OFF) {
|
||||
+ ALOGV("Skipped setPowerBoost %s because HAL doesn't support it", toString(boost).c_str());
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (boostSupportedArray[static_cast<int32_t>(boost)] == HalSupport::UNKNOWN) {
|
||||
+ bool isSupported = false;
|
||||
+ handle->isBoostSupported(boost, &isSupported);
|
||||
+ boostSupportedArray[static_cast<int32_t>(boost)] =
|
||||
+ isSupported ? HalSupport::ON : HalSupport::OFF;
|
||||
+ if (!isSupported) {
|
||||
+ ALOGV("Skipped setPowerBoost %s because HAL doesn't support it",
|
||||
+ toString(boost).c_str());
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ auto ret = handle->setBoost(boost, durationMs);
|
||||
+ processPowerHalReturn(ret.isOk(), "setPowerBoost");
|
||||
+}
|
||||
+
|
||||
+static void setPowerBoost(Boost boost, int32_t durationMs) {
|
||||
+ std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||
+ if (connectPowerHalLocked() != HalVersion::AIDL) {
|
||||
+ ALOGV("Power HAL AIDL not available");
|
||||
+ return;
|
||||
+ }
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerBoostWithHandle(handle, boost, durationMs);
|
||||
+}
|
||||
+
|
||||
+static bool setPowerModeWithHandle(sp<IPowerAidl> handle, Mode mode, bool enabled) {
|
||||
+ // Android framework only sends mode upto DISPLAY_INACTIVE.
|
||||
+ // Need to increase the array if more mode supported.
|
||||
+ static std::array<std::atomic<HalSupport>, static_cast<int32_t>(Mode::DISPLAY_INACTIVE) + 1>
|
||||
+ modeSupportedArray = {HalSupport::UNKNOWN};
|
||||
+
|
||||
+ // Quick return if mode is not supported by HAL
|
||||
+ if (mode > Mode::DISPLAY_INACTIVE ||
|
||||
+ modeSupportedArray[static_cast<int32_t>(mode)] == HalSupport::OFF) {
|
||||
+ ALOGV("Skipped setPowerMode %s because HAL doesn't support it", toString(mode).c_str());
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (modeSupportedArray[static_cast<int32_t>(mode)] == HalSupport::UNKNOWN) {
|
||||
+ bool isSupported = false;
|
||||
+ handle->isModeSupported(mode, &isSupported);
|
||||
+ modeSupportedArray[static_cast<int32_t>(mode)] =
|
||||
+ isSupported ? HalSupport::ON : HalSupport::OFF;
|
||||
+ if (!isSupported) {
|
||||
+ ALOGV("Skipped setPowerMode %s because HAL doesn't support it", toString(mode).c_str());
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ auto ret = handle->setMode(mode, enabled);
|
||||
+ processPowerHalReturn(ret.isOk(), "setPowerMode");
|
||||
+ return ret.isOk();
|
||||
+}
|
||||
+
|
||||
+static bool setPowerMode(Mode mode, bool enabled) {
|
||||
+ std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||
+ if (connectPowerHalLocked() != HalVersion::AIDL) {
|
||||
+ ALOGV("Power HAL AIDL not available");
|
||||
+ return false;
|
||||
+ }
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ return setPowerModeWithHandle(handle, mode, enabled);
|
||||
+}
|
||||
+
|
||||
+static void sendPowerHint(PowerHint hintId, uint32_t data) {
|
||||
+ std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||
+ switch (connectPowerHalLocked()) {
|
||||
+ case HalVersion::NONE:
|
||||
+ return;
|
||||
+ case HalVersion::HIDL_1_0: {
|
||||
+ sp<IPowerV1_0> handle = gPowerHalHidlV1_0_;
|
||||
+ lock.unlock();
|
||||
+ auto ret = handle->powerHint(hintId, data);
|
||||
+ processPowerHalReturn(ret.isOk(), "powerHint");
|
||||
+ break;
|
||||
+ }
|
||||
+ case HalVersion::HIDL_1_1: {
|
||||
+ sp<IPowerV1_1> handle = gPowerHalHidlV1_1_;
|
||||
+ lock.unlock();
|
||||
+ auto ret = handle->powerHintAsync(hintId, data);
|
||||
+ processPowerHalReturn(ret.isOk(), "powerHintAsync");
|
||||
+ break;
|
||||
+ }
|
||||
+ case HalVersion::AIDL: {
|
||||
+ if (hintId == PowerHint::INTERACTION) {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerBoostWithHandle(handle, Boost::INTERACTION, data);
|
||||
+ break;
|
||||
+ } else if (hintId == PowerHint::LAUNCH) {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerModeWithHandle(handle, Mode::LAUNCH, static_cast<bool>(data));
|
||||
+ break;
|
||||
+ } else if (hintId == PowerHint::LOW_POWER) {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerModeWithHandle(handle, Mode::LOW_POWER, static_cast<bool>(data));
|
||||
+ break;
|
||||
+ } else if (hintId == PowerHint::SUSTAINED_PERFORMANCE) {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerModeWithHandle(handle, Mode::SUSTAINED_PERFORMANCE,
|
||||
+ static_cast<bool>(data));
|
||||
+ break;
|
||||
+ } else if (hintId == PowerHint::VR_MODE) {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerModeWithHandle(handle, Mode::VR, static_cast<bool>(data));
|
||||
+ break;
|
||||
+ } else {
|
||||
+ ALOGE("Unsupported power hint: %s.", toString(hintId).c_str());
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ default: {
|
||||
+ ALOGE("Unknown power HAL state");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ SurfaceComposerClient::notifyPowerHint(static_cast<int32_t>(hintId));
|
||||
+}
|
||||
+
|
||||
+void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t eventType,
|
||||
+ int32_t keyCode) {
|
||||
+ if (gPowerManagerServiceObj) {
|
||||
+ // Throttle calls into user activity by event type.
|
||||
+ // We're a little conservative about argument checking here in case the caller
|
||||
+ // passes in bad data which could corrupt system state.
|
||||
+ if (eventType >= 0 && eventType <= USER_ACTIVITY_EVENT_LAST) {
|
||||
+ nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
|
||||
+ if (eventTime > now) {
|
||||
+ eventTime = now;
|
||||
+ }
|
||||
+
|
||||
+ if (gLastEventTime[eventType] + MIN_TIME_BETWEEN_USERACTIVITIES > eventTime) {
|
||||
+ return;
|
||||
+ }
|
||||
+ gLastEventTime[eventType] = eventTime;
|
||||
+
|
||||
+ // Tell the power HAL when user activity occurs.
|
||||
+ sendPowerHint(PowerHint::INTERACTION, 0);
|
||||
+ }
|
||||
+
|
||||
+ JNIEnv* env = AndroidRuntime::getJNIEnv();
|
||||
+
|
||||
+ int flags = 0;
|
||||
+ if (keyCode == AKEYCODE_VOLUME_UP || keyCode == AKEYCODE_VOLUME_DOWN) {
|
||||
+ flags |= USER_ACTIVITY_FLAG_NO_BUTTON_LIGHTS;
|
||||
+ }
|
||||
+
|
||||
+ env->CallVoidMethod(gPowerManagerServiceObj,
|
||||
+ gPowerManagerServiceClassInfo.userActivityFromNative,
|
||||
+ nanoseconds_to_milliseconds(eventTime), eventType, flags);
|
||||
+ checkAndClearExceptionFromCallback(env, "userActivityFromNative");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static sp<ISystemSuspend> gSuspendHal = nullptr;
|
||||
+static sp<ISuspendControlService> gSuspendControl = nullptr;
|
||||
+static sp<IWakeLock> gSuspendBlocker = nullptr;
|
||||
+static std::mutex gSuspendMutex;
|
||||
+
|
||||
+// Assume SystemSuspend HAL is always alive.
|
||||
+// TODO: Force device to restart if SystemSuspend HAL dies.
|
||||
+sp<ISystemSuspend> getSuspendHal() {
|
||||
+ static std::once_flag suspendHalFlag;
|
||||
+ std::call_once(suspendHalFlag, [](){
|
||||
+ ::android::hardware::details::waitForHwService(ISystemSuspend::descriptor, "default");
|
||||
+ gSuspendHal = ISystemSuspend::getService();
|
||||
+ assert(gSuspendHal != nullptr);
|
||||
+ });
|
||||
+ return gSuspendHal;
|
||||
+}
|
||||
+
|
||||
+sp<ISuspendControlService> getSuspendControl() {
|
||||
+ static std::once_flag suspendControlFlag;
|
||||
+ std::call_once(suspendControlFlag, [](){
|
||||
+ gSuspendControl = waitForService<ISuspendControlService>(String16("suspend_control"));
|
||||
+ LOG_ALWAYS_FATAL_IF(gSuspendControl == nullptr);
|
||||
+ });
|
||||
+ return gSuspendControl;
|
||||
+}
|
||||
+
|
||||
+void enableAutoSuspend() {
|
||||
+ static bool enabled = false;
|
||||
+ if (!enabled) {
|
||||
+ sp<ISuspendControlService> suspendControl = getSuspendControl();
|
||||
+ suspendControl->enableAutosuspend(&enabled);
|
||||
+ }
|
||||
+
|
||||
+ {
|
||||
+ std::lock_guard<std::mutex> lock(gSuspendMutex);
|
||||
+ if (gSuspendBlocker) {
|
||||
+ gSuspendBlocker->release();
|
||||
+ gSuspendBlocker.clear();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void disableAutoSuspend() {
|
||||
+ std::lock_guard<std::mutex> lock(gSuspendMutex);
|
||||
+ if (!gSuspendBlocker) {
|
||||
+ sp<ISystemSuspend> suspendHal = getSuspendHal();
|
||||
+ gSuspendBlocker = suspendHal->acquireWakeLock(WakeLockType::PARTIAL,
|
||||
+ "PowerManager.SuspendLockout");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static jint nativeGetFeature(JNIEnv* /* env */, jclass /* clazz */, jint featureId) {
|
||||
+ int value = -1;
|
||||
+
|
||||
+ sp<ILineagePowerV1_0> lineagePowerHalV1_0 = getLineagePowerHalV1_0();
|
||||
+ if (lineagePowerHalV1_0 != nullptr) {
|
||||
+ value = lineagePowerHalV1_0->getFeature(static_cast<LineageFeature>(featureId));
|
||||
+ }
|
||||
+
|
||||
+ return static_cast<jint>(value);
|
||||
+}
|
||||
+
|
||||
+// ----------------------------------------------------------------------------
|
||||
+
|
||||
+static void nativeInit(JNIEnv* env, jobject obj) {
|
||||
+ gPowerManagerServiceObj = env->NewGlobalRef(obj);
|
||||
+
|
||||
+ gPowerHalMutex.lock();
|
||||
+ connectPowerHalLocked();
|
||||
+ gPowerHalMutex.unlock();
|
||||
+}
|
||||
+
|
||||
+static void nativeAcquireSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring nameStr) {
|
||||
+ ScopedUtfChars name(env, nameStr);
|
||||
+ acquire_wake_lock(PARTIAL_WAKE_LOCK, name.c_str());
|
||||
+}
|
||||
+
|
||||
+static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring nameStr) {
|
||||
+ ScopedUtfChars name(env, nameStr);
|
||||
+ release_wake_lock(name.c_str());
|
||||
+}
|
||||
+
|
||||
+static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
|
||||
+ std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||
+ switch (connectPowerHalLocked()) {
|
||||
+ case HalVersion::NONE:
|
||||
+ return;
|
||||
+ case HalVersion::HIDL_1_0:
|
||||
+ FALLTHROUGH_INTENDED;
|
||||
+ case HalVersion::HIDL_1_1: {
|
||||
+ android::base::Timer t;
|
||||
+ sp<IPowerV1_0> handle = gPowerHalHidlV1_0_;
|
||||
+ lock.unlock();
|
||||
+ auto ret = handle->setInteractive(enable);
|
||||
+ processPowerHalReturn(ret.isOk(), "setInteractive");
|
||||
+ if (t.duration() > 20ms) {
|
||||
+ ALOGD("Excessive delay in setInteractive(%s) while turning screen %s",
|
||||
+ enable ? "true" : "false", enable ? "on" : "off");
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ case HalVersion::AIDL: {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerModeWithHandle(handle, Mode::INTERACTIVE, enable);
|
||||
+ return;
|
||||
+ }
|
||||
+ default: {
|
||||
+ ALOGE("Unknown power HAL state");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ sp<ISehMiscPower> sehMiscPower = getSehMiscPower();
|
||||
+ if(sehMiscPower != nullptr) {
|
||||
+ android::base::Timer t;
|
||||
+ Return<void> ret = sehMiscPower->setInteractiveAsync(enable, 0);
|
||||
+ if(!ret.isOk()) {
|
||||
+ ALOGE("set interactive async() failed: seh misc setInteractiveAsync");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nativeSetAutoSuspend(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
|
||||
+ if (enable) {
|
||||
+ android::base::Timer t;
|
||||
+ enableAutoSuspend();
|
||||
+ if (t.duration() > 100ms) {
|
||||
+ ALOGD("Excessive delay in autosuspend_enable() while turning screen off");
|
||||
+ }
|
||||
+ } else {
|
||||
+ android::base::Timer t;
|
||||
+ disableAutoSuspend();
|
||||
+ if (t.duration() > 100ms) {
|
||||
+ ALOGD("Excessive delay in autosuspend_disable() while turning screen on");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nativeSendPowerHint(JNIEnv* /* env */, jclass /* clazz */, jint hintId, jint data) {
|
||||
+ sendPowerHint(static_cast<PowerHint>(hintId), data);
|
||||
+}
|
||||
+
|
||||
+static void nativeSetPowerBoost(JNIEnv* /* env */, jclass /* clazz */, jint boost,
|
||||
+ jint durationMs) {
|
||||
+ setPowerBoost(static_cast<Boost>(boost), durationMs);
|
||||
+}
|
||||
+
|
||||
+static jboolean nativeSetPowerMode(JNIEnv* /* env */, jclass /* clazz */, jint mode,
|
||||
+ jboolean enabled) {
|
||||
+ return setPowerMode(static_cast<Mode>(mode), enabled);
|
||||
+}
|
||||
+
|
||||
+static void nativeSetFeature(JNIEnv* /* env */, jclass /* clazz */, jint featureId, jint data) {
|
||||
+ std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||
+ switch (connectPowerHalLocked()) {
|
||||
+ case HalVersion::NONE:
|
||||
+ return;
|
||||
+ case HalVersion::HIDL_1_0:
|
||||
+ FALLTHROUGH_INTENDED;
|
||||
+ case HalVersion::HIDL_1_1: {
|
||||
+ sp<IPowerV1_0> handle = gPowerHalHidlV1_0_;
|
||||
+ lock.unlock();
|
||||
+ auto ret = handle->setFeature(static_cast<Feature>(featureId), static_cast<bool>(data));
|
||||
+ processPowerHalReturn(ret.isOk(), "setFeature");
|
||||
+ return;
|
||||
+ }
|
||||
+ case HalVersion::AIDL: {
|
||||
+ sp<IPowerAidl> handle = gPowerHalAidl_;
|
||||
+ lock.unlock();
|
||||
+ setPowerModeWithHandle(handle, Mode::DOUBLE_TAP_TO_WAKE, static_cast<bool>(data));
|
||||
+ return;
|
||||
+ }
|
||||
+ default: {
|
||||
+ ALOGE("Unknown power HAL state");
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool nativeForceSuspend(JNIEnv* /* env */, jclass /* clazz */) {
|
||||
+ bool retval = false;
|
||||
+ getSuspendControl()->forceSuspend(&retval);
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+// ----------------------------------------------------------------------------
|
||||
+
|
||||
+static const JNINativeMethod gPowerManagerServiceMethods[] = {
|
||||
+ /* name, signature, funcPtr */
|
||||
+ {"nativeInit", "()V", (void*)nativeInit},
|
||||
+ {"nativeAcquireSuspendBlocker", "(Ljava/lang/String;)V",
|
||||
+ (void*)nativeAcquireSuspendBlocker},
|
||||
+ {"nativeForceSuspend", "()Z", (void*)nativeForceSuspend},
|
||||
+ {"nativeReleaseSuspendBlocker", "(Ljava/lang/String;)V",
|
||||
+ (void*)nativeReleaseSuspendBlocker},
|
||||
+ {"nativeSetInteractive", "(Z)V", (void*)nativeSetInteractive},
|
||||
+ {"nativeSetAutoSuspend", "(Z)V", (void*)nativeSetAutoSuspend},
|
||||
+ {"nativeSendPowerHint", "(II)V", (void*)nativeSendPowerHint},
|
||||
+ {"nativeSetPowerBoost", "(II)V", (void*)nativeSetPowerBoost},
|
||||
+ {"nativeSetPowerMode", "(IZ)Z", (void*)nativeSetPowerMode},
|
||||
+ {"nativeSetFeature", "(II)V", (void*)nativeSetFeature},
|
||||
+ {"nativeGetFeature", "(I)I", (void*)nativeGetFeature},
|
||||
+};
|
||||
+
|
||||
+#define FIND_CLASS(var, className) \
|
||||
+ var = env->FindClass(className); \
|
||||
+ LOG_FATAL_IF(! (var), "Unable to find class " className);
|
||||
+
|
||||
+#define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) \
|
||||
+ var = env->GetMethodID(clazz, methodName, methodDescriptor); \
|
||||
+ LOG_FATAL_IF(! (var), "Unable to find method " methodName);
|
||||
+
|
||||
+#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
|
||||
+ var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
|
||||
+ LOG_FATAL_IF(! (var), "Unable to find field " fieldName);
|
||||
+
|
||||
+int register_android_server_PowerManagerService(JNIEnv* env) {
|
||||
+ int res = jniRegisterNativeMethods(env, "com/android/server/power/PowerManagerService",
|
||||
+ gPowerManagerServiceMethods, NELEM(gPowerManagerServiceMethods));
|
||||
+ (void) res; // Faked use when LOG_NDEBUG.
|
||||
+ LOG_FATAL_IF(res < 0, "Unable to register native methods.");
|
||||
+
|
||||
+ // Callbacks
|
||||
+
|
||||
+ jclass clazz;
|
||||
+ FIND_CLASS(clazz, "com/android/server/power/PowerManagerService");
|
||||
+
|
||||
+ GET_METHOD_ID(gPowerManagerServiceClassInfo.userActivityFromNative, clazz,
|
||||
+ "userActivityFromNative", "(JII)V");
|
||||
+
|
||||
+ // Initialize
|
||||
+ for (int i = 0; i <= USER_ACTIVITY_EVENT_LAST; i++) {
|
||||
+ gLastEventTime[i] = LLONG_MIN;
|
||||
+ }
|
||||
+ gPowerManagerServiceObj = NULL;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+} /* namespace android */
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 792b863af87a7bd3d063da76ecefa7e229e1aded Mon Sep 17 00:00:00 2001
|
||||
From 368af07a0fc4fbed6f6946c8bf8237702841d914 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Fri, 18 Dec 2020 16:38:58 -0500
|
||||
Subject: [PATCH] Fix Samsung Power HAL (switch/case was filled with
|
||||
@@ -9,18 +9,18 @@ Subject: [PATCH] Fix Samsung Power HAL (switch/case was filled with
|
||||
1 file changed, 14 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
index 47fdcc9a87b..ed7d311ab9f 100644
|
||||
index dcd33366a35..298cd8c7171 100644
|
||||
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
@@ -83,7 +83,6 @@ static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
|
||||
static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
||||
@@ -89,7 +89,6 @@ static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
||||
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
||||
static sp<ILineagePowerAidl> gLineagePowerHalAidl_ = nullptr;
|
||||
static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
||||
-static bool gPowerHalExists = true;
|
||||
static std::mutex gPowerHalMutex;
|
||||
static std::mutex gLineagePowerHalMutex;
|
||||
|
||||
enum class HalVersion {
|
||||
@@ -129,9 +128,11 @@ static HalVersion connectPowerHalLocked() {
|
||||
@@ -136,9 +135,11 @@ static HalVersion connectPowerHalLocked() {
|
||||
gPowerHalAidlExists = false;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ index 47fdcc9a87b..ed7d311ab9f 100644
|
||||
}
|
||||
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
||||
@@ -484,7 +485,17 @@ static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring
|
||||
@@ -545,7 +546,17 @@ static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring
|
||||
|
||||
static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
|
||||
std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||
@@ -52,7 +52,7 @@ index 47fdcc9a87b..ed7d311ab9f 100644
|
||||
case HalVersion::NONE:
|
||||
return;
|
||||
case HalVersion::HIDL_1_0:
|
||||
@@ -512,14 +523,6 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
|
||||
@@ -573,14 +584,6 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
From e202b51e3522636dade7a0ede8688ccd38306468 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Sat, 13 Mar 2021 13:21:46 -0500
|
||||
Subject: [PATCH 42/45] On Samsung R vendor, there is still the ISehMiscPower
|
||||
HIDL HAL, but there is also the AOSP's AIDL HAL. It was previously assumed
|
||||
this wouldn't happen, fix this assumption.
|
||||
|
||||
---
|
||||
...om_android_server_power_PowerManagerService.cpp | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
index 2ebff05d6c5c..c5d9aa94687e 100644
|
||||
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||
@@ -112,6 +112,14 @@ static HalVersion connectPowerHalLocked() {
|
||||
if (!gPowerHalHidlExists && !gPowerHalAidlExists) {
|
||||
return HalVersion::NONE;
|
||||
}
|
||||
+ if (
|
||||
+ gPowerHalAidl_ == nullptr &&
|
||||
+ gPowerHalHidlV1_0_ == nullptr) {
|
||||
+ ALOGE("Trying to connect to Samsung Power HAL");
|
||||
+ gSehMiscPower = ISehMiscPower::getService();
|
||||
+ gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
|
||||
+ ALOGE("Got miscpower = %d, SehMiscPower = %d", gPowerHalHidlV1_0_ != nullptr ? 1 : 0, gSehMiscPower ? 1 : 0);
|
||||
+ }
|
||||
if (gPowerHalAidlExists) {
|
||||
if (!gPowerHalAidl_) {
|
||||
gPowerHalAidl_ = waitForVintfService<IPowerAidl>();
|
||||
@@ -123,12 +131,6 @@ static HalVersion connectPowerHalLocked() {
|
||||
gPowerHalAidlExists = false;
|
||||
}
|
||||
}
|
||||
- if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||
- ALOGE("Trying to connect to Samsung Power HAL");
|
||||
- gSehMiscPower = ISehMiscPower::getService();
|
||||
- gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
|
||||
- ALOGE("Got miscpower = %d, SehMiscPower = %d", gPowerHalHidlV1_0_ != nullptr ? 1 : 0, gSehMiscPower ? 1 : 0);
|
||||
- }
|
||||
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
||||
if (gPowerHalHidlV1_0_) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
From a4d9278457f0035b44a4b18e07a224d0a827e446 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Sat, 20 Mar 2021 14:30:17 +0100
|
||||
Subject: [PATCH 43/45] Handle another type of Samsung proximity sensor: Hover
|
||||
Proximity Sensor, with yet another behavior (seen on S20 FE)
|
||||
|
||||
---
|
||||
.../server/display/DisplayPowerController.java | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||
index bd41d38ad34c..0d160c37f6ea 100644
|
||||
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||
@@ -540,6 +540,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mProximitySensor = sensor;
|
||||
}
|
||||
}
|
||||
+ if(mProximitySensor == null) {
|
||||
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||
+ for(Sensor sensor: sensors) {
|
||||
+ if("com.samsung.sensor.hover_proximity".equals(sensor.getStringType()))
|
||||
+ mProximitySensor = sensor;
|
||||
+ }
|
||||
+ }
|
||||
if(mProximitySensor == null) {
|
||||
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||
for(Sensor sensor: sensors) {
|
||||
@@ -2055,6 +2062,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
handleProximitySensorEvent(time, positive);
|
||||
return;
|
||||
}
|
||||
+ if("com.samsung.sensor.hover_proximity".equals(mProximitySensor.getStringType())) {
|
||||
+ float v = event.values[0];
|
||||
+ boolean positive = (v >= 0.5f && v <= 4.5);
|
||||
+ android.util.Log.d("PHH", "Samsung hover sensor changed " + positive + ":" + v);
|
||||
+ handleProximitySensorEvent(time, positive);
|
||||
+ return;
|
||||
+ }
|
||||
final float distance = event.values[0];
|
||||
boolean positive = distance >= 0.0f && distance < mProximityThreshold;
|
||||
handleProximitySensorEvent(time, positive);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
From b560c2bba2559c95a97ca614fa46d542be6d2858 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Sat, 20 Mar 2021 14:31:01 +0100
|
||||
Subject: [PATCH 44/45] Automatically detect pick up sensor, so that an overlay
|
||||
is required for the sole purpose of enabling pulse doze on pick up sensor
|
||||
|
||||
---
|
||||
.../display/AmbientDisplayConfiguration.java | 18 +++++++++++++++++-
|
||||
1 file changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/core/java/android/hardware/display/AmbientDisplayConfiguration.java b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
|
||||
index ece5c28884fa..010fce24057d 100644
|
||||
--- a/core/java/android/hardware/display/AmbientDisplayConfiguration.java
|
||||
+++ b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
|
||||
@@ -23,6 +23,9 @@ import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
+import android.hardware.SensorManager;
|
||||
+import android.hardware.Sensor;
|
||||
+
|
||||
import com.android.internal.R;
|
||||
|
||||
/**
|
||||
@@ -74,7 +77,20 @@ public class AmbientDisplayConfiguration {
|
||||
|
||||
/** {@hide} */
|
||||
public boolean dozePickupSensorAvailable() {
|
||||
- return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
|
||||
+ SensorManager sm = mContext.getSystemService(SensorManager.class);
|
||||
+ boolean found = false;
|
||||
+ if(sm == null) {
|
||||
+ android.util.Log.d("PHH", "Failed getting sensor manager, can't detect pickup sensor");
|
||||
+ } else {
|
||||
+ java.util.List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL);
|
||||
+ for(Sensor s : sensors) {
|
||||
+ if(Sensor.STRING_TYPE_PICK_UP_GESTURE.equals(s.getStringType())) {
|
||||
+ found = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup) || found;
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
From 575db4c47ba68a6355774abc815f2f4c8de7a996 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Tue, 23 Mar 2021 19:43:26 +0100
|
||||
Subject: [PATCH 45/45] Catch broken mainBuiltInDisplayCutoutRectApproximation
|
||||
|
||||
Some devices (Redmi Note 9T) have:
|
||||
mainBuiltInDisplayCutoutRectApproximation = @android:mainBuiltInDisplayCutout
|
||||
Since mainBuiltInDisplayCutout is private, its ID is dynamic and can't
|
||||
be relied upon.
|
||||
This means that we'll get garbage in mainBuiltInDisplayCutoutRectApproximation
|
||||
The SVG Path parser will fail, triggering an exception.
|
||||
|
||||
Fix it by catching it, and parsing mainBuiltInDisplayCutout instead
|
||||
---
|
||||
core/java/android/view/DisplayCutout.java | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/core/java/android/view/DisplayCutout.java b/core/java/android/view/DisplayCutout.java
|
||||
index b4863f9c6dd0..e1d57e6869aa 100644
|
||||
--- a/core/java/android/view/DisplayCutout.java
|
||||
+++ b/core/java/android/view/DisplayCutout.java
|
||||
@@ -681,9 +681,15 @@ public final class DisplayCutout {
|
||||
* @hide
|
||||
*/
|
||||
public static DisplayCutout fromResourcesRectApproximation(Resources res, int displayWidth, int displayHeight) {
|
||||
- return fromSpec(res.getString(R.string.config_mainBuiltInDisplayCutoutRectApproximation),
|
||||
- displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
|
||||
- loadWaterfallInset(res));
|
||||
+ try {
|
||||
+ return fromSpec(res.getString(R.string.config_mainBuiltInDisplayCutoutRectApproximation),
|
||||
+ displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
|
||||
+ loadWaterfallInset(res));
|
||||
+ } catch(java.lang.IllegalArgumentException e) {
|
||||
+ return fromSpec(res.getString(R.string.config_mainBuiltInDisplayCutout),
|
||||
+ displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
|
||||
+ loadWaterfallInset(res));
|
||||
+ }
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user