Sync up to v304
This commit is contained in:
parent
cacd8b0430
commit
93d0ea8243
@ -0,0 +1,182 @@
|
|||||||
|
From 9f851c801719b45c79cd911d67ceb7e8f4cf63ab Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Wed, 31 Mar 2021 23:32:37 +0200
|
||||||
|
Subject: [PATCH] Workaround device/phh/treble conflict with SELinux policy
|
||||||
|
|
||||||
|
device/phh/treble defines the following three types (hostapd,
|
||||||
|
sysfs_usb_supply, rpmb_device)
|
||||||
|
However, Qualcomm Samsung Android 11 devices export those symbols as
|
||||||
|
typealias.
|
||||||
|
Type and typealias are fundamentally not mergeable.
|
||||||
|
Luckily, Samsung doesn't do anything with those typealias, so we can
|
||||||
|
simply ignore them.
|
||||||
|
|
||||||
|
Change-Id: I98db7e6eb55854887f90d0fd0f313fb0a19a488f
|
||||||
|
---
|
||||||
|
libsepol/cil/src/cil_binary.c | 8 ++++++--
|
||||||
|
libsepol/cil/src/cil_build_ast.c | 31 ++++++++++++++++++------------
|
||||||
|
libsepol/cil/src/cil_resolve_ast.c | 15 +++++++++++++--
|
||||||
|
3 files changed, 38 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
|
||||||
|
index 03d53e1f..160fd0e0 100644
|
||||||
|
--- a/libsepol/cil/src/cil_binary.c
|
||||||
|
+++ b/libsepol/cil/src/cil_binary.c
|
||||||
|
@@ -515,13 +515,17 @@ int cil_typealias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alias)
|
||||||
|
type_datum_init(sepol_alias);
|
||||||
|
|
||||||
|
rc = __cil_get_sepol_type_datum(pdb, DATUM(cil_alias->actual), &sepol_type);
|
||||||
|
- if (rc != SEPOL_OK) goto exit;
|
||||||
|
+ if (rc != SEPOL_OK) {
|
||||||
|
+ cil_log(CIL_ERR, "Failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
|
||||||
|
+ goto exit;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
sepol_alias->flavor = TYPE_TYPE;
|
||||||
|
|
||||||
|
key = cil_strdup(cil_alias->datum.fqn);
|
||||||
|
rc = symtab_insert(pdb, SYM_TYPES, key, sepol_alias, SCOPE_DECL, 0, NULL);
|
||||||
|
if (rc != SEPOL_OK) {
|
||||||
|
+ cil_log(CIL_ERR, "Failed at %s:%s:%d:%d\n", __FILE__, __FUNCTION__, __LINE__, rc);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
sepol_alias->s.value = sepol_type->s.value;
|
||||||
|
@@ -3776,7 +3780,7 @@ int __cil_node_to_policydb(struct cil_tree_node *node, void *extra_args)
|
||||||
|
|
||||||
|
exit:
|
||||||
|
if (rc != SEPOL_OK) {
|
||||||
|
- cil_tree_log(node, CIL_ERR, "Binary policy creation failed");
|
||||||
|
+ cil_tree_log(node, CIL_ERR, "Binary policy creation failed, for pass = %d, flavor = %d", pass, node->flavor);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
|
||||||
|
index 02cdcc65..2ba08bc6 100644
|
||||||
|
--- a/libsepol/cil/src/cil_build_ast.c
|
||||||
|
+++ b/libsepol/cil/src/cil_build_ast.c
|
||||||
|
@@ -1,16 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Tresys Technology, LLC. All rights reserved.
|
||||||
|
- *
|
||||||
|
+ *
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
- *
|
||||||
|
+ *
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
- *
|
||||||
|
+ *
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
- *
|
||||||
|
+ *
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS
|
||||||
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
|
@@ -21,7 +21,7 @@
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
- *
|
||||||
|
+ *
|
||||||
|
* The views and conclusions contained in the software and documentation are those
|
||||||
|
* of the authors and should not be interpreted as representing official policies,
|
||||||
|
* either expressed or implied, of Tresys Technology, LLC.
|
||||||
|
@@ -64,7 +64,7 @@ int cil_fill_list(struct cil_tree_node *current, enum cil_flavor flavor, struct
|
||||||
|
CIL_SYN_END
|
||||||
|
};
|
||||||
|
int syntax_len = sizeof(syntax)/sizeof(*syntax);
|
||||||
|
-
|
||||||
|
+
|
||||||
|
rc = __cil_verify_syntax(current, syntax, syntax_len);
|
||||||
|
if (rc != SEPOL_OK) {
|
||||||
|
goto exit;
|
||||||
|
@@ -108,7 +108,7 @@ int cil_gen_node(struct cil_db *db, struct cil_tree_node *ast_node, struct cil_s
|
||||||
|
{
|
||||||
|
int rc = SEPOL_ERR;
|
||||||
|
symtab_t *symtab = NULL;
|
||||||
|
- struct cil_symtab_datum *prev;
|
||||||
|
+ struct cil_symtab_datum *prev = NULL;
|
||||||
|
|
||||||
|
rc = __cil_verify_name((const char*)key);
|
||||||
|
if (rc != SEPOL_OK) {
|
||||||
|
@@ -133,13 +133,20 @@ int cil_gen_node(struct cil_db *db, struct cil_tree_node *ast_node, struct cil_s
|
||||||
|
/* multiple_decls not ok, ret error */
|
||||||
|
cil_log(CIL_ERR, "Re-declaration of %s %s\n",
|
||||||
|
cil_node_to_string(ast_node), key);
|
||||||
|
- if (cil_symtab_get_datum(symtab, key, &datum) == SEPOL_OK) {
|
||||||
|
+ if (cil_symtab_get_datum(symtab, key, &prev) == SEPOL_OK) {
|
||||||
|
if (sflavor == CIL_SYM_BLOCKS) {
|
||||||
|
- struct cil_tree_node *node = datum->nodes->head->data;
|
||||||
|
+ struct cil_tree_node *node = prev->nodes->head->data;
|
||||||
|
cil_tree_log(node, CIL_ERR, "Previous declaration");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- goto exit;
|
||||||
|
+ if(
|
||||||
|
+ strcmp(key, "sysfs_usb_supply") == 0 ||
|
||||||
|
+ strcmp(key, "hostapd") == 0 ||
|
||||||
|
+ strcmp(key, "rpmb_device") == 0) {
|
||||||
|
+ cil_log(CIL_ERR, "Ignoring...");
|
||||||
|
+ } else {
|
||||||
|
+ goto exit;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
/* multiple_decls is enabled and works for this datum type, add node */
|
||||||
|
cil_list_append(prev->nodes, CIL_NODE, ast_node);
|
||||||
|
@@ -572,7 +579,7 @@ int cil_gen_perm_nodes(struct cil_db *db, struct cil_tree_node *current_perm, st
|
||||||
|
|
||||||
|
while(current_perm != NULL) {
|
||||||
|
if (current_perm->cl_head != NULL) {
|
||||||
|
-
|
||||||
|
+
|
||||||
|
rc = SEPOL_ERR;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
@@ -5717,7 +5724,7 @@ int cil_fill_ipaddr(struct cil_tree_node *addr_node, struct cil_ipaddr *addr)
|
||||||
|
return SEPOL_OK;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
- cil_log(CIL_ERR, "Bad ip address or netmask\n");
|
||||||
|
+ cil_log(CIL_ERR, "Bad ip address or netmask\n");
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
|
||||||
|
index e72abdeb..db3f24f4 100644
|
||||||
|
--- a/libsepol/cil/src/cil_resolve_ast.c
|
||||||
|
+++ b/libsepol/cil/src/cil_resolve_ast.c
|
||||||
|
@@ -512,7 +512,13 @@ int cil_resolve_aliasactual(struct cil_tree_node *current, void *extra_args, enu
|
||||||
|
}
|
||||||
|
if (NODE(alias_datum)->flavor != alias_flavor) {
|
||||||
|
cil_log(CIL_ERR, "%s is not an alias\n",alias_datum->name);
|
||||||
|
- rc = SEPOL_ERR;
|
||||||
|
+ if(
|
||||||
|
+ strcmp(alias_datum->name, "hostapd") == 0 ||
|
||||||
|
+ strcmp(alias_datum->name, "sysfs_usb_supply") == 0 ||
|
||||||
|
+ strcmp(alias_datum->name, "rpmb_device") == 0)
|
||||||
|
+ rc = 0;
|
||||||
|
+ else
|
||||||
|
+ rc = SEPOL_ERR;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -553,7 +559,12 @@ int cil_resolve_alias_to_actual(struct cil_tree_node *current, enum cil_flavor f
|
||||||
|
int limit = 2;
|
||||||
|
|
||||||
|
if (alias->actual == NULL) {
|
||||||
|
- cil_tree_log(current, CIL_ERR, "Alias declared but not used");
|
||||||
|
+ cil_tree_log(current, CIL_ERR, "Alias %s declared but not used", a1->datum.name);
|
||||||
|
+ if(
|
||||||
|
+ strcmp(a1->datum.name, "hostapd") == 0 ||
|
||||||
|
+ strcmp(a1->datum.name, "sysfs_usb_supply") == 0 ||
|
||||||
|
+ strcmp(a1->datum.name, "rpmb_device") == 0)
|
||||||
|
+ return SEPOL_OK;
|
||||||
|
return SEPOL_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
From 9a240b125c01838dcd7be395354cd8d740b0923b Mon Sep 17 00:00:00 2001
|
|
||||||
From: Taehwan Kim <t_h.kim@samsung.com>
|
|
||||||
Date: Thu, 26 Nov 2020 22:40:40 +0900
|
|
||||||
Subject: [PATCH 30/30] CCodec: GraphicBufferSourceWrapper: fix to apply
|
|
||||||
nBufferCountActual for deciding number of inputs
|
|
||||||
|
|
||||||
Bug: 169398817
|
|
||||||
|
|
||||||
Change-Id: I58cd7da35a3ddc4abdb58df954307acf329c7ee7
|
|
||||||
Signed-off-by: Taehwan Kim <t_h.kim@samsung.com>
|
|
||||||
(cherry picked from commit 8b3bcddbc98af38d64a1ffefd5932b498f9d4c36)
|
|
||||||
---
|
|
||||||
media/codec2/sfplugin/CCodec.cpp | 15 +++++++++++++--
|
|
||||||
1 file changed, 13 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
|
|
||||||
index 54107bd852..2f16ca1104 100644
|
|
||||||
--- a/media/codec2/sfplugin/CCodec.cpp
|
|
||||||
+++ b/media/codec2/sfplugin/CCodec.cpp
|
|
||||||
@@ -246,8 +246,19 @@ public:
|
|
||||||
if (source == nullptr) {
|
|
||||||
return NO_INIT;
|
|
||||||
}
|
|
||||||
- constexpr size_t kNumSlots = 16;
|
|
||||||
- for (size_t i = 0; i < kNumSlots; ++i) {
|
|
||||||
+
|
|
||||||
+ size_t numSlots = 4;
|
|
||||||
+ constexpr OMX_U32 kPortIndexInput = 0;
|
|
||||||
+
|
|
||||||
+ OMX_PARAM_PORTDEFINITIONTYPE param;
|
|
||||||
+ param.nPortIndex = kPortIndexInput;
|
|
||||||
+ status_t err = mNode->getParameter(OMX_IndexParamPortDefinition,
|
|
||||||
+ ¶m, sizeof(param));
|
|
||||||
+ if (err == OK) {
|
|
||||||
+ numSlots = param.nBufferCountActual;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for (size_t i = 0; i < numSlots; ++i) {
|
|
||||||
source->onInputBufferAdded(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.25.1
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
|||||||
|
From ecab6fe48819adeafaceec1a33e7e1d380caec75 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Sat, 13 Mar 2021 14:20:03 -0500
|
||||||
|
Subject: [PATCH 33/38] Support Samsung R multi-cams
|
||||||
|
|
||||||
|
---
|
||||||
|
services/camera/libcameraservice/Android.bp | 1 +
|
||||||
|
.../libcameraservice/common/CameraProviderManager.cpp | 8 +++++++-
|
||||||
|
2 files changed, 8 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp
|
||||||
|
index be275e9346..bede98bfdc 100644
|
||||||
|
--- a/services/camera/libcameraservice/Android.bp
|
||||||
|
+++ b/services/camera/libcameraservice/Android.bp
|
||||||
|
@@ -129,6 +129,7 @@ cc_library_shared {
|
||||||
|
"android.hardware.camera.device@3.5",
|
||||||
|
"android.hardware.camera.device@3.6",
|
||||||
|
"vendor.samsung.hardware.camera.provider@3.0",
|
||||||
|
+ "vendor.samsung.hardware.camera.provider@4.0",
|
||||||
|
],
|
||||||
|
|
||||||
|
static_libs: [
|
||||||
|
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
|
||||||
|
index 3e6ad1ef52..b7d1a57567 100644
|
||||||
|
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
|
||||||
|
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
|
||||||
|
@@ -22,6 +22,7 @@
|
||||||
|
|
||||||
|
#include <android/hardware/camera/device/3.5/ICameraDevice.h>
|
||||||
|
#include <vendor/samsung/hardware/camera/provider/3.0/ISehCameraProvider.h>
|
||||||
|
+#include <vendor/samsung/hardware/camera/provider/4.0/ISehCameraProvider.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
@@ -1363,7 +1364,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
|
||||||
|
}
|
||||||
|
|
||||||
|
auto samsungCast = vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider::castFrom(interface);
|
||||||
|
+ auto samsung40Cast = vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider::castFrom(interface);
|
||||||
|
auto samsungProvider = samsungCast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider>>(samsungCast) : nullptr;
|
||||||
|
+ auto samsung40Provider = samsung40Cast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider>>(samsung40Cast) : nullptr;
|
||||||
|
|
||||||
|
hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
|
||||||
|
if (!linked.isOk()) {
|
||||||
|
@@ -1401,6 +1404,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
|
||||||
|
status = idStatus;
|
||||||
|
if (status == Status::OK) {
|
||||||
|
for (auto& name : cameraDeviceNames) {
|
||||||
|
+ ALOGE("Listing camera ID %s", name.c_str());
|
||||||
|
uint16_t major, minor;
|
||||||
|
std::string type, id;
|
||||||
|
status_t res = parseDeviceName(name, &major, &minor, &type, &id);
|
||||||
|
@@ -1414,7 +1418,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
|
||||||
|
}
|
||||||
|
} };
|
||||||
|
hardware::Return<void> ret;
|
||||||
|
- if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
|
||||||
|
+ if(samsung40Provider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
|
||||||
|
+ ret = samsung40Provider->sehGetCameraIdList(cb);
|
||||||
|
+ else if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
|
||||||
|
ret = samsungProvider->sehGetCameraIdList(cb);
|
||||||
|
else
|
||||||
|
ret = interface->getCameraIdList(cb);
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
From 347755b3b0d26b557ac0775433ccdbabe23ac6ed Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Tue, 23 Mar 2021 00:16:42 +0100
|
||||||
|
Subject: [PATCH 34/38] [audiopolicy] Don't crash on unknown audio devices
|
||||||
|
|
||||||
|
---
|
||||||
|
.../common/managerdefinitions/src/Serializer.cpp | 7 ++++++-
|
||||||
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
||||||
|
index 73e4a3e096..1f200ad850 100644
|
||||||
|
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
||||||
|
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
||||||
|
@@ -951,7 +951,12 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
|
||||||
|
sp<DeviceDescriptor> device = module->getDeclaredDevices().
|
||||||
|
getDeviceFromTagName(std::string(reinterpret_cast<const char*>(
|
||||||
|
attachedDevice.get())));
|
||||||
|
- ctx->addDevice(device);
|
||||||
|
+ if(device != nullptr) {
|
||||||
|
+ ctx->addDevice(device);
|
||||||
|
+ } else {
|
||||||
|
+ ALOGE("NULL DEVICE %s: %s %s=%s", __func__, tag, childAttachedDeviceTag,
|
||||||
|
+ reinterpret_cast<const char*>(attachedDevice.get()));
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -0,0 +1,99 @@
|
|||||||
|
From 0b8723c62a0d5b63f8afd46fddc3c38123b49d04 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Peter Cai <peter@typeblog.net>
|
||||||
|
Date: Sun, 28 Mar 2021 16:17:36 +0800
|
||||||
|
Subject: [PATCH 35/38] AudioPolicyManager: retry with SW bridge if hardware
|
||||||
|
audio patch fails
|
||||||
|
|
||||||
|
* On two of my MT6771 Q vendor devices, in-call audio is broken due to
|
||||||
|
the audio HAL claiming to support HW audio patch between the Rx / Tx
|
||||||
|
devices but failing when called with `createAudioPatch`.
|
||||||
|
|
||||||
|
> 03-28 11:56:42.300 1345 1345 W AudioALSAHardware: sinks[0].type ==
|
||||||
|
AUDIO_PORT_TYPE_DEVICE
|
||||||
|
> 03-28 11:56:42.300 1345 1345 W AudioALSAHardware: [createAudioPatch]
|
||||||
|
[5082]
|
||||||
|
> 03-28 11:56:42.300 1345 1345 E AudioALSAHardware: Fail status -38
|
||||||
|
> 03-28 11:56:42.300 1345 1345 W DeviceHAL: Error from HAL Device in
|
||||||
|
function create_audio_patch: Function not implemented
|
||||||
|
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
|
||||||
|
createAudioPatchInternal patch panel could not connect device patch,
|
||||||
|
error -38
|
||||||
|
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
|
||||||
|
createTelephonyPatch() error -38 creating RX audio patch
|
||||||
|
|
||||||
|
* This was not broken on Q because
|
||||||
|
`AudioPolicyManager::updateCallRouting` bypasses `createAudioPatch` by
|
||||||
|
directly calling the legacy `setOutputDevice` when `supportsPatch` is
|
||||||
|
true, i.e. `createAudioPatch` was *only* used for SW bridge for
|
||||||
|
in-call audio before R.
|
||||||
|
|
||||||
|
* As a workaround, re-try by forcing the creation of a SW bridge after
|
||||||
|
`createAudioPatch` fails. We could also restore the old behavior of
|
||||||
|
`updateCallRouting`, but that would probably break in-call audio on
|
||||||
|
newer HALs that may or may not work properly with `setOutputDevice`.
|
||||||
|
---
|
||||||
|
.../managerdefault/AudioPolicyManager.cpp | 13 ++++++++++---
|
||||||
|
.../audiopolicy/managerdefault/AudioPolicyManager.h | 4 +++-
|
||||||
|
2 files changed, 13 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
||||||
|
index 63dcd538b1..6d2c38811e 100644
|
||||||
|
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
||||||
|
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
|
||||||
|
@@ -3490,7 +3490,8 @@ status_t AudioPolicyManager::getAudioPort(struct audio_port *port)
|
||||||
|
status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *patch,
|
||||||
|
audio_patch_handle_t *handle,
|
||||||
|
uid_t uid, uint32_t delayMs,
|
||||||
|
- const sp<SourceClientDescriptor>& sourceDesc)
|
||||||
|
+ const sp<SourceClientDescriptor>& sourceDesc,
|
||||||
|
+ bool forceSwBridge)
|
||||||
|
{
|
||||||
|
ALOGV("%s", __func__);
|
||||||
|
if (handle == NULL || patch == NULL) {
|
||||||
|
@@ -3694,7 +3695,8 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
|
||||||
|
// - audio HAL version is >= 3.0 but no route has been declared between devices
|
||||||
|
// - called from startAudioSource (aka sourceDesc != nullptr) and source device does
|
||||||
|
// not have a gain controller
|
||||||
|
- if (!srcDevice->hasSameHwModuleAs(sinkDevice) ||
|
||||||
|
+ // - a previous attempt at using HW bridge failed (forceSwBridge)
|
||||||
|
+ if (forceSwBridge || !srcDevice->hasSameHwModuleAs(sinkDevice) ||
|
||||||
|
(srcDevice->getModuleVersionMajor() < 3) ||
|
||||||
|
!srcDevice->getModule()->supportsPatch(srcDevice, sinkDevice) ||
|
||||||
|
(sourceDesc != nullptr &&
|
||||||
|
@@ -3759,7 +3761,12 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
|
||||||
|
__func__, index, handle, patchBuilder.patch(), delayMs, uid, &patchDesc);
|
||||||
|
if (status != NO_ERROR) {
|
||||||
|
ALOGW("%s patch panel could not connect device patch, error %d", __func__, status);
|
||||||
|
- return INVALID_OPERATION;
|
||||||
|
+ if (forceSwBridge || patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE) {
|
||||||
|
+ return INVALID_OPERATION;
|
||||||
|
+ } else {
|
||||||
|
+ ALOGW("Retrying with software bridging.");
|
||||||
|
+ return createAudioPatchInternal(patch, handle, uid, delayMs, sourceDesc, true);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BAD_VALUE;
|
||||||
|
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
|
||||||
|
index b588f898d4..60cbd7175e 100644
|
||||||
|
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
|
||||||
|
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
|
||||||
|
@@ -910,12 +910,14 @@ private:
|
||||||
|
* @param[in] delayMs if required
|
||||||
|
* @param[in] sourceDesc [optional] in case of external source, source client to be
|
||||||
|
* configured by the patch, i.e. assigning an Output (HW or SW)
|
||||||
|
+ * @param[in] forceSwBridge [optional] force the creation of a SW bridge (internal use only)
|
||||||
|
* @return NO_ERROR if patch installed correctly, error code otherwise.
|
||||||
|
*/
|
||||||
|
status_t createAudioPatchInternal(const struct audio_patch *patch,
|
||||||
|
audio_patch_handle_t *handle,
|
||||||
|
uid_t uid, uint32_t delayMs = 0,
|
||||||
|
- const sp<SourceClientDescriptor>& sourceDesc = nullptr);
|
||||||
|
+ const sp<SourceClientDescriptor>& sourceDesc = nullptr,
|
||||||
|
+ bool forceSwBridge = false);
|
||||||
|
/**
|
||||||
|
* @brief releaseAudioPatchInternal internal function to remove an audio patch
|
||||||
|
* @param[in] handle of the patch to be removed
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
From c8a6af6fd0f3134b96fc291910cfc0380bc0dc31 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Sun, 28 Mar 2021 14:47:52 +0200
|
||||||
|
Subject: [PATCH 36/38] Reenable STRATEGY_ROUTING. This is a leftover of tries
|
||||||
|
of 587b198, wrongly commited in 20f869
|
||||||
|
|
||||||
|
---
|
||||||
|
services/audiopolicy/enginedefault/src/Engine.cpp | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
|
||||||
|
index 16a7a4bbac..b14d2bbb0b 100755
|
||||||
|
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
|
||||||
|
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
|
||||||
|
@@ -52,7 +52,7 @@ static const std::vector<legacy_strategy_map>& getLegacyStrategy() {
|
||||||
|
{ "STRATEGY_ENFORCED_AUDIBLE", STRATEGY_ENFORCED_AUDIBLE },
|
||||||
|
{ "STRATEGY_TRANSMITTED_THROUGH_SPEAKER", STRATEGY_TRANSMITTED_THROUGH_SPEAKER },
|
||||||
|
{ "STRATEGY_ACCESSIBILITY", STRATEGY_ACCESSIBILITY },
|
||||||
|
- //{ "STRATEGY_REROUTING", STRATEGY_REROUTING },
|
||||||
|
+ { "STRATEGY_REROUTING", STRATEGY_REROUTING },
|
||||||
|
{ "STRATEGY_PATCH", STRATEGY_REROUTING }, // boiler to manage stream patch volume
|
||||||
|
{ "STRATEGY_CALL_ASSISTANT", STRATEGY_CALL_ASSISTANT },
|
||||||
|
};
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
From c3bd3dc63c34de7c688b24999769f7eb504784a3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Sun, 28 Mar 2021 14:48:49 +0200
|
||||||
|
Subject: [PATCH 37/38] Use a fake volume policy when none has been found
|
||||||
|
|
||||||
|
This is useful, because on Samsung devices, the "real"
|
||||||
|
(=non-gsi-cheating) audio policy doesn't have any volume policy.
|
||||||
|
|
||||||
|
This requires actually adding the fake audio policy xml file (done in
|
||||||
|
device/phh/treble)
|
||||||
|
---
|
||||||
|
services/audiopolicy/engine/config/src/EngineConfig.cpp | 8 +++++++-
|
||||||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/services/audiopolicy/engine/config/src/EngineConfig.cpp b/services/audiopolicy/engine/config/src/EngineConfig.cpp
|
||||||
|
index 4842cb282f..e8d6917754 100644
|
||||||
|
--- a/services/audiopolicy/engine/config/src/EngineConfig.cpp
|
||||||
|
+++ b/services/audiopolicy/engine/config/src/EngineConfig.cpp
|
||||||
|
@@ -717,11 +717,17 @@ android::status_t parseLegacyVolumes(VolumeGroups &volumeGroups) {
|
||||||
|
snprintf(audioPolicyXmlConfigFile, sizeof(audioPolicyXmlConfigFile),
|
||||||
|
"%s/%s", path.c_str(), fileName);
|
||||||
|
ret = parseLegacyVolumeFile(audioPolicyXmlConfigFile, volumeGroups);
|
||||||
|
- if (ret == NO_ERROR) {
|
||||||
|
+ ALOGE("Parsing volume for %s gave %zu", audioPolicyXmlConfigFile, volumeGroups.size());
|
||||||
|
+ if (ret == NO_ERROR && volumeGroups.size() > 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ ret = parseLegacyVolumeFile("/system/etc/fake_audio_policy_volume.xml", volumeGroups);
|
||||||
|
+ ALOGE("Parsing volume for /system/etc/fake_audio_policy_volume.xml gave %zu", volumeGroups.size());
|
||||||
|
+ if (ret == NO_ERROR && volumeGroups.size() == 0) {
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
return BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
From 23f277e7a6afee9d256582204099c4c645606b98 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Sun, 28 Mar 2021 18:54:47 +0200
|
||||||
|
Subject: [PATCH 38/38] Not all sources in a route are valid. Dont ignore the
|
||||||
|
whole route because of one broken source
|
||||||
|
|
||||||
|
---
|
||||||
|
.../audiopolicy/common/managerdefinitions/src/Serializer.cpp | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
||||||
|
index 1f200ad850..e57bd24724 100644
|
||||||
|
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
||||||
|
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
|
||||||
|
@@ -609,10 +609,11 @@ Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSer
|
||||||
|
source = ctx->findPortByTagName(trim(devTag));
|
||||||
|
if (source == NULL) {
|
||||||
|
ALOGE("%s: no source found with name=%s", __func__, devTag);
|
||||||
|
- return Status::fromStatusT(BAD_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- sources.add(source);
|
||||||
|
+ if(source != nullptr) {
|
||||||
|
+ sources.add(source);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
devTag = strtok(NULL, ",");
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
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>
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
Date: Sun, 24 Mar 2019 23:05:14 +0100
|
Date: Sun, 24 Mar 2019 23:05:14 +0100
|
||||||
Subject: [PATCH] Support new samsung Pie and Q light hal and Samsung Power
|
Subject: [PATCH] Support new samsung Pie and Q light hal and Samsung Power
|
||||||
HALs
|
HALs
|
||||||
|
|
||||||
|
Change-Id: I37dc7af3fbc6f9bfa2a4822d4dfba817e803945e
|
||||||
---
|
---
|
||||||
services/core/jni/Android.bp | 3 ++
|
services/core/jni/Android.bp | 3 ++
|
||||||
...om_android_server_lights_LightsService.cpp | 51 +++++++++++++++++++
|
...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(+)
|
3 files changed, 76 insertions(+)
|
||||||
|
|
||||||
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
|
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
|
--- a/services/core/jni/Android.bp
|
||||||
+++ b/services/core/jni/Android.bp
|
+++ b/services/core/jni/Android.bp
|
||||||
@@ -167,6 +167,9 @@ cc_defaults {
|
@@ -169,6 +169,9 @@ cc_defaults {
|
||||||
"service.incremental",
|
|
||||||
"suspend_control_aidl_interface-cpp",
|
"suspend_control_aidl_interface-cpp",
|
||||||
"vendor.lineage.power@1.0",
|
"vendor.lineage.power@1.0",
|
||||||
|
"vendor.lineage.power-cpp",
|
||||||
+ "vendor.samsung.hardware.miscpower@2.0",
|
+ "vendor.samsung.hardware.miscpower@2.0",
|
||||||
+ "vendor.samsung.hardware.light@2.0",
|
+ "vendor.samsung.hardware.light@2.0",
|
||||||
+ "vendor.samsung.hardware.light@3.0",
|
+ "vendor.samsung.hardware.light@3.0",
|
||||||
@ -103,7 +104,7 @@ index 35d8219651d..b45b2137d0e 100644
|
|||||||
LightState state = constructState(
|
LightState state = constructState(
|
||||||
colorARGB, flashMode, onMS, offMS, brightnessMode);
|
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
|
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
|
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||||
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||||
@@ -24,6 +24,7 @@
|
@@ -24,6 +24,7 @@
|
||||||
@ -113,25 +114,25 @@ index 33b3bad2b33..47fdcc9a87b 100644
|
|||||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
||||||
#include <nativehelper/JNIHelp.h>
|
#include <nativehelper/JNIHelp.h>
|
||||||
#include <vendor/lineage/power/1.0/ILineagePower.h>
|
#include <vendor/lineage/power/1.0/ILineagePower.h>
|
||||||
#include "jni.h"
|
#include <vendor/lineage/power/IPower.h>
|
||||||
@@ -64,6 +65,7 @@ using IPowerV1_0 = android::hardware::power::V1_0::IPower;
|
@@ -69,6 +70,7 @@ using LineageBoostAidl = vendor::lineage::power::Boost;
|
||||||
using IPowerAidl = android::hardware::power::IPower;
|
using LineageFeatureV1_0 = vendor::lineage::power::V1_0::LineageFeature;
|
||||||
using ILineagePowerV1_0 = vendor::lineage::power::V1_0::ILineagePower;
|
using LineageFeatureAidl = vendor::lineage::power::Feature;
|
||||||
using vendor::lineage::power::V1_0::LineageFeature;
|
using LineagePowerHint1_0 = vendor::lineage::power::V1_0::LineagePowerHint;
|
||||||
+using ISehMiscPower = vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower;
|
+using ISehMiscPower = vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower;
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
@@ -80,6 +82,8 @@ static sp<IPowerV1_0> gPowerHalHidlV1_0_ = nullptr;
|
@@ -86,6 +88,8 @@ static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
|
||||||
static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
|
|
||||||
static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
||||||
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
||||||
|
static sp<ILineagePowerAidl> gLineagePowerHalAidl_ = nullptr;
|
||||||
+static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
+static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
||||||
+static bool gPowerHalExists = true;
|
+static bool gPowerHalExists = true;
|
||||||
static std::mutex gPowerHalMutex;
|
static std::mutex gPowerHalMutex;
|
||||||
|
static std::mutex gLineagePowerHalMutex;
|
||||||
|
|
||||||
enum class HalVersion {
|
@@ -132,6 +136,10 @@ static HalVersion connectPowerHalLocked() {
|
||||||
@@ -125,6 +129,10 @@ static HalVersion connectPowerHalLocked() {
|
|
||||||
gPowerHalAidlExists = false;
|
gPowerHalAidlExists = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,8 +143,8 @@ index 33b3bad2b33..47fdcc9a87b 100644
|
|||||||
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||||
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
||||||
if (gPowerHalHidlV1_0_) {
|
if (gPowerHalHidlV1_0_) {
|
||||||
@@ -163,6 +171,12 @@ void connectLineagePowerHalLocked() {
|
@@ -190,6 +198,12 @@ static HalVersion connectLineagePowerHalLocked() {
|
||||||
}
|
return HalVersion::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
+sp<ISehMiscPower> getSehMiscPower() {
|
+sp<ISehMiscPower> getSehMiscPower() {
|
||||||
@ -155,7 +156,7 @@ index 33b3bad2b33..47fdcc9a87b 100644
|
|||||||
// Retrieve a copy of PowerHAL HIDL V1_0
|
// Retrieve a copy of PowerHAL HIDL V1_0
|
||||||
sp<IPowerV1_0> getPowerHalHidlV1_0() {
|
sp<IPowerV1_0> getPowerHalHidlV1_0() {
|
||||||
std::lock_guard<std::mutex> lock(gPowerHalMutex);
|
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;
|
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>
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
Date: Sun, 6 Dec 2020 12:20:08 +0100
|
Date: Sun, 6 Dec 2020 12:20:08 +0100
|
||||||
Subject: [PATCH] Make rounded corners padding overridable with
|
Subject: [PATCH] Make rounded corners padding overridable with
|
||||||
@ -6,12 +6,10 @@ Subject: [PATCH] Make rounded corners padding overridable with
|
|||||||
|
|
||||||
Change-Id: Id5d73b06b9a2cb2da95ff31f204c1984555872ff
|
Change-Id: Id5d73b06b9a2cb2da95ff31f204c1984555872ff
|
||||||
---
|
---
|
||||||
.../systemui/qs/QuickStatusBarHeader.java | 6 +-
|
.../src/com/android/systemui/qs/QuickStatusBarHeader.java | 6 +++++-
|
||||||
.../phone/KeyguardStatusBarView.java | 6 +-
|
.../systemui/statusbar/phone/KeyguardStatusBarView.java | 6 +++++-
|
||||||
.../statusbar/phone/PhoneStatusBarView.java | 6 +-
|
.../systemui/statusbar/phone/PhoneStatusBarView.java | 6 +++++-
|
||||||
..._server_power_PowerManagerService.cpp.orig | 641 ++++++++++++++++++
|
3 files changed, 15 insertions(+), 3 deletions(-)
|
||||||
4 files changed, 656 insertions(+), 3 deletions(-)
|
|
||||||
create mode 100644 services/core/jni/com_android_server_power_PowerManagerService.cpp.orig
|
|
||||||
|
|
||||||
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
|
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
|
index 7533f2ac1db..94fd996d085 100644
|
||||||
@ -88,653 +86,6 @@ index 1c6c7db6a69..f0e5c7bb3d2 100644
|
|||||||
|
|
||||||
updateStatusBarHeight();
|
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
|
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>
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
Date: Fri, 18 Dec 2020 16:38:58 -0500
|
Date: Fri, 18 Dec 2020 16:38:58 -0500
|
||||||
Subject: [PATCH] Fix Samsung Power HAL (switch/case was filled with
|
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(-)
|
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
|
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
|
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||||
+++ b/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;
|
@@ -89,7 +89,6 @@ static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
||||||
static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
|
|
||||||
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
|
||||||
|
static sp<ILineagePowerAidl> gLineagePowerHalAidl_ = nullptr;
|
||||||
static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
static sp<ISehMiscPower> gSehMiscPower = nullptr;
|
||||||
-static bool gPowerHalExists = true;
|
-static bool gPowerHalExists = true;
|
||||||
static std::mutex gPowerHalMutex;
|
static std::mutex gPowerHalMutex;
|
||||||
|
static std::mutex gLineagePowerHalMutex;
|
||||||
|
|
||||||
enum class HalVersion {
|
@@ -136,9 +135,11 @@ static HalVersion connectPowerHalLocked() {
|
||||||
@@ -129,9 +128,11 @@ static HalVersion connectPowerHalLocked() {
|
|
||||||
gPowerHalAidlExists = false;
|
gPowerHalAidlExists = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ index 47fdcc9a87b..ed7d311ab9f 100644
|
|||||||
}
|
}
|
||||||
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
|
||||||
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
|
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) {
|
static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
|
||||||
std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
std::unique_lock<std::mutex> lock(gPowerHalMutex);
|
||||||
@ -52,7 +52,7 @@ index 47fdcc9a87b..ed7d311ab9f 100644
|
|||||||
case HalVersion::NONE:
|
case HalVersion::NONE:
|
||||||
return;
|
return;
|
||||||
case HalVersion::HIDL_1_0:
|
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;
|
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
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
From 862798495297d8cb0d02951d533644929570ae1f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Wed, 31 Mar 2021 23:36:03 +0200
|
||||||
|
Subject: [PATCH 14/14] Remove Samsung system permission on sensors
|
||||||
|
|
||||||
|
---
|
||||||
|
libs/sensor/Sensor.cpp | 1 +
|
||||||
|
libs/sensor/include/sensor/Sensor.h | 1 +
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/libs/sensor/Sensor.cpp b/libs/sensor/Sensor.cpp
|
||||||
|
index 9d817ae0b..aeae0589d 100644
|
||||||
|
--- a/libs/sensor/Sensor.cpp
|
||||||
|
+++ b/libs/sensor/Sensor.cpp
|
||||||
|
@@ -405,6 +405,7 @@ const String8& Sensor::getStringType() const {
|
||||||
|
}
|
||||||
|
|
||||||
|
const String8& Sensor::getRequiredPermission() const {
|
||||||
|
+ if (mRequiredPermission == "com.samsung.permission.SSENSOR") return mFakeRequiredPermission;
|
||||||
|
return mRequiredPermission;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/libs/sensor/include/sensor/Sensor.h b/libs/sensor/include/sensor/Sensor.h
|
||||||
|
index 324d44310..2d4446767 100644
|
||||||
|
--- a/libs/sensor/include/sensor/Sensor.h
|
||||||
|
+++ b/libs/sensor/include/sensor/Sensor.h
|
||||||
|
@@ -125,6 +125,7 @@ private:
|
||||||
|
uint32_t mFifoMaxEventCount;
|
||||||
|
String8 mStringType;
|
||||||
|
String8 mRequiredPermission;
|
||||||
|
+ String8 mFakeRequiredPermission;
|
||||||
|
bool mRequiredPermissionRuntime = false;
|
||||||
|
int32_t mRequiredAppOp;
|
||||||
|
int32_t mMaxDelay;
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
From aa8436c122f42c043bfd709f5aedbe7dcc3f7e9c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Danny Trunk <dtrunk90@gmail.com>
|
||||||
|
Date: Mon, 7 Sep 2020 16:44:24 +0200
|
||||||
|
Subject: [PATCH 4/4] Changed HID_DEV_MTU_SIZE from 64 to 512
|
||||||
|
|
||||||
|
Changed HID_DEV_MTU_SIZE for Amiibo Backups over Bluetooth support
|
||||||
|
|
||||||
|
Signed-off-by: Danny Trunk <dtrunk90@gmail.com>
|
||||||
|
Change-Id: Ie4226b477d040177108729cb25e711fd35bfe0f2
|
||||||
|
---
|
||||||
|
internal_include/bt_target.h | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/internal_include/bt_target.h b/internal_include/bt_target.h
|
||||||
|
index 57bd69e9f..389acda68 100644
|
||||||
|
--- a/internal_include/bt_target.h
|
||||||
|
+++ b/internal_include/bt_target.h
|
||||||
|
@@ -1143,7 +1143,7 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HID_DEV_MTU_SIZE
|
||||||
|
-#define HID_DEV_MTU_SIZE 64
|
||||||
|
+#define HID_DEV_MTU_SIZE 512
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HID_DEV_FLUSH_TO
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user