400 changed files with 144661 additions and 7166 deletions
+1
View File
@@ -0,0 +1 @@
/patches_treble_personal/vendor_hardware_overlay
@@ -1,36 +0,0 @@
From e3c7e720c893a6ecef90b4b950787ed820792581 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 12:54:23 +0200
Subject: [PATCH 1/2] Use vndk_lite ld.config only on same-version vendor
When running Q over P lite, there is currently absolutely no chance the
device boots, because it will be using Q vndk.
Thus using ld.config.28.txt when running Q over P lite gives a little more
chance for the device to boot, than when using vndk_lite ld.config.
Also, once this patch is applied, the required effort to boot
Q over P lite is exclusively in vndk, which is manageable.
Change-Id: I55257cd7c738b1d20582e198e1d5621e1c87a03e
---
linker/linker.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index f24167722..a82d7c430 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3372,7 +3372,10 @@ static std::string get_ld_config_file_apex_path(const char* executable_path) {
}
static std::string get_ld_config_file_vndk_path() {
- if (android::base::GetBoolProperty("ro.vndk.lite", false)) {
+ bool same_version_system_vendor = false;
+ if(std::to_string(__ANDROID_API__) == Config::get_vndk_version_string('.'))
+ same_version_system_vendor = true;
+ if (android::base::GetBoolProperty("ro.vndk.lite", false) && same_version_system_vendor) {
return kLdConfigVndkLiteFilePath;
}
--
2.17.1
@@ -1,27 +0,0 @@
From ddbe45ddd09f30beab8980d14c506f48ca1f8399 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 2 Mar 2018 22:49:55 +0100
Subject: [PATCH 01/10] Enable multipl_decls by default. This is needed because
8.0 init doesn't add -m
Change-Id: I43dc661d519f7b8576d72a828d8cbd444592bf5e
---
secilc/secilc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 186c5a73..b422175e 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
int target = SEPOL_TARGET_SELINUX;
int mls = -1;
int disable_dontaudit = 0;
- int multiple_decls = 0;
+ int multiple_decls = 1;
int disable_neverallow = 0;
int preserve_tunables = 0;
int handle_unknown = -1;
--
2.17.1
@@ -1,40 +0,0 @@
From ecb4746fb8ba4e97cc53e6290dfa7a75495d19a8 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 3 Dec 2018 20:54:54 +0100
Subject: [PATCH 03/10] ::Kirin:: Workaround some conflicting Kirin tether
SELinux context
Some Kirin devices declared some android.hardware.tetheroffload HALs,
but they didn't use AOSP contexts.
This leads to libselinux aborting when loading hwservice_contexts.
Workaround it the ugly way, by making them match.
This most likely kills tetheroffload for those devices.
---
libselinux/src/label_backends_android.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libselinux/src/label_backends_android.c b/libselinux/src/label_backends_android.c
index eaca5947..ab92985b 100644
--- a/libselinux/src/label_backends_android.c
+++ b/libselinux/src/label_backends_android.c
@@ -62,6 +62,16 @@ static int nodups_specs(struct saved_data *data)
curr_spec->property_key)) {
if (strcmp(spec_arr[jj].lr.ctx_raw,
curr_spec->lr.ctx_raw)) {
+ if(strcmp(spec_arr[jj].lr.ctx_raw, "u:object_r:hal_ipacm_hwservice:s0") == 0) {
+ free(spec_arr[jj].lr.ctx_raw);
+ spec_arr[jj].lr.ctx_raw = strdup("u:object_r:hal_tetheroffload_hwservice:s0");
+ continue;
+ }
+ if(strcmp(curr_spec->lr.ctx_raw, "u:object_r:hal_ipacm_hwservice:s0") == 0) {
+ free(curr_spec->lr.ctx_raw);
+ curr_spec->lr.ctx_raw = strdup("u:object_r:hal_tetheroffload_hwservice:s0");
+ continue;
+ }
rc = -1;
errno = EINVAL;
selinux_log
--
2.17.1
@@ -1,44 +0,0 @@
From 37d5e860031c84803c2533d940847dc214cb2597 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 20:34:28 +0200
Subject: [PATCH 05/10] Most horrific: Remove ramdisk's zygote init scripts
This is needed because:
- only secilc is run soon enough in /system to
remove it
- placing an init.zygote in system won't have init replace it, it's the
first that appears that wins
Change-Id: I8be31ceb9ef2124d04994d9fb08fc8012a2f819e
---
secilc/secilc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 1e550ab4..375320e6 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -34,6 +34,8 @@
#include <getopt.h>
#include <sys/stat.h>
+#include <unistd.h>
+
#ifdef ANDROID
#include <cil/cil.h>
#else
@@ -124,6 +126,11 @@ int main(int argc, char *argv[])
};
int i;
+ unlink("/init.zygote32.rc");
+ unlink("/init.zygote64_32.rc");
+ unlink("/init.zygote64.rc");
+ unlink("/init.zygote32_64.rc");
+
while (1) {
opt_char = getopt_long(argc, argv, "o:f:U:hvt:M:PDmNOc:GX:n", long_opts, &opt_index);
if (opt_char == -1) {
--
2.17.1
@@ -1,83 +0,0 @@
From 00f7989d79ad8e219dae29de8e8f20e4dbab008a Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 27 Sep 2020 20:20:35 +0200
Subject: [PATCH 10/10] [HACK] For System-as-System devices, init won't call us
with /system_ext sepolicy
So add system_ext sepolicy ourselves
---
secilc/secilc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 375320e6..162b87fb 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -233,6 +233,7 @@ int main(int argc, char *argv[])
usage(argv[0]);
}
}
+
if (optind >= argc) {
fprintf(stderr, "No cil files specified\n");
usage(argv[0]);
@@ -240,6 +241,11 @@ int main(int argc, char *argv[])
cil_set_log_level(log_level);
+ int needSystemExt = 1;
+ for (i = optind; i < argc; i++) {
+ if(strstr(argv[i], "system_ext")) needSystemExt = 0;
+ }
+
cil_db_init(&db);
cil_set_disable_dontaudit(db, disable_dontaudit);
cil_set_multiple_decls(db, multiple_decls);
@@ -261,6 +267,44 @@ int main(int argc, char *argv[])
}
for (i = optind; i < argc; i++) {
+ fprintf(stderr, "Hello, parsing %s\n", argv[i]);
+ if(needSystemExt && strstr(argv[i], "/etc/selinux/")) {
+ fprintf(stderr, "Hello, I'm adding system_ext to the mix!\n");
+ char *path = "/system/system_ext/etc/selinux/system_ext_sepolicy.cil";
+ file = fopen(path, "r");
+ if (!file) {
+ fprintf(stderr, "Could not open file: %s\n", path);
+ rc = SEPOL_ERR;
+ goto exit;
+ }
+ rc = stat(path, &filedata);
+ if (rc == -1) {
+ fprintf(stderr, "Could not stat file: %s\n", path);
+ rc = SEPOL_ERR;
+ goto exit;
+ }
+ file_size = filedata.st_size;
+
+ buffer = malloc(file_size);
+ rc = fread(buffer, file_size, 1, file);
+ if (rc != 1) {
+ fprintf(stderr, "Failure reading file: %s\n", path);
+ rc = SEPOL_ERR;
+ goto exit;
+ }
+ fclose(file);
+ file = NULL;
+
+ rc = cil_add_file(db, path, buffer, file_size);
+ if (rc != SEPOL_OK) {
+ fprintf(stderr, "Failure adding %s\n", path);
+ goto exit;
+ }
+
+ free(buffer);
+ buffer = NULL;
+
+ }
file = fopen(argv[i], "r");
if (!file) {
fprintf(stderr, "Could not open file: %s\n", argv[i]);
--
2.17.1
@@ -1,182 +0,0 @@
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,54 +0,0 @@
From 163f3f2b4a89df73d3ffede558d26bb0df966bbe Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Tue, 22 Sep 2020 10:38:04 +0200
Subject: [PATCH] GrGLCaps: allow ignoring vendor-supplied texture swizzle flag
* This is broken on MTK 8.1 vendor
Change-Id: I1ccae06f643f01e4ea6539e1d4e3c7df8d6e30ae
---
Android.bp | 1 +
src/gpu/gl/GrGLCaps.cpp | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/Android.bp b/Android.bp
index 122324c6ef..5ec949966a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -3,6 +3,7 @@
cc_library_static {
name: "libskia",
host_supported: true,
+ shared_libs: [ "libbase" ],
cflags: [
"-U_FORTIFY_SOURCE",
"-DATRACE_TAG=ATRACE_TAG_VIEW",
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 6a1bf56474..df007ba70c 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -22,6 +22,11 @@
#include "src/gpu/gl/GrGLTexture.h"
#include "src/utils/SkJSONWriter.h"
+#if defined(SK_BUILD_FOR_ANDROID)
+#include "android-base/properties.h"
+using android::base::GetBoolProperty;
+#endif
+
GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
const GrGLContextInfo& ctxInfo,
const GrGLInterface* glInterface) : INHERITED(contextOptions) {
@@ -273,6 +278,9 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
this->fShaderCaps->fTextureSwizzleAppliedInShader = false;
}
} // no WebGL support
+ if(GetBoolProperty("ro.skia.ignore_swizzle", false)) {
+ this->fShaderCaps->fTextureSwizzleAppliedInShader = true;
+ }
if (GR_IS_GR_GL(standard)) {
fMipMapLevelAndLodControlSupport = true;
--
2.17.1
@@ -1,31 +0,0 @@
From f85268cf7b0e928d741d316b59b3b31773fae7c8 Mon Sep 17 00:00:00 2001
From: Alexander Pohl <pohl199885@gmail.com>
Date: Fri, 15 Jun 2018 19:58:07 +0200
Subject: [PATCH 01/14] Fix WiFi-Display on Huawei devices (EMUI 8.0)
Huaweis media stack doesn't handle intra-refresh-mode, so skip the error instead.
Thanks to Chris Vandomelen for pointing that out.
---
media/libstagefright/ACodec.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 63ab6548b4..e25f8f6558 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -4432,9 +4432,8 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
if (msg->findInt32("intra-refresh-mode", &intraRefreshMode)) {
err = setCyclicIntraMacroblockRefresh(msg, intraRefreshMode);
if (err != OK) {
- ALOGE("Setting intra macroblock refresh mode (%d) failed: 0x%x",
- err, intraRefreshMode);
- return err;
+ ALOGE("setupAVCEncoderParameters(): set intra-refresh-mode failed, ignoring..");
+ //return err;
}
}
--
2.17.1
@@ -1,36 +0,0 @@
From 4ab15a33857452d990581a3d0073e35215e1c542 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 22:59:06 +0200
Subject: [PATCH 02/14] ::Kirin:: Remove lock to prevent self-lock
With Huawei Camera HAL, we get the following call order:
cameraserver CameraService::enumerateProviders (*)
=> HAL ICameraProvider::getVendorTags
=> HAL ICameraProviderCallback::cameraDeviceStatusChange
=> cameraserver CameraService::addState
=> cameraserver CameraService::updateCameraNumAndIds (*)
The two functions marked with (*) take mServiceLock
Hence the safe-lock
Change-Id: I464255b5a3af8d75d72b1772ab55aa655f395a60
---
services/camera/libcameraservice/CameraService.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index af1e01d8e1..05252d6308 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -301,7 +301,7 @@ status_t CameraService::getSystemCameraKind(const String8& cameraId, SystemCamer
}
void CameraService::updateCameraNumAndIds() {
- Mutex::Autolock l(mServiceLock);
+ //Mutex::Autolock l(mServiceLock);
std::pair<int, int> systemAndNonSystemCameras = mCameraProviderManager->getCameraCount();
// Excludes hidden secure cameras
mNumberOfCameras =
--
2.17.1
@@ -1,26 +0,0 @@
From 1083cc0b59ed11aa69af22103ebaf74ae11f272c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 23:05:26 +0200
Subject: [PATCH 03/14] We might not have a mFlashlight at this state, but
that's ok
---
services/camera/libcameraservice/CameraService.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 05252d6308..e1d23073f4 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -337,7 +337,7 @@ void CameraService::addStates(const String8 id) {
conflicting, deviceKind));
}
- if (mFlashlight->hasFlashUnit(id)) {
+ if (mFlashlight != nullptr && mFlashlight->hasFlashUnit(id)) {
Mutex::Autolock al(mTorchStatusMutex);
mTorchStatusMap.add(id, TorchModeStatus::AVAILABLE_OFF);
--
2.17.1
@@ -1,62 +0,0 @@
From 1c0e912c7bdef868de97dc07dd5227d298cd66a9 Mon Sep 17 00:00:00 2001
From: Artem Borisov <dedsa2002@gmail.com>
Date: Tue, 25 Sep 2018 12:39:22 +0300
Subject: [PATCH 04/14] CameraService: Support calling addStates in
enumerateProviders
Some pre-P camera HALs trigger onDeviceStatusChange callback during HAL init.
This is horribly wrong and causes a race condition between enumerateProviders
and onDeviceStatusChange. While it wasn't really harmful in O, in P call sequence
was changed and now this race condition leads to two problems: null pointer dereference
in addStates because mFlashlight is not initialized at a proper timing; mServiceLock
deadlock because updateCameraNumAndIds and enumerateProviders are called at the same time.
Moving addStates back to enumerateProviders makes the sequence more similar to O, and doesn't
let these two issues to happen.
Enable TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE when it is necessary.
@Dil3mm4 edit: Instead of TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE let's use a system property to make it more generic and suitable for GSI use.
Change-Id: Ife25b9753fdb679ab0c77f385e1b8527551a4711
---
.../camera/libcameraservice/CameraService.cpp | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index e1d23073f4..83dea10f3a 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -221,6 +221,20 @@ status_t CameraService::enumerateProviders() {
for (auto& cameraId : deviceIds) {
String8 id8 = String8(cameraId.c_str());
+ if (property_get_bool("persist.sys.camera.huawei", false)) {
+ bool cameraFound = false;
+ {
+ Mutex::Autolock lock(mCameraStatesLock);
+ auto iter = mCameraStates.find(id8);
+ if (iter != mCameraStates.end()) {
+ cameraFound = true;
+ }
+ }
+ if (!cameraFound) {
+ addStates(id8);
+ }
+ }
+
if (getCameraState(id8) == nullptr) {
onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
}
@@ -375,8 +389,10 @@ void CameraService::onDeviceStatusChanged(const String8& id,
ALOGI("%s: Unknown camera ID %s, a new camera is added",
__FUNCTION__, id.string());
+ if (!property_get_bool("persist.sys.camera.huawei", false)) {
// First add as absent to make sure clients are notified below
addStates(id);
+ }
updateStatus(newStatus, id);
} else {
--
2.17.1
@@ -1,341 +0,0 @@
From d24b9bfa7113578d6a9e7a98a01e0ef6dfb970ea Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 25 May 2020 21:26:54 +0200
Subject: [PATCH 14/14] Add persist.sys.phh.disable_a2dp_offload property to
force a2dp offload
Change-Id: Id474540c33c594cc4010a1a398d82bff8aadaeea
---
media/libstagefright/ACodec.cpp | 20 +-
.../managerdefinitions/src/Serializer.cpp | 181 +++++++++++++++++-
.../audiopolicy/enginedefault/src/Engine.cpp | 2 +-
.../managerdefault/AudioPolicyManager.cpp | 3 +
4 files changed, 199 insertions(+), 7 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index e25f8f6558..7ff3c8f61b 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1166,6 +1166,9 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
return err;
}
+ ALOGE("Window undequeued buffers is %d\n", *minUndequeuedBuffers);
+ ALOGE("Consumerrequested %d\n", def.nBufferCountMin);
+
// FIXME: assume that surface is controlled by app (native window
// returns the number for the case when surface is not controlled by app)
// FIXME2: This means that minUndeqeueudBufs can be 1 larger than reported
@@ -1178,22 +1181,29 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
// 2. try to allocate two (2) additional buffers to reduce starvation from
// the consumer
// plus an extra buffer to account for incorrect minUndequeuedBufs
- for (OMX_U32 extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
- OMX_U32 newBufferCount =
- def.nBufferCountMin + *minUndequeuedBuffers + extraBuffers;
+ for (int extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
+ int a = def.nBufferCountMin;
+ int b = *minUndequeuedBuffers;
+ int c = extraBuffers;
+ int newBufferCount = a+b+c;
def.nBufferCountActual = newBufferCount;
err = mOMXNode->setParameter(
OMX_IndexParamPortDefinition, &def, sizeof(def));
if (err == OK) {
- *minUndequeuedBuffers += extraBuffers;
+ ALOGE("Managed to allocate %d buffers (%d extra)\n", newBufferCount, extraBuffers);
+ if(extraBuffers > 0) {
+ *minUndequeuedBuffers += extraBuffers;
+ } else {
+ *minUndequeuedBuffers -= -extraBuffers;
+ }
break;
}
ALOGW("[%s] setting nBufferCountActual to %u failed: %d",
mComponentName.c_str(), newBufferCount, err);
/* exit condition */
- if (extraBuffers == 0) {
+ if (extraBuffers == -2 || newBufferCount == 1) {
return err;
}
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index a8eb142c81..73e4a3e096 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -29,6 +29,7 @@
#include <utils/StrongPointer.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
+#include <cutils/properties.h>
#include "Serializer.h"
#include "TypeConverter.h"
@@ -36,6 +37,8 @@ namespace android {
namespace {
+static bool forceDisableA2dpOffload = false;
+
// TODO(mnaganov): Consider finding an alternative for using HIDL code.
using hardware::Return;
using hardware::Status;
@@ -318,7 +321,7 @@ status_t deserializeCollection(const xmlNode *cur,
return status;
}
} else {
- return BAD_VALUE;
+ ALOGE("Ignoring...");
}
}
}
@@ -734,12 +737,34 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
Element module = new HwModule(name.c_str(), versionMajor, versionMinor);
+ bool isA2dpModule = strcmp(name.c_str(), "a2dp") == 0;
+ bool isPrimaryModule = strcmp(name.c_str(), "primary") == 0;
+
// Deserialize childrens: Audio Mix Port, Audio Device Ports (Source/Sink), Audio Routes
MixPortTraits::Collection mixPorts;
status_t status = deserializeCollection<MixPortTraits>(cur, &mixPorts, NULL);
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ if(forceDisableA2dpOffload && isA2dpModule) {
+ for(const auto& mixPort: mixPorts) {
+ ALOGE("Disable a2dp offload...? %s", mixPort->getTagName().c_str());
+ //"a2dp" sw module already has a2dp out
+ if(mixPort->getTagName() == "a2dp output") {
+ forceDisableA2dpOffload = false;
+ break;
+ }
+ }
+ }
+ if(forceDisableA2dpOffload && isA2dpModule) {
+ //Add
+ //<mixPort name="a2dp output" role="source"/>
+ auto mixPort = new IOProfile("a2dp output", AUDIO_PORT_ROLE_SOURCE);
+ AudioProfileTraits::Collection profiles;
+ profiles.add(AudioProfile::createFullDynamic());
+ mixPort->setAudioProfiles(profiles);
+ mixPorts.push_back(mixPort);
+ }
module->setProfiles(mixPorts);
DevicePortTraits::Collection devicePorts;
@@ -747,6 +772,90 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ Vector<std::string> a2dpOuts;
+ a2dpOuts.push_back("BT A2DP Out");
+ a2dpOuts.push_back("BT A2DP Headphones");
+ a2dpOuts.push_back("BT A2DP Speaker");
+ if(forceDisableA2dpOffload) {
+ if(isA2dpModule) {
+ //<devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink" address="lhdc_a2dp">
+ // <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ // samplingRates="44100,48000,96000"
+ // channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ //</devicePort>
+ if(true) {
+ FormatVector formats;
+ //auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, formats, "BT A2DP Out");
+ auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, "BT A2DP Out");
+ AudioProfileTraits::Collection profiles;
+ ChannelTraits::Collection channels;
+ channels.insert(AUDIO_CHANNEL_OUT_STEREO);
+ SampleRateSet sampleRates;
+ sampleRates.insert(44100);
+ sampleRates.insert(48000);
+ sampleRates.insert(96000);
+ auto profile = new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, channels, sampleRates);
+ profiles.add(profile);
+ devicePortOut->setAudioProfiles(profiles);
+ devicePortOut->setAddress("lhdc_a2dp");
+ devicePorts.add(devicePortOut);
+ }
+ //<devicePort tagName="BT A2DP Headphones" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES" role="sink" address="lhdc_a2dp">
+ // <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ // samplingRates="44100,48000,96000"
+ // channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ //</devicePort>
+ if(true) {
+ FormatVector formats;
+ auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, "BT A2DP Headphones");
+ AudioProfileTraits::Collection profiles;
+ ChannelTraits::Collection channels;
+ channels.insert(AUDIO_CHANNEL_OUT_STEREO);
+ SampleRateSet sampleRates;
+ sampleRates.insert(44100);
+ sampleRates.insert(48000);
+ sampleRates.insert(96000);
+ auto profile = new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, channels, sampleRates);
+ profiles.add(profile);
+ devicePortOut->setAudioProfiles(profiles);
+ devicePortOut->setAddress("lhdc_a2dp");
+ devicePorts.add(devicePortOut);
+ }
+ //<devicePort tagName="BT A2DP Speaker" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER" role="sink" address="lhdc_a2dp">
+ // <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ // samplingRates="44100,48000,96000"
+ // channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ //</devicePort>
+ if(true) {
+ FormatVector formats;
+ auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, "BT A2DP Speaker");
+ AudioProfileTraits::Collection profiles;
+ ChannelTraits::Collection channels;
+ channels.insert(AUDIO_CHANNEL_OUT_STEREO);
+ SampleRateSet sampleRates;
+ sampleRates.insert(44100);
+ sampleRates.insert(48000);
+ sampleRates.insert(96000);
+ auto profile = new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, channels, sampleRates);
+ profiles.add(profile);
+ devicePortOut->setAudioProfiles(profiles);
+ devicePortOut->setAddress("lhdc_a2dp");
+ devicePorts.add(devicePortOut);
+
+ }
+ } else if(isPrimaryModule) {
+ for(const auto& out: a2dpOuts) {
+ auto iterA = std::find_if(devicePorts.begin(), devicePorts.end(), [out](const auto port) {
+ if(port->getTagName() == out) return true;
+ return false;
+ });
+ if(iterA != devicePorts.end()) {
+ ALOGE("Erasing device port %s", (*iterA)->getTagName().c_str());
+ devicePorts.erase(iterA);
+ }
+ }
+ }
+ }
module->setDeclaredDevices(devicePorts);
RouteTraits::Collection routes;
@@ -754,7 +863,76 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ if(forceDisableA2dpOffload) {
+ if(strcmp(name.c_str(), "primary") == 0) {
+ for(const auto& out: a2dpOuts) {
+ auto iterA = std::find_if(routes.begin(), routes.end(), [out](const auto route) {
+ if(route->getType() != AUDIO_ROUTE_MIX)
+ return false;
+ auto sink = route->getSink();
+ if(sink->getTagName() == out) {
+ return true;
+ }
+ return false;
+ });
+ if(iterA != routes.end()) {
+ auto sink = (*iterA)->getSink()->getTagName();
+ ALOGE("Erasing route %s", sink.c_str());
+ routes.erase(iterA);
+ }
+ }
+ } else if(isA2dpModule) {
+ //<route type="mix" sink="BT A2DP Out"
+ // sources="a2dp output"/>
+ if(true) {
+ auto newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+ auto sink = module->findPortByTagName("BT A2DP Out");
+ auto source = module->findPortByTagName("a2dp output");
+ newRoute->setSink(sink);
+ Vector<sp<PolicyAudioPort>> sources;
+ sources.add(source);
+
+ sink->addRoute(newRoute);
+ source->addRoute(newRoute);
+ newRoute->setSources(sources);
+
+ routes.add(newRoute);
+ }
+ //<route type="mix" sink="BT A2DP Headphones"
+ // sources="a2dp output"/>
+ if(true) {
+ auto newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+ auto sink = module->findPortByTagName("BT A2DP Headphones");
+ auto source = module->findPortByTagName("a2dp output");
+ newRoute->setSink(sink);
+ Vector<sp<PolicyAudioPort>> sources;
+ sources.add(source);
+
+ sink->addRoute(newRoute);
+ source->addRoute(newRoute);
+ newRoute->setSources(sources);
+ routes.add(newRoute);
+ }
+ //<route type="mix" sink="BT A2DP Speaker"
+ // sources="a2dp output"/>
+ if(true) {
+ auto newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+ auto sink = module->findPortByTagName("BT A2DP Speaker");
+ auto source = module->findPortByTagName("a2dp output");
+ newRoute->setSink(sink);
+ Vector<sp<PolicyAudioPort>> sources;
+ sources.add(source);
+
+ sink->addRoute(newRoute);
+ source->addRoute(newRoute);
+ newRoute->setSources(sources);
+ routes.add(newRoute);
+ }
+ }
+ }
+ ALOGE("Good morning");
fixupQualcommBtScoRoute(routes, devicePorts, module.get());
+ ALOGE("Good morning2");
module->setRoutes(routes);
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
@@ -932,6 +1110,7 @@ status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig
status_t deserializeAudioPolicyFile(const char *fileName, AudioPolicyConfig *config)
{
PolicySerializer serializer;
+ forceDisableA2dpOffload = property_get_bool("persist.sys.phh.disable_a2dp_offload", false);
return serializer.deserialize(fileName, config);
}
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index b14d2bbb0b..16a7a4bbac 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 },
};
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index c5c13e9a5a..1c5ed86b86 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -93,6 +93,8 @@ bool operator!= (const SortedVector<T> &left, const SortedVector<T> &right)
return !(left == right);
}
+static bool forceDisableA2dpOffload = false;
+
// ----------------------------------------------------------------------------
// AudioPolicyInterface implementation
// ----------------------------------------------------------------------------
@@ -4458,6 +4460,7 @@ static status_t deserializeAudioPolicyXmlConfig(AudioPolicyConfig &config) {
} else if (property_get_bool("persist.bluetooth.bluetooth_audio_hal.disabled", false)) {
fileNames.push_back(AUDIO_POLICY_BLUETOOTH_LEGACY_HAL_XML_CONFIG_FILE_NAME);
}
+ forceDisableA2dpOffload = property_get_bool("persist.sys.phh.disable_a2dp_offload", false);
fileNames.push_back(AUDIO_POLICY_XML_CONFIG_FILE_NAME);
for (const char* fileName : fileNames) {
--
2.17.1
@@ -1,40 +0,0 @@
From 3c374cb65bd0e28c73fbd452e8201487dd1acb94 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 3 Dec 2019 14:04:17 +0100
Subject: [PATCH 15/15] Fix for some Huawei camera
---
services/camera/libcameraservice/CameraService.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 5d062a5fb3..97e9825c51 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "CameraService"
#define ATRACE_TAG ATRACE_TAG_CAMERA
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
#include <algorithm>
#include <climits>
@@ -235,10 +235,11 @@ status_t CameraService::enumerateProviders() {
if (!cameraFound) {
addStates(id8);
}
- }
-
- if (getCameraState(id8) == nullptr) {
onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
+ } else {
+ if (getCameraState(id8) == nullptr) {
+ onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
+ }
}
}
--
2.25.1
@@ -1,30 +0,0 @@
From 6a6c54584fae07783b493a56afd047984f589ed0 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 21 Dec 2020 20:19:11 +0100
Subject: [PATCH 16/16] Make camera IDs filter-out optional
Nowadays most people have Camera 2 apps, and would like to have all
cameras, rather than limit which cameras are available.
Add a property for that.
---
.../camera/libcameraservice/common/CameraProviderManager.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 0bff3606df..3e6ad1ef52 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -183,7 +183,9 @@ std::vector<std::string> CameraProviderManager::getAPI1CompatibleCameraDeviceIds
// API1 app doesn't handle logical and physical camera devices well. So
// for each camera facing, only take the first id advertised by HAL in
// all [logical, physical1, physical2, ...] id combos, and filter out the rest.
- filterLogicalCameraIdsLocked(providerDeviceIds);
+ if(!property_get_bool("persist.sys.phh.include_all_cameras", false)) {
+ filterLogicalCameraIdsLocked(providerDeviceIds);
+ }
collectDeviceIdsLocked(providerDeviceIds, publicDeviceIds, systemDeviceIds);
}
auto sortFunc =
--
2.25.1
@@ -1,88 +0,0 @@
From 8d97b4814211158932b8482888f5b7bcc8a5a21e Mon Sep 17 00:00:00 2001
From: Houxiang Dai <houxiang.dai@mediatek.com>
Date: Thu, 23 Jul 2020 14:07:22 +0800
Subject: [PATCH 17/30] ACodec: Handle HDR10+ metadata at
OutputPortSettingsChangedState
[Description]
handle kWhatSetParameters message in OutputPortSettingsChangedState
handle OMX_EventConfigUpdate event in OutputPortSettingsChangedState
In HDR10+ test, we have to associate each HDR10+ metadata to a particular
frame. If receive a kWhatSetParameters message with "hdr10-plus-info"
buffer, it should not be deferred in OutputPortSettingsChangedState and
adopt OMX_SetConfig to associates this config with the next input buffer
sent in OMX_EmptyThisBuffer. The OMX_EventConfigUpdate event report from
component should be handled also in OutputPortSettingsChangedState,
where is to associate updated "hdr10-plus-info" metadata with the next
output buffer sent via FillBufferDone callback.
Bug: 157213958
Bug: 157435393
Change-Id: I27e4614487414063831fa760b9e9ca96b1c3712c
(cherry picked from commit c111aa4fda9b5b434edb1b46898ff8dd7e51cec6)
---
media/libstagefright/ACodec.cpp | 36 ++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index b9d0f5bb72..f843c7f45f 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -8296,13 +8296,34 @@ bool ACodec::OutputPortSettingsChangedState::onMessageReceived(
FALLTHROUGH_INTENDED;
}
case kWhatResume:
+ {
+ ALOGV("[%s] Deferring resume", mCodec->mComponentName.c_str());
+
+ mCodec->deferMessage(msg);
+ handled = true;
+ break;
+ }
+
case kWhatSetParameters:
{
- if (msg->what() == kWhatResume) {
- ALOGV("[%s] Deferring resume", mCodec->mComponentName.c_str());
+ sp<AMessage> params;
+ CHECK(msg->findMessage("params", &params));
+
+ sp<ABuffer> hdr10PlusInfo;
+ if (params->findBuffer("hdr10-plus-info", &hdr10PlusInfo)) {
+ if (hdr10PlusInfo != nullptr && hdr10PlusInfo->size() > 0) {
+ (void)mCodec->setHdr10PlusInfo(hdr10PlusInfo);
+ }
+ params->removeEntryAt(params->findEntryByName("hdr10-plus-info"));
+
+ if (params->countEntries() == 0) {
+ msg->removeEntryAt(msg->findEntryByName("params"));
+ }
}
- mCodec->deferMessage(msg);
+ if (msg->countEntries() > 0) {
+ mCodec->deferMessage(msg);
+ }
handled = true;
break;
}
@@ -8417,6 +8438,15 @@ bool ACodec::OutputPortSettingsChangedState::onOMXEvent(
return false;
}
+ case OMX_EventConfigUpdate:
+ {
+ CHECK_EQ(data1, (OMX_U32)kPortIndexOutput);
+
+ mCodec->onConfigUpdate((OMX_INDEXTYPE)data2);
+
+ return true;
+ }
+
default:
return BaseState::onOMXEvent(event, data1, data2);
}
--
2.25.1
@@ -1,174 +0,0 @@
From a141c7102252377bc882b982b36980edb60f931e Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Tue, 5 Jan 2021 18:58:15 -0800
Subject: [PATCH 19/30] CCodec: store flushed config as work items
Store flushed config as work items and queue them to the component
directly, instead of going through MediaCodecBuffer.
Bug: 176501678
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Test: atest CtsMediaTestCases:AdaptivePlaybackTest
Merged-In: I19991101c388eca49226ad2abc37df9cea22dbb8
Change-Id: I19991101c388eca49226ad2abc37df9cea22dbb8
(cherry picked from commit 5ebfcb24855e526ec040b9f41d216f7604b8981a)
---
media/codec2/sfplugin/CCodecBufferChannel.cpp | 119 ++++++++----------
media/codec2/sfplugin/CCodecBufferChannel.h | 2 +-
2 files changed, 53 insertions(+), 68 deletions(-)
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 1654b11c31..b8ca41b9a8 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -1300,54 +1300,30 @@ status_t CCodecBufferChannel::requestInitialInputBuffers() {
return a.capacity < b.capacity;
});
- {
- Mutexed<std::list<sp<ABuffer>>>::Locked configs(mFlushedConfigs);
- if (!configs->empty()) {
- while (!configs->empty()) {
- sp<ABuffer> config = configs->front();
- configs->pop_front();
- // Find the smallest input buffer that can fit the config.
- auto i = std::find_if(
- clientInputBuffers.begin(),
- clientInputBuffers.end(),
- [cfgSize = config->size()](const ClientInputBuffer& b) {
- return b.capacity >= cfgSize;
- });
- if (i == clientInputBuffers.end()) {
- ALOGW("[%s] no input buffer large enough for the config "
- "(%zu bytes)",
- mName, config->size());
- return NO_MEMORY;
- }
- sp<MediaCodecBuffer> buffer = i->buffer;
- memcpy(buffer->base(), config->data(), config->size());
- buffer->setRange(0, config->size());
- buffer->meta()->clear();
- buffer->meta()->setInt64("timeUs", 0);
- buffer->meta()->setInt32("csd", 1);
- if (queueInputBufferInternal(buffer) != OK) {
- ALOGW("[%s] Error while queueing a flushed config",
- mName);
- return UNKNOWN_ERROR;
- }
- clientInputBuffers.erase(i);
- }
- } else if (oStreamFormat.value == C2BufferData::LINEAR &&
- (!prepend || prepend.value == PREPEND_HEADER_TO_NONE)) {
- sp<MediaCodecBuffer> buffer = clientInputBuffers.front().buffer;
- // WORKAROUND: Some apps expect CSD available without queueing
- // any input. Queue an empty buffer to get the CSD.
- buffer->setRange(0, 0);
- buffer->meta()->clear();
- buffer->meta()->setInt64("timeUs", 0);
- if (queueInputBufferInternal(buffer) != OK) {
- ALOGW("[%s] Error while queueing an empty buffer to get CSD",
- mName);
- return UNKNOWN_ERROR;
- }
- clientInputBuffers.pop_front();
+ std::list<std::unique_ptr<C2Work>> flushedConfigs;
+ mFlushedConfigs.lock()->swap(flushedConfigs);
+ if (!flushedConfigs.empty()) {
+ err = mComponent->queue(&flushedConfigs);
+ if (err != C2_OK) {
+ ALOGW("[%s] Error while queueing a flushed config", mName);
+ return UNKNOWN_ERROR;
}
}
+ if (oStreamFormat.value == C2BufferData::LINEAR &&
+ (!prepend || prepend.value == PREPEND_HEADER_TO_NONE)) {
+ sp<MediaCodecBuffer> buffer = clientInputBuffers.front().buffer;
+ // WORKAROUND: Some apps expect CSD available without queueing
+ // any input. Queue an empty buffer to get the CSD.
+ buffer->setRange(0, 0);
+ buffer->meta()->clear();
+ buffer->meta()->setInt64("timeUs", 0);
+ if (queueInputBufferInternal(buffer) != OK) {
+ ALOGW("[%s] Error while queueing an empty buffer to get CSD",
+ mName);
+ return UNKNOWN_ERROR;
+ }
+ clientInputBuffers.pop_front();
+ }
for (const ClientInputBuffer& clientInputBuffer: clientInputBuffers) {
mCallback->onInputBufferAvailable(
@@ -1396,27 +1372,36 @@ void CCodecBufferChannel::release() {
void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushedWork) {
ALOGV("[%s] flush", mName);
- {
- Mutexed<std::list<sp<ABuffer>>>::Locked configs(mFlushedConfigs);
- for (const std::unique_ptr<C2Work> &work : flushedWork) {
- if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG)) {
- continue;
- }
- if (work->input.buffers.empty()
- || work->input.buffers.front()->data().linearBlocks().empty()) {
- ALOGD("[%s] no linear codec config data found", mName);
- continue;
- }
- C2ReadView view =
- work->input.buffers.front()->data().linearBlocks().front().map().get();
- if (view.error() != C2_OK) {
- ALOGD("[%s] failed to map flushed codec config data: %d", mName, view.error());
- continue;
- }
- configs->push_back(ABuffer::CreateAsCopy(view.data(), view.capacity()));
- ALOGV("[%s] stashed flushed codec config data (size=%u)", mName, view.capacity());
- }
- }
+ std::list<std::unique_ptr<C2Work>> configs;
+ for (const std::unique_ptr<C2Work> &work : flushedWork) {
+ if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG)) {
+ continue;
+ }
+ if (work->input.buffers.empty()
+ || work->input.buffers.front() == nullptr
+ || work->input.buffers.front()->data().linearBlocks().empty()) {
+ ALOGD("[%s] no linear codec config data found", mName);
+ continue;
+ }
+ std::unique_ptr<C2Work> copy(new C2Work);
+ copy->input.flags = C2FrameData::flags_t(work->input.flags | C2FrameData::FLAG_DROP_FRAME);
+ copy->input.ordinal = work->input.ordinal;
+ copy->input.buffers.insert(
+ copy->input.buffers.begin(),
+ work->input.buffers.begin(),
+ work->input.buffers.end());
+ for (const std::unique_ptr<C2Param> &param : work->input.configUpdate) {
+ copy->input.configUpdate.push_back(C2Param::Copy(*param));
+ }
+ copy->input.infoBuffers.insert(
+ copy->input.infoBuffers.begin(),
+ work->input.infoBuffers.begin(),
+ work->input.infoBuffers.end());
+ copy->worklets.emplace_back(new C2Worklet);
+ configs.push_back(std::move(copy));
+ ALOGV("[%s] stashed flushed codec config data", mName);
+ }
+ mFlushedConfigs.lock()->swap(configs);
{
Mutexed<Input>::Locked input(mInput);
input->buffers->flush();
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.h b/media/codec2/sfplugin/CCodecBufferChannel.h
index 046c5c3c49..e2c9aaa287 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.h
+++ b/media/codec2/sfplugin/CCodecBufferChannel.h
@@ -277,7 +277,7 @@ private:
uint32_t outputDelay;
};
Mutexed<Output> mOutput;
- Mutexed<std::list<sp<ABuffer>>> mFlushedConfigs;
+ Mutexed<std::list<std::unique_ptr<C2Work>>> mFlushedConfigs;
std::atomic_uint64_t mFrameIndex;
std::atomic_uint64_t mFirstValidFrameIndex;
--
2.25.1
@@ -1,121 +0,0 @@
From bfa866666f0fb3e95755e5fb5d22a89c1fdd6767 Mon Sep 17 00:00:00 2001
From: David Stevens <stevensd@google.com>
Date: Tue, 20 Oct 2020 15:00:41 +0900
Subject: [PATCH 20/30] BufferPool: limit number of idle buffers in caches
Some systems have limits on the total number of graphics buffers that
can be allocated, not just the total size. When dealing with
particularly small buffers, the caches could end up retaining 1000s of
buffers. This change adds an additional eviction trigger based on the
number of idle cached buffers.
Bug: 170702290
Bug: 171553040
Test: android.video.cts.VideoEncoderDecoderTest on ARCVM
Change-Id: If3f4433ba1794ccb624b864a56619c8613a315f2
(cherry picked from commit 0f50e523ef1404f9afbaa7b919e2801e5d94012a)
Merged-In: If3f4433ba1794ccb624b864a56619c8613a315f2
---
media/bufferpool/2.0/AccessorImpl.cpp | 13 +++++++++----
media/bufferpool/2.0/AccessorImpl.h | 6 ++++++
media/bufferpool/2.0/BufferPoolClient.cpp | 12 ++++++++++--
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/media/bufferpool/2.0/AccessorImpl.cpp b/media/bufferpool/2.0/AccessorImpl.cpp
index 6111feafb9..1d2562e41d 100644
--- a/media/bufferpool/2.0/AccessorImpl.cpp
+++ b/media/bufferpool/2.0/AccessorImpl.cpp
@@ -39,6 +39,8 @@ namespace {
static constexpr size_t kMinAllocBytesForEviction = 1024*1024*15;
static constexpr size_t kMinBufferCountForEviction = 25;
+ static constexpr size_t kMaxUnusedBufferCount = 64;
+ static constexpr size_t kUnusedBufferCountTarget = kMaxUnusedBufferCount - 16;
static constexpr nsecs_t kEvictGranularityNs = 1000000000; // 1 sec
static constexpr nsecs_t kEvictDurationNs = 5000000000; // 5 secs
@@ -724,9 +726,11 @@ ResultStatus Accessor::Impl::BufferPool::addNewBuffer(
}
void Accessor::Impl::BufferPool::cleanUp(bool clearCache) {
- if (clearCache || mTimestampUs > mLastCleanUpUs + kCleanUpDurationUs) {
+ if (clearCache || mTimestampUs > mLastCleanUpUs + kCleanUpDurationUs ||
+ mStats.buffersNotInUse() > kMaxUnusedBufferCount) {
mLastCleanUpUs = mTimestampUs;
- if (mTimestampUs > mLastLogUs + kLogDurationUs) {
+ if (mTimestampUs > mLastLogUs + kLogDurationUs ||
+ mStats.buffersNotInUse() > kMaxUnusedBufferCount) {
mLastLogUs = mTimestampUs;
ALOGD("bufferpool2 %p : %zu(%zu size) total buffers - "
"%zu(%zu size) used buffers - %zu/%zu (recycle/alloc) - "
@@ -737,8 +741,9 @@ void Accessor::Impl::BufferPool::cleanUp(bool clearCache) {
mStats.mTotalFetches, mStats.mTotalTransfers);
}
for (auto freeIt = mFreeBuffers.begin(); freeIt != mFreeBuffers.end();) {
- if (!clearCache && (mStats.mSizeCached < kMinAllocBytesForEviction
- || mBuffers.size() < kMinBufferCountForEviction)) {
+ if (!clearCache && mStats.buffersNotInUse() <= kUnusedBufferCountTarget &&
+ (mStats.mSizeCached < kMinAllocBytesForEviction ||
+ mBuffers.size() < kMinBufferCountForEviction)) {
break;
}
auto it = mBuffers.find(*freeIt);
diff --git a/media/bufferpool/2.0/AccessorImpl.h b/media/bufferpool/2.0/AccessorImpl.h
index cd1b4d08c1..3d39941337 100644
--- a/media/bufferpool/2.0/AccessorImpl.h
+++ b/media/bufferpool/2.0/AccessorImpl.h
@@ -193,6 +193,12 @@ private:
: mSizeCached(0), mBuffersCached(0), mSizeInUse(0), mBuffersInUse(0),
mTotalAllocations(0), mTotalRecycles(0), mTotalTransfers(0), mTotalFetches(0) {}
+ /// # of currently unused buffers
+ size_t buffersNotInUse() const {
+ ALOG_ASSERT(mBuffersCached >= mBuffersInUse);
+ return mBuffersCached - mBuffersInUse;
+ }
+
/// A new buffer is allocated on an allocation request.
void onBufferAllocated(size_t allocSize) {
mSizeCached += allocSize;
diff --git a/media/bufferpool/2.0/BufferPoolClient.cpp b/media/bufferpool/2.0/BufferPoolClient.cpp
index 342fef6b9d..9308b8159b 100644
--- a/media/bufferpool/2.0/BufferPoolClient.cpp
+++ b/media/bufferpool/2.0/BufferPoolClient.cpp
@@ -32,6 +32,8 @@ namespace implementation {
static constexpr int64_t kReceiveTimeoutUs = 1000000; // 100ms
static constexpr int kPostMaxRetry = 3;
static constexpr int kCacheTtlUs = 1000000; // TODO: tune
+static constexpr size_t kMaxCachedBufferCount = 64;
+static constexpr size_t kCachedBufferCountTarget = kMaxCachedBufferCount - 16;
class BufferPoolClient::Impl
: public std::enable_shared_from_this<BufferPoolClient::Impl> {
@@ -136,6 +138,10 @@ private:
--mActive;
mLastChangeUs = getTimestampNow();
}
+
+ int cachedBufferCount() const {
+ return mBuffers.size() - mActive;
+ }
} mCache;
// FMQ - release notifier
@@ -668,10 +674,12 @@ bool BufferPoolClient::Impl::syncReleased(uint32_t messageId) {
// should have mCache.mLock
void BufferPoolClient::Impl::evictCaches(bool clearCache) {
int64_t now = getTimestampNow();
- if (now >= mLastEvictCacheUs + kCacheTtlUs || clearCache) {
+ if (now >= mLastEvictCacheUs + kCacheTtlUs ||
+ clearCache || mCache.cachedBufferCount() > kMaxCachedBufferCount) {
size_t evicted = 0;
for (auto it = mCache.mBuffers.begin(); it != mCache.mBuffers.end();) {
- if (!it->second->hasCache() && (it->second->expire() || clearCache)) {
+ if (!it->second->hasCache() && (it->second->expire() ||
+ clearCache || mCache.cachedBufferCount() > kCachedBufferCountTarget)) {
it = mCache.mBuffers.erase(it);
++evicted;
} else {
--
2.25.1
@@ -1,37 +0,0 @@
From 7e08eb2a701487a4b56b449fd5758b8ab5cfce90 Mon Sep 17 00:00:00 2001
From: Taehwan Kim <t_h.kim@samsung.com>
Date: Thu, 17 Sep 2020 12:26:40 +0900
Subject: [PATCH 21/30] CCodec: fix underflow issue on handleImageData
the logic is assumed that gralloc does assume a contiguous mapping
at GraphicView2MediaImageConverter() in Codec2Buffer.
if it doesn't, underflow could happen because
type of variable is unsigned.
Bug: 168757280
Change-Id: I04e13d0680af74e76d96d3ab10a549f6368205cf
Signed-off-by: Taehwan Kim <t_h.kim@samsung.com>
(cherry picked from commit fd9b809147b78330d1db7ec17e200071e779fd46)
---
media/codec2/sfplugin/CCodecBuffers.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index bddaa9f22b..692da584ce 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -91,7 +91,9 @@ void CCodecBuffers::handleImageData(const sp<Codec2Buffer> &buffer) {
newFormat->setInt32(KEY_STRIDE, stride);
ALOGD("[%s] updating stride = %d", mName, stride);
if (img->mNumPlanes > 1 && stride > 0) {
- int32_t vstride = (img->mPlane[1].mOffset - img->mPlane[0].mOffset) / stride;
+ int64_t offsetDelta =
+ (int64_t)img->mPlane[1].mOffset - (int64_t)img->mPlane[0].mOffset;
+ int32_t vstride = int32_t(offsetDelta / stride);
newFormat->setInt32(KEY_SLICE_HEIGHT, vstride);
ALOGD("[%s] updating vstride = %d", mName, vstride);
}
--
2.25.1
@@ -1,139 +0,0 @@
From 73517d3e56b2ee0eb171af1e68fa1c729eadd564 Mon Sep 17 00:00:00 2001
From: Ray Essick <essick@google.com>
Date: Mon, 14 Sep 2020 17:05:07 -0700
Subject: [PATCH 22/30] OMX Opus decoder omits sample rate / channel count
The OMX Opus decoder doesn't signal back the channel/samplerate info to
the framework, leading to a CTS failure when checking required values.
Based on an AOSP patch provided by denis.hsu@mediatek.com
Bug: 166695414
Test: CtsMediaTestCases android.media.cts.DecoderTest#testDecodeOpusChannelsAndRates
Change-Id: If710405caea4be6336b4aec3aa0c051ad3c0fe95
(cherry picked from commit 74d4b70841b2aa3154b10b82ebcc6737d1d36a6d)
---
media/libstagefright/ACodec.cpp | 26 +++++++++++++++++++
.../codecs/opus/dec/SoftOpus.cpp | 11 +++++---
.../libstagefright/codecs/opus/dec/SoftOpus.h | 2 ++
.../include/media/stagefright/ACodec.h | 1 +
4 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index f843c7f45f..7ea444dc77 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2247,6 +2247,12 @@ status_t ACodec::configureCodec(
}
err = setupG711Codec(encoder, sampleRate, numChannels);
}
+ } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_OPUS)) {
+ int32_t numChannels = 1, sampleRate = 48000;
+ if (msg->findInt32("channel-count", &numChannels) &&
+ msg->findInt32("sample-rate", &sampleRate)) {
+ err = setupOpusCodec(encoder, sampleRate, numChannels);
+ }
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) {
// numChannels needs to be set to properly communicate PCM values.
int32_t numChannels = 2, sampleRate = 44100, compressionLevel = -1;
@@ -3120,6 +3126,26 @@ status_t ACodec::setupG711Codec(bool encoder, int32_t sampleRate, int32_t numCha
kPortIndexInput, sampleRate, numChannels);
}
+status_t ACodec::setupOpusCodec(bool encoder, int32_t sampleRate, int32_t numChannels) {
+ if (encoder) {
+ return INVALID_OPERATION;
+ }
+ OMX_AUDIO_PARAM_ANDROID_OPUSTYPE def;
+ InitOMXParams(&def);
+ def.nPortIndex = kPortIndexInput;
+ status_t err = mOMXNode->getParameter(
+ (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus, &def, sizeof(def));
+ if (err != OK) {
+ ALOGE("setupOpusCodec(): Error %d getting OMX_IndexParamAudioAndroidOpus parameter", err);
+ return err;
+ }
+ def.nSampleRate = sampleRate;
+ def.nChannels = numChannels;
+ err = mOMXNode->setParameter(
+ (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus, &def, sizeof(def));
+ return err;
+}
+
status_t ACodec::setupFlacCodec(
bool encoder, int32_t numChannels, int32_t sampleRate, int32_t compressionLevel,
AudioEncoding encoding) {
diff --git a/media/libstagefright/codecs/opus/dec/SoftOpus.cpp b/media/libstagefright/codecs/opus/dec/SoftOpus.cpp
index 4f61aa8be2..5bb1879da1 100644
--- a/media/libstagefright/codecs/opus/dec/SoftOpus.cpp
+++ b/media/libstagefright/codecs/opus/dec/SoftOpus.cpp
@@ -58,6 +58,8 @@ SoftOpus::SoftOpus(
mInputBufferCount(0),
mDecoder(NULL),
mHeader(NULL),
+ mNumChannels(1),
+ mSamplingRate(kRate),
mCodecDelay(0),
mSeekPreRoll(0),
mAnchorTimeUs(0),
@@ -169,11 +171,11 @@ OMX_ERRORTYPE SoftOpus::internalGetParameter(
}
opusParams->nAudioBandWidth = 0;
- opusParams->nSampleRate = kRate;
+ opusParams->nSampleRate = mSamplingRate;
opusParams->nBitRate = 0;
if (!isConfigured()) {
- opusParams->nChannels = 1;
+ opusParams->nChannels = mNumChannels;
} else {
opusParams->nChannels = mHeader->channels;
}
@@ -274,7 +276,8 @@ OMX_ERRORTYPE SoftOpus::internalSetParameter(
if (opusParams->nPortIndex != 0) {
return OMX_ErrorUndefined;
}
-
+ mNumChannels = opusParams->nChannels;
+ mSamplingRate = opusParams->nSampleRate;
return OMX_ErrorNone;
}
@@ -496,6 +499,8 @@ void SoftOpus::onQueueFilled(OMX_U32 /* portIndex */) {
*(reinterpret_cast<int64_t*>(inHeader->pBuffer +
inHeader->nOffset)),
kRate);
+ mSamplingRate = kRate;
+ mNumChannels = mHeader->channels;
notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
mOutputPortSettingsChange = AWAITING_DISABLED;
}
diff --git a/media/libstagefright/codecs/opus/dec/SoftOpus.h b/media/libstagefright/codecs/opus/dec/SoftOpus.h
index 91cafa14c7..00058c8212 100644
--- a/media/libstagefright/codecs/opus/dec/SoftOpus.h
+++ b/media/libstagefright/codecs/opus/dec/SoftOpus.h
@@ -70,6 +70,8 @@ private:
OpusMSDecoder *mDecoder;
OpusHeader *mHeader;
+ int32_t mNumChannels;
+ int32_t mSamplingRate;
int64_t mCodecDelay;
int64_t mSeekPreRoll;
int64_t mSamplesToDiscard;
diff --git a/media/libstagefright/include/media/stagefright/ACodec.h b/media/libstagefright/include/media/stagefright/ACodec.h
index 83e92b9f43..105e7f7f98 100644
--- a/media/libstagefright/include/media/stagefright/ACodec.h
+++ b/media/libstagefright/include/media/stagefright/ACodec.h
@@ -499,6 +499,7 @@ private:
status_t setupAMRCodec(bool encoder, bool isWAMR, int32_t bitRate);
status_t setupG711Codec(bool encoder, int32_t sampleRate, int32_t numChannels);
+ status_t setupOpusCodec(bool encoder, int32_t sampleRate, int32_t numChannels);
status_t setupFlacCodec(
bool encoder, int32_t numChannels, int32_t sampleRate, int32_t compressionLevel,
AudioEncoding encoding);
--
2.25.1
@@ -1,138 +0,0 @@
From bf69673517df3b7c1f90cc07621f8af998310110 Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Tue, 22 Sep 2020 18:44:47 -0700
Subject: [PATCH 23/30] ACodec: submit extra output metadata buffers if in low
latency mode
Bug: 166250452
Test: atest CtsMediaTestCases:DecoderTest
Merged-In: I134a16a70e8ac94dbd4f505c0a5553a3ca0f87a2
Change-Id: I134a16a70e8ac94dbd4f505c0a5553a3ca0f87a2
(cherry picked from commit 7e0bb3845b3059c0ee5bd33e506368828cca40fe)
---
media/libstagefright/ACodec.cpp | 39 ++++++++++++++++++-
.../include/media/stagefright/ACodec.h | 2 +
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 7ea444dc77..0f8cd39edb 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -279,6 +279,13 @@ protected:
void postFillThisBuffer(BufferInfo *info);
+ void maybePostExtraOutputMetadataBufferRequest() {
+ if (!mPendingExtraOutputMetadataBufferRequest) {
+ (new AMessage(kWhatSubmitExtraOutputMetadataBuffer, mCodec))->post();
+ mPendingExtraOutputMetadataBufferRequest = true;
+ }
+ }
+
private:
// Handles an OMX message. Returns true iff message was handled.
bool onOMXMessage(const sp<AMessage> &msg);
@@ -302,6 +309,8 @@ private:
void getMoreInputDataIfPossible();
+ bool mPendingExtraOutputMetadataBufferRequest;
+
DISALLOW_EVIL_CONSTRUCTORS(BaseState);
};
@@ -555,6 +564,7 @@ ACodec::ACodec()
mShutdownInProgress(false),
mExplicitShutdown(false),
mIsLegacyVP9Decoder(false),
+ mIsLowLatency(false),
mEncoderDelay(0),
mEncoderPadding(0),
mRotationDegrees(0),
@@ -2425,6 +2435,7 @@ status_t ACodec::setLowLatency(int32_t lowLatency) {
if (err != OK) {
ALOGE("decoder can not set low-latency to %d (err %d)", lowLatency, err);
}
+ mIsLowLatency = (lowLatency && err == OK);
return err;
}
@@ -5785,7 +5796,8 @@ status_t ACodec::requestIDRFrame() {
ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)
: AState(parentState),
- mCodec(codec) {
+ mCodec(codec),
+ mPendingExtraOutputMetadataBufferRequest(false) {
}
ACodec::BaseState::PortMode ACodec::BaseState::getPortMode(
@@ -5886,6 +5898,21 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ case kWhatSubmitExtraOutputMetadataBuffer: {
+ mPendingExtraOutputMetadataBufferRequest = false;
+ if (getPortMode(kPortIndexOutput) == RESUBMIT_BUFFERS && mCodec->mIsLowLatency) {
+ // Decoders often need more than one output buffer to be
+ // submitted before processing a single input buffer.
+ // For low latency codecs, we don't want to wait for more input
+ // to be queued to get those output buffers submitted.
+ if (mCodec->submitOutputMetadataBuffer() == OK
+ && mCodec->mMetadataBuffersToSubmit > 0) {
+ maybePostExtraOutputMetadataBufferRequest();
+ }
+ }
+ break;
+ }
+
default:
return false;
}
@@ -6242,7 +6269,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
(outputMode == FREE_BUFFERS ? "FREE" :
outputMode == KEEP_BUFFERS ? "KEEP" : "RESUBMIT"));
if (outputMode == RESUBMIT_BUFFERS) {
- mCodec->submitOutputMetadataBuffer();
+ status_t err = mCodec->submitOutputMetadataBuffer();
+ if (mCodec->mIsLowLatency
+ && err == OK
+ && mCodec->mMetadataBuffersToSubmit > 0) {
+ maybePostExtraOutputMetadataBufferRequest();
+ }
}
}
info->checkReadFence("onInputBufferFilled");
@@ -7388,6 +7420,9 @@ void ACodec::ExecutingState::submitOutputMetaBuffers() {
break;
}
}
+ if (mCodec->mIsLowLatency) {
+ maybePostExtraOutputMetadataBufferRequest();
+ }
// *** NOTE: THE FOLLOWING WORKAROUND WILL BE REMOVED ***
mCodec->signalSubmitOutputMetadataBufferIfEOS_workaround();
diff --git a/media/libstagefright/include/media/stagefright/ACodec.h b/media/libstagefright/include/media/stagefright/ACodec.h
index 105e7f7f98..8ef92783ec 100644
--- a/media/libstagefright/include/media/stagefright/ACodec.h
+++ b/media/libstagefright/include/media/stagefright/ACodec.h
@@ -147,6 +147,7 @@ private:
kWhatReleaseCodecInstance = 'relC',
kWhatForceStateTransition = 'fstt',
kWhatCheckIfStuck = 'Cstk',
+ kWhatSubmitExtraOutputMetadataBuffer = 'sbxo',
};
enum {
@@ -272,6 +273,7 @@ private:
bool mShutdownInProgress;
bool mExplicitShutdown;
bool mIsLegacyVP9Decoder;
+ bool mIsLowLatency;
// If "mKeepComponentAllocated" we only transition back to Loaded state
// and do not release the component instance.
--
2.25.1
@@ -1,39 +0,0 @@
From 20517633099c124e1c639fab9b693c32875c7fba Mon Sep 17 00:00:00 2001
From: Paras Nagda <pnagda@codeaurora.org>
Date: Tue, 27 Oct 2020 13:01:47 +0530
Subject: [PATCH 24/30] NuPlayerRenderer: Reset negative media time to zero
Reset negative media time to zero before call is made to
Mediaclock's setStartingTimeMedia().
Test:run android.mediastress.cts.HEVCR1080pAacLongPlayerTest#testPlay00 on gsi
Bug: 170621757
Bug: 171945667
Bug: 170797642
Bug: 171562715
Bug: 171850618
Change-Id: I2c405007b38229038119760423156bd53a2701c0
---
media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index c30f048c2d..7e8fe45121 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -922,6 +922,11 @@ size_t NuPlayer::Renderer::fillAudioBuffer(void *buffer, size_t size) {
firstEntry = false;
int64_t mediaTimeUs;
CHECK(entry->mBuffer->meta()->findInt64("timeUs", &mediaTimeUs));
+ if (mediaTimeUs < 0) {
+ ALOGD("fillAudioBuffer: reset negative media time %.2f secs to zero",
+ mediaTimeUs / 1E6);
+ mediaTimeUs = 0;
+ }
ALOGV("fillAudioBuffer: rendering audio at media time %.2f secs", mediaTimeUs / 1E6);
setAudioFirstAnchorTimeIfNeeded_l(mediaTimeUs);
}
--
2.25.1
@@ -1,68 +0,0 @@
From 3e4bfa2b9f1516d70f117c16abfa7bb7b085faf5 Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Thu, 12 Nov 2020 11:14:42 -0800
Subject: [PATCH 25/30] C2OMXNode: read delay from component to determine
buffer count
Bug: 169398817
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Test: atest CtsMediaTestCases:VideoEncoderTest
Change-Id: I76a3411addd83108d2da2c8f74df55acab03a365
(cherry picked from commit 414eb15c3c6cd7e1677245508fd23899bef01feb)
---
media/codec2/sfplugin/C2OMXNode.cpp | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/media/codec2/sfplugin/C2OMXNode.cpp b/media/codec2/sfplugin/C2OMXNode.cpp
index c7588e9a51..dd1f4858a5 100644
--- a/media/codec2/sfplugin/C2OMXNode.cpp
+++ b/media/codec2/sfplugin/C2OMXNode.cpp
@@ -25,6 +25,7 @@
#include <C2AllocatorGralloc.h>
#include <C2BlockInternal.h>
#include <C2Component.h>
+#include <C2Config.h>
#include <C2PlatformSupport.h>
#include <OMX_Component.h>
@@ -44,6 +45,8 @@ namespace android {
namespace {
+constexpr OMX_U32 kPortIndexInput = 0;
+
class Buffer2D : public C2Buffer {
public:
explicit Buffer2D(C2ConstGraphicBlock block) : C2Buffer({ block }) {}
@@ -200,11 +203,27 @@ status_t C2OMXNode::getParameter(OMX_INDEXTYPE index, void *params, size_t size)
return BAD_VALUE;
}
OMX_PARAM_PORTDEFINITIONTYPE *pDef = (OMX_PARAM_PORTDEFINITIONTYPE *)params;
- // TODO: read these from intf()
+ if (pDef->nPortIndex != kPortIndexInput) {
+ break;
+ }
+
pDef->nBufferCountActual = 16;
+
+ std::shared_ptr<Codec2Client::Component> comp = mComp.lock();
+ C2PortActualDelayTuning::input inputDelay(0);
+ C2ActualPipelineDelayTuning pipelineDelay(0);
+ c2_status_t c2err = comp->query(
+ {&inputDelay, &pipelineDelay}, {}, C2_DONT_BLOCK, nullptr);
+ if (c2err == C2_OK || c2err == C2_BAD_INDEX) {
+ pDef->nBufferCountActual = 4;
+ pDef->nBufferCountActual += (inputDelay ? inputDelay.value : 0u);
+ pDef->nBufferCountActual += (pipelineDelay ? pipelineDelay.value : 0u);
+ }
+
pDef->eDomain = OMX_PortDomainVideo;
pDef->format.video.nFrameWidth = mWidth;
pDef->format.video.nFrameHeight = mHeight;
+ pDef->format.video.eColorFormat = OMX_COLOR_FormatAndroidOpaque;
err = OK;
break;
}
--
2.25.1
@@ -1,37 +0,0 @@
From 9a6c5d750f7060922c4a9675f45df15310e75d5b Mon Sep 17 00:00:00 2001
From: Sungtak Lee <taklee@google.com>
Date: Sun, 8 Nov 2020 00:07:27 -0800
Subject: [PATCH 26/30] CCodec: Increase max linear buffer size for 8K video
Increase max linear buffer size to fit a 8K video frame.
Bug: 172190459
Bug: 173683705
Bug: 173725276
Bug: 173768931
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Change-Id: I47cfc2718447ac51be0f90638d7e7055fd7d95ba
(cherry picked from commit 5692578e0d3ff5eb273a63ee9a4f07b719508973)
---
media/codec2/sfplugin/CCodecBuffers.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/media/codec2/sfplugin/CCodecBuffers.h b/media/codec2/sfplugin/CCodecBuffers.h
index 4772ab53eb..c383a7ce1a 100644
--- a/media/codec2/sfplugin/CCodecBuffers.h
+++ b/media/codec2/sfplugin/CCodecBuffers.h
@@ -33,8 +33,8 @@ class MemoryDealer;
class SkipCutBuffer;
constexpr size_t kLinearBufferSize = 1048576;
-// This can fit 4K RGBA frame, and most likely client won't need more than this.
-constexpr size_t kMaxLinearBufferSize = 4096 * 2304 * 4;
+// This can fit an 8K frame.
+constexpr size_t kMaxLinearBufferSize = 7680 * 4320 * 2;
/**
* Base class for representation of buffers at one port.
--
2.25.1
@@ -1,56 +0,0 @@
From 55aa1d77e5fa44434fa4ec7976bd3d4ef0bd4629 Mon Sep 17 00:00:00 2001
From: Lajos Molnar <lajos@google.com>
Date: Wed, 12 Aug 2020 15:56:31 -0700
Subject: [PATCH 27/30] omx: calculate nodePrefix only for components listed in
IOmx
Also make common prefix matching case insensitive.
Bug: 162578527
Change-Id: Iaf66967fd519e0c3eabb8f0c320b8c7e7fd03497
(cherry picked from commit 42f653bd87672f3427bdb522f46c55502e6d20d1)
---
media/libstagefright/omx/1.0/OmxStore.cpp | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/media/libstagefright/omx/1.0/OmxStore.cpp b/media/libstagefright/omx/1.0/OmxStore.cpp
index 67f478ead0..b5c116656f 100644
--- a/media/libstagefright/omx/1.0/OmxStore.cpp
+++ b/media/libstagefright/omx/1.0/OmxStore.cpp
@@ -54,6 +54,24 @@ OmxStore::OmxStore(
});
}
+ if (!nodes.empty()) {
+ auto anyNode = nodes.cbegin();
+ std::string::const_iterator first = anyNode->cbegin();
+ std::string::const_iterator last = anyNode->cend();
+ for (const std::string &name : nodes) {
+ std::string::const_iterator it1 = first;
+ for (std::string::const_iterator it2 = name.cbegin();
+ it1 != last && it2 != name.cend() && tolower(*it1) == tolower(*it2);
+ ++it1, ++it2) {
+ }
+ last = it1;
+ }
+ mPrefix = std::string(first, last);
+ LOG(INFO) << "omx common prefix: '" << mPrefix.c_str() << "'";
+ } else {
+ LOG(INFO) << "omx common prefix: no nodes";
+ }
+
MediaCodecsXmlParser parser;
parser.parseXmlFilesInSearchDirs(xmlNames, searchDirs);
if (profilingResultsXmlPath != nullptr) {
@@ -112,8 +130,6 @@ OmxStore::OmxStore(
mRoleList[i] = std::move(role);
++i;
}
-
- mPrefix = parser.getCommonPrefix();
}
OmxStore::~OmxStore() {
--
2.25.1
@@ -1,126 +0,0 @@
From 7fda1fcb614eab32aec99713919c2e915cca1ccd Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Wed, 25 Nov 2020 10:12:32 -0800
Subject: [PATCH 28/30] C2AllocatorBlob: allow multiple maps
Test: CtsMediaTestCases:DecoderTest
Test: CtsMediaV2TestCases:CodecDecoderTest
Test: VtsHalMediaC2V1_0TargetVideoDecTest
Test: VtsHalMediaC2V1_0TargetVideoEncTest
Test: VtsHalMediaC2V1_0TargetAudioDecTest
Test: VtsHalMediaC2V1_0TargetAudioEncTest
Bug: 173730101
Change-Id: Ief24371e19c8e957ea218ffd9bbfd516353b0cc9
(cherry picked from d04f34cdd8c7ce1a3249a9fbfdd18ca989bb1685)
---
media/codec2/vndk/C2AllocatorBlob.cpp | 72 ++++++++++++++++++++++++---
1 file changed, 66 insertions(+), 6 deletions(-)
diff --git a/media/codec2/vndk/C2AllocatorBlob.cpp b/media/codec2/vndk/C2AllocatorBlob.cpp
index 50c9e59af8..aa054998f8 100644
--- a/media/codec2/vndk/C2AllocatorBlob.cpp
+++ b/media/codec2/vndk/C2AllocatorBlob.cpp
@@ -17,6 +17,8 @@
// #define LOG_NDEBUG 0
#define LOG_TAG "C2AllocatorBlob"
+#include <set>
+
#include <C2AllocatorBlob.h>
#include <C2PlatformSupport.h>
@@ -67,6 +69,10 @@ public:
private:
const std::shared_ptr<C2GraphicAllocation> mGraphicAllocation;
const C2Allocator::id_t mAllocatorId;
+
+ std::mutex mMapLock;
+ std::multiset<std::pair<size_t, size_t>> mMappedOffsetSize;
+ uint8_t *mMappedAddr;
};
C2AllocationBlob::C2AllocationBlob(
@@ -74,20 +80,74 @@ C2AllocationBlob::C2AllocationBlob(
C2Allocator::id_t allocatorId)
: C2LinearAllocation(capacity),
mGraphicAllocation(std::move(graphicAllocation)),
- mAllocatorId(allocatorId) {}
+ mAllocatorId(allocatorId),
+ mMappedAddr(nullptr) {}
-C2AllocationBlob::~C2AllocationBlob() {}
+C2AllocationBlob::~C2AllocationBlob() {
+ if (mMappedAddr) {
+ C2Rect rect(capacity(), kLinearBufferHeight);
+ mGraphicAllocation->unmap(&mMappedAddr, rect, nullptr);
+ }
+}
c2_status_t C2AllocationBlob::map(size_t offset, size_t size, C2MemoryUsage usage,
C2Fence* fence, void** addr /* nonnull */) {
+ *addr = nullptr;
+ if (size > capacity() || offset > capacity() || offset > capacity() - size) {
+ ALOGV("C2AllocationBlob: map: bad offset / size: offset=%zu size=%zu capacity=%u",
+ offset, size, capacity());
+ return C2_BAD_VALUE;
+ }
+ std::unique_lock<std::mutex> lock(mMapLock);
+ if (mMappedAddr) {
+ *addr = mMappedAddr + offset;
+ mMappedOffsetSize.insert({offset, size});
+ ALOGV("C2AllocationBlob: mapped from existing mapping: offset=%zu size=%zu capacity=%u",
+ offset, size, capacity());
+ return C2_OK;
+ }
C2PlanarLayout layout;
- C2Rect rect = C2Rect(size, kLinearBufferHeight).at(offset, 0u);
- return mGraphicAllocation->map(rect, usage, fence, &layout, reinterpret_cast<uint8_t**>(addr));
+ C2Rect rect = C2Rect(capacity(), kLinearBufferHeight);
+ c2_status_t err = mGraphicAllocation->map(rect, usage, fence, &layout, &mMappedAddr);
+ if (err != C2_OK) {
+ ALOGV("C2AllocationBlob: map failed: offset=%zu size=%zu capacity=%u err=%d",
+ offset, size, capacity(), err);
+ mMappedAddr = nullptr;
+ return err;
+ }
+ *addr = mMappedAddr + offset;
+ mMappedOffsetSize.insert({offset, size});
+ ALOGV("C2AllocationBlob: new map succeeded: offset=%zu size=%zu capacity=%u",
+ offset, size, capacity());
+ return C2_OK;
}
c2_status_t C2AllocationBlob::unmap(void* addr, size_t size, C2Fence* fenceFd) {
- C2Rect rect(size, kLinearBufferHeight);
- return mGraphicAllocation->unmap(reinterpret_cast<uint8_t**>(&addr), rect, fenceFd);
+ std::unique_lock<std::mutex> lock(mMapLock);
+ uint8_t *u8Addr = static_cast<uint8_t *>(addr);
+ if (u8Addr < mMappedAddr || mMappedAddr + capacity() < u8Addr + size) {
+ ALOGV("C2AllocationBlob: unmap: Bad addr / size: addr=%p size=%zu capacity=%u",
+ addr, size, capacity());
+ return C2_BAD_VALUE;
+ }
+ auto it = mMappedOffsetSize.find(std::make_pair(u8Addr - mMappedAddr, size));
+ if (it == mMappedOffsetSize.end()) {
+ ALOGV("C2AllocationBlob: unrecognized map: addr=%p size=%zu capacity=%u",
+ addr, size, capacity());
+ return C2_BAD_VALUE;
+ }
+ mMappedOffsetSize.erase(it);
+ if (!mMappedOffsetSize.empty()) {
+ ALOGV("C2AllocationBlob: still maintain mapping: addr=%p size=%zu capacity=%u",
+ addr, size, capacity());
+ return C2_OK;
+ }
+ C2Rect rect(capacity(), kLinearBufferHeight);
+ c2_status_t err = mGraphicAllocation->unmap(&mMappedAddr, rect, fenceFd);
+ ALOGV("C2AllocationBlob: last unmap: addr=%p size=%zu capacity=%u err=%d",
+ addr, size, capacity(), err);
+ mMappedAddr = nullptr;
+ return err;
}
/* ====================================== BLOB ALLOCATOR ====================================== */
--
2.25.1
@@ -1,546 +0,0 @@
From 607c1d606efd9f955ad7545dbfdaf38450c5ce20 Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Thu, 3 Dec 2020 11:07:58 -0800
Subject: [PATCH 29/30] CCodec: fix ByteBuffer mode image
- Set offset to (0,0) of Y plane.
- Fix wrapping criteria.
Bug: 169379476
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Test: atest ccodec_unit_test
Change-Id: Ic7e074ddaef277833707363b0b9fecfe210bd57f
(cherry picked from commit 2eb063152f67e886472ed42c07f3634a5eb63f19)
---
media/codec2/sfplugin/CCodecBuffers.cpp | 3 +
media/codec2/sfplugin/Codec2Buffer.cpp | 14 +-
.../sfplugin/tests/CCodecBuffers_test.cpp | 450 +++++++++++++++++-
3 files changed, 456 insertions(+), 11 deletions(-)
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index 692da584ce..566a18fbee 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -96,6 +96,9 @@ void CCodecBuffers::handleImageData(const sp<Codec2Buffer> &buffer) {
int32_t vstride = int32_t(offsetDelta / stride);
newFormat->setInt32(KEY_SLICE_HEIGHT, vstride);
ALOGD("[%s] updating vstride = %d", mName, vstride);
+ buffer->setRange(
+ img->mPlane[0].mOffset,
+ buffer->size() - img->mPlane[0].mOffset);
}
}
setFormat(newFormat);
diff --git a/media/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp
index 25e7da9206..19414a0a0c 100644
--- a/media/codec2/sfplugin/Codec2Buffer.cpp
+++ b/media/codec2/sfplugin/Codec2Buffer.cpp
@@ -276,20 +276,22 @@ public:
int32_t planeSize = 0;
for (uint32_t i = 0; i < layout.numPlanes; ++i) {
const C2PlaneInfo &plane = layout.planes[i];
- ssize_t minOffset = plane.minOffset(mWidth, mHeight);
- ssize_t maxOffset = plane.maxOffset(mWidth, mHeight);
+ int64_t planeStride = std::abs(plane.rowInc / plane.colInc);
+ ssize_t minOffset = plane.minOffset(
+ mWidth / plane.colSampling, mHeight / plane.rowSampling);
+ ssize_t maxOffset = plane.maxOffset(
+ mWidth / plane.colSampling, mHeight / plane.rowSampling);
if (minPtr > mView.data()[i] + minOffset) {
minPtr = mView.data()[i] + minOffset;
}
if (maxPtr < mView.data()[i] + maxOffset) {
maxPtr = mView.data()[i] + maxOffset;
}
- planeSize += std::abs(plane.rowInc) * align(mHeight, 64)
- / plane.rowSampling / plane.colSampling
- * divUp(mAllocatedDepth, 8u);
+ planeSize += planeStride * divUp(mAllocatedDepth, 8u)
+ * align(mHeight, 64) / plane.rowSampling;
}
- if ((maxPtr - minPtr + 1) <= planeSize) {
+ if (minPtr == mView.data()[0] && (maxPtr - minPtr + 1) <= planeSize) {
// FIXME: this is risky as reading/writing data out of bound results
// in an undefined behavior, but gralloc does assume a
// contiguous mapping
diff --git a/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp b/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
index 5bee605276..ad8f6e555b 100644
--- a/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
+++ b/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
@@ -18,22 +18,31 @@
#include <gtest/gtest.h>
+#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/MediaCodecConstants.h>
+#include <C2BlockInternal.h>
#include <C2PlatformSupport.h>
namespace android {
+static std::shared_ptr<RawGraphicOutputBuffers> GetRawGraphicOutputBuffers(
+ int32_t width, int32_t height) {
+ std::shared_ptr<RawGraphicOutputBuffers> buffers =
+ std::make_shared<RawGraphicOutputBuffers>("test");
+ sp<AMessage> format{new AMessage};
+ format->setInt32(KEY_WIDTH, width);
+ format->setInt32(KEY_HEIGHT, height);
+ buffers->setFormat(format);
+ return buffers;
+}
+
TEST(RawGraphicOutputBuffersTest, ChangeNumSlots) {
constexpr int32_t kWidth = 3840;
constexpr int32_t kHeight = 2160;
std::shared_ptr<RawGraphicOutputBuffers> buffers =
- std::make_shared<RawGraphicOutputBuffers>("test");
- sp<AMessage> format{new AMessage};
- format->setInt32("width", kWidth);
- format->setInt32("height", kHeight);
- buffers->setFormat(format);
+ GetRawGraphicOutputBuffers(kWidth, kHeight);
std::shared_ptr<C2BlockPool> pool;
ASSERT_EQ(OK, GetCodec2BlockPool(C2BlockPool::BASIC_GRAPHIC, nullptr, &pool));
@@ -96,4 +105,435 @@ TEST(RawGraphicOutputBuffersTest, ChangeNumSlots) {
}
}
+class TestGraphicAllocation : public C2GraphicAllocation {
+public:
+ TestGraphicAllocation(
+ uint32_t width,
+ uint32_t height,
+ const C2PlanarLayout &layout,
+ size_t capacity,
+ std::vector<size_t> offsets)
+ : C2GraphicAllocation(width, height),
+ mLayout(layout),
+ mMemory(capacity, 0xAA),
+ mOffsets(offsets) {
+ }
+
+ c2_status_t map(
+ C2Rect rect, C2MemoryUsage usage, C2Fence *fence,
+ C2PlanarLayout *layout, uint8_t **addr) override {
+ (void)rect;
+ (void)usage;
+ (void)fence;
+ *layout = mLayout;
+ for (size_t i = 0; i < mLayout.numPlanes; ++i) {
+ addr[i] = mMemory.data() + mOffsets[i];
+ }
+ return C2_OK;
+ }
+
+ c2_status_t unmap(uint8_t **, C2Rect, C2Fence *) override { return C2_OK; }
+
+ C2Allocator::id_t getAllocatorId() const override { return -1; }
+
+ const C2Handle *handle() const override { return nullptr; }
+
+ bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override {
+ return other.get() == this;
+ }
+
+private:
+ C2PlanarLayout mLayout;
+ std::vector<uint8_t> mMemory;
+ std::vector<uint8_t *> mAddr;
+ std::vector<size_t> mOffsets;
+};
+
+class LayoutTest : public ::testing::TestWithParam<std::tuple<bool, std::string, bool, int32_t>> {
+private:
+ static C2PlanarLayout YUVPlanarLayout(int32_t stride) {
+ C2PlanarLayout layout = {
+ C2PlanarLayout::TYPE_YUV,
+ 3, /* numPlanes */
+ 3, /* rootPlanes */
+ {}, /* planes --- to be filled below */
+ };
+ layout.planes[C2PlanarLayout::PLANE_Y] = {
+ C2PlaneInfo::CHANNEL_Y,
+ 1, /* colInc */
+ stride, /* rowInc */
+ 1, /* colSampling */
+ 1, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_Y, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_U] = {
+ C2PlaneInfo::CHANNEL_CB,
+ 1, /* colInc */
+ stride / 2, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_U, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_V] = {
+ C2PlaneInfo::CHANNEL_CR,
+ 1, /* colInc */
+ stride / 2, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_V, /* rootIx */
+ 0, /* offset */
+ };
+ return layout;
+ }
+
+ static C2PlanarLayout YUVSemiPlanarLayout(int32_t stride) {
+ C2PlanarLayout layout = {
+ C2PlanarLayout::TYPE_YUV,
+ 3, /* numPlanes */
+ 2, /* rootPlanes */
+ {}, /* planes --- to be filled below */
+ };
+ layout.planes[C2PlanarLayout::PLANE_Y] = {
+ C2PlaneInfo::CHANNEL_Y,
+ 1, /* colInc */
+ stride, /* rowInc */
+ 1, /* colSampling */
+ 1, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_Y, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_U] = {
+ C2PlaneInfo::CHANNEL_CB,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_U, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_V] = {
+ C2PlaneInfo::CHANNEL_CR,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_U, /* rootIx */
+ 1, /* offset */
+ };
+ return layout;
+ }
+
+ static C2PlanarLayout YVUSemiPlanarLayout(int32_t stride) {
+ C2PlanarLayout layout = {
+ C2PlanarLayout::TYPE_YUV,
+ 3, /* numPlanes */
+ 2, /* rootPlanes */
+ {}, /* planes --- to be filled below */
+ };
+ layout.planes[C2PlanarLayout::PLANE_Y] = {
+ C2PlaneInfo::CHANNEL_Y,
+ 1, /* colInc */
+ stride, /* rowInc */
+ 1, /* colSampling */
+ 1, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_Y, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_U] = {
+ C2PlaneInfo::CHANNEL_CB,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_V, /* rootIx */
+ 1, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_V] = {
+ C2PlaneInfo::CHANNEL_CR,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_V, /* rootIx */
+ 0, /* offset */
+ };
+ return layout;
+ }
+
+ static std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
+ uint32_t width,
+ uint32_t height,
+ const C2PlanarLayout &layout,
+ size_t capacity,
+ std::vector<size_t> offsets) {
+ std::shared_ptr<C2GraphicAllocation> alloc = std::make_shared<TestGraphicAllocation>(
+ width,
+ height,
+ layout,
+ capacity,
+ offsets);
+
+ return _C2BlockFactory::CreateGraphicBlock(alloc);
+ }
+
+ static constexpr uint8_t GetPixelValue(uint8_t value, uint32_t row, uint32_t col) {
+ return (uint32_t(value) * row + col) & 0xFF;
+ }
+
+ static void FillPlane(C2GraphicView &view, size_t index, uint8_t value) {
+ C2PlanarLayout layout = view.layout();
+
+ uint8_t *rowPtr = view.data()[index];
+ C2PlaneInfo plane = layout.planes[index];
+ for (uint32_t row = 0; row < view.height() / plane.rowSampling; ++row) {
+ uint8_t *colPtr = rowPtr;
+ for (uint32_t col = 0; col < view.width() / plane.colSampling; ++col) {
+ *colPtr = GetPixelValue(value, row, col);
+ colPtr += plane.colInc;
+ }
+ rowPtr += plane.rowInc;
+ }
+ }
+
+ static void FillBlock(const std::shared_ptr<C2GraphicBlock> &block) {
+ C2GraphicView view = block->map().get();
+
+ FillPlane(view, C2PlanarLayout::PLANE_Y, 'Y');
+ FillPlane(view, C2PlanarLayout::PLANE_U, 'U');
+ FillPlane(view, C2PlanarLayout::PLANE_V, 'V');
+ }
+
+ static bool VerifyPlane(
+ const MediaImage2 *mediaImage,
+ const uint8_t *base,
+ uint32_t index,
+ uint8_t value,
+ std::string *errorMsg) {
+ *errorMsg = "";
+ MediaImage2::PlaneInfo plane = mediaImage->mPlane[index];
+ const uint8_t *rowPtr = base + plane.mOffset;
+ for (uint32_t row = 0; row < mediaImage->mHeight / plane.mVertSubsampling; ++row) {
+ const uint8_t *colPtr = rowPtr;
+ for (uint32_t col = 0; col < mediaImage->mWidth / plane.mHorizSubsampling; ++col) {
+ if (GetPixelValue(value, row, col) != *colPtr) {
+ *errorMsg = AStringPrintf("row=%u col=%u expected=%02x actual=%02x",
+ row, col, GetPixelValue(value, row, col), *colPtr).c_str();
+ return false;
+ }
+ colPtr += plane.mColInc;
+ }
+ rowPtr += plane.mRowInc;
+ }
+ return true;
+ }
+
+public:
+ static constexpr int32_t kWidth = 320;
+ static constexpr int32_t kHeight = 240;
+ static constexpr int32_t kGapLength = kWidth * kHeight * 10;
+
+ static std::shared_ptr<C2Buffer> CreateAndFillBufferFromParam(const ParamType &param) {
+ bool contiguous = std::get<0>(param);
+ std::string planeOrderStr = std::get<1>(param);
+ bool planar = std::get<2>(param);
+ int32_t stride = std::get<3>(param);
+
+ C2PlanarLayout::plane_index_t planeOrder[3];
+ C2PlanarLayout layout;
+
+ if (planeOrderStr.size() != 3) {
+ return nullptr;
+ }
+ for (size_t i = 0; i < 3; ++i) {
+ C2PlanarLayout::plane_index_t planeIndex;
+ switch (planeOrderStr[i]) {
+ case 'Y': planeIndex = C2PlanarLayout::PLANE_Y; break;
+ case 'U': planeIndex = C2PlanarLayout::PLANE_U; break;
+ case 'V': planeIndex = C2PlanarLayout::PLANE_V; break;
+ default: return nullptr;
+ }
+ planeOrder[i] = planeIndex;
+ }
+
+ if (planar) {
+ layout = YUVPlanarLayout(stride);
+ } else { // semi-planar
+ for (size_t i = 0; i < 3; ++i) {
+ if (planeOrder[i] == C2PlanarLayout::PLANE_U) {
+ layout = YUVSemiPlanarLayout(stride);
+ break;
+ }
+ if (planeOrder[i] == C2PlanarLayout::PLANE_V) {
+ layout = YVUSemiPlanarLayout(stride);
+ break;
+ }
+ }
+ }
+
+ size_t yPlaneSize = stride * kHeight;
+ size_t uvPlaneSize = stride * kHeight / 4;
+ size_t capacity = yPlaneSize + uvPlaneSize * 2;
+ std::vector<size_t> offsets(3);
+
+ if (!contiguous) {
+ if (planar) {
+ capacity += kGapLength * 2;
+ } else { // semi-planar
+ capacity += kGapLength;
+ }
+ }
+
+ offsets[planeOrder[0]] = 0;
+ size_t planeSize = (planeOrder[0] == C2PlanarLayout::PLANE_Y) ? yPlaneSize : uvPlaneSize;
+ for (size_t i = 1; i < 3; ++i) {
+ offsets[planeOrder[i]] = offsets[planeOrder[i - 1]] + planeSize;
+ if (!contiguous) {
+ offsets[planeOrder[i]] += kGapLength;
+ }
+ planeSize = (planeOrder[i] == C2PlanarLayout::PLANE_Y) ? yPlaneSize : uvPlaneSize;
+ if (!planar // semi-planar
+ && planeOrder[i - 1] != C2PlanarLayout::PLANE_Y
+ && planeOrder[i] != C2PlanarLayout::PLANE_Y) {
+ offsets[planeOrder[i]] = offsets[planeOrder[i - 1]] + 1;
+ planeSize = uvPlaneSize * 2 - 1;
+ }
+ }
+
+ std::shared_ptr<C2GraphicBlock> block = CreateGraphicBlock(
+ kWidth,
+ kHeight,
+ layout,
+ capacity,
+ offsets);
+ FillBlock(block);
+ return C2Buffer::CreateGraphicBuffer(
+ block->share(block->crop(), C2Fence()));
+ }
+
+ static bool VerifyClientBuffer(
+ const sp<MediaCodecBuffer> &buffer, std::string *errorMsg) {
+ *errorMsg = "";
+ sp<ABuffer> imageData;
+ if (!buffer->format()->findBuffer("image-data", &imageData)) {
+ *errorMsg = "Missing image data";
+ return false;
+ }
+ MediaImage2 *mediaImage = (MediaImage2 *)imageData->data();
+ if (mediaImage->mType != MediaImage2::MEDIA_IMAGE_TYPE_YUV) {
+ *errorMsg = AStringPrintf("Unexpected type: %d", mediaImage->mType).c_str();
+ return false;
+ }
+ std::string planeErrorMsg;
+ if (!VerifyPlane(mediaImage, buffer->base(), MediaImage2::Y, 'Y', &planeErrorMsg)) {
+ *errorMsg = "Y plane does not match: " + planeErrorMsg;
+ return false;
+ }
+ if (!VerifyPlane(mediaImage, buffer->base(), MediaImage2::U, 'U', &planeErrorMsg)) {
+ *errorMsg = "U plane does not match: " + planeErrorMsg;
+ return false;
+ }
+ if (!VerifyPlane(mediaImage, buffer->base(), MediaImage2::V, 'V', &planeErrorMsg)) {
+ *errorMsg = "V plane does not match: " + planeErrorMsg;
+ return false;
+ }
+
+ int32_t width, height, stride;
+ buffer->format()->findInt32(KEY_WIDTH, &width);
+ buffer->format()->findInt32(KEY_HEIGHT, &height);
+ buffer->format()->findInt32(KEY_STRIDE, &stride);
+
+ MediaImage2 legacyYLayout = {
+ MediaImage2::MEDIA_IMAGE_TYPE_Y,
+ 1, // mNumPlanes
+ uint32_t(width),
+ uint32_t(height),
+ 8,
+ 8,
+ {}, // mPlane
+ };
+ legacyYLayout.mPlane[MediaImage2::Y] = {
+ 0, // mOffset
+ 1, // mColInc
+ stride, // mRowInc
+ 1, // mHorizSubsampling
+ 1, // mVertSubsampling
+ };
+ if (!VerifyPlane(&legacyYLayout, buffer->data(), MediaImage2::Y, 'Y', &planeErrorMsg)) {
+ *errorMsg = "Y plane by legacy layout does not match: " + planeErrorMsg;
+ return false;
+ }
+ return true;
+ }
+
+};
+
+TEST_P(LayoutTest, VerifyLayout) {
+ std::shared_ptr<RawGraphicOutputBuffers> buffers =
+ GetRawGraphicOutputBuffers(kWidth, kHeight);
+
+ std::shared_ptr<C2Buffer> c2Buffer = CreateAndFillBufferFromParam(GetParam());
+ ASSERT_NE(nullptr, c2Buffer);
+ sp<MediaCodecBuffer> clientBuffer;
+ size_t index;
+ ASSERT_EQ(OK, buffers->registerBuffer(c2Buffer, &index, &clientBuffer));
+ ASSERT_NE(nullptr, clientBuffer);
+ std::string errorMsg;
+ ASSERT_TRUE(VerifyClientBuffer(clientBuffer, &errorMsg)) << errorMsg;
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ RawGraphicOutputBuffersTest,
+ LayoutTest,
+ ::testing::Combine(
+ ::testing::Bool(), /* contiguous */
+ ::testing::Values("YUV", "YVU", "UVY", "VUY"),
+ ::testing::Bool(), /* planar */
+ ::testing::Values(320, 512)),
+ [](const ::testing::TestParamInfo<LayoutTest::ParamType> &info) {
+ std::string contiguous = std::get<0>(info.param) ? "Contiguous" : "Noncontiguous";
+ std::string planar = std::get<2>(info.param) ? "Planar" : "SemiPlanar";
+ return contiguous
+ + std::get<1>(info.param)
+ + planar
+ + std::to_string(std::get<3>(info.param));
+ });
+
} // namespace android
--
2.25.1
@@ -1,53 +0,0 @@
From c833b08d188dbb1294e164958c51ac2afb0e3e2e Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Tue, 5 Jan 2021 18:55:22 -0800
Subject: [PATCH 31/32] CCodec: workaround for frame drops
Retain old behavior for lower resolution (<=4K) to workaround
possible frame drops.
Bug: 175354926
Bug: 175182085
Test: atest CtsCameraTestCases:RecordingTest
Change-Id: I170102e928714c5b48817bf7915f55ce8a6280f0
---
media/codec2/sfplugin/CCodec.cpp | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 2f16ca1104..55ff18f4a2 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -247,15 +247,20 @@ public:
return NO_INIT;
}
- size_t numSlots = 4;
- constexpr OMX_U32 kPortIndexInput = 0;
-
- OMX_PARAM_PORTDEFINITIONTYPE param;
- param.nPortIndex = kPortIndexInput;
- status_t err = mNode->getParameter(OMX_IndexParamPortDefinition,
- &param, sizeof(param));
- if (err == OK) {
- numSlots = param.nBufferCountActual;
+ size_t numSlots = 16;
+ // WORKAROUND: having more slots improve performance while consuming
+ // more memory. This is a temporary workaround to reduce memory for
+ // larger-than-4K scenario.
+ if (mWidth * mHeight > 4096 * 2340) {
+ constexpr OMX_U32 kPortIndexInput = 0;
+
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ param.nPortIndex = kPortIndexInput;
+ status_t err = mNode->getParameter(OMX_IndexParamPortDefinition,
+ &param, sizeof(param));
+ if (err == OK) {
+ numSlots = param.nBufferCountActual;
+ }
}
for (size_t i = 0; i < numSlots; ++i) {
--
2.25.1
@@ -1,30 +0,0 @@
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
@@ -1,99 +0,0 @@
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
@@ -1,26 +0,0 @@
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
@@ -1,40 +0,0 @@
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
@@ -1,31 +0,0 @@
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
@@ -1,73 +0,0 @@
From 2fd4810ec5e6a453e980cacba2e1bcdd30b3f967 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 14 Apr 2021 10:20:22 +0800
Subject: [PATCH 39/40] Revert "AudioPolicyManager: retry with SW bridge if
hardware audio patch fails"
This reverts commit 5d869232d42a2fee6b7cb07b6a240aef5838021b.
---
.../managerdefault/AudioPolicyManager.cpp | 13 +++----------
.../audiopolicy/managerdefault/AudioPolicyManager.h | 4 +---
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 6d2c38811e..63dcd538b1 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -3490,8 +3490,7 @@ 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,
- bool forceSwBridge)
+ const sp<SourceClientDescriptor>& sourceDesc)
{
ALOGV("%s", __func__);
if (handle == NULL || patch == NULL) {
@@ -3695,8 +3694,7 @@ 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
- // - a previous attempt at using HW bridge failed (forceSwBridge)
- if (forceSwBridge || !srcDevice->hasSameHwModuleAs(sinkDevice) ||
+ if (!srcDevice->hasSameHwModuleAs(sinkDevice) ||
(srcDevice->getModuleVersionMajor() < 3) ||
!srcDevice->getModule()->supportsPatch(srcDevice, sinkDevice) ||
(sourceDesc != nullptr &&
@@ -3761,12 +3759,7 @@ 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);
- 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);
- }
+ return INVALID_OPERATION;
}
} else {
return BAD_VALUE;
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 60cbd7175e..b588f898d4 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -910,14 +910,12 @@ 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,
- bool forceSwBridge = false);
+ const sp<SourceClientDescriptor>& sourceDesc = nullptr);
/**
* @brief releaseAudioPatchInternal internal function to remove an audio patch
* @param[in] handle of the patch to be removed
--
2.25.1
@@ -1,78 +0,0 @@
From 7bb3de067cec0c8c3bd5341bf9ad42b808fefd39 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 14 Apr 2021 11:09:12 +0800
Subject: [PATCH 40/40] APM: Fall back to legacy voice call routing if creating
audio patch failed
* On some MT6771 Q vendor devices, in-call audio is broken due to APM
failing to create an HW audio patch for RX / TX devices.
> 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
* Our previous attempt at fixing this by falling back to SW bridging was
wrong, because SW bridging requires a corresponding audio policy
configuration that includes said SW bridges, which is not the case on
these devices.
* The sole reason why this was broken at all is that the new R behavior
tries to use the newer `createAudioPatch` interface of the audio HAL,
which is broken on these devices for telephony inputs and outputs,
even though the HAL claims to support it.
* Let's fall back to pre-R behavior (i.e. using the legacy
setOutputDevices() interface) whenever the new method fails. The
legacy method takes care of TX (Mic input) as well, so we don't need
to create the TX patch either.
---
.../managerdefault/AudioPolicyManager.cpp | 23 +++++++++++++++----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 63dcd538b1..124c6ca6ef 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -575,17 +575,30 @@ uint32_t AudioPolicyManager::updateCallRouting(const DeviceVector &rxDevices, ui
createTxPatch = !(availablePrimaryModuleInputDevices().contains(txSourceDevice)) &&
(txSinkDevice != 0);
}
- // Use legacy routing method for voice calls via setOutputDevice() on primary output.
- // Otherwise, create two audio patches for TX and RX path.
- if (!createRxPatch) {
- muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
- } else { // create RX path audio patch
+ if (createRxPatch) { // create RX path audio patch
mCallRxPatch = createTelephonyPatch(true /*isRx*/, rxDevices.itemAt(0), delayMs);
+ if (mCallRxPatch == nullptr) {
+ // Fall back to legacy routing for voice calls if the new patching method
+ // failed. setOutputDevice() will take care of TX in this case, so don't
+ // create the TX patch either.
+ // This is seen on some MT6771 devices on Q vendor, where the HAL claims
+ // support for HW patch between telephony inputs and outputs, but fails
+ // to create one when called with the createAudioPatch() method. SW audio
+ // bridges are also broken on them due to improperly configured audio policy.
+ ALOGW("Failed to create RX path audio patch, falling back to pre-R behavior");
+ createRxPatch = false;
+ createTxPatch = false;
+ }
+
// If the TX device is on the primary HW module but RX device is
// on other HW module, SinkMetaData of telephony input should handle it
// assuming the device uses audio HAL V5.0 and above
}
+ // Use legacy routing method for voice calls via setOutputDevice() on primary output.
+ if (!createRxPatch) {
+ muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
+ }
if (createTxPatch) { // create TX path audio patch
// terminate active capture if on the same HW module as the call TX source device
// FIXME: would be better to refine to only inputs whose profile connects to the
--
2.25.1
@@ -1,136 +0,0 @@
From db0376e279f7aa4744934376157b844f51d334ce Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 24 Mar 2018 08:01:48 +0100
Subject: [PATCH] backlight: Fix backlight control on Galaxy S9(+)
Change-Id: I1fbbb47939c377597ef8ad6b88b2acea5f4acaa6
:backlight: S9 brightness override only for screen
Change-Id: Ie16a46336fa64850014b962429f7a20ff569222f
:backlight: [WIP] Fix OP6 brightness
Change-Id: If08959ece6cac1f27e1f1a0bd966ee8e1813241d
:backlight: Try to make brightness more generic using property set by rw-system
Change-Id: I0f20ca4b1f0fa1fcfd19833aa291fbdf16d6eedd
:backlight: Add Qualcomm starlte
Change-Id: I12a445344deb8b2e59a2f6ce6b24c1ffe5675092
:backlight: Switch samsung light fingerprint match to regexp, to include Note9
Change-Id: I2995f7bab615aec125927a5a027ad8f9ae43405f
Add a property toggle to enable high brightness range on samsung device
Change-Id: I649a3985ef87f46a5515a63935fdae9cdcbd8ec5
:backlight: Add japanese S9
Change-Id: I5e245469f5f51fed14c6080e5be72506e10389e0
:backlight: Fix backlight on S10*. Add an additional property to check, so testers can try it more easily
Change-Id: Ia224e641cad8561201b4dee3d896362bee80c903
:backlight: Make samsung light HAL more overridable
Change-Id: Ie04f394f8a614da8070f330bcadbcbe12895bed0
Use new backlight control API only for backlight, not for other lights
Change-Id: I35c35fabff8b275f35671dcb8578b96dcad526f1
:backlight: fixup
Change-Id: I4e85178327d2bb63d5d0a37786058843662a89ba
---
.../android/server/lights/LightsService.java | 49 ++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index f712e8de353..43264cb32d2 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -33,6 +33,7 @@ import android.os.Looper;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemProperties;
import android.os.Trace;
import android.provider.Settings;
import android.util.Slog;
@@ -302,12 +303,13 @@ public class LightsService extends SystemService {
+ ": brightness=" + brightness);
return;
}
+
// Ideally, we'd like to set the brightness mode through the SF/HWC as well, but
// right now we just fall back to the old path through Lights brightessMode is
// anything but USER or the device shouldBeInLowPersistenceMode().
if (brightnessMode == BRIGHTNESS_MODE_USER && !shouldBeInLowPersistenceMode()
&& mHwLight.type == LightsManager.LIGHT_ID_BACKLIGHT
- && mSurfaceControlMaximumBrightness == 255) {
+ && mSurfaceControlMaximumBrightness == 255 && mHwLight.id == 0) {
// New system
// TODO: the last check should be mSurfaceControlMaximumBrightness != 0; the
// reason we enforce 255 right now is to stay consistent with the old path. In
@@ -322,6 +324,51 @@ public class LightsService extends SystemService {
// Old system
int brightnessInt = BrightnessSynchronizer.brightnessFloatToInt(
getContext(), brightness);
+
+ if(mHwLight.id == 0) {
+ String fp = SystemProperties.get("ro.vendor.build.fingerprint", "hello");
+ if(fp.matches(".*astarqlte.*")) {
+ int newBrightness = brightnessInt;
+ if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
+ newBrightness = (int) (brightnessInt * 365.0 / 255.0);
+ }
+ setLightLocked(newBrightness, LIGHT_FLASH_HARDWARE, 0, 0, brightnessMode);
+ return;
+ }
+
+ int useSamsungBacklight = SystemProperties.getInt("persist.sys.phh.samsung_backlight", -1);
+ if(useSamsungBacklight != 0) {
+ if(useSamsungBacklight > 0 ||
+ fp.matches(".*beyond.*lte.*") ||
+ fp.matches(".*(crown|star)[q2]*lte.*") ||
+ fp.matches(".*(SC-0[23]K|SCV3[89]).*")) {
+ int ratio = 100;
+ if(useSamsungBacklight > 1)
+ ratio = useSamsungBacklight;
+ int newBrightness = brightnessInt * ratio;
+ if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
+ newBrightness = (int) (brightnessInt * 40960.0 / 255.0);
+ }
+ setLightLocked(newBrightness, LIGHT_FLASH_HARDWARE, 0, 0, brightnessMode);
+ return;
+ }
+ }
+
+ boolean qcomExtendBrightness = SystemProperties.getBoolean("persist.extend.brightness", false);
+ int scale = SystemProperties.getInt("persist.display.max_brightness", 1023);
+ //This is set by vndk-detect
+ int qcomScale = SystemProperties.getInt("persist.sys.qcom-brightness", -1);
+ if(qcomScale != -1) {
+ qcomExtendBrightness = true;
+ scale = qcomScale;
+ }
+
+ if(qcomExtendBrightness) {
+ setLightLocked(brightnessInt * scale / 255, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
+ return;
+ }
+ }
+
int color = brightnessInt & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
--
2.25.1
@@ -1,43 +0,0 @@
From b236ed36a97c09a15fa18d3387ff20dadd5be965 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 1 May 2018 17:47:36 +0200
Subject: [PATCH 03/25] Also scan /system/overlay
Change-Id: Ib0223560606b80cdaaa986b159b34b4db0154589
---
core/jni/android_util_AssetManager.cpp | 4 ++++
core/jni/fd_utils.cpp | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 12abc256a20..3133f2f3023 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -140,6 +140,10 @@ static jobjectArray NativeCreateIdmapsForStaticOverlaysTargetingAndroid(JNIEnv*
input_dirs.push_back(AssetManager::OEM_OVERLAY_DIR);
}
+ if (stat("/system/overlay", &st) == 0) {
+ input_dirs.push_back("/system/overlay");
+ }
+
if (input_dirs.empty()) {
LOG(WARNING) << "no directories for idmap2 to scan";
return env->NewObjectArray(0, g_stringClass, nullptr);
diff --git a/core/jni/fd_utils.cpp b/core/jni/fd_utils.cpp
index c72668f84fb..d4307ae6579 100644
--- a/core/jni/fd_utils.cpp
+++ b/core/jni/fd_utils.cpp
@@ -135,7 +135,8 @@ bool FileDescriptorWhitelist::IsAllowed(const std::string& path) const {
|| android::base::StartsWith(path, kSystemOdmOverlayDir)
|| android::base::StartsWith(path, kOdmOverlayDir)
|| android::base::StartsWith(path, kSystemOemOverlayDir)
- || android::base::StartsWith(path, kOemOverlayDir))
+ || android::base::StartsWith(path, kOemOverlayDir)
+ || android::base::StartsWith(path, "/system/overlay"))
&& android::base::EndsWith(path, kApkSuffix)
&& path.find("/../") == std::string::npos) {
return true;
--
2.17.1
@@ -1,25 +0,0 @@
From 2436b6da10c438a3b71ca3a2a5aa9705e7c00813 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 17 May 2018 20:28:35 +0200
Subject: [PATCH 04/25] Don't crash if there is IR HAL is not declared
---
services/core/java/com/android/server/ConsumerIrService.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
index 2ed6c77baa0..c574a03c9a3 100644
--- a/services/core/java/com/android/server/ConsumerIrService.java
+++ b/services/core/java/com/android/server/ConsumerIrService.java
@@ -50,8 +50,6 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
if (!mHasNativeHal) {
throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
}
- } else if (mHasNativeHal) {
- throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
}
}
--
2.17.1
@@ -1,28 +0,0 @@
From 25b2ec68fe9ce8a2e3b35fc91ff47ae65ba95be4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 30 May 2018 14:05:30 +0200
Subject: [PATCH 05/25] Fix(?) #62
---
.../src/com/android/keyguard/KeyguardUpdateMonitor.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 3acbfb87c3f..358053343f2 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -1270,7 +1270,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
- handleFingerprintError(errMsgId, errString.toString());
+ if(errString != null)
+ handleFingerprintError(errMsgId, errString.toString());
+ else
+ handleFingerprintError(errMsgId, "unknown error");
}
@Override
--
2.17.1
@@ -1,38 +0,0 @@
From f3d0a467c4c1f9df19c3c4819b4c6cb4b26fe2a3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 11 Sep 2020 23:42:37 +0200
Subject: [PATCH] property-matching RROs: allow to prefix the value with + to
do glob match instead of exact match
Change-Id: I1f5b7c907523eb6e48d41f5163984564d3db9506
---
cmds/idmap2/idmap2/Scan.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmds/idmap2/idmap2/Scan.cpp b/cmds/idmap2/idmap2/Scan.cpp
index 36250450cc7..6a5162dd0d9 100644
--- a/cmds/idmap2/idmap2/Scan.cpp
+++ b/cmds/idmap2/idmap2/Scan.cpp
@@ -15,6 +15,7 @@
*/
#include <dirent.h>
+#include <fnmatch.h>
#include <fstream>
#include <memory>
@@ -187,7 +188,10 @@ Result<Unit> Scan(const std::vector<std::string>& args) {
// if property set & equal to value, then include overlay - otherwise skip
if (android::base::GetProperty(overlay_info->requiredSystemPropertyName, "") !=
overlay_info->requiredSystemPropertyValue) {
- continue;
+ auto osValue = android::base::GetProperty(overlay_info->requiredSystemPropertyName, "");
+ if(fnmatch(overlay_info->requiredSystemPropertyValue.c_str()+1, osValue.c_str(), 0) != 0) {
+ continue;
+ }
}
}
--
2.25.1
@@ -1,33 +0,0 @@
From 649f6bd7789acae16c1e3fa8c57919bd4ae0d1e3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 2 Jul 2018 23:36:39 +0200
Subject: [PATCH 07/25] [Galaxy S9] "remaining" of HAL onEnroll is actually a
percent of progress
Change-Id: I8a586163eca93ae3c5bd968d1e7ddbf994ddcc91
---
.../server/biometrics/fingerprint/FingerprintService.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
index 6b7ba6a56d8..c247731be13 100644
--- a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
@@ -588,7 +588,13 @@ public class FingerprintService extends BiometricServiceBase {
final Fingerprint fingerprint =
new Fingerprint(getBiometricUtils().getUniqueName(getContext(), groupId),
groupId, fingerId, deviceId);
- FingerprintService.super.handleEnrollResult(fingerprint, remaining);
+
+ int remaining2 = remaining;
+ String fp = android.os.SystemProperties.get("ro.vendor.build.fingerprint");
+ if(fp != null && (fp.contains("starlte") || fp.contains("star2lte") || fp.contains("starqlte") || fp.contains("star2qlte")))
+ remaining2 = 100 - remaining2;
+
+ FingerprintService.super.handleEnrollResult(fingerprint, remaining2);
});
}
--
2.17.1
@@ -1,176 +0,0 @@
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 +++++++++++++++++++
...droid_server_power_PowerManagerService.cpp | 22 ++++++++
3 files changed, 76 insertions(+)
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index 0b085d65e4c..36315e951e3 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -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",
],
static_libs: [
diff --git a/services/core/jni/com_android_server_lights_LightsService.cpp b/services/core/jni/com_android_server_lights_LightsService.cpp
index 35d8219651d..b45b2137d0e 100644
--- a/services/core/jni/com_android_server_lights_LightsService.cpp
+++ b/services/core/jni/com_android_server_lights_LightsService.cpp
@@ -23,6 +23,10 @@
#include <android/hardware/light/2.0/ILight.h>
#include <android/hardware/light/2.0/types.h>
+#include <vendor/samsung/hardware/light/2.0/ISecLight.h>
+#include <vendor/samsung/hardware/light/2.0/types.h>
+#include <vendor/samsung/hardware/light/3.0/ISehLight.h>
+#include <vendor/samsung/hardware/light/3.0/types.h>
#include <android-base/chrono_utils.h>
#include <utils/misc.h>
#include <utils/Log.h>
@@ -40,8 +44,17 @@ using Type = ::android::hardware::light::V2_0::Type;
template<typename T>
using Return = ::android::hardware::Return<T>;
+using ISecLight = ::vendor::samsung::hardware::light::V2_0::ISecLight;
+using SecType = ::vendor::samsung::hardware::light::V2_0::SecType;
+using ISehLight = ::vendor::samsung::hardware::light::V3_0::ISehLight;
+using SehType = ::vendor::samsung::hardware::light::V3_0::SehType;
+using SehLightState = ::vendor::samsung::hardware::light::V3_0::SehLightState;
static bool sLightSupported = true;
+static sp<ISecLight> sSecHal;
+static sp<ISehLight> sSehHal;
+static bool sSecTried = false;
+
static bool validate(jint light, jint flash, jint brightness) {
bool valid = true;
@@ -152,6 +165,44 @@ static void setLight_native(
colorARGB = (colorAlpha << 24) + (colorARGB & 0x00FFFFFF);
}
+ if(!sSecTried) {
+ sSecHal = ISecLight::getService();
+ sSehHal = ISehLight::getService();
+ //sSecTried = true;
+ }
+
+ if(sSecHal != nullptr) {
+ SecType type = static_cast<SecType>(light);
+ LightState state = constructState(
+ colorARGB, flashMode, onMS, offMS, brightnessMode);
+
+ {
+ android::base::Timer t;
+ Return<Status> ret = sSecHal->setLightSec(type, state);
+ processReturn(ret, static_cast<Type>(light), state);
+ if (t.duration() > 50ms) ALOGD("Excessive delay setting light");
+ }
+ }
+
+ if(sSehHal != nullptr && light == 0 && flashMode == static_cast<jint>(Flash::HARDWARE)) {
+ SehType type = static_cast<SehType>(light);
+ SehLightState state {};
+ state.flashMode = Flash::NONE;
+ Brightness brightness = static_cast<Brightness>(brightnessMode);
+ state.brightnessMode = brightness;
+ state.extendedBrightness = colorARGB;
+
+ {
+ android::base::Timer t;
+ Return<Status> ret = sSehHal->sehSetLight(type, state);
+ if(!ret.isOk()) {
+ ALOGE("Failed to issue set light command.");
+ }
+ if (t.duration() > 50ms) ALOGD("Excessive delay setting light");
+ }
+ return;
+ }
+
Type type = static_cast<Type>(light);
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 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 @@
#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 <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 {
@@ -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;
@@ -132,6 +136,10 @@ static HalVersion connectPowerHalLocked() {
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_) {
@@ -190,6 +198,12 @@ static HalVersion connectLineagePowerHalLocked() {
return HalVersion::NONE;
}
+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);
@@ -559,6 +573,14 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
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) {
--
2.25.1
@@ -1,29 +0,0 @@
From ea68a77524fc2cbfa571d7afa01442460b3ea284 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 2 Jul 2019 21:19:29 +0200
Subject: [PATCH 12/25] Make Samsung fingerprint broken HAL overridable
Change-Id: I8be38daa7c80fdb61e9209f12215e6daea171d03
---
.../server/biometrics/fingerprint/FingerprintService.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
index c247731be13..5552086c17f 100644
--- a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
@@ -590,8 +590,10 @@ public class FingerprintService extends BiometricServiceBase {
groupId, fingerId, deviceId);
int remaining2 = remaining;
+ int overrideSamsung = android.os.SystemProperties.getInt("persist.sys.phh.samsung_fingerprint", -1);
+
String fp = android.os.SystemProperties.get("ro.vendor.build.fingerprint");
- if(fp != null && (fp.contains("starlte") || fp.contains("star2lte") || fp.contains("starqlte") || fp.contains("star2qlte")))
+ if(overrideSamsung == 1 || (overrideSamsung != 0 && fp != null && fp.startsWith("samsung/")))
remaining2 = 100 - remaining2;
FingerprintService.super.handleEnrollResult(fingerprint, remaining2);
--
2.17.1
@@ -1,38 +0,0 @@
From e9848dbafb20526eed8e5d8dfbd2df01b240cab8 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 11 Aug 2019 10:30:37 +0200
Subject: [PATCH 13/25] Add property to use linear brightness slider
Change-Id: I1af7eb923779fa60c7a735904ba8fc82d0622c1d
---
.../com/android/settingslib/display/BrightnessUtils.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
index 4f86afaa995..f1fe73a6a1d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
@@ -51,7 +51,12 @@ public class BrightnessUtils {
* @param max The maximum acceptable value for the setting.
* @return The corresponding setting value.
*/
+ private static final boolean useLinearBrightness = android.os.SystemProperties.getBoolean("persist.sys.phh.linear_brightness", false);
public static final int convertGammaToLinear(int val, int min, int max) {
+ if(useLinearBrightness) {
+ if(val < 4) return 1;
+ return val/4;
+ }
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
final float ret;
if (normalizedVal <= R) {
@@ -127,6 +132,7 @@ public class BrightnessUtils {
* @return The corresponding slider value
*/
public static final int convertLinearToGammaFloat(float val, float min, float max) {
+ if(useLinearBrightness) return (int)(val*4);
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
final float ret;
--
2.17.1
@@ -1,45 +0,0 @@
From 33ba0d099de0181f34b3795ad5b2ee25d8c252a4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 12 Aug 2019 23:08:26 +0200
Subject: [PATCH 14/25] Add support for samsung touch proximity sensor as
fallback to real proximity sensor
---
.../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 9411c562945..774e5a38777 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -527,6 +527,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ if(mProximitySensor == null) {
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor sensor: sensors) {
+ if("com.samsung.sensor.touch_proximity".equals(sensor.getStringType()))
+ mProximitySensor = sensor;
+ }
+ }
if (mProximitySensor != null) {
mProximityThreshold = Math.min(mProximitySensor.getMaximumRange(),
TYPICAL_PROXIMITY_THRESHOLD);
@@ -1970,6 +1977,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
public void onSensorChanged(SensorEvent event) {
if (mProximitySensorEnabled) {
final long time = SystemClock.uptimeMillis();
+ if("com.samsung.sensor.touch_proximity".equals(mProximitySensor.getStringType())) {
+ int v = (int)event.values[0];
+ boolean positive = (v <= 4);
+ android.util.Log.d("PHH", "Samsung 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.17.1
@@ -1,31 +0,0 @@
From 298c7cd14541920c09b4bbcfb3255ec1ddcaad67 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 14 Aug 2019 23:36:45 +0200
Subject: [PATCH 15/25] Also add com.samsung.sensor.physical_proximity (if
available, it is more a true proximity sensor than touch proximity sensor)
---
.../com/android/server/display/DisplayPowerController.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 774e5a38777..4c12ebbd94f 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -527,6 +527,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ if(mProximitySensor == null) {
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor sensor: sensors) {
+ if("com.samsung.sensor.physical_proximity".equals(sensor.getStringType()))
+ mProximitySensor = sensor;
+ }
+ }
if(mProximitySensor == null) {
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
for(Sensor sensor: sensors) {
--
2.17.1
@@ -1,56 +0,0 @@
From d2cdf9ba6dc99f28c94e093078c1307dd4414a56 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 2 Jan 2020 10:16:49 +0800
Subject: [PATCH] fix crashing on devices with higher aspect ratio down to
sw288dp
* This is what the Qin 2 (Pro) is.
Change-Id: Ia39682b327fcf947f06219ce2dab996f53dcb01d
---
.../SystemUI/res/values-sw288dp/dimens.xml | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 packages/SystemUI/res/values-sw288dp/dimens.xml
diff --git a/packages/SystemUI/res/values-sw288dp/dimens.xml b/packages/SystemUI/res/values-sw288dp/dimens.xml
new file mode 100644
index 00000000000..40adc2e6879
--- /dev/null
+++ b/packages/SystemUI/res/values-sw288dp/dimens.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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
+ -->
+<resources>
+ <!-- Global actions grid -->
+ <dimen name="global_actions_grid_vertical_padding">3dp</dimen>
+ <dimen name="global_actions_grid_horizontal_padding">3dp</dimen>
+
+ <dimen name="global_actions_grid_item_side_margin">5dp</dimen>
+ <dimen name="global_actions_grid_item_vertical_margin">4dp</dimen>
+ <dimen name="global_actions_grid_item_width">64dp</dimen>
+ <dimen name="global_actions_grid_item_height">64dp</dimen>
+
+ <dimen name="global_actions_grid_item_icon_width">20dp</dimen>
+ <dimen name="global_actions_grid_item_icon_height">20dp</dimen>
+ <dimen name="global_actions_grid_item_icon_top_margin">12dp</dimen>
+ <dimen name="global_actions_grid_item_icon_side_margin">22dp</dimen>
+ <dimen name="global_actions_grid_item_icon_bottom_margin">4dp</dimen>
+
+</resources>
--
2.25.1
@@ -1,28 +0,0 @@
From 76cbbb0d09a80eaad75c64281d635e58976bd5be Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 1 Mar 2020 18:14:40 +0100
Subject: [PATCH 17/25] Remove orientation 4 from sensor earlier in the process
chain
Change-Id: Id8e2e860a73d417fc70db6cf5fc5fa5ef187aa50
---
.../com/android/server/policy/WindowOrientationListener.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/services/core/java/com/android/server/policy/WindowOrientationListener.java b/services/core/java/com/android/server/policy/WindowOrientationListener.java
index 0157706866c..732417b88f4 100644
--- a/services/core/java/com/android/server/policy/WindowOrientationListener.java
+++ b/services/core/java/com/android/server/policy/WindowOrientationListener.java
@@ -1055,6 +1055,9 @@ public abstract class WindowOrientationListener {
synchronized (mLock) {
mDesiredRotation = reportedRotation;
+ if(mDesiredRotation >= 4 || mDesiredRotation < 0) {
+ mDesiredRotation = 0;
+ }
newRotation = evaluateRotationChangeLocked();
}
if (newRotation >=0) {
--
2.17.1
@@ -1,39 +0,0 @@
From 0dc5a490d8aac60ce2ed3efafc9f6bcb6ced71f4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 10 Mar 2020 23:30:17 +0100
Subject: [PATCH 18/25] Allow disabling of fingerprint cleanups, needed on some
Realme devices that cant enumerate
Change-Id: I8a486e707712b81711fb1a691faec029499fa897
---
.../android/server/biometrics/BiometricServiceBase.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
index 75452ea5fb6..fd77ada1109 100644
--- a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
+++ b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
@@ -344,6 +344,7 @@ public abstract class BiometricServiceBase extends SystemService
private List<? extends BiometricAuthenticator.Identifier> mEnrolledList;
// List of templates to remove from the HAL
private List<BiometricAuthenticator.Identifier> mUnknownHALTemplates = new ArrayList<>();
+ final boolean mNocleanup = android.os.SystemProperties.getBoolean("persist.sys.phh.fingerprint.nocleanup", false);
InternalEnumerateClient(Context context,
DaemonWrapper daemon, long halDeviceId, IBinder token,
@@ -389,8 +390,10 @@ public abstract class BiometricServiceBase extends SystemService
Slog.e(getTag(), "doTemplateCleanup(): Removing dangling template from framework: "
+ identifier.getBiometricId() + " "
+ identifier.getName());
- mUtils.removeBiometricForUser(getContext(),
- getTargetUserId(), identifier.getBiometricId());
+ if(!mNocleanup) {
+ mUtils.removeBiometricForUser(getContext(),
+ getTargetUserId(), identifier.getBiometricId());
+ }
FrameworkStatsLog.write(FrameworkStatsLog.BIOMETRIC_SYSTEM_HEALTH_ISSUE_DETECTED,
statsModality(),
BiometricsProtoEnums.ISSUE_UNKNOWN_TEMPLATE_ENROLLED_FRAMEWORK);
--
2.17.1
@@ -1,33 +0,0 @@
From b8adbf5e35d5d1e40077b3226ad3f842fc9be6dc Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 21 Sep 2020 10:30:18 +0200
Subject: [PATCH 23/25] On old inits (A-only devices), multi-sim basedband
property too long, catch that and make it shorter
Change-Id: I2f52595409f0d43b148063d5fd90c80d1182ff8c
---
telephony/java/android/telephony/TelephonyManager.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 8ae1ee99b06..4659c7909bc 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -10104,7 +10104,13 @@ public class TelephonyManager {
if (SubscriptionManager.isValidPhoneId(phoneId)) {
List<String> newList = updateTelephonyProperty(
TelephonyProperties.baseband_version(), phoneId, version);
- TelephonyProperties.baseband_version(newList);
+ try {
+ TelephonyProperties.baseband_version(newList);
+ } catch(java.lang.IllegalArgumentException e) {
+ List<String> list = new ArrayList<>();
+ list.add(newList.get(0));
+ TelephonyProperties.baseband_version(list);
+ }
}
}
--
2.17.1
@@ -1,28 +0,0 @@
From 11dae80179722994abd9e3501e6c14d4393c4c93 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 29 Sep 2020 22:39:47 +0200
Subject: [PATCH 24/25] Some devices have proximity sensor reporting NaN as max
range for some reason. Make them behave standard way by setting 5 cm
Change-Id: I3c39e3e914a05903c140235702e0480d2d58a612
---
.../com/android/server/display/DisplayPowerController.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 4c12ebbd94f..01f367e8a2f 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -544,6 +544,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (mProximitySensor != null) {
mProximityThreshold = Math.min(mProximitySensor.getMaximumRange(),
TYPICAL_PROXIMITY_THRESHOLD);
+ if(Float.isNaN(mProximityThreshold)) {
+ mProximityThreshold = 5.0f;
+ }
}
}
mCurrentScreenBrightnessSetting = getScreenBrightnessSetting();
--
2.17.1
@@ -1,37 +0,0 @@
From cbe557557ea73ea8fef866f362c869daf4c3be51 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 25 Oct 2020 23:57:26 +0100
Subject: [PATCH 26/26] Re-implement fnmatch-like behaviour for RRO java-side
Change-Id: Id38292a9a1453aa87b8401c1fdb390fa4e63c7d1
---
core/java/android/content/pm/PackageParser.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 70e4e6cbf62..a4d8941d1e5 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2476,8 +2476,17 @@ public class PackageParser {
for (int i = 0; i < propNames.length; i++) {
// Check property value: make sure it is both set and equal to expected value
final String currValue = SystemProperties.get(propNames[i]);
- if (!TextUtils.equals(currValue, propValues[i])) {
- return false;
+ final String value = propValues[i];
+ if(value.startsWith("+")) {
+ final java.util.regex.Pattern regex = java.util.regex.Pattern.compile(value.substring(1, value.length()).replace("*", ".*"));
+ java.util.regex.Matcher matcher = regex.matcher(currValue);
+ if (!matcher.find()) {
+ return false;
+ }
+ } else {
+ if(!value.equals(currValue)) {
+ return false;
+ }
}
}
return true;
--
2.17.1
@@ -1,157 +0,0 @@
From 772f3c12ec0676d9e22eea8a005ddf302ad09940 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Mon, 5 Oct 2020 12:36:35 -0700
Subject: [PATCH 27/27] Add support for app signature spoofing
This is needed by microG GmsCore to pretend to be the official Google
Play Services package, because client apps check the package signature
to make sure it matches Google's official certificate.
This was forward-ported from the Android 10 patch by gudenau:
https://github.com/microg/android_packages_apps_GmsCore/pull/957
Changes made for Android 11:
- Updated PackageInfo calls
- Added new permission to public API surface, needed for
PermissionController which is now an updatable APEX on 11
- Added a dummy permission group to allow users to manage the
permission through the PermissionController UI
(by Vachounet <vachounet@live.fr>)
- Updated location provider comment for conciseness
Change made by PHH:
- Permission is exposed as "privileged" rather than "dangerous", so that
apps need to be in system;product's priv-app
Change-Id: Ied7d6ce0b83a2d2345c3abba0429998d86494a88
---
api/current.txt | 1 +
core/res/AndroidManifest.xml | 7 ++++++
core/res/res/values/config.xml | 2 ++
core/res/res/values/strings.xml | 12 ++++++++++
non-updatable-api/current.txt | 1 +
.../server/pm/PackageManagerService.java | 23 +++++++++++++++++--
6 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/api/current.txt b/api/current.txt
index 952ccdad992..73fb59fedab 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -79,6 +79,7 @@ package android {
field public static final String DUMP = "android.permission.DUMP";
field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
+ field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 9945057f0e9..e1adee20ccf 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2829,6 +2829,13 @@
android:description="@string/permdesc_getPackageSize"
android:protectionLevel="normal" />
+ <!-- Allows an application to change the package signature as
+ seen by applications -->
+ <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
+ android:protectionLevel="signature|privileged"
+ android:label="@string/permlab_fakePackageSignature"
+ android:description="@string/permdesc_fakePackageSignature" />
+
<!-- @deprecated No longer useful, see
{@link android.content.pm.PackageManager#addPackageToPreferred}
for details. -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index d21930f31df..372319ed32b 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1646,6 +1646,8 @@
<string-array name="config_locationProviderPackageNames" translatable="false">
<!-- The standard AOSP fused location provider -->
<item>com.android.location.fused</item>
+ <!-- Google Play Services or microG (free reimplementation) location provider -->
+ <item>com.google.android.gms</item>
</string-array>
<!-- This string array can be overriden to enable test location providers initially. -->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4f9911fbe38..32f2dbf33d3 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -847,6 +847,18 @@
<!-- Permissions -->
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_fakePackageSignature">Spoof package signature</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_fakePackageSignature">Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Legitimate uses include an emulator pretending to be what it emulates. Grant this permission with caution only!</string>
+ <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permgrouplab_fake_package_signature">Spoof package signature</string>
+ <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permgroupdesc_fake_package_signature">allow to spoof package signature</string>
+ <!-- Message shown to the user when the apps requests permission from this group. If ever possible this should stay below 80 characters (assuming the parameters takes 20 characters). Don't abbreviate until the message reaches 120 characters though. [CHAR LIMIT=120] -->
+ <string name="permgrouprequest_fake_package_signature">Allow
+ &lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to spoof package signature?</string>
+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_statusBar">disable or modify status bar</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt
index 5f15216e840..c29feb9cd7b 100644
--- a/non-updatable-api/current.txt
+++ b/non-updatable-api/current.txt
@@ -79,6 +79,7 @@ package android {
field public static final String DUMP = "android.permission.DUMP";
field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
+ field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c3c655d632e..f7faf418fb4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4395,8 +4395,9 @@ public class PackageManagerService extends IPackageManager.Stub
});
}
- PackageInfo packageInfo = PackageInfoUtils.generate(p, gids, flags,
- ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId, ps);
+ PackageInfo packageInfo = mayFakeSignature(p, PackageInfoUtils.generate(p, gids, flags,
+ ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId, ps),
+ permissions);
if (packageInfo == null) {
return null;
@@ -4432,6 +4433,24 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
+ private PackageInfo mayFakeSignature(AndroidPackage p, PackageInfo pi,
+ Set<String> permissions) {
+ try {
+ if (permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")
+ && p.getTargetSdkVersion() > Build.VERSION_CODES.LOLLIPOP_MR1
+ && p.getMetaData() != null) {
+ String sig = p.getMetaData().getString("fake-signature");
+ if (sig != null) {
+ pi.signatures = new Signature[] {new Signature(sig)};
+ }
+ }
+ } catch (Throwable t) {
+ // We should never die because of any failures, this is system code!
+ Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE", t);
+ }
+ return pi;
+ }
+
@Override
public void checkPackageStartable(String packageName, int userId) {
final int callingUid = Binder.getCallingUid();
--
2.17.1
@@ -1,91 +0,0 @@
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
persist.sys.phh.rounded_corners_padding
Change-Id: Id5d73b06b9a2cb2da95ff31f204c1984555872ff
---
.../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
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
@@ -32,6 +32,7 @@ import android.graphics.Rect;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Looper;
+import android.os.SystemProperties;
import android.provider.AlarmClock;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
@@ -447,8 +448,11 @@ public class QuickStatusBarHeader extends RelativeLayout implements
Resources resources = mContext.getResources();
updateMinimumHeight();
- mRoundedCornerPadding = resources.getDimensionPixelSize(
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if (mRoundedCornerPadding == -1) {
+ mRoundedCornerPadding = resources.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
+ }
mStatusBarPaddingTop = resources.getDimensionPixelSize(R.dimen.status_bar_padding_top);
// Update height for a few views, especially due to landscape mode restricting space.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
index 8a4ea21a11c..a54269460e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -25,6 +25,7 @@ import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
@@ -186,8 +187,11 @@ public class KeyguardStatusBarView extends RelativeLayout
R.dimen.system_icons_super_container_avatarless_margin_end);
mCutoutSideNudge = getResources().getDimensionPixelSize(
R.dimen.display_cutout_margin_consumption);
- mRoundedCornerPadding = res.getDimensionPixelSize(
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if (mRoundedCornerPadding == -1) {
+ mRoundedCornerPadding = res.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
+ }
}
private void updateVisibilities() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 1c6c7db6a69..f0e5c7bb3d2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.RemoteException;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.EventLog;
import android.util.Pair;
@@ -331,8 +332,11 @@ public class PhoneStatusBarView extends PanelBar implements Callbacks {
public void updateResources() {
mCutoutSideNudge = getResources().getDimensionPixelSize(
R.dimen.display_cutout_margin_consumption);
- mRoundedCornerPadding = getResources().getDimensionPixelSize(
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if (mRoundedCornerPadding == -1) {
+ mRoundedCornerPadding = getResources().getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
+ }
updateStatusBarHeight();
}
--
2.25.1
@@ -1,25 +0,0 @@
From 9d2d5c8b106404769d8e6c2bebd4a2779fd2f21f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 13 Dec 2020 01:38:50 +0100
Subject: [PATCH 31/35] [Tethering] Ignore DUN required and always use main APN
---
.../android/networkstack/tethering/TetheringConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java b/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
index e1771a56137..65d17ffa54b 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
@@ -132,7 +132,7 @@ public class TetheringConfiguration {
tetherableBluetoothRegexs = getResourceStringArray(
res, R.array.config_tether_bluetooth_regexs);
- isDunRequired = checkDunRequired(ctx);
+ isDunRequired = false;
chooseUpstreamAutomatically = getResourceBoolean(
res, R.bool.config_tether_upstream_automatic, false /** defaultValue */);
--
2.25.1
@@ -1,72 +0,0 @@
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
mines/returns), and cleanup code and add logs
---
...droid_server_power_PowerManagerService.cpp | 25 +++++++++++--------
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 dcd33366a35..298cd8c7171 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -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;
@@ -136,9 +135,11 @@ static HalVersion connectPowerHalLocked() {
gPowerHalAidlExists = false;
}
}
- if (gPowerHalExists && gPowerHalHidlV1_0_ == nullptr) {
+ 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();
@@ -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);
- switch (connectPowerHalLocked()) {
+
+ auto powerHalType = connectPowerHalLocked();
+ if(gSehMiscPower != nullptr) {
+ android::base::Timer t;
+ Return<void> ret = gSehMiscPower->setInteractiveAsync(enable, 0);
+ if(!ret.isOk()) {
+ ALOGE("set interactive async() failed: seh misc setInteractiveAsync");
+ }
+ }
+
+ switch (powerHalType) {
case HalVersion::NONE:
return;
case HalVersion::HIDL_1_0:
@@ -573,14 +584,6 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
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) {
--
2.25.1
@@ -1,27 +0,0 @@
From a54f02964ce04634fcf6178c8127800dfb1cfba6 Mon Sep 17 00:00:00 2001
From: Alberto Ponces <ponces26@gmail.com>
Date: Mon, 18 Jan 2021 09:23:57 +0000
Subject: [PATCH] KeyStore: Block key attestation for Google Play Services
Change-Id: Ia2cd58ea1abfdb1a2c0eb358442c36b5c6809c6b
---
keystore/java/android/security/KeyStore.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index 88b614dc7ee..de4e9ade191 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -1124,6 +1124,9 @@ public class KeyStore {
public int attestKey(
String alias, KeymasterArguments params, KeymasterCertificateChain outChain) {
+ if (mContext.getPackageName().equals("com.google.android.gms")) {
+ return KeymasterDefs.KM_ERROR_UNIMPLEMENTED; // Prevent Google Play Services from using key attestation for SafetyNet
+ }
CertificateChainPromise promise = new CertificateChainPromise();
try {
mBinder.asBinder().linkToDeath(promise, 0);
--
2.25.1
@@ -1,37 +0,0 @@
From 109bc691f314f18f923c5c72fc82ff072c77eca3 Mon Sep 17 00:00:00 2001
From: N Harish <kqn736@zebra.com>
Date: Mon, 25 Jan 2021 17:22:33 +0530
Subject: [PATCH 40/40] Fix for TestDirectBootEmulated testcase
In case of emulated FBE the secrets are empty hence add this
exception to prevent from unlocking userkey.
Bug: 177617301
Test: android.appsecurity.cts.DirectBootHostTest#testDirectBootEmulated
Change-Id: I5be2ceb61d9ef47219862e75cc8ec03ab5513426
(cherry picked from commit 2912b101aaa34abfa9637f2f00c992e7d129b994)
---
.../core/java/com/android/server/StorageManagerService.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 87afdac45dae..179899ee6067 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -3295,6 +3295,12 @@ class StorageManagerService extends IStorageManager.Stub
enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
if (isFsEncrypted) {
+ // When a user has secure lock screen, require secret to actually unlock.
+ // This check is mostly in place for emulation mode.
+ if (StorageManager.isFileEncryptedEmulatedOnly() &&
+ mLockPatternUtils.isSecure(userId) && ArrayUtils.isEmpty(secret)) {
+ throw new IllegalStateException("Secret required to unlock secure user " + userId);
+ }
try {
mVold.unlockUserKey(userId, serialNumber, encodeBytes(token),
encodeBytes(secret));
--
2.25.1
@@ -1,27 +0,0 @@
From 8b9a1e5df3dd1b25b2cf9d83eca1353327697796 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 6 Mar 2021 18:39:15 -0500
Subject: [PATCH 41/41] Make secondary displays' lock screen black. Useful for
Moto Razr AOD
---
.../SystemUI/res-keyguard/layout/keyguard_presentation.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml b/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml
index f4d34f4ca141..58650b26ceaf 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml
@@ -22,7 +22,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/presentation"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:background="@android:color/black">
<!-- This is mostly keyguard_status_view.xml with minor modifications -->
<com.android.keyguard.KeyguardStatusView
android:id="@+id/clock"
--
2.25.1
@@ -1,46 +0,0 @@
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
@@ -1,45 +0,0 @@
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
@@ -1,43 +0,0 @@
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
@@ -1,24 +0,0 @@
From 50edb017dc10058835e178885d432eb89ec7e131 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 19 Apr 2021 21:03:45 +0200
Subject: [PATCH 49/49] Fix build
---
.../java/com/android/server/display/DisplayPowerController.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 908c3b852fe1..550965ef7cd2 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -62,6 +62,7 @@ import com.android.server.display.whitebalance.DisplayWhiteBalanceController;
import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory;
import com.android.server.display.whitebalance.DisplayWhiteBalanceSettings;
import com.android.server.lights.LightsManager;
+import com.android.server.lights.LogicalLight;
import com.android.server.policy.WindowManagerPolicy;
import java.io.PrintWriter;
--
2.25.1
@@ -1,32 +0,0 @@
From d8fbdb4092155a1c8f8e2b2ee77b4fcfb7102367 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 12 Aug 2019 23:48:37 +0200
Subject: [PATCH 1/8] Some Samsung devices requires lying colorspace
Change-Id: I4153b8e7abc10c519565e4e4386c6388621477b2
---
opengl/libs/EGL/egl_platform_entries.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp
index aa24e8ee6..1c6380f6f 100644
--- a/opengl/libs/EGL/egl_platform_entries.cpp
+++ b/opengl/libs/EGL/egl_platform_entries.cpp
@@ -454,8 +454,14 @@ EGLBoolean eglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config,
// ----------------------------------------------------------------------------
// Translates EGL color spaces to Android data spaces.
+static int samsungColorspace = -1;
static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
+ if(samsungColorspace == -1) {
+ samsungColorspace = property_get_bool("persist.sys.phh.samsung_colorspace", false);
+ }
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
+ if(samsungColorspace)
+ return HAL_DATASPACE_UNKNOWN;
return HAL_DATASPACE_UNKNOWN;
} else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
return HAL_DATASPACE_V0_SRGB;
--
2.17.1
@@ -1,51 +0,0 @@
From 61f5f4b804e8e14f15b928630489f22a5e7df04e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 14 Aug 2019 23:37:10 +0200
Subject: [PATCH 2/8] On Samsung, we need to send a hack-message to HAL to get
all Sensors
Change-Id: Id6a1fa48340de61c418493668e9abd22c2599376
---
opengl/libs/EGL/egl_platform_entries.cpp | 2 +-
services/sensorservice/SensorDevice.cpp | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp
index 1c6380f6f..6e810e592 100644
--- a/opengl/libs/EGL/egl_platform_entries.cpp
+++ b/opengl/libs/EGL/egl_platform_entries.cpp
@@ -457,7 +457,7 @@ EGLBoolean eglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config,
static int samsungColorspace = -1;
static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
if(samsungColorspace == -1) {
- samsungColorspace = property_get_bool("persist.sys.phh.samsung_colorspace", false);
+ samsungColorspace = base::GetBoolProperty("persist.sys.phh.samsung_colorspace", false);
}
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
if(samsungColorspace)
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 8a282e238..53b686870 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -34,7 +34,9 @@
#include <cinttypes>
#include <thread>
+#include <android-base/properties.h>
using namespace android::hardware::sensors;
+
using namespace android::hardware::sensors::V1_0;
using namespace android::hardware::sensors::V1_0::implementation;
using android::hardware::sensors::V2_0::EventQueueFlagBits;
@@ -134,6 +136,8 @@ SensorDevice::SensorDevice()
void SensorDevice::initializeSensorList() {
float minPowerMa = 0.001; // 1 microAmp
+ if(::android::base::GetBoolProperty("persist.sys.phh.samsung_sensors", false))
+ setMode(5555);
checkReturn(mSensors->getSensorsList(
[&](const auto &list) {
const size_t count = list.size();
--
2.17.1
@@ -1,42 +0,0 @@
From 113f48e1e25d168e16e6a6717c7ea70fbef033e3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 10 Mar 2020 23:26:55 +0100
Subject: [PATCH 3/8] Use BKK's hwcomposer hacks to properly display FOD layers
Insecure hack: Set FOD layers to magical Z values to trigger
OPPO/Realme/Oneplus' whole blitter behaviours:
- reports touch event to fingerprint driver
- removes dim on touched layer
Change-Id: I1d924b1e5c2389c8df17174c079cee8ef2380112
---
.../CompositionEngine/src/OutputLayer.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 1faf775ed..deb0b0923 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -370,7 +370,18 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(
static_cast<int32_t>(error));
}
- if (auto error = hwcLayer->setZOrder(outputDependentState.z); error != hal::Error::NONE) {
+ uint32_t z = outputDependentState.z;
+ if(strstr(getLayerFE().getDebugName(), "Fingerprint on display") != nullptr) {
+ ALOGE("Found fingerprint on display!");
+ z = 0x41000031;
+ }
+
+ if(strstr(getLayerFE().getDebugName(), "Fingerprint on display.touched") != nullptr) {
+ ALOGE("Found fingerprint on display touched!");
+ z = 0x41000033;
+ }
+
+ if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) {
ALOGE("[%s] Failed to set Z %u: %s (%d)", getLayerFE().getDebugName(),
outputDependentState.z, to_string(error).c_str(), static_cast<int32_t>(error));
}
--
2.17.1
@@ -1,122 +0,0 @@
From 0c7b289c3d724f32f4d64e8972736f3aa8e3261f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 20 May 2020 21:16:56 +0200
Subject: [PATCH 4/8] Samsung + Xiaomi new FOD HBM controls
Change-Id: I5ab27fa70882efa85f0c917bf31bb32adaa09bb1
---
services/surfaceflinger/BufferQueueLayer.cpp | 19 ++++++++++++++++-
.../CompositionEngine/src/OutputLayer.cpp | 21 +++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index 07be7916e..472ceda4d 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -26,6 +26,7 @@
#include <compositionengine/LayerFECompositionState.h>
#include <gui/BufferQueueConsumer.h>
#include <system/window.h>
+#include <cutils/properties.h>
#include "LayerRejecter.h"
#include "SurfaceInterceptor.h"
@@ -34,6 +35,14 @@
#include "Scheduler/LayerHistory.h"
#include "TimeStats/TimeStats.h"
+static bool sCheckedProps = false;
+static bool sSamsungFod = false;
+static void init_fod_props() {
+ if(sCheckedProps) return;
+ sCheckedProps = true;
+ sSamsungFod = property_get_bool("persist.sys.phh.fod.samsung", false);
+}
+
namespace android {
BufferQueueLayer::BufferQueueLayer(const LayerCreationArgs& args) : BufferLayer(args) {}
@@ -486,6 +495,7 @@ void BufferQueueLayer::onFirstRef() {
mConsumer =
mFlinger->getFactory().createBufferLayerConsumer(consumer, mFlinger->getRenderEngine(),
mTextureName, this);
+ init_fod_props();
mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
mContentsChangedListener = new ContentsChangedListener(this);
@@ -509,9 +519,16 @@ status_t BufferQueueLayer::setDefaultBufferProperties(uint32_t w, uint32_t h, Pi
return BAD_VALUE;
}
+ init_fod_props();
+
setDefaultBufferSize(w, h);
mConsumer->setDefaultBufferFormat(format);
- mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
+ uint64_t usageBits = getEffectiveUsage(0);
+ if(sSamsungFod && strstr(mName.c_str(), "Fingerprint on display.touched") != nullptr) {
+ ALOGE("Found on touched layer!");
+ usageBits |= 0x400000000LL;
+ }
+ mConsumer->setConsumerUsageBits(usageBits);
return NO_ERROR;
}
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index deb0b0923..5f9620715 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -22,6 +22,7 @@
#include <compositionengine/impl/OutputCompositionState.h>
#include <compositionengine/impl/OutputLayer.h>
#include <compositionengine/impl/OutputLayerCompositionState.h>
+#include <cutils/properties.h>
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic push
@@ -32,6 +33,10 @@
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion"
+static bool sCheckedProps = false;
+static bool sBBKFod = false;
+static bool sXiaomiFod = false;
+
namespace android::compositionengine {
OutputLayer::~OutputLayer() = default;
@@ -370,15 +375,31 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(
static_cast<int32_t>(error));
}
+ if(!sCheckedProps) {
+ sCheckedProps = true;
+ sBBKFod = property_get_bool("persist.sys.phh.fod.bbk", false);
+ sXiaomiFod = property_get_bool("persist.sys.phh.fod.xiaomi", false);
+ }
+
uint32_t z = outputDependentState.z;
if(strstr(getLayerFE().getDebugName(), "Fingerprint on display") != nullptr) {
ALOGE("Found fingerprint on display!");
z = 0x41000031;
+ if(sBBKFod) {
+ z = 0x41000031;
+ } else if(sXiaomiFod) {
+ z |= 0x1000000;
+ }
}
if(strstr(getLayerFE().getDebugName(), "Fingerprint on display.touched") != nullptr) {
ALOGE("Found fingerprint on display touched!");
z = 0x41000033;
+ if(sBBKFod) {
+ z = 0x41000033;
+ } else if(sXiaomiFod) {
+ z |= 0x2000000;
+ }
}
if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) {
--
2.17.1
@@ -1,27 +0,0 @@
From 15125c6d89352f46742c0e575556e43720e1c03c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 11 Sep 2020 21:33:05 +0200
Subject: [PATCH 5/8] vr_hwc crashes because it registers a 2.3 hwc, while
manifest says 2.1
Change-Id: Icfaea3e471209e5773f52f880ffbcf5de744737e
---
services/vr/hardware_composer/manifest_vr_hwc.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/vr/hardware_composer/manifest_vr_hwc.xml b/services/vr/hardware_composer/manifest_vr_hwc.xml
index 1068cac33..6694ac086 100644
--- a/services/vr/hardware_composer/manifest_vr_hwc.xml
+++ b/services/vr/hardware_composer/manifest_vr_hwc.xml
@@ -2,7 +2,7 @@
<hal>
<name>android.hardware.graphics.composer</name>
<transport>hwbinder</transport>
- <version>2.1</version>
+ <version>2.3</version>
<interface>
<name>IComposer</name>
<instance>vr</instance>
--
2.17.1
@@ -1,50 +0,0 @@
From 1003d0293dc372b8fc0bbefe160f7d6a770b184b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 30 Sep 2020 22:41:39 +0200
Subject: [PATCH 6/8] Add persist.sys.phh.no_present_or_validate property to
disable presentOrValidate since on vndk 26/27 presentOrValidate can be broken
Change-Id: I5f0c6c5e129bc21348d6f279d3ba455a5a0f008b
---
.../surfaceflinger/DisplayHardware/HWComposer.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 7a2f0f34e..1ea104521 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -34,6 +34,7 @@
#include <ui/GraphicBuffer.h>
#include <utils/Errors.h>
#include <utils/Trace.h>
+#include <android-base/properties.h>
#include "../Layer.h" // needed only for debugging
#include "../Promise.h"
@@ -500,12 +501,22 @@ status_t HWComposer::getDeviceCompositionChanges(
hal::Error error = hal::Error::NONE;
+ static int forceNoPresentOrValidate = -1;
+ if(forceNoPresentOrValidate == -1) {
+ bool res = android::base::GetBoolProperty("persist.sys.phh.no_present_or_validate", false);
+ if(res) {
+ forceNoPresentOrValidate = 1;
+ } else {
+ forceNoPresentOrValidate = 0;
+ }
+ }
+
// First try to skip validate altogether when there is no client
// composition. When there is client composition, since we haven't
// rendered to the client target yet, we should not attempt to skip
// validate.
displayData.validateWasSkipped = false;
- if (!frameUsesClientComposition) {
+ if (forceNoPresentOrValidate == 0 && !frameUsesClientComposition) {
sp<Fence> outPresentFence;
uint32_t state = UINT32_MAX;
error = hwcDisplay->presentOrValidate(&numTypes, &numRequests, &outPresentFence , &state);
--
2.17.1
@@ -1,41 +0,0 @@
From dc47d76a49d2a2d8dc2bd6bf68098cd910fcb364 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 30 Sep 2020 22:51:37 +0200
Subject: [PATCH 7/8] Add persist.sys.phh.disable_sensor_direct_report property
to disable Sensors direct report (it seems to break Qin 2 Pro sensors HAL)
Change-Id: I0763324a4bd6a3ba6716c396c4cb3f0772b85d62
---
services/sensorservice/SensorDevice.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 53b686870..87899e2cd 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -22,6 +22,7 @@
#include "convertV2_1.h"
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include <android/util/ProtoOutputStream.h>
#include <frameworks/base/core/proto/android/service/sensor_service.proto.h>
#include <sensors/convert.h>
@@ -129,8 +130,12 @@ SensorDevice::SensorDevice()
initializeSensorList();
- mIsDirectReportSupported =
- (checkReturnAndGetStatus(mSensors->unregisterDirectChannel(-1)) != INVALID_OPERATION);
+ if(::android::base::GetBoolProperty("persist.sys.phh.disable_sensor_direct_report", false)) {
+ mIsDirectReportSupported = false;
+ } else {
+ mIsDirectReportSupported =
+ (checkReturnAndGetStatus(mSensors->unregisterDirectChannel(-1)) != INVALID_OPERATION);
+ }
}
void SensorDevice::initializeSensorList() {
--
2.17.1
@@ -1,173 +0,0 @@
From 5edeb168bf831aaca539aa8f063564f740676e16 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 26 Oct 2020 23:16:30 +0100
Subject: [PATCH 09/10] Apply associated display for joysticks
Change-Id: I5f6c237e6bf53312aff3dc02a46ce1c779063203
---
.../reader/mapper/JoystickInputMapper.cpp | 4 +-
.../reader/mapper/JoystickInputMapper.h | 2 +
.../inputflinger/tests/InputReader_test.cpp | 100 ++++++++++++++++++
3 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
index 030a84672..929bfc5f9 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
@@ -196,6 +196,8 @@ void JoystickInputMapper::configure(nsecs_t when, const InputReaderConfiguration
}
}
}
+ std::optional<DisplayViewport> viewport = getDeviceContext().getAssociatedViewport();
+ mDisplayId = viewport ? viewport->displayId : ADISPLAY_ID_NONE;
}
bool JoystickInputMapper::haveAxis(int32_t axisId) {
@@ -334,7 +336,7 @@ void JoystickInputMapper::sync(nsecs_t when, bool force) {
uint32_t policyFlags = 0;
NotifyMotionArgs args(getContext()->getNextId(), when, getDeviceId(), AINPUT_SOURCE_JOYSTICK,
- ADISPLAY_ID_NONE, policyFlags, AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState,
+ mDisplayId, policyFlags, AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState,
buttonState, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1,
&pointerProperties, &pointerCoords, 0, 0,
AMOTION_EVENT_INVALID_CURSOR_POSITION,
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.h b/services/inputflinger/reader/mapper/JoystickInputMapper.h
index 823a096d6..cf864ba75 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.h
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.h
@@ -105,6 +105,8 @@ private:
static void addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo* info);
static void setPointerCoordsAxisValue(PointerCoords* pointerCoords, int32_t axis, float value);
+
+ int32_t mDisplayId = ADISPLAY_ID_NONE;
};
} // namespace android
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index c457a1525..c9b704993 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -20,6 +20,7 @@
#include <InputReader.h>
#include <InputReaderBase.h>
#include <InputReaderFactory.h>
+#include <JoystickInputMapper.h>
#include <KeyboardInputMapper.h>
#include <MultiTouchInputMapper.h>
#include <SingleTouchInputMapper.h>
@@ -252,6 +253,10 @@ public:
mConfig.portAssociations.insert({inputPort, displayPort});
}
+ void removeInputPortAssociation(const std::string& inputPort) {
+ mConfig.portAssociations.erase(inputPort);
+ }
+
void addDisabledDevice(int32_t deviceId) { mConfig.disabledDevices.insert(deviceId); }
void removeDisabledDevice(int32_t deviceId) { mConfig.disabledDevices.erase(deviceId); }
@@ -7336,4 +7341,99 @@ TEST_F(MultiTouchInputMapperTest_SurfaceRange, Viewports_SurfaceRange_270) {
constexpr int32_t yExpected = (x + 1) - DISPLAY_WIDTH / 4;
processPositionAndVerify(mapper, x - 1, y, x + 1, y, xExpected, yExpected);
}
+class JoystickInputMapperTest : public InputMapperTest {
+ protected:
+ const std::string PRIMARY_UNIQUE_ID = "local:0";
+ const std::string SECONDARY_UNIQUE_ID = "local:1";
+ static const uint8_t HDMI1;
+ static const uint8_t HDMI2;
+ virtual void SetUp() override {
+ InputMapperTest::SetUp(INPUT_DEVICE_CLASS_JOYSTICK);
+ }
+
+ static void process(InputMapper& mapper, nsecs_t when, int32_t type, int32_t code,
+ int32_t value) {
+ RawEvent event;
+ event.when = when;
+ event.deviceId = mapper.getDeviceContext().getEventHubId();
+ event.type = type;
+ event.code = code;
+ event.value = value;
+ mapper.process(&event);
+ }
+
+ static void process(InputMapper& mapper, int x, int y) {
+ process(mapper, ARBITRARY_TIME, EV_ABS, ABS_X, x);
+ process(mapper, ARBITRARY_TIME, EV_ABS, ABS_Y, y);
+ process(mapper, ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
+ }
+};
+
+const uint8_t JoystickInputMapperTest::HDMI1 = 0;
+const uint8_t JoystickInputMapperTest::HDMI2 = 1;
+TEST_F(JoystickInputMapperTest, Configure_AssignsDisplayPort) {
+ NotifyMotionArgs args;
+
+ // Prepare test
+ setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0,
+ PRIMARY_UNIQUE_ID, HDMI1, ViewportType::VIEWPORT_INTERNAL);
+
+ mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_X, 0, 255, 15, 0, 0);
+ mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_Y, 0, 255, 15, 0, 0);
+
+ JoystickInputMapper& mapper =
+ addMapperAndConfigure<JoystickInputMapper>();
+ // 1. Ensure when initially unmapped, that event goes to focused display
+ // Center joystick
+ process(mapper, 127, 127);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+
+ // Joystick hasn't been mapped to any display yet, so it goes where the focus is
+ ASSERT_EQ(args.displayId, ADISPLAY_ID_NONE);
+ ASSERT_TRUE(mDevice->isEnabled());
+
+ // 2. Ensure that when mapping joystick to non-existing display, device is disabled
+
+ // Assign joystick to a non-existing display
+ mFakePolicy->addInputPortAssociation(DEVICE_LOCATION, HDMI2);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
+ // We don't test mapper's return value here, because it may or may not have a notion
+ // of whether the viewport exists
+ ASSERT_FALSE(mDevice->isEnabled());
+
+ // 3. Ensure that when joystick is mapped and screen is attached, events go to correct display
+ // Prepare second display.
+ constexpr int32_t newDisplayId = 37;
+ setDisplayInfoAndReconfigure(newDisplayId, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0,
+ SECONDARY_UNIQUE_ID, HDMI2, ViewportType::VIEWPORT_EXTERNAL);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
+ // Device should be enabled after the associated display is found.
+ ASSERT_TRUE(mDevice->isEnabled());
+
+ // Send an event and ensure it goes to the correct display
+ process(mapper, 40, 127);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+
+ ASSERT_EQ(args.displayId, newDisplayId);
+ ASSERT_EQ(args.pointerCount, 1U);
+
+ // ABS_{X,Y} are mapped to GENERIC_{1,2} because FakeInputReaderContext does no axis mapping
+ ASSERT_NEAR(args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_GENERIC_1), 0.16, 0.02f);
+ ASSERT_NEAR(args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_GENERIC_2), 0.5, 0.02f);
+
+ // 4. Ensure that when removing association again, joystick goes back to focus-based display
+ // Remove association
+ mFakePolicy->removeInputPortAssociation(DEVICE_LOCATION);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
+ process(mapper, 127, 127);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+
+ // And check we're back to focus-based
+ ASSERT_EQ(args.displayId, ADISPLAY_ID_NONE);
+}
} // namespace android
--
2.25.1
@@ -1,28 +0,0 @@
From 6097954863cabad45d48672f56b878686e6be088 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 23:07:24 +0200
Subject: [PATCH 10/10] Ignore usage bits verification
This didn't ignore as of 8.1, so we're ""safe""
Change-Id: I40c1d588c1fa104d844322b469f76e52bee1495a
---
libs/ui/Gralloc2.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp
index 040a62b54..01dba7689 100644
--- a/libs/ui/Gralloc2.cpp
+++ b/libs/ui/Gralloc2.cpp
@@ -108,7 +108,7 @@ status_t Gralloc2Mapper::validateBufferDescriptorInfo(
if (descriptorInfo->usage & ~validUsageBits) {
ALOGE("buffer descriptor contains invalid usage bits 0x%" PRIx64,
descriptorInfo->usage & ~validUsageBits);
- return BAD_VALUE;
+ //return BAD_VALUE;
}
return NO_ERROR;
}
--
2.25.1
@@ -1,50 +0,0 @@
From 603b18beca562d922a546cb25d69778cf2af7c1d Mon Sep 17 00:00:00 2001
From: liyong <liyong@allwinnertech.com>
Date: Sat, 10 Oct 2020 17:08:47 +0800
Subject: [PATCH 12/13] DO NOT MERGE Correct physical orientation
setProjection already includes the physical orientation when updating
the DisplayDevice orientation. Therefore applying the physical
orientation when capturing a screenshot applies the rotation twice
which is incorrect.
Bug: 170512822
Test: run cts-on-gsi -m CtsInputMethodServiceHostTestCases -t android.inputmethodservice.cts.hostside.InputMethodServiceLifecycleTest#testImeVisibilityAfterImeSwitchingFull
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.FocusHandlingTest#testNonFocusablePopupWindowDoesNotAffectImeVisibility
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.ImeInsetsVisibilityTest#testEditTextPositionAndPersistWhenAboveImeWindowShown
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.ImeInsetsVisibilityTest#testImeVisibilityWhenImeFocusableChildPopup" />
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.InputMethodServiceTest#testRequestHideSelf
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.InputMethodServiceTest#testRequestShowSelf
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.KeyboardVisibilityControlTest#testBasicShowHideSoftInput
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.KeyboardVisibilityControlTest#testFloatingImeHideKeyboardAfterBackPressed
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.KeyboardVisibilityControlTest#testImeVisibilityWhenDismisingDialogWithImeFocused
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.KeyboardVisibilityControlTest#testShowHideKeyboardOnWebView
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.KeyboardVisibilityControlTest#testToggleSoftInput
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.SearchViewTest#testShowImeWhenSearchViewFocusInListView
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.SearchViewTest#testShowImeWithSearchViewFocus
run cts-on-gsi -m CtsInputMethodTestCases -t android.view.inputmethod.cts.SearchViewTest#testTapThenSetQuery
run cts-on-gsi -m CtsWindowManagerDeviceTestCases -t android.server.wm.WindowInsetsAnimationSynchronicityTests#testControl_rendersSynchronouslyBetweenImeWindowAndAppContent
run cts-on-gsi -m CtsWindowManagerDeviceTestCases -t android.server.wm.WindowInsetsAnimationSynchronicityTests#testShowAndHide_renderSynchronouslyBetweenImeWindowAndAppContent
Change-Id: I72aba3cdbae1075dcf9d99661bfd13fe5fd74c72
(cherry picked from commit d4d89976ea3f98248064fd755505ee5dc9b35c2f)
---
services/surfaceflinger/DisplayDevice.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index cb467ea29..ca7119e2c 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -313,7 +313,7 @@ private:
logicalOrientation = ui::Rotation::Rotation90;
}
- const ui::Rotation orientation = device->getPhysicalOrientation() + logicalOrientation;
+ const ui::Rotation orientation = logicalOrientation;
switch (orientation) {
case ui::ROTATION_0:
--
2.25.1
@@ -1,68 +0,0 @@
From 54a80ed3e7039548d565c4e40e2fa7a45c89bce8 Mon Sep 17 00:00:00 2001
From: SeYeong Byeon <sy.byeon@samsung.com>
Date: Tue, 15 Sep 2020 15:02:40 +0900
Subject: [PATCH 13/13] gralloc4: fix PlaneLayout encode typecasting
Fixes a bug where planeLayout members were being downcasted
to int32_t during the encoding step.
Bug: 168564125
Signed-off-by: SeYeong Byeon <sy.byeon@samsung.com>
Change-Id: I8d5139dbd253278193775380ca387d45bfe2589d
(cherry picked from commit 389ee53332904b49c8f9fb35ef4e9e624e1ee3d2)
---
libs/gralloc/types/Gralloc4.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libs/gralloc/types/Gralloc4.cpp b/libs/gralloc/types/Gralloc4.cpp
index 53c68b723..e2f072a7a 100644
--- a/libs/gralloc/types/Gralloc4.cpp
+++ b/libs/gralloc/types/Gralloc4.cpp
@@ -706,35 +706,35 @@ status_t encodePlaneLayout(const PlaneLayout& input, OutputHidlVec* output) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.offsetInBytes), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.offsetInBytes), output);
if (err) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.sampleIncrementInBits), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.sampleIncrementInBits), output);
if (err) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.strideInBytes), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.strideInBytes), output);
if (err) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.widthInSamples), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.widthInSamples), output);
if (err) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.heightInSamples), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.heightInSamples), output);
if (err) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.totalSizeInBytes), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.totalSizeInBytes), output);
if (err) {
return err;
}
- err = encodeInteger<int64_t>(static_cast<int32_t>(input.horizontalSubsampling), output);
+ err = encodeInteger<int64_t>(static_cast<int64_t>(input.horizontalSubsampling), output);
if (err) {
return err;
}
- return encodeInteger<int64_t>(static_cast<int32_t>(input.verticalSubsampling), output);
+ return encodeInteger<int64_t>(static_cast<int64_t>(input.verticalSubsampling), output);
}
status_t decodePlaneLayout(InputHidlVec* input, PlaneLayout* output) {
--
2.25.1
@@ -1,130 +0,0 @@
From 6e55b139d548a51a13221eaa64546c21511af9dd Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 14 Aug 2018 16:59:12 +0200
Subject: [PATCH 1/4] Revert "SupplicantManager: Remove
|ensure_config_file_exists|"
This reverts commit f61dc8cd7dadda5741d6e4a1bb6b576ba89cc24b.
---
libwifi_system/supplicant_manager.cpp | 97 +++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/libwifi_system/supplicant_manager.cpp b/libwifi_system/supplicant_manager.cpp
index 60720d40f..f22eea92e 100644
--- a/libwifi_system/supplicant_manager.cpp
+++ b/libwifi_system/supplicant_manager.cpp
@@ -33,7 +33,89 @@ namespace wifi_system {
namespace {
const char kSupplicantInitProperty[] = "init.svc.wpa_supplicant";
+const char kSupplicantConfigTemplatePath[] =
+ "/etc/wifi/wpa_supplicant.conf";
+const char kSupplicantConfigFile[] = "/data/misc/wifi/wpa_supplicant.conf";
+const char kP2pConfigFile[] = "/data/misc/wifi/p2p_supplicant.conf";
const char kSupplicantServiceName[] = "wpa_supplicant";
+constexpr mode_t kConfigFileMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+
+int ensure_config_file_exists(const char* config_file) {
+ char buf[2048];
+ int srcfd, destfd;
+ int nread;
+ int ret;
+ std::string templatePath;
+
+ ret = access(config_file, R_OK | W_OK);
+ if ((ret == 0) || (errno == EACCES)) {
+ if ((ret != 0) && (chmod(config_file, kConfigFileMode) != 0)) {
+ LOG(ERROR) << "Cannot set RW to \"" << config_file << "\": "
+ << strerror(errno);
+ return false;
+ }
+ return true;
+ } else if (errno != ENOENT) {
+ LOG(ERROR) << "Cannot access \"" << config_file << "\": "
+ << strerror(errno);
+ return false;
+ }
+
+ std::string configPathSystem =
+ std::string("/system") + std::string(kSupplicantConfigTemplatePath);
+ std::string configPathVendor =
+ std::string("/vendor") + std::string(kSupplicantConfigTemplatePath);
+ srcfd = TEMP_FAILURE_RETRY(open(configPathSystem.c_str(), O_RDONLY));
+ templatePath = configPathSystem;
+ if (srcfd < 0) {
+ int errnoSystem = errno;
+ srcfd = TEMP_FAILURE_RETRY(open(configPathVendor.c_str(), O_RDONLY));
+ templatePath = configPathVendor;
+ if (srcfd < 0) {
+ int errnoVendor = errno;
+ LOG(ERROR) << "Cannot open \"" << configPathSystem << "\": "
+ << strerror(errnoSystem);
+ LOG(ERROR) << "Cannot open \"" << configPathVendor << "\": "
+ << strerror(errnoVendor);
+ return false;
+ }
+ }
+
+ destfd = TEMP_FAILURE_RETRY(open(config_file,
+ O_CREAT | O_RDWR,
+ kConfigFileMode));
+ if (destfd < 0) {
+ close(srcfd);
+ LOG(ERROR) << "Cannot create \"" << config_file << "\": "
+ << strerror(errno);
+ return false;
+ }
+
+ while ((nread = TEMP_FAILURE_RETRY(read(srcfd, buf, sizeof(buf)))) != 0) {
+ if (nread < 0) {
+ LOG(ERROR) << "Error reading \"" << templatePath
+ << "\": " << strerror(errno);
+ close(srcfd);
+ close(destfd);
+ unlink(config_file);
+ return false;
+ }
+ TEMP_FAILURE_RETRY(write(destfd, buf, nread));
+ }
+
+ close(destfd);
+ close(srcfd);
+
+ /* chmod is needed because open() didn't set permisions properly */
+ if (chmod(config_file, kConfigFileMode) < 0) {
+ LOG(ERROR) << "Error changing permissions of " << config_file
+ << " to 0660: " << strerror(errno);
+ unlink(config_file);
+ return false;
+ }
+
+ return true;
+}
} // namespace
@@ -49,6 +131,21 @@ bool SupplicantManager::StartSupplicant() {
return true;
}
+ /* Before starting the daemon, make sure its config file exists */
+ if (ensure_config_file_exists(kSupplicantConfigFile) < 0) {
+ LOG(ERROR) << "Wi-Fi will not be enabled";
+ return false;
+ }
+
+ /*
+ * Some devices have another configuration file for the p2p interface.
+ * However, not all devices have this, and we'll let it slide if it
+ * is missing. For devices that do expect this file to exist,
+ * supplicant will refuse to start and emit a good error message.
+ * No need to check for it here.
+ */
+ (void)ensure_config_file_exists(kP2pConfigFile);
+
/*
* Get a reference to the status property, so we can distinguish
* the case where it goes stopped => running => stopped (i.e.,
--
2.17.1
@@ -1,96 +0,0 @@
From 2acdc4231294616ca3a5dd778f05e92aa0bbd9c0 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <pierre-hugues.husson@softathome.com>
Date: Tue, 18 Sep 2018 17:05:07 +0200
Subject: [PATCH 2/4] Support hostap on O/O-MR1 vendors
Two issues are fixed here:
- some vendor HALs lied (because of Android behaviour) about ap interface name.
O/O-MR1 behaviour meant hostap/sta had same interface. So "wlan0" sound
quite a good guess
- doing multiple configureChip in one IWifi session wasn't allowed.
Now, it is a requirement to be supported, so most(all?) HALs don't
support it. force stop/start for every reconfiguration
Change-Id: Ib2f1c94e7f794af65a7006fb05f14b31c910a238
---
.../android/server/wifi/HalDeviceManager.java | 22 +++++++++++++++++--
.../com/android/server/wifi/WifiNative.java | 15 ++++++++++++-
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 3d0c89c4a..dd814b99d 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -62,8 +62,8 @@ import java.util.Set;
*/
public class HalDeviceManager {
private static final String TAG = "HalDevMgr";
- private static final boolean VDBG = false;
- private boolean mDbg = false;
+ private static final boolean VDBG = true;
+ private boolean mDbg = true;
private static final int START_HAL_RETRY_INTERVAL_MS = 20;
// Number of attempts a start() is re-tried. A value of 0 means no retries after a single
@@ -229,6 +229,16 @@ public class HalDeviceManager {
*/
public IWifiStaIface createStaIface(
@Nullable InterfaceDestroyedListener destroyedListener, @Nullable Handler handler) {
+ //As of O and O-MR1, configureChip MUST BE after a startWifi
+ //Pie changed this to allow dynamic configureChip
+ //No O/O-MR1 HAL support that, so restart wifi HAL when we do that
+ if(android.os.SystemProperties.getInt("persist.sys.vndk", 28) < 28) {
+ Log.e(TAG, "createStaIface: Stopping wifi");
+ stopWifi();
+ Log.e(TAG, "createStaIface: Starting wifi");
+ startWifi();
+ Log.e(TAG, "createStaIface: Creating iface");
+ }
return (IWifiStaIface) createIface(IfaceType.STA, destroyedListener, handler);
}
@@ -237,6 +247,14 @@ public class HalDeviceManager {
*/
public IWifiApIface createApIface(@Nullable InterfaceDestroyedListener destroyedListener,
@Nullable Handler handler) {
+ //cf createStaIface
+ if(android.os.SystemProperties.getInt("persist.sys.vndk", 28) < 28) {
+ Log.e(TAG, "createApIface: Stopping wifi");
+ stopWifi();
+ Log.e(TAG, "createApIface: Starting wifi");
+ startWifi();
+ Log.e(TAG, "createApIface: Creating iface");
+ }
return (IWifiApIface) createIface(IfaceType.AP, destroyedListener, handler);
}
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index cf362d6a8..41b6ff604 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -833,8 +833,21 @@ public class WifiNative {
private String createApIface(@NonNull Iface iface) {
synchronized (mLock) {
if (mWifiVendorHal.isVendorHalSupported()) {
- return mWifiVendorHal.createApIface(
+ String ret = mWifiVendorHal.createApIface(
new InterfaceDestoyedListenerInternal(iface.id));
+ //In O and O-MR1, there was only ONE wifi interface for everything (sta and ap)
+ //Most vendors used "wlan0" for those interfaces, but there is no guarantee
+ //This override exists here, because most OEMs return "ap0" when doing createApIface,
+ //even when the iface is actually called "wlan0"
+ //
+ //To be perfectly clean, we should check what value createStaIface (would have) returned
+ //and use the same one.
+ //That's overly complicated, so let's assume this is wlan0 for the moment
+ if(android.os.SystemProperties.getInt("persist.sys.vndk", 28) < 28) {
+ ret = "wlan0";
+ }
+
+ return ret;
} else {
Log.i(TAG, "Vendor Hal not supported, ignoring createApIface.");
return handleIfaceCreationWhenVendorHalNotSupported(iface);
--
2.17.1
@@ -1,94 +0,0 @@
From 34687b301da56b05b0677e5e5673fdce28f9e399 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 16 Sep 2019 17:42:37 +0200
Subject: [PATCH 3/4] Restore O/O-MR1 behaviour of initing ifaces before supp.
Still not perfect, because wifi can be turned on only once
Change-Id: I7a94b3c4a3fca140a50962e6787af3a7aa2c7d61
---
.../server/wifi/SupplicantStaIfaceHal.java | 4 ++--
.../java/com/android/server/wifi/WifiNative.java | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index 657b081dd..aed2d51f9 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -827,7 +827,7 @@ public class SupplicantStaIfaceHal {
* the device.
* @return true if supported, false otherwise.
*/
- private boolean isV1_1() {
+ /* package */ boolean isV1_1() {
return checkHalVersionByInterfaceName(
android.hardware.wifi.supplicant.V1_1.ISupplicant.kInterfaceName);
}
@@ -837,7 +837,7 @@ public class SupplicantStaIfaceHal {
* the device.
* @return true if supported, false otherwise.
*/
- private boolean isV1_2() {
+ /* package */ boolean isV1_2() {
return checkHalVersionByInterfaceName(
android.hardware.wifi.supplicant.V1_2.ISupplicant.kInterfaceName);
}
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 41b6ff604..ee7f75325 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -439,9 +439,11 @@ public class WifiNative {
}
/** Helper method invoked to start supplicant if there were no STA ifaces */
+ private boolean supplicantOn = false;
private boolean startSupplicant() {
synchronized (mLock) {
- if (!mIfaceMgr.hasAnyStaIfaceForConnectivity()) {
+ boolean prePieWifi = !mSupplicantStaIfaceHal.isV1_2();
+ if (!mIfaceMgr.hasAnyStaIfaceForConnectivity() || (prePieWifi && !supplicantOn)) {
if (!startAndWaitForSupplicantConnection()) {
Log.e(TAG, "Failed to connect to supplicant");
return false;
@@ -451,6 +453,8 @@ public class WifiNative {
Log.e(TAG, "Failed to register supplicant death handler");
return false;
}
+
+ supplicantOn = true;
}
return true;
}
@@ -464,6 +468,7 @@ public class WifiNative {
Log.e(TAG, "Failed to deregister supplicant death handler");
}
mSupplicantStaIfaceHal.terminate();
+ supplicantOn = false;
}
}
}
@@ -1041,7 +1046,9 @@ public class WifiNative {
mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToHal();
return null;
}
- if (!startSupplicant()) {
+ boolean prePieWifi = !mSupplicantStaIfaceHal.isV1_2();
+
+ if (!prePieWifi && !startSupplicant()) {
Log.e(TAG, "Failed to start supplicant");
mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToSupplicant();
return null;
@@ -1067,6 +1074,11 @@ public class WifiNative {
mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToWificond();
return null;
}
+ if (prePieWifi && !startSupplicant()) {
+ Log.e(TAG, "Failed to start supplicant");
+ mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToSupplicant();
+ return null;
+ }
if (!mSupplicantStaIfaceHal.setupIface(iface.name)) {
Log.e(TAG, "Failed to setup iface in supplicant on " + iface);
teardownInterface(iface.name);
--
2.17.1
@@ -1,36 +0,0 @@
From 33c30770c097d39d62be91e6d5861589a04f6607 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 16 Sep 2019 22:47:37 +0200
Subject: [PATCH 4/4] Boot wifi supplicant both with lazy-hal style and init
style
Change-Id: I7e23348d4d16d3787f2c80bce3f8d0178dd5c4c7
---
.../com/android/server/wifi/SupplicantStaIfaceHal.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index aed2d51f9..88306ab29 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -686,14 +686,13 @@ public class SupplicantStaIfaceHal {
*/
public boolean startDaemon() {
synchronized (mLock) {
+ Log.i(TAG, "Starting supplicant using init");
+ mFrameworkFacade.startSupplicant();
if (isV1_1()) {
Log.i(TAG, "Starting supplicant using HIDL");
return startDaemon_V1_1();
- } else {
- Log.i(TAG, "Starting supplicant using init");
- mFrameworkFacade.startSupplicant();
- return true;
}
+ return true;
}
}
--
2.17.1
@@ -1,55 +0,0 @@
From 0c26ab9bf431940096a0cf363363b7c9a8da2d71 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 13 Oct 2019 17:21:31 +0800
Subject: [PATCH] telephony: forward-port support for forceCognitive
* This is needed on some MTK devices. Android 10 refactored some code,
so now the "non-persistent/cognitive" filter is relocated to RIL and
also in DcTracker.setupData().
Change-Id: I5e93cbef317b7973e0dc1125cfc3cc576a1cf9fa
---
src/java/com/android/internal/telephony/RIL.java | 4 +++-
.../android/internal/telephony/dataconnection/DcTracker.java | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index 76ea3abe1..cbde5d850 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -66,6 +66,7 @@ import android.os.HwBinder;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
+import android.os.SystemProperties;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
@@ -4476,7 +4477,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
for (DataProfile dp : dps) {
// For v1.0 to v1.2, we only send data profiles that has the persistent
// (a.k.a modem cognitive) bit set to true.
- if (dp.isPersistent()) {
+ boolean forceCognitive = SystemProperties.getBoolean("persist.sys.phh.radio.force_cognitive", false);
+ if (dp.isPersistent() || forceCognitive) {
dpis.add(convertToHalDataProfile10(dp));
}
}
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
index 7b1560ffb..6920911e3 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
@@ -1955,8 +1955,9 @@ public class DcTracker extends Handler {
}
// profile id is only meaningful when the profile is persistent on the modem.
+ boolean forceCognitive = SystemProperties.getBoolean("persist.sys.phh.radio.force_cognitive", false);
int profileId = DATA_PROFILE_INVALID;
- if (apnSetting.isPersistent()) {
+ if (apnSetting.isPersistent() || forceCognitive) {
profileId = apnSetting.getProfileId();
if (profileId == DATA_PROFILE_DEFAULT) {
profileId = getApnProfileID(apnContext.getApnType());
--
2.25.1
@@ -1,54 +0,0 @@
From bf7c5e06d196b9863c1cc61fa073442c353f5075 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@cryptomilk.org>
Date: Mon, 7 Jun 2021 13:23:02 -0400
Subject: [PATCH] On Samsung devices, we need to tell Audio HAL if we're
running narrow band or wide band
Change-Id: Ibfa0f632d9acbb920a85a613ce4e2f1d26556bd1
---
.../android/bluetooth/hfp/HeadsetStateMachine.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 8a6bc5527..667f215b6 100644
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -82,6 +82,9 @@ public class HeadsetStateMachine extends StateMachine {
private static final String HEADSET_WBS = "bt_wbs";
private static final String HEADSET_AUDIO_FEATURE_ON = "on";
private static final String HEADSET_AUDIO_FEATURE_OFF = "off";
+ private static final String HEADSET_G_SCO_SAMPLERATE = "g_sco_samplerate";
+ private static final String HEADSET_G_WB_SAMPLERATE = "16000";
+ private static final String HEADSET_G_NB_SAMPLERATE = "8000";
static final int CONNECT = 1;
static final int DISCONNECT = 2;
@@ -1511,6 +1514,12 @@ public class HeadsetStateMachine extends StateMachine {
HEADSET_WBS + "=" + mAudioParams.getOrDefault(HEADSET_WBS,
HEADSET_AUDIO_FEATURE_OFF)
});
+ keyValuePairs = keyValuePairs.concat(";"
+ + HEADSET_G_SCO_SAMPLERATE
+ + "="
+ + mAudioParams.getOrDefault(
+ HEADSET_G_SCO_SAMPLERATE,
+ HEADSET_G_NB_SAMPLERATE));
Log.i(TAG, "setAudioParameters for " + mDevice + ": " + keyValuePairs);
mSystemInterface.getAudioManager().setParameters(keyValuePairs);
}
@@ -1649,10 +1658,12 @@ public class HeadsetStateMachine extends StateMachine {
String prevWbs = mAudioParams.getOrDefault(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF);
switch (wbsConfig) {
case HeadsetHalConstants.BTHF_WBS_YES:
+ mAudioParams.put(HEADSET_G_SCO_SAMPLERATE, HEADSET_G_WB_SAMPLERATE);
mAudioParams.put(HEADSET_WBS, HEADSET_AUDIO_FEATURE_ON);
break;
case HeadsetHalConstants.BTHF_WBS_NO:
case HeadsetHalConstants.BTHF_WBS_NONE:
+ mAudioParams.put(HEADSET_G_SCO_SAMPLERATE, HEADSET_G_NB_SAMPLERATE);
mAudioParams.put(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF);
break;
default:
--
2.25.1
@@ -1,41 +0,0 @@
From abe69da83e1b79f661de25bd94f825ea0d57e7c6 Mon Sep 17 00:00:00 2001
From: Artem Borisov <dedsa2002@gmail.com>
Date: Wed, 19 Sep 2018 17:02:06 +0300
Subject: [PATCH] Telephony: Support muting by RIL command
While almost everyone already moved to AudioManager years ago,
some OEMs (cough Huawei) still use RIL for muting and don't
promote the necessary calls in their audio HAL.
Let's handle these odd cases too when it's necessary.
Change-Id: Id916dec2574d6e57b6f809fbaf2b0959c0cc7256
---
src/com/android/services/telephony/TelephonyConnection.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index b4dd050ee..52224f8f1 100755
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -28,6 +28,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
+import android.os.SystemProperties;
import android.telecom.CallAudioState;
import android.telecom.Conference;
import android.telecom.Connection;
@@ -822,6 +823,10 @@ abstract class TelephonyConnection extends Connection implements Holdable {
// TODO: update TTY mode.
if (getPhone() != null) {
getPhone().setEchoSuppressionEnabled();
+
+ if (SystemProperties.getBoolean("persist.sys.radio.huawei", false)) {
+ getPhone().setMute(audioState.isMuted());
+ }
}
}
--
2.25.1
@@ -1,105 +0,0 @@
From 3337759a488bf320bbebcb5b7d5da981555bb758 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 20 Feb 2018 23:04:50 +0100
Subject: [PATCH 1/3] Make BTM_BYPASS_EXTRA_ACL_SETUP dynamic
Change-Id: Icb0868566b29b053ed7e83c9fd32e225af3f2e46
---
hci/include/bt_hci_bdroid.h | 3 +++
internal_include/bt_target.h | 3 +++
stack/btm/btm_acl.cc | 20 ++++++++++----------
stack/btm/btm_sec.cc | 18 +++++++++---------
4 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/hci/include/bt_hci_bdroid.h b/hci/include/bt_hci_bdroid.h
index 110354f05..b81185e2c 100644
--- a/hci/include/bt_hci_bdroid.h
+++ b/hci/include/bt_hci_bdroid.h
@@ -32,6 +32,9 @@
#ifdef HAS_BDROID_BUILDCFG
#include "bdroid_buildcfg.h"
#endif
+#ifndef BTM_BYPASS_EXTRA_ACL_SETUP
+#define BTM_BYPASS_EXTRA_ACL_SETUP TRUE
+#endif
/******************************************************************************
* Constants & Macros
diff --git a/internal_include/bt_target.h b/internal_include/bt_target.h
index 4aca86822..57bd69e9f 100644
--- a/internal_include/bt_target.h
+++ b/internal_include/bt_target.h
@@ -32,6 +32,9 @@
#ifdef HAS_BDROID_BUILDCFG
#include "bdroid_buildcfg.h"
#endif
+#ifndef BTM_BYPASS_EXTRA_ACL_SETUP
+#define BTM_BYPASS_EXTRA_ACL_SETUP TRUE
+#endif
#include "bt_types.h" /* This must be defined AFTER buildcfg.h */
diff --git a/stack/btm/btm_acl.cc b/stack/btm/btm_acl.cc
index 3c8a6a69a..894459854 100644
--- a/stack/btm/btm_acl.cc
+++ b/stack/btm/btm_acl.cc
@@ -1208,17 +1208,17 @@ void btm_read_remote_ext_features_failed(uint8_t status, uint16_t handle) {
void btm_establish_continue(tACL_CONN* p_acl_cb) {
tBTM_BL_EVENT_DATA evt_data;
BTM_TRACE_DEBUG("btm_establish_continue");
-#if (BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
- if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR) {
- /* For now there are a some devices that do not like sending */
- /* commands events and data at the same time. */
- /* Set the packet types to the default allowed by the device */
- btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
-
- if (btm_cb.btm_def_link_policy)
- BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
+ if (!BTM_BYPASS_EXTRA_ACL_SETUP) {
+ if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR) {
+ /* For now there are a some devices that do not like sending */
+ /* commands events and data at the same time. */
+ /* Set the packet types to the default allowed by the device */
+ btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
+
+ if (btm_cb.btm_def_link_policy)
+ BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
+ }
}
-#endif
if (p_acl_cb->link_up_issued) {
BTM_TRACE_ERROR("%s: Already link is up ", __func__);
return;
diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc
index 63e4f6ce1..7dea81b44 100644
--- a/stack/btm/btm_sec.cc
+++ b/stack/btm/btm_sec.cc
@@ -4168,15 +4168,15 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
if (p_acl_cb) {
/* whatever is in btm_establish_continue() without reporting the BTM_BL_CONN_EVT
* event */
-#if (BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
- /* For now there are a some devices that do not like sending */
- /* commands events and data at the same time. */
- /* Set the packet types to the default allowed by the device */
- btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
-
- if (btm_cb.btm_def_link_policy)
- BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
-#endif
+ if(!BTM_BYPASS_EXTRA_ACL_SETUP) {
+ /* For now there are a some devices that do not like sending */
+ /* commands events and data at the same time. */
+ /* Set the packet types to the default allowed by the device */
+ btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
+
+ if (btm_cb.btm_def_link_policy)
+ BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
+ }
}
btm_acl_created(bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, handle,
HCI_ROLE_SLAVE, BT_TRANSPORT_BR_EDR);
--
2.17.1
@@ -1,153 +0,0 @@
From a39b9abfe1e7e1bea9c409a1680cb6f18a6ec354 Mon Sep 17 00:00:00 2001
From: penn5 <penn5@users.noreply.github.com>
Date: Mon, 4 Mar 2019 22:21:07 +0000
Subject: [PATCH 2/3] Add props to control supported features and states (#1)
* Add bitmask for supported fields
Use persist.sys.bt.unsupport.states, defaults to 0, left-aligned.
Huawei suggest to use 000000000000000000000011111
* Add bitmask to LOCAL_SUPPORTED_FEATURES
For Huawei, suggest to use 00000001
Documentation:
- persist.sys.bt.unsupport.features matches the values:
HCI_3_SLOT_PACKETS..HCI_LMP_EXTENDED_SUPPORTED (max 8bits * 8 bytes =
64 bits)
- persist.sys.bt.unsupport.states matches the values:
BTM_BLE_STATE_INVALID..BTM_BLE_STATE_SCAN_ADV (max = 0x3ff, 11 bits)
- persist.sys.bt.unsupport.stdfeatures ( max: 16 bits)
HCI_LE_ENCRYPTION..HCI_LE_PERIODIC_ADVERTISING
---
hci/src/hci_packet_parser.cc | 77 ++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/hci/src/hci_packet_parser.cc b/hci/src/hci_packet_parser.cc
index b1efd444d..88dc4c6cd 100644
--- a/hci/src/hci_packet_parser.cc
+++ b/hci/src/hci_packet_parser.cc
@@ -27,6 +27,8 @@
#include "hcimsgs.h"
#include "osi/include/log.h"
+#include <cutils/properties.h>
+
static const command_opcode_t NO_OPCODE_CHECKING = 0;
static const allocator_t* buffer_allocator;
@@ -108,6 +110,31 @@ static void parse_read_local_supported_commands_response(
buffer_allocator->free(response);
}
+static void setup_bitmask(uint8_t *v, const char* property) {
+ char str[PROPERTY_VALUE_MAX];
+ int len = property_get(property, str, "");
+ memset(v, 255, 8);
+ for(int i = 0; i<len; i++) {
+ if(str[i] == '1') {
+ v[i/8] &= ~(1 << (i%8));
+ } else if(str[i] != '0') {
+ LOG_ERROR(LOG_TAG, "invalid characters in bitmask; skipping %c", str[i]);
+ }
+ }
+}
+
+static void filter_supported_feature(uint8_t *v) {
+ static int setup = 0;
+ static uint8_t unsupport_bitmask[8];
+ if(!setup) {
+ setup = 1;
+ setup_bitmask(unsupport_bitmask, "persist.sys.bt.unsupport.features");
+ }
+
+ for(unsigned i=0; i<sizeof(bt_device_features_t); i++)
+ v[i] &= unsupport_bitmask[i];
+}
+
static void parse_read_local_extended_features_response(
BT_HDR* response, uint8_t* page_number_ptr, uint8_t* max_page_number_ptr,
bt_device_features_t* feature_pages, size_t feature_pages_count) {
@@ -123,6 +150,16 @@ static void parse_read_local_extended_features_response(
STREAM_TO_ARRAY(feature_pages[*page_number_ptr].as_array, stream,
(int)sizeof(bt_device_features_t));
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
+ LOG_DEBUG(LOG_TAG, "supported feature 0x%x is 0x%x", i, feature_pages[*page_number_ptr].as_array[i]);
+
+ filter_supported_feature(feature_pages[*page_number_ptr].as_array);
+
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
+ LOG_DEBUG(LOG_TAG, "post-filtering supported feature 0x%x is 0x%x", i, feature_pages[*page_number_ptr].as_array[i]);
+
+ LOG_DEBUG(LOG_TAG, "supported_features array done");
+
buffer_allocator->free(response);
}
@@ -148,6 +185,19 @@ static void parse_ble_read_buffer_size_response(BT_HDR* response,
buffer_allocator->free(response);
}
+
+static void filter_supported_states(uint8_t *v, int size) {
+ static int setup = 0;
+ static uint8_t unsupport_bitmask[8];
+ if(!setup) {
+ setup = 1;
+ setup_bitmask(unsupport_bitmask, "persist.sys.bt.unsupport.states");
+ }
+
+ for(int i=0; i<size && i<8; i++)
+ v[i] &= unsupport_bitmask[i];
+}
+
static void parse_ble_read_supported_states_response(
BT_HDR* response, uint8_t* supported_states, size_t supported_states_size) {
uint8_t* stream =
@@ -156,9 +206,30 @@ static void parse_ble_read_supported_states_response(
CHECK(stream != NULL);
STREAM_TO_ARRAY(supported_states, stream, (int)supported_states_size);
+ for (int i = 0; i < ((int)supported_states_size); i++)
+ LOG_DEBUG(LOG_TAG, "supported state 0x%x is 0x%x", i, supported_states[i]);
+
+ filter_supported_states(supported_states, supported_states_size);
+
+ for (int i = 0; i < ((int)supported_states_size); i++)
+ LOG_DEBUG(LOG_TAG, "supported.2 state 0x%x is 0x%x", i, supported_states[i]);
+
+ LOG_DEBUG(LOG_TAG, "supported_states array done");
buffer_allocator->free(response);
}
+static void filter_supported_stdfeatures(uint8_t *v) {
+ static int setup = 0;
+ static uint8_t unsupport_bitmask[8];
+ if(!setup) {
+ setup = 1;
+ setup_bitmask(unsupport_bitmask, "persist.sys.bt.unsupport.stdfeatures");
+ }
+
+ for(unsigned i=0; i<sizeof(bt_device_features_t); i++)
+ v[i] &= unsupport_bitmask[i];
+}
+
static void parse_ble_read_local_supported_features_response(
BT_HDR* response, bt_device_features_t* supported_features) {
uint8_t* stream = read_command_complete_header(
@@ -168,6 +239,12 @@ static void parse_ble_read_local_supported_features_response(
STREAM_TO_ARRAY(supported_features->as_array, stream,
(int)sizeof(bt_device_features_t));
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
+ LOG_DEBUG(LOG_TAG, "supported state 0x%x is 0x%x", i, supported_features->as_array[i]);
+ filter_supported_stdfeatures(supported_features->as_array);
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
+ LOG_DEBUG(LOG_TAG, "supported.2 state 0x%x is 0x%x", i, supported_features->as_array[i]);
+
buffer_allocator->free(response);
}
--
2.17.1
@@ -1,67 +0,0 @@
From eba7ce1a14f942bfdc6ac93eac14188b7b2b91ec Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 25 May 2020 21:25:12 +0200
Subject: [PATCH 3/3] Add persist.sys.phh.disable_a2dp_offload property to
force a2dp offload
---
btif/src/btif_av.cc | 7 ++++++-
stack/a2dp/a2dp_codec_config.cc | 9 +++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/btif/src/btif_av.cc b/btif/src/btif_av.cc
index 1003b0f82..b7832a478 100644
--- a/btif/src/btif_av.cc
+++ b/btif/src/btif_av.cc
@@ -968,9 +968,14 @@ bt_status_t BtifAvSource::Init(
osi_property_get("ro.bluetooth.a2dp_offload.supported", value_sup, "false");
osi_property_get("persist.bluetooth.a2dp_offload.disabled", value_dis,
"false");
+ char value_phh[PROPERTY_VALUE_MAX] = {'\0'};
+ osi_property_get("persist.sys.phh.disable_a2dp_offload", value_phh, "false");
a2dp_offload_enabled_ =
(strcmp(value_sup, "true") == 0) && (strcmp(value_dis, "false") == 0);
- BTIF_TRACE_DEBUG("a2dp_offload.enable = %d", a2dp_offload_enabled_);
+ if(strcmp(value_phh, "true") == 0)
+ a2dp_offload_enabled_ = false;
+
+ LOG_ERROR(LOG_TAG, "a2dp_offload.enable = %s", a2dp_offload_enabled_ ? "on" : "off");
callbacks_ = callbacks;
if (a2dp_offload_enabled_) {
diff --git a/stack/a2dp/a2dp_codec_config.cc b/stack/a2dp/a2dp_codec_config.cc
index edf7e0c46..795cbab9c 100644
--- a/stack/a2dp/a2dp_codec_config.cc
+++ b/stack/a2dp/a2dp_codec_config.cc
@@ -560,13 +560,18 @@ bool A2dpCodecs::init() {
char* tok = NULL;
char* tmp_token = NULL;
bool offload_codec_support[BTAV_A2DP_CODEC_INDEX_MAX] = {false};
- char value_sup[PROPERTY_VALUE_MAX], value_dis[PROPERTY_VALUE_MAX];
+ char value_sup[PROPERTY_VALUE_MAX], value_dis[PROPERTY_VALUE_MAX], value_phh[PROPERTY_VALUE_MAX];
osi_property_get("ro.bluetooth.a2dp_offload.supported", value_sup, "false");
osi_property_get("persist.bluetooth.a2dp_offload.disabled", value_dis,
"false");
+ osi_property_get("persist.sys.phh.disable_a2dp_offload", value_phh, "false");
a2dp_offload_status =
(strcmp(value_sup, "true") == 0) && (strcmp(value_dis, "false") == 0);
+ if(strcmp(value_phh, "true") == 0)
+ a2dp_offload_status = false;
+
+ LOG_ERROR(LOG_TAG, "Got a2dp offload status %s", a2dp_offload_status ? "on" : "off");
if (a2dp_offload_status) {
char value_cap[PROPERTY_VALUE_MAX];
@@ -654,7 +659,7 @@ bool A2dpCodecs::init() {
}
}
- return (!ordered_source_codecs_.empty() && !ordered_sink_codecs_.empty());
+ return (!ordered_source_codecs_.empty() && !ordered_sink_codecs_.empty()) && !a2dp_offload_status;
}
A2dpCodecConfig* A2dpCodecs::findSourceCodecConfig(
--
2.17.1
@@ -1,29 +0,0 @@
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
@@ -1,31 +0,0 @@
From f40e85b84e53cccee6a80e5aff2db2adec55dfeb Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 7 Jun 2021 17:09:13 -0400
Subject: [PATCH 5/5] Add a property to disable eSCO
eSCO is troublesome on some old devices.
It is unknown whether it applies to any Treble device, but investigation
is ongoing, this will help the investigation.
---
hci/src/hci_packet_parser.cc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hci/src/hci_packet_parser.cc b/hci/src/hci_packet_parser.cc
index 88dc4c6cd..3bd0efe21 100644
--- a/hci/src/hci_packet_parser.cc
+++ b/hci/src/hci_packet_parser.cc
@@ -107,6 +107,11 @@ static void parse_read_local_supported_commands_response(
STREAM_TO_ARRAY(supported_commands_ptr, stream,
(int)supported_commands_length);
+ bool disable_eSCO = property_get_bool("persist.sys.bt.disable_esco", false);
+ if(disable_eSCO) {
+ supported_commands_ptr[29] &= ~0x08;
+ }
+
buffer_allocator->free(response);
}
--
2.25.1
@@ -1,29 +0,0 @@
From b7ff0d28b15d50e4c3aa6ff636eed67290d20e33 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 14 Aug 2018 19:33:03 +0200
Subject: [PATCH 1/7] Detect allowed sdcard options based on vndk
Some kernel crashes when using too recent sdcardfs options
Change-Id: I632e485f9b2a09a46d4a1fde2ea15217f8d92eff
---
sdcard/sdcard.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 622de5b7a..955ddbb4c 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -110,7 +110,8 @@ static bool sdcardfs_setup(const std::string& source_path, const std::string& de
if (unshared_obb) new_opts_list.push_back("unshared_obb,");
// Try several attempts, each time with one less option, to gracefully
// handle older kernels that aren't updated yet.
- for (int i = 0; i <= new_opts_list.size(); ++i) {
+ int first_option_to_try = property_get_bool("persist.sys.phh.modern_sdcard", false) ? 0 : 2;
+ for (int i = first_option_to_try; i <= new_opts_list.size(); ++i) {
std::string new_opts;
for (int j = 0; j < new_opts_list.size() - i; ++j) {
new_opts += new_opts_list[j];
--
2.17.1
@@ -1,33 +0,0 @@
From 79508b1e216217f4e9b8a8692049407e30bbb0b6 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 2 Jan 2019 17:17:20 +0100
Subject: [PATCH 2/7] Ignore /proc/kmsg if reading from it faults
On some devices, (The only known one is Y6 2018), reading from
/proc/kmsg fails, with a status EFAULT
This isn't just from logd, a simple cat /proc/kmsg does that as well.
Simply stop reading logs from kernel in that case
Change-Id: I4b902b7ec36107c722e2f5cc5dbb7964734bb71d
---
logd/LogKlog.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp
index edd326aec..8ff719f6e 100644
--- a/logd/LogKlog.cpp
+++ b/logd/LogKlog.cpp
@@ -238,6 +238,9 @@ bool LogKlog::onDataAvailable(SocketClient* cli) {
break;
}
if (retval < 0) {
+ if(errno == EFAULT) {
+ stopListener();
+ }
return false;
}
len += retval;
--
2.17.1
@@ -1,41 +0,0 @@
From 87add47acc49be7c6b2eb9802f8d99382409847a Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 13:05:37 +0200
Subject: [PATCH 3/7] [first stage] If Vboot2 fails, fall-back to Vboot1
Some devices, for instance Honor View 10, running Pie vendor declares
vbmeta in their device-tree, but doesn't have a vbmeta partition.
Test: without this fix the device reboots into bootloader
Test: with this fix, the device boots.
Please note that other fixes are also required to get this device to
actually boot.
Change-Id: I97a7042fb03f817c41b801d558e438d2c1f6c375
---
init/first_stage_mount.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index 8eb2f9748..990d76928 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -809,7 +809,13 @@ bool DoFirstStageMount() {
LOG(ERROR) << "Failed to create FirstStageMount";
return false;
}
- return handle->DoFirstStageMount();
+ if(!handle->DoFirstStageMount()) {
+ handle = nullptr;
+ auto fstab = ReadFirstStageFstab();
+ std::unique_ptr<FirstStageMount> v = std::make_unique<FirstStageMountVBootV1>(std::move(fstab));
+ return v->DoFirstStageMount();
+ }
+ return true;
}
void SetInitAvbVersionInRecovery() {
--
2.17.1
@@ -1,32 +0,0 @@
From 69b547930f6484cd8b0117b445b4468b9035655b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 28 Sep 2020 21:41:34 +0200
Subject: [PATCH 7/7] Enable PASSCRED incoditionnally. This is needed on A-only
devices that cant set passcred on socket
Change-Id: I74168aa94d91fd91e1baa321582a2b2893efa3af
---
logd/LogListener.cpp | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index ba610424f..4f1df46fa 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -121,11 +121,8 @@ int LogListener::getLogSocket() {
if (sock < 0) { // logd started up in init.sh
sock = socket_local_server(
socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_DGRAM);
-
- int on = 1;
- if (setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on))) {
- return -1;
- }
}
+ int on = 1;
+ setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
return sock;
}
--
2.17.1
@@ -1,104 +0,0 @@
From e9288c036c55b8d7cc1c3ba9e1b20a3ca4fb29e3 Mon Sep 17 00:00:00 2001
From: SzuWei Lin <szuweilin@google.com>
Date: Thu, 31 Dec 2020 16:52:39 +0800
Subject: [PATCH] Make ro.product.cpu.abilist* to be fetched dynamically
Basically, ro.product.cpu.abilist* are defined by
ro.vendor.cpu.abilist*. And they can be overried by
ro.odm.cpu.abilist* and ro.product.cpu.abilist*.
ro.system.cpu.abilist* are for fallback if others are no defined.
Bug: 176520383
Test: check the result by flashing aosp_arm64-userdebug on
Test: aosp_blueline-user and aosp_blueline-user hacked by
Test: 64-bits-only
Change-Id: I01ae01af099a4ec8fe3d4525edecc233a477ff60
---
init/property_service.cpp | 64 +++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 42dd5afcb..44b51c2cf 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -874,6 +874,69 @@ static void property_derive_build_fingerprint() {
}
}
+// If the ro.product.cpu.abilist* properties have not been explicitly
+// set, derive them from ro.${partition}.product.cpu.abilist* properties.
+static void property_initialize_ro_cpu_abilist() {
+ // From high to low priority.
+ const char* kAbilistSources[] = {
+ "product",
+ "odm",
+ "vendor",
+ "system",
+ };
+ const std::string EMPTY = "";
+ const char* kAbilistProp = "ro.product.cpu.abilist";
+ const char* kAbilist32Prop = "ro.product.cpu.abilist32";
+ const char* kAbilist64Prop = "ro.product.cpu.abilist64";
+
+ // If the properties are defined explicitly, just use them.
+ if (GetProperty(kAbilistProp, EMPTY) != EMPTY) {
+ return;
+ }
+
+ // Find the first source defining these properties by order.
+ std::string abilist32_prop_val;
+ std::string abilist64_prop_val;
+ for (const auto& source : kAbilistSources) {
+ const auto abilist32_prop = std::string("ro.") + source + ".product.cpu.abilist32";
+ const auto abilist64_prop = std::string("ro.") + source + ".product.cpu.abilist64";
+ abilist32_prop_val = GetProperty(abilist32_prop, EMPTY);
+ abilist64_prop_val = GetProperty(abilist64_prop, EMPTY);
+ // The properties could be empty on 32-bit-only or 64-bit-only devices,
+ // but we cannot identify a property is empty or undefined by GetProperty().
+ // So, we assume both of these 2 properties are empty as undefined.
+ if (abilist32_prop_val != EMPTY || abilist64_prop_val != EMPTY) {
+ break;
+ }
+ }
+
+ // Merge ABI lists for ro.product.cpu.abilist
+ auto abilist_prop_val = abilist64_prop_val;
+ if (abilist32_prop_val != EMPTY) {
+ if (abilist_prop_val != EMPTY) {
+ abilist_prop_val += ",";
+ }
+ abilist_prop_val += abilist32_prop_val;
+ }
+
+ // Set these properties
+ const std::pair<const char*, const std::string&> set_prop_list[] = {
+ {kAbilistProp, abilist_prop_val},
+ {kAbilist32Prop, abilist32_prop_val},
+ {kAbilist64Prop, abilist64_prop_val},
+ };
+ for (const auto& [prop, prop_val] : set_prop_list) {
+ LOG(INFO) << "Setting property '" << prop << "' to '" << prop_val << "'";
+
+ std::string error;
+ uint32_t res = PropertySet(prop, prop_val, &error);
+ if (res != PROP_SUCCESS) {
+ LOG(ERROR) << "Error setting property '" << prop << "': err=" << res << " (" << error
+ << ")";
+ }
+ }
+}
+
void PropertyLoadBootDefaults() {
// TODO(b/117892318): merge prop.default and build.prop files into one
// We read the properties and their values into a map, in order to always allow properties
@@ -918,6 +981,7 @@ void PropertyLoadBootDefaults() {
property_initialize_ro_product_props();
property_derive_build_fingerprint();
+ property_initialize_ro_cpu_abilist();
if (android::base::GetBoolProperty("ro.persistent_properties.ready", false)) {
update_sys_usb_config();
--
2.25.1
@@ -1,174 +0,0 @@
From d3debf43a576aebfc505803eeb95b099c9129ae3 Mon Sep 17 00:00:00 2001
From: Nikita Ioffe <ioffe@google.com>
Date: Mon, 7 Sep 2020 10:27:25 +0100
Subject: [PATCH 10/12] Only store result of mount_all that mounted userdata
During boot sequence there can be multiple calls to mount_all. For the
userspace reboot to correctly remount userdata, we need to store the
return code of the one that was responsible in mounting userdata.
Test: adb root
Test: adb shell setprop init.userspace_reboot.is_supported 1
Test: adb reboot userspace
Test: checked dmsg
Bug: 166353152
Change-Id: Id0ae15f3bcf65fa54e4e72b76f64716c053af7fb
Merged-In: Id0ae15f3bcf65fa54e4e72b76f64716c053af7fb
(cherry picked from commit 9ede7ec273539d7ad6820bdf3f1f2f28433a9fb3)
---
fs_mgr/fs_mgr.cpp | 24 ++++++++++++++----------
fs_mgr/include/fs_mgr.h | 14 +++++++++++++-
init/builtins.cpp | 14 +++++++++++---
3 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 30db652ed..bc2d8a475 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -1305,14 +1305,15 @@ static bool IsMountPointMounted(const std::string& mount_point) {
// When multiple fstab records share the same mount_point, it will try to mount each
// one in turn, and ignore any duplicates after a first successful mount.
// Returns -1 on error, and FS_MGR_MNTALL_* otherwise.
-int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
+MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
int encryptable = FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE;
int error_count = 0;
CheckpointManager checkpoint_manager;
AvbUniquePtr avb_handle(nullptr);
+ bool userdata_mounted = false;
if (fstab->empty()) {
- return FS_MGR_MNTALL_FAIL;
+ return {FS_MGR_MNTALL_FAIL, userdata_mounted};
}
// Keep i int to prevent unsigned integer overflow from (i = top_idx - 1),
@@ -1352,7 +1353,7 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
}
// Terrible hack to make it possible to remount /data.
- // TODO: refact fs_mgr_mount_all and get rid of this.
+ // TODO: refactor fs_mgr_mount_all and get rid of this.
if (mount_mode == MOUNT_MODE_ONLY_USERDATA && current_entry.mount_point != "/data") {
continue;
}
@@ -1388,7 +1389,7 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
avb_handle = AvbHandle::Open();
if (!avb_handle) {
LERROR << "Failed to open AvbHandle";
- return FS_MGR_MNTALL_FAIL;
+ return {FS_MGR_MNTALL_FAIL, userdata_mounted};
}
}
if (avb_handle->SetUpAvbHashtree(&current_entry, true /* wait_for_verity_dev */) ==
@@ -1430,7 +1431,7 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
if (status == FS_MGR_MNTALL_FAIL) {
// Fatal error - no point continuing.
- return status;
+ return {status, userdata_mounted};
}
if (status != FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE) {
@@ -1444,11 +1445,14 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
attempted_entry.mount_point},
nullptr)) {
LERROR << "Encryption failed";
- return FS_MGR_MNTALL_FAIL;
+ return {FS_MGR_MNTALL_FAIL, userdata_mounted};
}
}
}
+ if (current_entry.mount_point == "/data") {
+ userdata_mounted = true;
+ }
// Success! Go get the next one.
continue;
}
@@ -1546,9 +1550,9 @@ int fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
#endif
if (error_count) {
- return FS_MGR_MNTALL_FAIL;
+ return {FS_MGR_MNTALL_FAIL, userdata_mounted};
} else {
- return encryptable;
+ return {encryptable, userdata_mounted};
}
}
@@ -1770,8 +1774,8 @@ int fs_mgr_remount_userdata_into_checkpointing(Fstab* fstab) {
}
LINFO << "Remounting /data";
// TODO(b/143970043): remove this hack after fs_mgr_mount_all is refactored.
- int result = fs_mgr_mount_all(fstab, MOUNT_MODE_ONLY_USERDATA);
- return result == FS_MGR_MNTALL_FAIL ? -1 : 0;
+ auto result = fs_mgr_mount_all(fstab, MOUNT_MODE_ONLY_USERDATA);
+ return result.code == FS_MGR_MNTALL_FAIL ? -1 : 0;
}
return 0;
}
diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h
index 2a67b8c9f..11e36645e 100644
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -60,8 +60,20 @@ enum mount_mode {
#define FS_MGR_MNTALL_DEV_NOT_ENCRYPTED 1
#define FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE 0
#define FS_MGR_MNTALL_FAIL (-1)
+
+struct MountAllResult {
+ // One of the FS_MGR_MNTALL_* returned code defined above.
+ int code;
+ // Whether userdata was mounted as a result of |fs_mgr_mount_all| call.
+ bool userdata_mounted;
+};
+
// fs_mgr_mount_all() updates fstab entries that reference device-mapper.
-int fs_mgr_mount_all(android::fs_mgr::Fstab* fstab, int mount_mode);
+// Returns a |MountAllResult|. The first element is one of the FS_MNG_MNTALL_* return codes
+// defined above, and the second element tells whether this call to fs_mgr_mount_all was responsible
+// for mounting userdata. Later is required for init to correctly enqueue fs-related events as part
+// of userdata remount during userspace reboot.
+MountAllResult fs_mgr_mount_all(android::fs_mgr::Fstab* fstab, int mount_mode);
#define FS_MGR_DOMNT_FAILED (-1)
#define FS_MGR_DOMNT_BUSY (-2)
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 0ac66f272..789316621 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -666,18 +666,26 @@ static Result<void> do_mount_all(const BuiltinArguments& args) {
}
}
- auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_all->mode);
+ auto mount_fstab_result = fs_mgr_mount_all(&fstab, mount_all->mode);
SetProperty(prop_name, std::to_string(t.duration().count()));
if (mount_all->import_rc) {
import_late(mount_all->rc_paths);
}
+ if (mount_fstab_result.userdata_mounted) {
+ // This call to fs_mgr_mount_all mounted userdata. Keep the result in
+ // order for userspace reboot to correctly remount userdata.
+ LOG(INFO) << "Userdata mounted using "
+ << (mount_all->fstab_path.empty() ? "(default fstab)" : mount_all->fstab_path)
+ << " result : " << mount_fstab_result.code;
+ initial_mount_fstab_return_code = mount_fstab_result.code;
+ }
+
if (queue_event) {
/* queue_fs_event will queue event based on mount_fstab return code
* and return processed return code*/
- initial_mount_fstab_return_code = mount_fstab_return_code;
- auto queue_fs_result = queue_fs_event(mount_fstab_return_code, false);
+ auto queue_fs_result = queue_fs_event(mount_fstab_result.code, false);
if (!queue_fs_result.ok()) {
return Error() << "queue_fs_event() failed: " << queue_fs_result.error();
}
--
2.25.1
@@ -1,33 +0,0 @@
From 60cf1d694c1550c0b9b8139e70d0627c54b44d6b Mon Sep 17 00:00:00 2001
From: Qilin Tan <qilin.tan@mediatek.com>
Date: Mon, 2 Nov 2020 11:25:09 +0800
Subject: [PATCH 11/12] Store result of mount_all for mounted userdata by
metadata encryption
When the userdata is mounted, its result will be stored and return.
But the result is not stored when the userdata is mounted with
metadata encryption. Store the result of metadata encryption mount.
Bug: 172180818
Test: run cts-on-gsi -m CtsUserspaceRebootHostSideTestCases
Change-Id: I88b1b4f6a2b1ed81773e18243cb6c46244dc1ba5
---
fs_mgr/fs_mgr.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index bc2d8a475..b20086e5d 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -1521,6 +1521,8 @@ MountAllResult fs_mgr_mount_all(Fstab* fstab, int mount_mode) {
attempted_entry.mount_point},
nullptr)) {
++error_count;
+ } else if (current_entry.mount_point == "/data") {
+ userdata_mounted = true;
}
encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
continue;
--
2.25.1
@@ -1,45 +0,0 @@
From 26478551e8a20d3abf1c302e58ee8fee97cab728 Mon Sep 17 00:00:00 2001
From: Bowgo Tsai <bowgotsai@google.com>
Date: Fri, 4 Dec 2020 17:04:34 +0800
Subject: [PATCH 12/12] Adding 'postinstall' root dir unconditionally.
It is required to pass update_engine_unittests in GSI
compliance test. And it's clean to just add this mount
dir unconditionally.
Bug: 172696594
Test: `m init.environ.rc` and checks that $OUT/root/postinstall exists
Change-Id: Ib340a78af442ea66c45cecb373a9eb3c428f8dda
Merged-In: Ib340a78af442ea66c45cecb373a9eb3c428f8dda
---
rootdir/Android.mk | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index a9d0ed08a..7d383f522 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -78,7 +78,7 @@ endif
# create some directories (some are mount points) and symlinks
LOCAL_POST_INSTALL_CMD := mkdir -p $(addprefix $(TARGET_ROOT_OUT)/, \
dev proc sys system data data_mirror odm oem acct config storage mnt apex debug_ramdisk \
- linkerconfig $(BOARD_ROOT_EXTRA_FOLDERS)); \
+ linkerconfig postinstall $(BOARD_ROOT_EXTRA_FOLDERS)); \
ln -sf /system/bin $(TARGET_ROOT_OUT)/bin; \
ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
ln -sf /data/user_de/0/com.android.shell/files/bugreports $(TARGET_ROOT_OUT)/bugreports; \
@@ -132,11 +132,6 @@ ifdef BOARD_ROOT_EXTRA_SYMLINKS
; mkdir -p $(dir $(TARGET_ROOT_OUT)/$(word 2,$(p))) \
; ln -sf $(word 1,$(p)) $(TARGET_ROOT_OUT)/$(word 2,$(p)))
endif
-# The A/B updater uses a top-level /postinstall directory to mount the new
-# system before reboot.
-ifeq ($(AB_OTA_UPDATER),true)
- LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/postinstall
-endif
# The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT.
# Since init.environ.rc is required for init and satisfies that requirement, we hijack it to create the symlink.
--
2.25.1
@@ -1,33 +0,0 @@
From f287850503008d796b7873e5fc0b06981c2318fe Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 20 Sep 2020 20:53:14 +0200
Subject: [PATCH 1/2] Disable vndk.lite
Change-Id: I129bbee49f6c9b901ca4f5cf55dae2ec36bea107
---
modules/environment.cc | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/modules/environment.cc b/modules/environment.cc
index e63be71..bc2630b 100644
--- a/modules/environment.cc
+++ b/modules/environment.cc
@@ -24,13 +24,11 @@ namespace android {
namespace linkerconfig {
namespace modules {
bool IsLegacyDevice() {
- return (!Variables::GetValue("ro.vndk.version").has_value() &&
- !Variables::GetValue("ro.vndk.lite").has_value()) ||
- Variables::GetValue("ro.treble.enabled") == "false";
+ return false;
}
bool IsVndkLiteDevice() {
- return Variables::GetValue("ro.vndk.lite").value_or("") == "true";
+ return false;
}
bool IsVndkInSystemNamespace() {
--
2.17.1
@@ -1,72 +0,0 @@
From 99e0657c0215e9ce9ba55aba5c41fbfe438c82e6 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 28 Sep 2020 21:02:19 +0200
Subject: [PATCH 2/2] Add special handling of vndk 26 (remove liblog.so from
llndk, it is provided by vndk, and allow linking against libnativeloader)
Change-Id: I29b0bb6087ba58f69ee6406e003513bceb6785d8
---
contents/namespace/vendordefault.cc | 14 +++++++++++++-
contents/namespace/vndk.cc | 5 +++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/contents/namespace/vendordefault.cc b/contents/namespace/vendordefault.cc
index b3be200..af53602 100644
--- a/contents/namespace/vendordefault.cc
+++ b/contents/namespace/vendordefault.cc
@@ -17,6 +17,7 @@
// This is the default linker namespace for a vendor process (a process started
// from /vendor/bin/*).
+#include <iostream>
#include "linkerconfig/namespacebuilder.h"
#include "linkerconfig/common.h"
@@ -105,9 +106,20 @@ Namespace BuildVendorDefaultNamespace([[maybe_unused]] const Context& ctx) {
ns.AddRequires(kVndkLiteVendorRequires);
ns.AddProvides(GetSystemStubLibraries());
} else {
+ auto llndk = Var("LLNDK_LIBRARIES_VENDOR");
+ std::cerr << "handing llndk for default vendor namespace" << std::endl;
+ if(GetVendorVndkVersion()== "26") {
+ std::cerr << "vndk 26" << std::endl;
+ std::string lookFor = ":liblog.so";
+ std::cerr << "Before " << llndk << std::endl;
+
+ llndk = llndk.replace(llndk.find(lookFor), lookFor.length(), "");
+ std::cerr << "After " << llndk << std::endl;
+ }
+
ns.GetLink(ctx.GetSystemNamespaceName())
.AddSharedLib(
- {Var("LLNDK_LIBRARIES_VENDOR"), Var("SANITIZER_DEFAULT_VENDOR")});
+ {llndk, Var("SANITIZER_DEFAULT_VENDOR")});
ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_VENDOR"),
Var("VNDK_CORE_LIBRARIES_VENDOR")});
if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
diff --git a/contents/namespace/vndk.cc b/contents/namespace/vndk.cc
index a95db80..589f745 100644
--- a/contents/namespace/vndk.cc
+++ b/contents/namespace/vndk.cc
@@ -17,6 +17,7 @@
// This namespace is exclusively for vndk-sp libs.
#include "linkerconfig/environment.h"
+using android::linkerconfig::modules::GetVendorVndkVersion;
#include "linkerconfig/namespacebuilder.h"
using android::linkerconfig::modules::AsanPath;
@@ -121,6 +122,10 @@ Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx,
ns.AddRequires(std::vector{"libneuralnetworks.so"});
+ if(GetVendorVndkVersion() == "26" || GetVendorVndkVersion() == "27" ) {
+ ns.GetLink("com_android_art").AddSharedLib("libnativeloader.so");
+ }
+
return ns;
}
} // namespace contents
--
2.25.1
@@ -1,28 +0,0 @@
From 791aba3f1be4cf9ba56a94d1744cc308ac439a2b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 28 Sep 2020 22:03:00 +0200
Subject: [PATCH] Enable passcred (useful on A-only when init cant do it for
us)
Change-Id: I0984518531011276acf21c4f226dea35a7f9373f
---
lmkd.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lmkd.cpp b/lmkd.cpp
index 882ae4a..2f1c649 100644
--- a/lmkd.cpp
+++ b/lmkd.cpp
@@ -2924,6 +2924,9 @@ static int init(void) {
return -1;
}
+ int on = 1;
+ setsockopt(ctrl_sock.sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+
ret = listen(ctrl_sock.sock, MAX_DATA_CONN);
if (ret < 0) {
ALOGE("lmkd control socket listen failed (errno=%d)", errno);
--
2.17.1
@@ -1,44 +0,0 @@
From f19e29be30ae859c084bebd2d5c32f7ff94bc31f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 20 Aug 2018 22:37:54 +0200
Subject: [PATCH 2/6] Support Samsung's implementation of exfat, called sdfat
---
fs/Exfat.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/Exfat.cpp b/fs/Exfat.cpp
index 34f1024..3aa9494 100644
--- a/fs/Exfat.cpp
+++ b/fs/Exfat.cpp
@@ -35,7 +35,7 @@ static const char* kFsckPath = "/system/bin/fsck.exfat";
bool IsSupported() {
return access(kMkfsPath, X_OK) == 0 && access(kFsckPath, X_OK) == 0 &&
- IsFilesystemSupported("exfat");
+ (IsFilesystemSupported("exfat") || IsFilesystemSupported("sdfat"));
}
status_t Check(const std::string& source) {
@@ -61,13 +61,16 @@ status_t Mount(const std::string& source, const std::string& target, int ownerUi
auto mountData = android::base::StringPrintf("uid=%d,gid=%d,fmask=%o,dmask=%o", ownerUid,
ownerGid, permMask, permMask);
- if (mount(source.c_str(), target.c_str(), "exfat", mountFlags, mountData.c_str()) == 0) {
+ const char *fs = "exfat";
+ if(IsFilesystemSupported("sdfat"))
+ fs = "sdfat";
+ if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
return 0;
}
PLOG(ERROR) << "Mount failed; attempting read-only";
mountFlags |= MS_RDONLY;
- if (mount(source.c_str(), target.c_str(), "exfat", mountFlags, mountData.c_str()) == 0) {
+ if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
return 0;
}
--
2.17.1
@@ -1,32 +0,0 @@
From d69f9a1231d08fd6508e7219b3298cdbc3158796 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 16 Sep 2019 13:49:05 +0200
Subject: [PATCH] Check needsCheckpoint only if checkpoint is supported
This is needed because some devices (Xiaomi MiPad 4, uncertified)
declares a bootctrl HAL in manifest, but doesn't have it.
vold will then hang in needsCheckpoint waiting for bootctrl
Change-Id: I2dafcbca7e994d7a3ac36ef3698590db2ab482fa
---
cryptfs.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 33f0913..7db1ef6 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -1963,7 +1963,9 @@ static int cryptfs_restart_internal(int restart_main) {
SLOGE("Failed to setexeccon");
return -1;
}
- bool needs_cp = android::vold::cp_needsCheckpoint();
+ bool supportsCheckpoint = false;
+ android::vold::cp_supportsCheckpoint(supportsCheckpoint);
+ bool needs_cp = supportsCheckpoint && android::vold::cp_needsCheckpoint();
#ifdef CONFIG_HW_DISK_ENCRYPTION
while ((mount_rc = fs_mgr_do_mount(&fstab_default, DATA_MNT_POINT, blkdev.data(), 0,
needs_cp, false)) != 0) {
--
2.25.1
@@ -1,38 +0,0 @@
From 8ffe3b736fa6736eb12951977eabdde6cd999359 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 28 Jan 2020 00:27:17 +0100
Subject: [PATCH 4/6] Sony has `texfat` exfat fs
---
fs/Exfat.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/Exfat.cpp b/fs/Exfat.cpp
index 3aa9494..03ad649 100644
--- a/fs/Exfat.cpp
+++ b/fs/Exfat.cpp
@@ -35,7 +35,11 @@ static const char* kFsckPath = "/system/bin/fsck.exfat";
bool IsSupported() {
return access(kMkfsPath, X_OK) == 0 && access(kFsckPath, X_OK) == 0 &&
- (IsFilesystemSupported("exfat") || IsFilesystemSupported("sdfat"));
+ (
+ IsFilesystemSupported("exfat") ||
+ IsFilesystemSupported("sdfat") ||
+ IsFilesystemSupported("texfat")
+ );
}
status_t Check(const std::string& source) {
@@ -64,6 +68,8 @@ status_t Mount(const std::string& source, const std::string& target, int ownerUi
const char *fs = "exfat";
if(IsFilesystemSupported("sdfat"))
fs = "sdfat";
+ if(IsFilesystemSupported("texfat"))
+ fs = "texfat";
if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
return 0;
}
--
2.17.1

Some files were not shown because too many files have changed in this diff Show More