Initial unified commit for Android 12, syncing up to v400.a

This commit is contained in:
Andy CrossGate Yan
2021-10-20 14:54:55 +00:00
commit 796726eb09
166 changed files with 20826 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
From 9c440d31d462e558ba6961e8cd42c91411299826 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 27 Oct 2021 14:39:29 -0400
Subject: [PATCH] Disable vndklite handling
Change-Id: Ic4474cf80fc4b45a9a2760dd51e2ca29c4d961e2
---
linker/linker.cpp | 5 -----
1 file changed, 5 deletions(-)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 3488f5cc7..c32ea8484 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -93,7 +93,6 @@ static uint64_t g_module_unload_counter = 0;
static const char* const kLdConfigArchFilePath = "/system/etc/ld.config." ABI_STRING ".txt";
static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
-static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
static const char* const kLdGeneratedConfigFilePath = "/linkerconfig/ld.config.txt";
@@ -3368,10 +3367,6 @@ 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)) {
- return kLdConfigVndkLiteFilePath;
- }
-
std::string ld_config_file_vndk = kLdConfigFilePath;
size_t insert_pos = ld_config_file_vndk.find_last_of('.');
if (insert_pos == std::string::npos) {
--
2.29.2

View File

@@ -0,0 +1,26 @@
From 1de21d04e398527381a751bc0f35cb9a298ef7b6 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 20:31:07 +0200
Subject: [PATCH] Don't reboot if we couldn't get bootctrl
Change-Id: Id1793660bd1c97ab369607f58a772ca3512ec1af
---
update_verifier/update_verifier.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index a042f900..ea3645af 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -310,7 +310,7 @@ int update_verifier(int argc, char** argv) {
sp<IBootControl> module = IBootControl::getService();
if (module == nullptr) {
LOG(ERROR) << "Error getting bootctrl module.";
- return reboot_device();
+ return 0;
}
uint32_t current_slot = module->getCurrentSlot();
--
2.29.2

View File

@@ -0,0 +1,26 @@
From 69ec54d90d2b41ae4e1c27be02b320432c9a1f92 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 9 Apr 2018 00:19:49 +0200
Subject: [PATCH 1/8] Increase default log_level to get actual selinux error in
kmsg
---
secilc/secilc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 9c78e425..71a0f685 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
int opt_index = 0;
char *fc_buf = NULL;
size_t fc_size;
- enum cil_log_level log_level = CIL_ERR;
+ enum cil_log_level log_level = CIL_WARN;
static struct option long_opts[] = {
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
--
2.25.1

View File

@@ -0,0 +1,45 @@
From 9f95f8b0858cec9d105efcfb5923a96610eab76f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 9 Sep 2020 22:36:42 +0200
Subject: [PATCH 2/8] Revert "libsepol: Make an unknown permission an error in
CIL"
This reverts commit dc4e54126bf25dea4d51820922ccd1959be68fbc.
This is required because some targets calls undefined permissions:
- Realme X2 Pro calls sigcont
- Honor 7X calls perf_event
---
libsepol/cil/src/cil_resolve_ast.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
index 87575860..e72abdeb 100644
--- a/libsepol/cil/src/cil_resolve_ast.c
+++ b/libsepol/cil/src/cil_resolve_ast.c
@@ -131,14 +131,18 @@ static int __cil_resolve_perms(symtab_t *class_symtab, symtab_t *common_symtab,
}
}
if (rc != SEPOL_OK) {
+ struct cil_list *empty_list;
if (class_flavor == CIL_MAP_CLASS) {
cil_log(CIL_ERR, "Failed to resolve permission %s for map class\n", (char*)curr->data);
- } else {
- cil_log(CIL_ERR, "Failed to resolve permission %s\n", (char*)curr->data);
+ goto exit;
}
- goto exit;
+ cil_log(CIL_WARN, "Failed to resolve permission %s\n", (char*)curr->data);
+ /* Use an empty list to represent unknown perm */
+ cil_list_init(&empty_list, perm_strs->flavor);
+ cil_list_append(*perm_datums, CIL_LIST, empty_list);
+ } else {
+ cil_list_append(*perm_datums, CIL_DATUM, perm_datum);
}
- cil_list_append(*perm_datums, CIL_DATUM, perm_datum);
} else {
cil_list_append(*perm_datums, curr->flavor, curr->data);
}
--
2.25.1

View File

@@ -0,0 +1,125 @@
From 357d0c61451ab507248697d1b2327f6204884b78 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 3/8] 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: I52938703c1c39de8f881c98c82cfbf5a04d96cf7
---
libsepol/cil/src/cil_binary.c | 8 ++++++--
libsepol/cil/src/cil_build_ast.c | 15 +++++++++++----
libsepol/cil/src/cil_resolve_ast.c | 15 +++++++++++++--
3 files changed, 30 insertions(+), 8 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 307b1ee3..aaec0a9b 100644
--- a/libsepol/cil/src/cil_build_ast.c
+++ b/libsepol/cil/src/cil_build_ast.c
@@ -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);
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

View File

@@ -0,0 +1,84 @@
From df88fcc15f776b8ba1831b491509137b01b58356 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 25 Oct 2019 13:29:20 +0200
Subject: [PATCH 4/8] Fix boot on Moto devices using unknown class
vendor sepolicy never contains new class or classorder, and are not
allowed to.
Though this is not tested, and it turns out Moto did it anyway.
This raises an issue, because class need to be ordered, and thus the cil
contains the ordering. This ordering needs to be merged.
Android 10 added new classes, so the ordering can no longer be merged,
and secilc fails on those devices, preventing boot.
Considering vendor are not supposed to declare new class (and thus
declare classorder), this fix ignores class-es/classorder in vendor
SELinux policy.
Since the vendor selinux policy has allows rules based on this context,
those allows will fail since the class doesn't exist.
Workaround this by ignoring rules with the problematic class
( keystore_moto_key )
Lucky us, this new class `keystore_moto_key` is used by Moto for
framework to framework (more accurately priv app to keymaster), since
our own framework doesn't use this class, simply ignoring it fixes the
issue.
Change-Id: I66339857634ebfdba359f12a99dfd0bff709d80b
---
libsepol/cil/src/cil_build_ast.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
index aaec0a9b..6b4b8708 100644
--- a/libsepol/cil/src/cil_build_ast.c
+++ b/libsepol/cil/src/cil_build_ast.c
@@ -393,6 +393,14 @@ int cil_gen_class(struct cil_db *db, struct cil_tree_node *parse_current, struct
struct cil_tree_node *perms = NULL;
int rc = SEPOL_ERR;
+ {
+ const char* path = cil_tree_get_cil_path(parse_current);
+ if(strstr(path, "vendor")) {
+ cil_clear_node(ast_node);
+ return SEPOL_OK;
+ }
+ }
+
rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
if (rc != SEPOL_OK) {
goto exit;
@@ -459,6 +467,14 @@ int cil_gen_classorder(struct cil_db *db, struct cil_tree_node *parse_current, s
struct cil_list_item *head = NULL;
int rc = SEPOL_ERR;
+ {
+ const char* path = cil_tree_get_cil_path(parse_current);
+ if(strstr(path, "vendor")) {
+ cil_clear_node(ast_node);
+ return SEPOL_OK;
+ }
+ }
+
if (db == NULL || parse_current == NULL || ast_node == NULL) {
goto exit;
}
@@ -2057,6 +2073,14 @@ int cil_gen_avrule(struct cil_tree_node *parse_current, struct cil_tree_node *as
rule->src_str = parse_current->next->data;
rule->tgt_str = parse_current->next->next->data;
+ {
+ const char *classname = parse_current->next->next->next->cl_head->data;
+ if(strcmp(classname, "keystore_moto_key") == 0) {
+ cil_clear_node(ast_node);
+ return SEPOL_OK;
+ }
+ }
+
rc = cil_fill_classperms_list(parse_current->next->next->next, &rule->perms.classperms);
if (rc != SEPOL_OK) {
goto exit;
--
2.25.1

View File

@@ -0,0 +1,43 @@
From 55627b8443a01f8daa37892d0cede3fef98a6758 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 6 Sep 2019 15:07:25 +0200
Subject: [PATCH 5/8] Allow /devices/virtual/block/ genfscon conflict (seen on
Xiaomi Mi 9)
Change-Id: I06e4e9d5b82d61a8aeab595b47e2589249675895
---
libsepol/cil/src/cil_post.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
index a0cadfde..68c0318e 100644
--- a/libsepol/cil/src/cil_post.c
+++ b/libsepol/cil/src/cil_post.c
@@ -477,7 +477,23 @@ int cil_post_genfscon_context_compare(const void *a, const void *b)
{
struct cil_genfscon *a_genfscon = *(struct cil_genfscon**)a;
struct cil_genfscon *b_genfscon = *(struct cil_genfscon**)b;
- return context_compare(a_genfscon->context, b_genfscon->context);
+ int rc = context_compare(a_genfscon->context, b_genfscon->context);
+ if(rc) {
+ fprintf(stderr, "hello %s\n", a_genfscon->fs_str);
+ int bypass = 0;
+ /*
+ * This conflict has been seen on Xiaomi Mi 9:
+ * - AOSP Q says (genfscon sysfs /devices/virtual/block/ (u object_r sysfs_devices_block ((s0) (s0))))
+ * - stock rom says (genfscon sysfs /devices/virtual/block/ (u object_r sysfs_ufs_target ((s0) (s0))))
+ */
+ if(strcmp(a_genfscon->path_str, "/devices/virtual/block/") == 0)
+ bypass = 1;
+ if(bypass == 1) {
+ fprintf(stderr, "Received conflicting %s vs %s but ignore\n", a_genfscon->path_str, b_genfscon->path_str);
+ return 0;
+ }
+ }
+ return rc;
}
int cil_post_netifcon_context_compare(const void *a, const void *b)
--
2.25.1

View File

@@ -0,0 +1,44 @@
From ec8e7155afc36bbe1a9649ba307abaa92c32cb0d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 20:37:04 +0200
Subject: [PATCH 6/8] if service is "rcs", accept conflict. Seen on Moto E5
Change-Id: I0cc2d0fad83f403f2b5d7458039b1564ce5ed9dd
---
libselinux/src/label_backends_android.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libselinux/src/label_backends_android.c b/libselinux/src/label_backends_android.c
index d81faabe..1e4513e9 100644
--- a/libselinux/src/label_backends_android.c
+++ b/libselinux/src/label_backends_android.c
@@ -62,14 +62,24 @@ 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)) {
- rc = -1;
- errno = EINVAL;
selinux_log
(SELINUX_ERROR,
"Multiple different specifications for %s (%s and %s).\n",
curr_spec->property_key,
spec_arr[jj].lr.ctx_raw,
curr_spec->lr.ctx_raw);
+ int ignore = 0;
+ /*
+ * This issue has been found on Moto E5
+ * E SELinux : Multiple different specifications for rcs (u:object_r:radio_service:s0 and u:object_r:mot_rcs_service:s0).
+ */
+ if(!strcmp(curr_spec->property_key, "rcs"))
+ ignore = 1;
+
+ if(!ignore) {
+ rc = -1;
+ errno = EINVAL;
+ }
} else {
selinux_log
(SELINUX_WARNING,
--
2.25.1

View File

@@ -0,0 +1,27 @@
From 379d7cf233f500f1914fb86698688717b84385d0 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 24 May 2020 17:22:22 +0200
Subject: [PATCH 7/8] Allow mismatches of exfat genfscon
---
libsepol/cil/src/cil_post.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
index 68c0318e..75e5128c 100644
--- a/libsepol/cil/src/cil_post.c
+++ b/libsepol/cil/src/cil_post.c
@@ -488,6 +488,10 @@ int cil_post_genfscon_context_compare(const void *a, const void *b)
*/
if(strcmp(a_genfscon->path_str, "/devices/virtual/block/") == 0)
bypass = 1;
+ if(strcmp(a_genfscon->fs_str, "exfat") == 0 || strcmp(a_genfscon->fs_str, "esdfs") == 0) {
+ if(strcmp(a_genfscon->path_str, "/") == 0)
+ bypass = 1;
+ }
if(bypass == 1) {
fprintf(stderr, "Received conflicting %s vs %s but ignore\n", a_genfscon->path_str, b_genfscon->path_str);
return 0;
--
2.25.1

View File

@@ -0,0 +1,27 @@
From aca2ac082800d1db0bb6a1b7ffa9069dd3a3bc2d 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 8/8] 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 71a0f685..a7e2e531 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.25.1

View File

@@ -0,0 +1,131 @@
From e280efe7945437b9295600f3ade73deb978284eb Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 18:09:50 +0200
Subject: [PATCH 01/19] Fix BT in-call on CAF devices
See https://github.com/phhusson/treble_experimentations/issues/374
In Qualcomm's BSP audio_policy_configuration.xml, one route is missing,
from primary output and telephony to BT SCO.
Add it if we detect telephony and bt sco, but no such route.
Change-Id: Ifea0f88276ec9a0811f3cb1973c4b06f2c82077b
---
.../managerdefinitions/src/Serializer.cpp | 93 +++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 84ed6567b2..9a857ff091 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -648,6 +648,98 @@ std::variant<status_t, RouteTraits::Element> PolicySerializer::deserialize<Route
return route;
}
+static void fixupQualcommBtScoRoute(RouteTraits::Collection& routes, DevicePortTraits::Collection& devicePorts, HwModule* ctx) {
+ // On many Qualcomm devices, there is a BT SCO Headset Mic => primary input mix
+ // But Telephony Rx => BT SCO Headset route is missing
+ // When we detect such case, add the missing route
+
+ // If we have:
+ // <route type="mix" sink="Telephony Tx" sources="voice_tx"/>
+ // <route type="mix" sink="primary input" sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
+ // <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink" />
+ // And no <route type="mix" sink="BT SCO Headset" />
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ bool foundBtScoHeadsetDevice = false;
+ for(const auto& device: devicePorts) {
+ if(device->getTagName() == "BT SCO Headset") {
+ foundBtScoHeadsetDevice = true;
+ break;
+ }
+ }
+ if(!foundBtScoHeadsetDevice) {
+ ALOGE("No BT SCO Headset device found, don't patch policy");
+ return;
+ }
+
+ bool foundTelephony = false;
+ bool foundBtScoInput = false;
+ bool foundScoHeadsetRoute = false;
+ for(const auto& route: routes) {
+ ALOGE("Looking at route %d\n", route->getType());
+ if(route->getType() != AUDIO_ROUTE_MIX)
+ continue;
+ auto sink = route->getSink();
+ ALOGE("... With sink %s\n", sink->getTagName().c_str());
+ if(sink->getTagName() == "Telephony Tx") {
+ foundTelephony = true;
+ continue;
+ }
+ if(sink->getTagName() == "BT SCO Headset") {
+ foundScoHeadsetRoute = true;
+ break;
+ }
+ for(const auto& source: route->getSources()) {
+ ALOGE("... With source %s\n", source->getTagName().c_str());
+ if(source->getTagName() == "BT SCO Headset Mic") {
+ foundBtScoInput = true;
+ break;
+ }
+ }
+ }
+ //The route we want to add is already there
+ ALOGE("Done looking for existing routes");
+ if(foundScoHeadsetRoute)
+ return;
+
+ ALOGE("No existing route found... %d %d", foundTelephony ? 1 : 0, foundBtScoInput ? 1 : 0);
+ //We couldn't find the routes we assume are required for the function we want to add
+ if(!foundTelephony || !foundBtScoInput)
+ return;
+ ALOGE("Adding our own.");
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ AudioRoute *newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+
+ auto sink = ctx->findPortByTagName("BT SCO Headset");
+ ALOGE("Got sink %p\n", sink.get());
+ newRoute->setSink(sink);
+
+ Vector<sp<PolicyAudioPort>> sources;
+ for(const auto& sourceName: {
+ "primary output",
+ "deep_buffer",
+ "compressed_offload",
+ "Telephony Rx"
+ }) {
+ auto source = ctx->findPortByTagName(sourceName);
+ ALOGE("Got source %p\n", source.get());
+ if (source.get() != nullptr) {
+ sources.add(source);
+ source->addRoute(newRoute);
+ }
+ }
+
+ newRoute->setSources(sources);
+
+ sink->addRoute(newRoute);
+
+ auto ret = routes.add(newRoute);
+ ALOGE("route add returned %zd", ret);
+}
+
template<>
std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<ModuleTraits>(
const xmlNode *cur, ModuleTraits::PtrSerializingCtx ctx)
@@ -695,6 +787,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
if (status != NO_ERROR) {
return status;
}
+ fixupQualcommBtScoRoute(routes, devicePorts, module.get());
module->setRoutes(routes);
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
--
2.29.2

View File

@@ -0,0 +1,94 @@
From f12a643ff63c4d54bb5d50a0a9d62d518b5db470 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 1 Oct 2019 13:35:49 +0200
Subject: [PATCH 02/19] Add (partial, cam id is hardcoded) support for Asus ZF6
motor camera
Change-Id: Iea6e1370780a1d16f728748d1d948d092532d8fe
---
.../camera/libcameraservice/CameraService.cpp | 26 +++++++++++++++++++
.../camera/libcameraservice/CameraService.h | 3 +++
2 files changed, 29 insertions(+)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index d0d3a9d81b..6705186fdd 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -26,6 +26,7 @@
#include <ctime>
#include <string>
#include <sys/types.h>
+#include <sys/wait.h>
#include <inttypes.h>
#include <pthread.h>
@@ -142,6 +143,7 @@ const String8 CameraService::kOfflineDevice("offline-");
static std::set<String8> sServiceErrorEventSet;
CameraService::CameraService() :
+ mPhysicalFrontCamStatus(false),
mEventLog(DEFAULT_EVENT_LOG_LENGTH),
mNumberOfCameras(0),
mNumberOfCamerasWithoutSystemCamera(0),
@@ -1874,6 +1876,7 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
mServiceLock.lock();
} else {
// Otherwise, add client to active clients list
+ physicalFrontCam(cameraId == "1");
finishConnectLocked(client, partial, oomScoreOffset);
}
@@ -1963,6 +1966,27 @@ status_t CameraService::addOfflineClient(String8 cameraId, sp<BasicClient> offli
return OK;
}
+void CameraService::physicalFrontCam(bool on) {
+ if(on == mPhysicalFrontCamStatus) return;
+ mPhysicalFrontCamStatus = on;
+
+ if(access("/dev/asusMotoDrv", F_OK) == 0) {
+ int pid = fork();
+ if(pid == 0) {
+ const char* cmd[] = {
+ "/system/bin/asus-motor",
+ "0",
+ NULL
+ };
+ cmd[1] = on ? "0" : "1";
+ execve("/system/bin/asus-motor", (char**)cmd, environ);
+ _exit(1);
+ } else {
+ waitpid(pid, NULL, 0);
+ }
+ }
+}
+
Status CameraService::setTorchMode(const String16& cameraId, bool enabled,
const sp<IBinder>& clientBinder) {
Mutex::Autolock lock(mServiceLock);
@@ -3049,6 +3073,8 @@ binder::Status CameraService::BasicClient::disconnect() {
}
mDisconnected = true;
+ sCameraService->physicalFrontCam(false);
+
sCameraService->removeByClient(this);
sCameraService->logDisconnected(mCameraIdStr, mClientPid, String8(mClientPackageName));
sCameraService->mCameraProviderManager->removeRef(CameraProviderManager::DeviceMode::CAMERA,
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index bc2e3479bc..b58c41e115 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -211,6 +211,9 @@ public:
// Register an offline client for a given active camera id
status_t addOfflineClient(String8 cameraId, sp<BasicClient> offlineClient);
+ bool mPhysicalFrontCamStatus;
+ void physicalFrontCam(bool on);
+
/////////////////////////////////////////////////////////////////////
// Client functionality
--
2.29.2

View File

@@ -0,0 +1,55 @@
From ee73ef44e02af6f673e83a8810fe9ea88dc2c821 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 23 Jan 2020 11:13:43 +0800
Subject: [PATCH 03/19] audiopolicy: try again with trimmed audio port name if
not found
* In Spreadtrum BSP, some audio routes may contain ports with extra
spaces at the beginning and the end, causing audiopolicy to refuse to
load and leading to broken audio.
* Fix this by retrying with trimmed port name when not found. Do not
use trimmed name all the time because a white space is a valid
character in port name, and we cannot be sure nobody is using it for
legitimite purposes.
Change-Id: I993708b28e8404bc8c483d71a850ac69382231bd
---
.../common/managerdefinitions/src/Serializer.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 9a857ff091..d919951007 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -579,6 +579,17 @@ std::variant<status_t, DevicePortTraits::Element> PolicySerializer::deserialize<
return deviceDesc;
}
+char* trim(char * s) {
+ int l = strlen(s);
+
+ if (l > 0) {
+ while (isspace(s[l - 1])) --l;
+ while (*s && isspace(*s)) ++s, --l;
+ }
+
+ return strndup(s, l);
+}
+
template<>
std::variant<status_t, RouteTraits::Element> PolicySerializer::deserialize<RouteTraits>(
const xmlNode *cur, RouteTraits::PtrSerializingCtx ctx)
@@ -626,6 +637,9 @@ std::variant<status_t, RouteTraits::Element> PolicySerializer::deserialize<Route
while (devTag != NULL) {
if (strlen(devTag) != 0) {
sp<PolicyAudioPort> source = ctx->findPortByTagName(devTag);
+ if (source == NULL) {
+ source = ctx->findPortByTagName(trim(devTag));
+ }
if (source == NULL && !mIgnoreVendorExtensions) {
ALOGE("%s: no source found with name=%s", __func__, devTag);
return BAD_VALUE;
--
2.29.2

View File

@@ -0,0 +1,46 @@
From 8c442bfb93e93c8ea4e7a6de03ea7b5e42369f11 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 13 Apr 2020 21:01:16 +0200
Subject: [PATCH 04/19] There are three SCO devices. Fallback from one to the
others if needed
Change-Id: I414dcb6b154855c00cb8520b23dc1069827864b2
---
.../managerdefinitions/src/HwModule.cpp | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index 3a143b0058..565defc203 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -309,6 +309,27 @@ sp<HwModule> HwModuleCollection::getModuleForDeviceType(audio_devices_t type,
}
}
}
+ //We didn't find one? Ok but all SCOs are equivalent surely?
+ if(type == AUDIO_DEVICE_OUT_BLUETOOTH_SCO ||
+ type == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET ||
+ type == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
+ ALOGE("Fallback SCO");
+ if(type != AUDIO_DEVICE_OUT_BLUETOOTH_SCO) {
+ auto ret = getModuleForDeviceType(AUDIO_DEVICE_OUT_BLUETOOTH_SCO, encodedFormat);
+ ALOGE("Fallback SCO simple? %s", (ret != nullptr) ? "yes" : "no");
+ if(ret != nullptr) return ret;
+ }
+ if(type != AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
+ auto ret = getModuleForDeviceType(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET, encodedFormat);
+ ALOGE("Fallback SCO headset? %s", (ret != nullptr) ? "yes" : "no");
+ if(ret != nullptr) return ret;
+ }
+ if(type != AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
+ auto ret = getModuleForDeviceType(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, encodedFormat);
+ ALOGE("Fallback SCO carkit? %s", (ret != nullptr) ? "yes" : "no");
+ if(ret != nullptr) return ret;
+ }
+ }
return nullptr;
}
--
2.29.2

View File

@@ -0,0 +1,80 @@
From 7541559278b514f14a4f2f8a5f775996ee1e5e68 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 14 May 2020 19:54:55 +0200
Subject: [PATCH 05/19] Add persist.sys.phh.samsung.camera_ids property to
access hidden Samsung cameras
Change-Id: I2c7bf535272acc28ed2277e96c78ddd28a0b4593
---
services/camera/libcameraservice/Android.bp | 1 +
.../common/CameraProviderManager.cpp | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp
index 26562e0426..e940c33845 100644
--- a/services/camera/libcameraservice/Android.bp
+++ b/services/camera/libcameraservice/Android.bp
@@ -154,6 +154,7 @@ cc_library_shared {
"android.hardware.camera.device@3.5",
"android.hardware.camera.device@3.6",
"android.hardware.camera.device@3.7",
+ "vendor.samsung.hardware.camera.provider@3.0",
"media_permission-aidl-cpp",
],
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 4f2b878d26..d11ad8d766 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -21,6 +21,7 @@
#include "CameraProviderManager.h"
#include <android/hardware/camera/device/3.7/ICameraDevice.h>
+#include <vendor/samsung/hardware/camera/provider/3.0/ISehCameraProvider.h>
#include <algorithm>
#include <chrono>
@@ -1371,6 +1372,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
mMinorVersion = 6;
}
}
+
// We need to check again since cast2_6.isOk() succeeds even if the provider
// version isn't actually 2.6.
if (interface2_6 == nullptr){
@@ -1407,6 +1409,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
return mapToStatusT(status);
}
+ auto samsungCast = vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider::castFrom(interface);
+ auto samsungProvider = samsungCast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider>>(samsungCast) : nullptr;
+
hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
if (!linked.isOk()) {
ALOGE("%s: Transaction error in linking to camera provider '%s' death: %s",
@@ -1437,7 +1442,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
// Get initial list of camera devices, if any
std::vector<std::string> devices;
- hardware::Return<void> ret = interface->getCameraIdList([&status, this, &devices](
+ auto cb = [&status, this, &devices](
Status idStatus,
const hardware::hidl_vec<hardware::hidl_string>& cameraDeviceNames) {
status = idStatus;
@@ -1454,7 +1459,12 @@ status_t CameraProviderManager::ProviderInfo::initialize(
mProviderPublicCameraIds.push_back(id);
}
}
- } });
+ } };
+ hardware::Return<void> ret;
+ if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
+ ret = samsungProvider->sehGetCameraIdList(cb);
+ else
+ ret = interface->getCameraIdList(cb);
if (!ret.isOk()) {
ALOGE("%s: Transaction error in getting camera ID list from provider '%s': %s",
__FUNCTION__, mProviderName.c_str(), linked.description().c_str());
--
2.29.2

View File

@@ -0,0 +1,45 @@
From 274f3141e9dc93dde02a81a1889cd76b14860251 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 19 May 2020 14:01:14 +0200
Subject: [PATCH 06/19] Add a property to force camera timestamp source
Some devices wrongly report their timesource
Camera's timesource can either be CLOCK_MONOTONIC, or CLOCK_BOOTTIME
The former doesn't increment in sleep, while the later does.
There is a camera HAL property for that, though some devices don't
report it properly.
This issue happens on Xiaomi Redmi 7A, it needs to force the value to 1
Add a property persist.sys.phh.camera.force_timestampsource to force
timestamp source.
---
.../libcameraservice/device3/Camera3Device.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index fd645c7a72..4a6a922c43 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -346,8 +346,16 @@ status_t Camera3Device::initializeCommonLocked() {
// Measure the clock domain offset between camera and video/hw_composer
camera_metadata_entry timestampSource =
mDeviceInfo.find(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE);
- if (timestampSource.count > 0 && timestampSource.data.u8[0] ==
- ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME) {
+ int timestampSourceValue = 0;
+ if ((timestampSource.count > 0 && timestampSource.data.u8[0] ==
+ ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME)) {
+ timestampSourceValue = 1;
+ }
+ int forceTimestampSource = property_get_int32("persist.sys.phh.camera.force_timestampsource", -1);
+ //Don't override if it's -1, default value
+ if(forceTimestampSource == 0) timestampSourceValue = 0;
+ if(forceTimestampSource == 1) timestampSourceValue = 1;
+ if (timestampSourceValue == 1) {
mTimestampOffset = getMonoToBoottimeOffset();
}
--
2.29.2

View File

@@ -0,0 +1,87 @@
From 6d40f84ff32e4c1f50f794890790d6159132ba4e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 24 Apr 2018 00:14:28 +0200
Subject: [PATCH 07/19] FIH devices: Fix "Earpiece" audio output
On some FIH devices (confirmed on Razer, and probably on Aquos SS2),
Earpiece is not listed in attachedDevices, and devicePort's profile
mentions it is AUDIO_CHANNEL_IN_MONO, instead of AUDIO_CHANNEL_OUT_MONO.
Detect such cases (output device, but got only AUDIO_CHANNEL_IN_MONO),
and fix both channelMasks and attachedDevices
Change-Id: I4a88ba6d34d0fcd346eeea2ca903772f0271040a
---
.../managerdefinitions/src/Serializer.cpp | 27 ++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index d919951007..abc54ccc24 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -416,23 +416,32 @@ std::variant<status_t, AudioGainTraits::Element> PolicySerializer::deserialize<A
}
}
+static bool fixedEarpieceChannels = false;
template<>
std::variant<status_t, AudioProfileTraits::Element>
PolicySerializer::deserialize<AudioProfileTraits>(
- const xmlNode *cur, AudioProfileTraits::PtrSerializingCtx /*serializingContext*/)
+ const xmlNode *cur, AudioProfileTraits::PtrSerializingCtx serializingContext)
{
using Attributes = AudioProfileTraits::Attributes;
+ bool isOutput = serializingContext != nullptr;
std::string samplingRates = getXmlAttribute(cur, Attributes::samplingRates);
std::string format = getXmlAttribute(cur, Attributes::format);
std::string channels = getXmlAttribute(cur, Attributes::channelMasks);
+ ChannelTraits::Collection channelsMask = channelMasksFromString(channels, ",");
+
+ //Some Foxconn devices have wrong earpiece channel mask, leading to no channel mask
+ if(channelsMask.size() == 1 && *channelsMask.begin() == AUDIO_CHANNEL_IN_MONO && isOutput) {
+ fixedEarpieceChannels = true;
+ channelsMask = channelMasksFromString("AUDIO_CHANNEL_OUT_MONO", ",");
+ }
if (mIgnoreVendorExtensions && maybeVendorExtension(format)) {
ALOGI("%s: vendor extension format \"%s\" skipped", __func__, format.c_str());
return NO_INIT;
}
AudioProfileTraits::Element profile = new AudioProfile(formatFromString(format, gDynamicFormat),
- channelMasksFromString(channels, mChannelMasksSeparator.c_str()),
+ channelsMask,
samplingRatesFromString(samplingRates, mSamplingRatesSeparator.c_str()));
profile->setDynamicFormat(profile->getFormat() == gDynamicFormat);
@@ -557,7 +566,11 @@ std::variant<status_t, DevicePortTraits::Element> PolicySerializer::deserialize<
new DeviceDescriptor(type, name, address, encodedFormats);
AudioProfileTraits::Collection profiles;
- status_t status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
+ status_t status;
+ if(audio_is_output_devices(type))
+ status = deserializeCollection<AudioProfileTraits>(cur, &profiles, (AudioProfileTraits::PtrSerializingCtx)1);
+ else
+ status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
if (status != NO_ERROR) {
return status;
}
@@ -848,6 +861,14 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
}
}
}
+
+ if(fixedEarpieceChannels) {
+ sp<DeviceDescriptor> device =
+ module->getDeclaredDevices().getDeviceFromTagName("Earpiece");
+ if(device != 0)
+ ctx->addDevice(device);
+ fixedEarpieceChannels = false;
+ }
return module;
}
--
2.29.2

View File

@@ -0,0 +1,32 @@
From ed83392795ee1511619cb8d81160e6feecdcb7f9 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 12 Sep 2020 12:32:50 +0200
Subject: [PATCH 08/19] [audiopolicy] No longer make re-assigning legacy audio
groups fatal. Mi9 declares AUDIO_STREAM_PATCH and AUDIO_STREAM_REROUTING
which is defined by framework too
Change-Id: I794fe22d63a8af705be4f5f09b9879ecaab3eae5
---
services/audiopolicy/engine/common/src/EngineBase.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/services/audiopolicy/engine/common/src/EngineBase.cpp b/services/audiopolicy/engine/common/src/EngineBase.cpp
index 150a9a8e4f..740eab288c 100644
--- a/services/audiopolicy/engine/common/src/EngineBase.cpp
+++ b/services/audiopolicy/engine/common/src/EngineBase.cpp
@@ -216,9 +216,9 @@ engineConfig::ParsingResult EngineBase::loadAudioPolicyEngineConfig()
}
if (group.stream != AUDIO_STREAM_DEFAULT) {
// A legacy stream can be assigned once to a volume group
- LOG_ALWAYS_FATAL_IF(checkStreamForGroups(group.stream, mVolumeGroups),
- "stream %s already assigned to a volume group, "
- "review the configuration", toString(group.stream).c_str());
+ if(checkStreamForGroups(group.stream, mVolumeGroups)) {
+ ALOGE("stream %s already assigned to a volume group, review the configuration", toString(group.stream).c_str());
+ }
volumeGroup->addSupportedStream(group.stream);
}
addSupportedAttributesToGroup(group, volumeGroup, strategy);
--
2.29.2

View File

@@ -0,0 +1,326 @@
From 55f69fe9965419355d26e7b5a2bb9975eef0f23c 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 09/19] Add persist.sys.phh.disable_a2dp_offload property to
force a2dp offload
Change-Id: Id474540c33c594cc4010a1a398d82bff8aadaeea
---
media/libstagefright/ACodec.cpp | 20 +-
.../managerdefinitions/src/Serializer.cpp | 182 +++++++++++++++++-
.../audiopolicy/enginedefault/src/Engine.cpp | 2 +-
3 files changed, 197 insertions(+), 7 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 1aa18485f9..f9365cacc9 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1183,6 +1183,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
@@ -1195,22 +1198,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 abc54ccc24..c6db471c8c 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;
+
using utilities::convertTo;
static inline bool maybeVendorExtension(const std::string& s) {
@@ -335,7 +338,7 @@ status_t PolicySerializer::deserializeCollection(const xmlNode *cur,
} else if (mIgnoreVendorExtensions && std::get<status_t>(maybeElement) == NO_INIT) {
// Skip a vendor extension element.
} else {
- return BAD_VALUE;
+ ALOGE("Ignoring...");
}
}
}
@@ -795,11 +798,33 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
ModuleTraits::Element module = new HwModule(name.c_str(), versionMajor, versionMinor);
// Deserialize children: Audio Mix Port, Audio Device Ports (Source/Sink), Audio Routes
+ bool isA2dpModule = strcmp(name.c_str(), "a2dp") == 0;
+ bool isPrimaryModule = strcmp(name.c_str(), "primary") == 0;
+
MixPortTraits::Collection mixPorts;
status_t status = deserializeCollection<MixPortTraits>(cur, &mixPorts, NULL);
if (status != NO_ERROR) {
return 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;
@@ -807,6 +832,90 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
if (status != NO_ERROR) {
return 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;
@@ -814,7 +923,76 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
if (status != NO_ERROR) {
return 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;
@@ -1019,6 +1197,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);
status_t status = serializer.deserialize(fileName, config);
if (status != OK) config->clear();
return status;
@@ -1027,6 +1206,7 @@ status_t deserializeAudioPolicyFile(const char *fileName, AudioPolicyConfig *con
status_t deserializeAudioPolicyFileForVts(const char *fileName, AudioPolicyConfig *config)
{
PolicySerializer serializer;
+ forceDisableA2dpOffload = property_get_bool("persist.sys.phh.disable_a2dp_offload", false);
status_t status = serializer.deserialize(fileName, config, true /*ignoreVendorExtensions*/);
if (status != OK) config->clear();
return status;
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index c73c17d1e4..314de7889b 100644
--- 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.29.2

View File

@@ -0,0 +1,30 @@
From c461aa6104426d270e1297a1e2d6213fb4c34297 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 10/19] 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 d11ad8d766..ab5ddd12d0 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.29.2

View File

@@ -0,0 +1,37 @@
From 91e653004e622132574610017e855056358d8f6c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 6 Mar 2021 19:15:24 -0500
Subject: [PATCH 11/19] Fix AAC decoder failing to instantiate
This has been caused by I50fcc5ef35cb7e96592c2267652228b5fa074ba9
Non-Android 11 vendors won't provide those calls, and will thus fail.
---
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 f9365cacc9..52ca1955e8 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -5405,9 +5405,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
err = mOMXNode->getParameter(
(OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacDrcPresentation,
&presentation, sizeof(presentation));
- if (err != OK) {
- return err;
- }
+ if (err == OK) {
notify->setInt32("aac-encoded-target-level",
presentation.nEncodedTargetLevel);
notify->setInt32("aac-drc-cut-level", presentation.nDrcCut);
@@ -5420,6 +5418,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
notify->setInt32("aac-drc-album-mode", presentation.nDrcAlbumMode);
notify->setInt32("aac-drc-output-loudness",
presentation.nDrcOutputLoudness);
+ }
}
}
break;
--
2.29.2

View File

@@ -0,0 +1,67 @@
From 80e55073914af5719060ef1c6b1f3bddfb6b7b5f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 13 Mar 2021 14:20:03 -0500
Subject: [PATCH 12/19] Support Samsung R multi-cams
Change-Id: If46f385e8dd16185cbf37ab083e6a1242e1d1555
---
services/camera/libcameraservice/Android.bp | 1 +
.../libcameraservice/common/CameraProviderManager.cpp | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp
index e940c33845..a2a2ad623e 100644
--- a/services/camera/libcameraservice/Android.bp
+++ b/services/camera/libcameraservice/Android.bp
@@ -155,6 +155,7 @@ cc_library_shared {
"android.hardware.camera.device@3.6",
"android.hardware.camera.device@3.7",
"vendor.samsung.hardware.camera.provider@3.0",
+ "vendor.samsung.hardware.camera.provider@4.0",
"media_permission-aidl-cpp",
],
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index ab5ddd12d0..c08bcb9ce2 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/camera/device/3.7/ICameraDevice.h>
#include <vendor/samsung/hardware/camera/provider/3.0/ISehCameraProvider.h>
+#include <vendor/samsung/hardware/camera/provider/4.0/ISehCameraProvider.h>
#include <algorithm>
#include <chrono>
@@ -1412,7 +1413,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
}
auto samsungCast = vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider::castFrom(interface);
+ auto samsung40Cast = vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider::castFrom(interface);
auto samsungProvider = samsungCast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider>>(samsungCast) : nullptr;
+ auto samsung40Provider = samsung40Cast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider>>(samsung40Cast) : nullptr;
hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
if (!linked.isOk()) {
@@ -1450,6 +1453,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
status = idStatus;
if (status == Status::OK) {
for (auto& name : cameraDeviceNames) {
+ ALOGE("Listing camera ID %s", name.c_str());
uint16_t major, minor;
std::string type, id;
status_t res = parseDeviceName(name, &major, &minor, &type, &id);
@@ -1463,7 +1467,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
}
} };
hardware::Return<void> ret;
- if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
+ if(samsung40Provider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
+ ret = samsung40Provider->sehGetCameraIdList(cb);
+ else if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
ret = samsungProvider->sehGetCameraIdList(cb);
else
ret = interface->getCameraIdList(cb);
--
2.29.2

View File

@@ -0,0 +1,26 @@
From 0b33dc520b09f9ad74005280920f561356333f99 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 13/19] [audiopolicy] Don't crash on unknown audio devices
Change-Id: I2df8d88f742da6a84aa8888cdf19de25444de919
---
.../audiopolicy/common/managerdefinitions/src/Serializer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index c6db471c8c..a76da4569b 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -1011,7 +1011,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
sp<DeviceDescriptor> device = module->getDeclaredDevices().
getDeviceFromTagName(std::string(reinterpret_cast<const char*>(
attachedDevice.get())));
- if (device == nullptr && mIgnoreVendorExtensions) {
+ if (device == nullptr) {
ALOGW("Skipped attached device \"%s\" because it likely uses a vendor"
"extension type",
reinterpret_cast<const char*>(attachedDevice.get()));
--
2.29.2

View File

@@ -0,0 +1,26 @@
From f9a6347168b123aa485e642fa0c63eaef0be0d30 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 14/19] 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 314de7889b..c73c17d1e4 100644
--- 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.29.2

View File

@@ -0,0 +1,37 @@
From 3fe99a1ab087bfc46cd4c1f190239fe422435a7f 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 15/19] 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)
Change-Id: I461a3f22893ab2b1d96d67f22397369b2cae41e5
---
services/audiopolicy/engine/config/src/EngineConfig.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/services/audiopolicy/engine/config/src/EngineConfig.cpp b/services/audiopolicy/engine/config/src/EngineConfig.cpp
index 81e803fa7f..340eb1b358 100644
--- a/services/audiopolicy/engine/config/src/EngineConfig.cpp
+++ b/services/audiopolicy/engine/config/src/EngineConfig.cpp
@@ -714,7 +714,12 @@ android::status_t parseLegacyVolumeFile(const char* path, VolumeGroups &volumeGr
android::status_t parseLegacyVolumes(VolumeGroups &volumeGroups) {
if (std::string audioPolicyXmlConfigFile = audio_get_audio_policy_config_file();
!audioPolicyXmlConfigFile.empty()) {
- return parseLegacyVolumeFile(audioPolicyXmlConfigFile.c_str(), volumeGroups);
+ int ret = parseLegacyVolumeFile(audioPolicyXmlConfigFile.c_str(), volumeGroups);
+ if (ret == NO_ERROR && volumeGroups.size() == 0) {
+ 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());
+ }
+ return ret;
} else {
ALOGE("No readable audio policy config file found");
return BAD_VALUE;
--
2.29.2

View File

@@ -0,0 +1,27 @@
From ed52289663535821829ebdd1241471d72e0f9d2f 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 16/19] Not all sources in a route are valid. Dont ignore the
whole route because of one broken source
Change-Id: If8a51740e71bef3a4738262ad7b43a337b0ec36d
---
.../audiopolicy/common/managerdefinitions/src/Serializer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index a76da4569b..2ff11ddbab 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -656,7 +656,7 @@ std::variant<status_t, RouteTraits::Element> PolicySerializer::deserialize<Route
if (source == NULL) {
source = ctx->findPortByTagName(trim(devTag));
}
- if (source == NULL && !mIgnoreVendorExtensions) {
+ if (source == NULL) {
ALOGE("%s: no source found with name=%s", __func__, devTag);
return BAD_VALUE;
} else if (source == NULL) {
--
2.29.2

View File

@@ -0,0 +1,35 @@
From 3db998a6d6224eda055820b23ff7db1e3b49b555 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 7 Aug 2021 11:11:39 +0200
Subject: [PATCH 17/19] When aux cameras are enabled, ignore "system only"
camera flag (it shouldnt be q security issue since secure cameras are listed
otherwise)
---
.../libcameraservice/common/CameraProviderManager.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index c08bcb9ce2..5a68fe8cc9 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -579,10 +579,12 @@ SystemCameraKind CameraProviderManager::ProviderInfo::DeviceInfo3::getSystemCame
// Go through the capabilities and check if it has
// ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA
- for (size_t i = 0; i < entryCap.count; ++i) {
- uint8_t capability = entryCap.data.u8[i];
- if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA) {
- return SystemCameraKind::SYSTEM_ONLY_CAMERA;
+ if(!property_get_bool("persist.sys.phh.include_all_cameras", false)) {
+ for (size_t i = 0; i < entryCap.count; ++i) {
+ uint8_t capability = entryCap.data.u8[i];
+ if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA) {
+ return SystemCameraKind::SYSTEM_ONLY_CAMERA;
+ }
}
}
return SystemCameraKind::PUBLIC;
--
2.29.2

View File

@@ -0,0 +1,106 @@
From 29a38afa10725fefa574fa46e63d6f0e93b62952 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Tue, 19 Oct 2021 21:16:55 -0400
Subject: [PATCH 18/19] APM: Restore R and Q behavior respectively for
telephony audio
This conditionally reverts part of 51c9cc (S) and afd4ce (R) when the
VNDK version is equal to or before R and Q respectively.
On R, commit afd4ce made it so that both HW and SW bridging go through
`createAudioPatch()`, which is broken on some devices such as on MTK Q
vendor, because their HAL do not support HW patching via the newer
`createAudioPatch()` method. Instead, the patching on Q was done through
`setOutputDevices()`.
On S, commit 51c9cc refactored the related code again such that HW
bridging for the Rx direction is essentially removed, replaced with SW
bridging through `startAudioSource()`. This is, again, broken on MTK R
vendor devices.
Both of these commits rely on assumptions that are not tested through
VTS and just presumed to be true. Although we can blame MTK for not
supporting all the possible cases in their HAL, it will not fix
anything, and really frameworks code should not depend on such untested
assumptions.
To work around said issues, we restore old behavior from R and Q relying
on the value of `ro.vndk.version`.
Change-Id: I56d36d2aef4319935cb88a3e4771b23c6d5b2145
---
.../managerdefault/AudioPolicyManager.cpp | 31 ++++++++++++++++---
.../managerdefault/AudioPolicyManager.h | 1 +
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index cc2d8e8cf4..8defaad32c 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -601,6 +601,11 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
rxDevices.itemAt(0)->toString().c_str(), txSourceDevice->toString().c_str());
disconnectTelephonyRxAudioSource();
+ // release existing RX patch if any
+ if (mCallRxPatch != 0) {
+ releaseAudioPatchInternal(mCallRxPatch->getHandle());
+ mCallRxPatch.clear();
+ }
// release TX patch if any
if (mCallTxPatch != 0) {
releaseAudioPatchInternal(mCallTxPatch->getHandle());
@@ -629,9 +634,20 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
ALOGE("%s() no telephony Tx and/or RX device", __func__);
return INVALID_OPERATION;
}
- // createAudioPatchInternal now supports both HW / SW bridging
- createRxPatch = true;
- createTxPatch = true;
+ if (property_get_int32("ro.vndk.version", 31) >= 30) {
+ // createAudioPatchInternal now supports both HW / SW bridging
+ createRxPatch = true;
+ createTxPatch = true;
+ } else {
+ // pre-R behavior: some devices before VNDK 30 do not support createAudioPatch correctly
+ // for HW bridging even though they declare support for it
+ // do not create a patch (aka Sw Bridging) if Primary HW module has declared supporting a
+ // route between telephony RX to Sink device and Source device to telephony TX
+ ALOGI("%s() Using pre-R behavior for createRxPatch and createTxPatch", __func__);
+ const auto &primaryModule = telephonyRxModule;
+ createRxPatch = !primaryModule->supportsPatch(rxSourceDevice, rxDevices.itemAt(0));
+ createTxPatch = !primaryModule->supportsPatch(txSourceDevice, txSinkDevice);
+ }
} else {
// If the RX device is on the primary HW module, then use legacy routing method for
// voice calls via setOutputDevice() on primary output.
@@ -648,7 +664,14 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
if (!createRxPatch) {
muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
} else { // create RX path audio patch
- connectTelephonyRxAudioSource();
+ if (property_get_int32("ro.vndk.version", 31) >= 31) {
+ connectTelephonyRxAudioSource();
+ } else {
+ // pre-S behavior: some devices do not support SW bridging correctly when HW bridge is
+ // available through createAudioPatch(); startAudioSource() forces SW bridging.
+ ALOGI("%s() Using pre-S behavior to create HW Rx patch", __func__);
+ mCallRxPatch = createTelephonyPatch(true /*isRx*/, rxDevices.itemAt(0), delayMs);
+ }
// 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
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 98f96d1951..e8b19091d5 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -827,6 +827,7 @@ protected:
SoundTriggerSessionCollection mSoundTriggerSessions;
sp<AudioPatch> mCallTxPatch;
+ sp<AudioPatch> mCallRxPatch;
HwAudioOutputCollection mHwOutputs;
SourceClientCollection mAudioSources;
--
2.29.2

View File

@@ -0,0 +1,73 @@
From 9f4bc135f5863b4da0a3092db56dee499be6c2a7 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 11 Oct 2021 16:10:42 -0400
Subject: [PATCH 19/19] Revert "Remove support for audio HAL V2 from the
framework"
This reverts commit cbf517f837f7bf8a59f3ff8aa1e0e3e19612e251.
Also enable new extensions required to actually build
Change-Id: Icfd638a91b22ffa6d2cd6d19a624e699a85a850a
---
media/libaudiohal/Android.bp | 1 +
media/libaudiohal/FactoryHalHidl.cpp | 1 +
media/libaudiohal/impl/Android.bp | 18 ++++++++++++++++++
3 files changed, 20 insertions(+)
diff --git a/media/libaudiohal/Android.bp b/media/libaudiohal/Android.bp
index bd24c84dbc..f7a9ecc2b7 100644
--- a/media/libaudiohal/Android.bp
+++ b/media/libaudiohal/Android.bp
@@ -23,6 +23,7 @@ cc_library_shared {
],
required: [
+ "libaudiohal@2.0",
"libaudiohal@4.0",
"libaudiohal@5.0",
"libaudiohal@6.0",
diff --git a/media/libaudiohal/FactoryHalHidl.cpp b/media/libaudiohal/FactoryHalHidl.cpp
index e420d079b8..7228b221b9 100644
--- a/media/libaudiohal/FactoryHalHidl.cpp
+++ b/media/libaudiohal/FactoryHalHidl.cpp
@@ -35,6 +35,7 @@ const char* sAudioHALVersions[] = {
"6.0",
"5.0",
"4.0",
+ "2.0",
nullptr
};
diff --git a/media/libaudiohal/impl/Android.bp b/media/libaudiohal/impl/Android.bp
index a2c6e8aeba..4e360be7e8 100644
--- a/media/libaudiohal/impl/Android.bp
+++ b/media/libaudiohal/impl/Android.bp
@@ -62,6 +62,24 @@ cc_defaults {
],
}
+cc_library_shared {
+ name: "libaudiohal@2.0",
+ defaults: ["libaudiohal_default"],
+ shared_libs: [
+ "android.hardware.audio.common@2.0",
+ "android.hardware.audio.common@2.0-util",
+ "android.hardware.audio.effect@2.0",
+ "android.hardware.audio.effect@2.0-util",
+ "android.hardware.audio@2.0",
+ "android.hardware.audio@2.0-util",
+ ],
+ cflags: [
+ "-DMAJOR_VERSION=2",
+ "-DMINOR_VERSION=0",
+ "-include common/all-versions/VersionMacro.h",
+ ]
+}
+
cc_library_shared {
name: "libaudiohal@4.0",
defaults: ["libaudiohal_default"],
--
2.29.2

View File

@@ -0,0 +1,36 @@
From cca2f852f59bc76fb4228c44a5c58a39cb0f3bba Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 5 Oct 2021 17:59:16 -0400
Subject: [PATCH 01/24] Fallback to stupid autobrightness if brightness values
are broken
This is needed because of:
`ava.lang.IllegalArgumentException: The control points must all have strictly increasing X values.`
on some Samsung devices
Change-Id: Ieb679b34239013a5e31b34cb010b12febd9ef6d9
---
.../com/android/server/display/DisplayDeviceConfig.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
index 4c9d0f2691b3..4ad21835c1ad 100644
--- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java
+++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
@@ -172,7 +172,12 @@ public class DisplayDeviceConfig {
public static DisplayDeviceConfig create(Context context, boolean useConfigXml) {
DisplayDeviceConfig config;
if (useConfigXml) {
- config = getConfigFromGlobalXml(context);
+ try {
+ config = getConfigFromGlobalXml(context);
+ } catch(Exception e) {
+ android.util.Log.e("PHH", "Failed parsing automatic brightness values, fallbacking", e);
+ config = getConfigFromPmValues(context);
+ }
} else {
config = getConfigFromPmValues(context);
}
--
2.25.1

View File

@@ -0,0 +1,31 @@
From c11becc169cecb489e6bc3e75f7eb42af349aa3b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 28 Nov 2017 18:28:04 +0100
Subject: [PATCH 02/24] Relax requirement for visible flag to sdcards
The vast majority of sdcard readers are stable enough to be declared by
the API. (I see no counter-example)
FBE broke adoptable storage with SDCard, hence this need.
Change-Id: Ia616671c03562d1eadaff5531a5c708a62d7ad3a
---
.../core/java/com/android/server/StorageManagerService.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 69c29269b7a9..72d37655c1e5 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1579,7 +1579,8 @@ class StorageManagerService extends IStorageManager.Stub
// Adoptable public disks are visible to apps, since they meet
// public API requirement of being in a stable location.
- if (vol.disk.isAdoptable()) {
+ // Assume all SDs match this as well
+ if (vol.disk.isAdoptable() || vol.disk.isSd()) {
vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
}
--
2.25.1

View File

@@ -0,0 +1,45 @@
From 1660aee7805afa51f230552fb8724f86f27c1129 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 03/24] Don't crash if there is IR HAL is not declared
Change-Id: I3afded27441bbee8244d5fda544b3e6d1238dc1b
---
.../core/java/com/android/server/ConsumerIrService.java | 7 -------
services/core/jni/com_android_server_ConsumerIrService.cpp | 2 +-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
index 2ed6c77baa0d..82ec033bc30b 100644
--- a/services/core/java/com/android/server/ConsumerIrService.java
+++ b/services/core/java/com/android/server/ConsumerIrService.java
@@ -46,13 +46,6 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
mWakeLock.setReferenceCounted(true);
mHasNativeHal = halOpen();
- if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR)) {
- 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!");
- }
}
@Override
diff --git a/services/core/jni/com_android_server_ConsumerIrService.cpp b/services/core/jni/com_android_server_ConsumerIrService.cpp
index 2ca348b3ae46..148fba9a688c 100644
--- a/services/core/jni/com_android_server_ConsumerIrService.cpp
+++ b/services/core/jni/com_android_server_ConsumerIrService.cpp
@@ -36,7 +36,7 @@ static sp<IConsumerIr> mHal;
static jboolean halOpen(JNIEnv* /* env */, jobject /* obj */) {
// TODO(b/31632518)
- mHal = IConsumerIr::getService();
+ mHal = IConsumerIr::tryGetService();
return mHal != nullptr;
}
--
2.25.1

View File

@@ -0,0 +1,25 @@
From 4796112133b072b8e4a2d05ace920c6a38a065d7 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 6 Aug 2018 12:49:00 +0200
Subject: [PATCH 04/24] Show APN Settings for CDMA carriers
---
telephony/java/android/telephony/CarrierConfigManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 72ad23b8edb1..1b35fe483eb4 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -5154,7 +5154,7 @@ public class CarrierConfigManager {
sDefaults.putBoolean(KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL, false);
sDefaults.putBoolean(KEY_OPERATOR_SELECTION_EXPAND_BOOL, true);
sDefaults.putBoolean(KEY_PREFER_2G_BOOL, true);
- sDefaults.putBoolean(KEY_SHOW_APN_SETTING_CDMA_BOOL, false);
+ sDefaults.putBoolean(KEY_SHOW_APN_SETTING_CDMA_BOOL, true);
sDefaults.putBoolean(KEY_SHOW_CDMA_CHOICES_BOOL, false);
sDefaults.putBoolean(KEY_SMS_REQUIRES_DESTINATION_NUMBER_CONVERSION_BOOL, false);
sDefaults.putBoolean(KEY_SUPPORT_EMERGENCY_SMS_OVER_IMS_BOOL, false);
--
2.25.1

View File

@@ -0,0 +1,39 @@
From 1afba32ac67360be35b6e7fe054932532efbbf20 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 8 Nov 2018 23:04:03 +0100
Subject: [PATCH 05/24] Re-order services so that it works even without qtaguid
Change-Id: I0c0f527b3ae151d45c68f7ac6c205da3f34e74df
---
.../android/server/net/NetworkPolicyManagerService.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 84be7f5809e6..58f7f7dacc6d 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -845,6 +845,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "systemReady");
final int oldPriority = Process.getThreadPriority(Process.myTid());
try {
+ mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
+ mAppStandby = LocalServices.getService(AppStandbyInternal.class);
+ mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
+
// Boost thread's priority during system server init
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
if (!isBandwidthControlEnabled()) {
@@ -852,10 +856,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
return;
}
- mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
- mAppStandby = LocalServices.getService(AppStandbyInternal.class);
- mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
-
synchronized (mUidRulesFirstLock) {
synchronized (mNetworkPoliciesSecondLock) {
updatePowerSaveWhitelistUL();
--
2.25.1

View File

@@ -0,0 +1,105 @@
From 7bb10322e9b9c0f89ff1f05412c5a1816380c1d6 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 06/24] Support samsung Pie and Q light hal
Change-Id: I01f94acd7d0672733e48854d80368f9ac6f861c6
---
services/core/jni/Android.bp | 2 +
...om_android_server_lights_LightsService.cpp | 51 +++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index 81532bcba0ae..8ddc16aae3d7 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -184,6 +184,8 @@ cc_defaults {
"android.system.suspend@1.0",
"service.incremental",
"vendor.lineage.power-V1-cpp",
+ "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 26f6d7428fcc..268b59a58010 100644
--- a/services/core/jni/com_android_server_lights_LightsService.cpp
+++ b/services/core/jni/com_android_server_lights_LightsService.cpp
@@ -22,6 +22,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>
@@ -39,8 +43,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;
@@ -141,6 +154,44 @@ static void setLight_native(
return;
}
+ 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);
--
2.25.1

View File

@@ -0,0 +1,67 @@
From 7a73ac08b22ed3458e78dd03c2ca373f396d5396 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 07/24] Add support for samsung touch, physical and hover
proximity sensor as fallback to real proximity sensor
Change-Id: I7a0f8b4665c802140d19197d850b77b2a7ac1865
---
.../display/DisplayPowerController.java | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index abbe13ac260f..7ee297c60539 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -1671,6 +1671,27 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
? Sensor.TYPE_PROXIMITY : SensorUtils.NO_FALLBACK;
mProximitySensor = SensorUtils.findSensor(mSensorManager, proxSensor.type, proxSensor.name,
fallbackType);
+ if(mProximitySensor == null) {
+ java.util.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) {
+ java.util.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) {
+ java.util.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);
@@ -2415,6 +2436,20 @@ 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;
+ }
+ 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

View File

@@ -0,0 +1,32 @@
From f293d063501c95f9d1bfdcac894544a16ecf56b9 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 5 Apr 2020 16:32:46 +0200
Subject: [PATCH 08/24] Always allow overriding the number of work profiles
Change-Id: I6eb09aa71663c6fbe7563e3038bffcabdba0ff6a
---
.../java/com/android/server/pm/UserManagerService.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index eff1e3b5377f..66296912ba98 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -5820,12 +5820,8 @@ public class UserManagerService extends IUserManager.Stub {
*/
private static int getMaxUsersOfTypePerParent(UserTypeDetails userTypeDetails) {
final int defaultMax = userTypeDetails.getMaxAllowedPerParent();
- if (!Build.IS_DEBUGGABLE) {
- return defaultMax;
- } else {
- if (userTypeDetails.isManagedProfile()) {
- return SystemProperties.getInt("persist.sys.max_profiles", defaultMax);
- }
+ if (userTypeDetails.isManagedProfile()) {
+ return SystemProperties.getInt("persist.sys.max_profiles", defaultMax);
}
return defaultMax;
}
--
2.25.1

View File

@@ -0,0 +1,26 @@
From e83aa5ea72c3063a337e471db7c39485e23a33a0 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 6 Jun 2020 18:21:56 +0200
Subject: [PATCH 09/24] HOME deserves to wake-up devices just as well as back
and menu
Change-Id: Ia562bafd8c620d00c17e8eb338e4701c6c4a3c3a
---
core/java/android/view/KeyEvent.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index cda9b233576c..bb35e3172165 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -1988,6 +1988,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
switch (keyCode) {
case KeyEvent.KEYCODE_CAMERA:
case KeyEvent.KEYCODE_MENU:
+ case KeyEvent.KEYCODE_HOME:
case KeyEvent.KEYCODE_PAIRING:
case KeyEvent.KEYCODE_STEM_1:
case KeyEvent.KEYCODE_STEM_2:
--
2.25.1

View File

@@ -0,0 +1,28 @@
From 7edc52f626f669f0330fc411ceb360a5cd2ed21b 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 10/24] 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 7ee297c60539..759720ba4f71 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -1695,6 +1695,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;
+ }
}
}
--
2.25.1

View File

@@ -0,0 +1,37 @@
From 1b0ebec45a3cbc0e0a7edb9d3e63c85901c7efbf Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 29 Sep 2020 22:40:10 +0200
Subject: [PATCH 11/24] Fix brightness range not being complete on Samsung
devices
On some devices, minimum brightness is 0, which totally messes with
Brightness computations (minimum float brightness becomes -1.0 instead
of 0.0...).
Cheat and have them report 1 as minimum instead, which fixes the slope
Change-Id: I4d97cbc32490949e83272b81ec6320a5483310b1
---
.../java/com/android/server/power/PowerManagerService.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 6f7a7cf152b8..58b665add2cf 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -989,9 +989,11 @@ public final class PowerManagerService extends SystemService
if (min == INVALID_BRIGHTNESS_IN_CONFIG || max == INVALID_BRIGHTNESS_IN_CONFIG
|| def == INVALID_BRIGHTNESS_IN_CONFIG) {
+ int correctedMin = mContext.getResources().getInteger(com.android.internal.R.integer
+ .config_screenBrightnessSettingMinimum);
+ if(correctedMin == 0) correctedMin = 1;
mScreenBrightnessMinimum = BrightnessSynchronizer.brightnessIntToFloat(
- mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessSettingMinimum));
+ correctedMin);
mScreenBrightnessMaximum = BrightnessSynchronizer.brightnessIntToFloat(
mContext.getResources().getInteger(com.android.internal.R.integer
.config_screenBrightnessSettingMaximum));
--
2.25.1

View File

@@ -0,0 +1,37 @@
From 6a5b471745545ff85f87d1eb37d7b6310869f403 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 12/24] 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 4ff26242dab2..9379a634afa8 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2489,8 +2489,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.25.1

View File

@@ -0,0 +1,89 @@
From bd31f40a9c03f568e6dfa1defbe1fb73d8a57a9a 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 13/24] Make rounded corners padding overridable with
persist.sys.phh.rounded_corners_padding
Change-Id: I481c1c8849b2f22a7cdfb2896a6d3c2e7e3b44d9
---
.../src/com/android/systemui/qs/QuickStatusBarHeader.java | 7 +++++--
.../systemui/statusbar/phone/KeyguardStatusBarView.java | 7 +++++--
.../statusbar/phone/StatusBarContentInsetsProvider.kt | 5 ++++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
index 77906abce625..8cbfefcb4fea 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
@@ -22,6 +22,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.DisplayCutout;
@@ -219,8 +220,10 @@ public class QuickStatusBarHeader extends FrameLayout {
mConfigShowBatteryEstimate = resources.getBoolean(R.bool.config_showBatteryEstimateQSBH);
- mRoundedCornerPadding = resources.getDimensionPixelSize(
- R.dimen.rounded_corner_content_padding);
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if(mRoundedCornerPadding == -1)
+ mRoundedCornerPadding = resources.getDimensionPixelSize(
+ R.dimen.rounded_corner_content_padding);
int qsOffsetHeight = resources.getDimensionPixelSize(
com.android.internal.R.dimen.quick_qs_offset_height);
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 e272d2713e2a..ed0abcce5b06 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -30,6 +30,7 @@ import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.UserManager;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
@@ -200,8 +201,10 @@ public class KeyguardStatusBarView extends RelativeLayout implements
R.dimen.display_cutout_margin_consumption);
mShowPercentAvailable = getContext().getResources().getBoolean(
com.android.internal.R.bool.config_battery_percentage_setting_available);
- mRoundedCornerPadding = res.getDimensionPixelSize(
- R.dimen.rounded_corner_content_padding);
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if(mRoundedCornerPadding == -1)
+ mRoundedCornerPadding = res.getDimensionPixelSize(
+ R.dimen.rounded_corner_content_padding);
}
// Set hidden status bar items
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
index fe1f63a34acd..3ee8c688376d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
@@ -25,6 +25,7 @@ import android.view.DisplayCutout
import android.view.View.LAYOUT_DIRECTION_RTL
import android.view.WindowManager
import android.view.WindowMetrics
+import android.os.SystemProperties
import androidx.annotation.VisibleForTesting
import com.android.systemui.Dumpable
import com.android.systemui.R
@@ -157,7 +158,9 @@ class StatusBarContentInsetsProvider @Inject constructor(
val currentRotation = RotationUtils.getExactRotation(context)
val isRtl = rotatedResources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL
- val roundedCornerPadding = rotatedResources
+ var roundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if(roundedCornerPadding == -1)
+ roundedCornerPadding = rotatedResources
.getDimensionPixelSize(R.dimen.rounded_corner_content_padding)
val minDotWidth = rotatedResources
.getDimensionPixelSize(R.dimen.ongoing_appops_dot_min_padding)
--
2.25.1

View File

@@ -0,0 +1,26 @@
From 322fd1c3aadbfce8863360ce1e64ff58f00ce24c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 11 Dec 2020 14:41:09 +0100
Subject: [PATCH 14/24] Remove useless notification about "console" service
being running
---
.../core/java/com/android/server/am/ActivityManagerService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 953e6e24236f..856ecc7c469d 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4775,7 +4775,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
private void showConsoleNotificationIfActive() {
- if (!SystemProperties.get("init.svc.console").equals("running")) {
+ if (!SystemProperties.get("init.svc.console").equals("running") || true) {
return;
}
String title = mContext
--
2.25.1

View File

@@ -0,0 +1,95 @@
From a274dd1fdc784a82a41ca6eff4acc899fd3adb44 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 21:24:12 +0800
Subject: [PATCH 15/24] Revert "Remove unused SystemProperties.set"
This reverts commit debb4616ef67f9ed5054eca51ec58592358ff55f.
* Needed for SPRD IMS
---
.../android/telephony/TelephonyManager.java | 69 +++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 255a61266ebf..7243221f0998 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -7405,6 +7405,75 @@ public class TelephonyManager {
}
}
+ /**
+ * Sets a per-phone telephony property with the value specified.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static void setTelephonyProperty(int phoneId, String property, String value) {
+ String propVal = "";
+ String p[] = null;
+ String prop = SystemProperties.get(property);
+
+ if (value == null) {
+ value = "";
+ }
+ value.replace(',', ' ');
+ if (prop != null) {
+ p = prop.split(",");
+ }
+
+ if (!SubscriptionManager.isValidPhoneId(phoneId)) {
+ Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId +
+ " property=" + property + " value: " + value + " prop=" + prop);
+ return;
+ }
+
+ for (int i = 0; i < phoneId; i++) {
+ String str = "";
+ if ((p != null) && (i < p.length)) {
+ str = p[i];
+ }
+ propVal = propVal + str + ",";
+ }
+
+ propVal = propVal + value;
+ if (p != null) {
+ for (int i = phoneId + 1; i < p.length; i++) {
+ propVal = propVal + "," + p[i];
+ }
+ }
+
+ int propValLen = propVal.length();
+ try {
+ propValLen = propVal.getBytes("utf-8").length;
+ } catch (java.io.UnsupportedEncodingException e) {
+ Rlog.d(TAG, "setTelephonyProperty: utf-8 not supported");
+ }
+ if (propValLen > SystemProperties.PROP_VALUE_MAX) {
+ Rlog.d(TAG, "setTelephonyProperty: property too long phoneId=" + phoneId +
+ " property=" + property + " value: " + value + " propVal=" + propVal);
+ return;
+ }
+
+ SystemProperties.set(property, propVal);
+ }
+
+ /**
+ * Sets a global telephony property with the value specified.
+ *
+ * @hide
+ */
+ public static void setTelephonyProperty(String property, String value) {
+ if (value == null) {
+ value = "";
+ }
+ Rlog.d(TAG, "setTelephonyProperty: success" + " property=" +
+ property + " value: " + value);
+ SystemProperties.set(property, value);
+ }
+
/**
* Inserts or updates a list property. Expands the list if its length is not enough.
*/
--
2.25.1

View File

@@ -0,0 +1,84 @@
From 622df54f19543a5dd66a8446f58ed8818ed7aa6f Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 13:46:15 +0800
Subject: [PATCH 16/24] TelephonyManager: bring back getNetworkClass()
This partially reverts commit c058cac051ab083dc7fb7ea6aa85699110b2e9bf.
* Needed by Spreadtrum IMS
---
.../android/telephony/TelephonyManager.java | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 7243221f0998..674d09c3bfd8 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3042,6 +3042,64 @@ public class TelephonyManager {
}
}
+ /**
+ * Network Class Definitions.
+ * Do not change this order, it is used for sorting during emergency calling in
+ * {@link TelephonyConnectionService#getFirstPhoneForEmergencyCall()}. Any newer technologies
+ * should be added after the current definitions.
+ */
+ /** Unknown network class. {@hide} */
+ public static final int NETWORK_CLASS_UNKNOWN = 0;
+ /** Class of broadly defined "2G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_2_G = 1;
+ /** Class of broadly defined "3G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_3_G = 2;
+ /** Class of broadly defined "4G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_4_G = 3;
+ /** Class of broadly defined "5G" networks. {@hide} */
+ public static final int NETWORK_CLASS_5_G = 4;
+
+ /**
+ * Return general class of network type, such as "3G" or "4G". In cases
+ * where classification is contentious, this method is conservative.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static int getNetworkClass(int networkType) {
+ switch (networkType) {
+ case NETWORK_TYPE_GPRS:
+ case NETWORK_TYPE_GSM:
+ case NETWORK_TYPE_EDGE:
+ case NETWORK_TYPE_CDMA:
+ case NETWORK_TYPE_1xRTT:
+ case NETWORK_TYPE_IDEN:
+ return NETWORK_CLASS_2_G;
+ case NETWORK_TYPE_UMTS:
+ case NETWORK_TYPE_EVDO_0:
+ case NETWORK_TYPE_EVDO_A:
+ case NETWORK_TYPE_HSDPA:
+ case NETWORK_TYPE_HSUPA:
+ case NETWORK_TYPE_HSPA:
+ case NETWORK_TYPE_EVDO_B:
+ case NETWORK_TYPE_EHRPD:
+ case NETWORK_TYPE_HSPAP:
+ case NETWORK_TYPE_TD_SCDMA:
+ return NETWORK_CLASS_3_G;
+ case NETWORK_TYPE_LTE:
+ case NETWORK_TYPE_IWLAN:
+ case NETWORK_TYPE_LTE_CA:
+ return NETWORK_CLASS_4_G;
+ case NETWORK_TYPE_NR:
+ return NETWORK_CLASS_5_G;
+ default:
+ return NETWORK_CLASS_UNKNOWN;
+ }
+ }
+
/**
* Returns a string representation of the radio technology (network type)
* currently in use on the device.
--
2.25.1

View File

@@ -0,0 +1,41 @@
From 2cfd2dbee3c7744895d5af492661aad3297f6f97 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 21:26:45 +0800
Subject: [PATCH 17/24] TelephonyManager: add API annotations for
setTelephonyProperty
* This method was added back by reverting commit
debb4616ef67f9ed5054eca51ec58592358ff55f, but they do not conform to
the new R API requirements.
* R requires such annotations.
---
telephony/java/android/telephony/TelephonyManager.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 674d09c3bfd8..a7f32cb0cd4b 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -7469,7 +7469,7 @@ public class TelephonyManager {
* @hide
*/
@UnsupportedAppUsage
- public static void setTelephonyProperty(int phoneId, String property, String value) {
+ public static void setTelephonyProperty(int phoneId, @NonNull String property, @Nullable String value) {
String propVal = "";
String p[] = null;
String prop = SystemProperties.get(property);
@@ -7523,7 +7523,8 @@ public class TelephonyManager {
*
* @hide
*/
- public static void setTelephonyProperty(String property, String value) {
+ @UnsupportedAppUsage
+ public static void setTelephonyProperty(@NonNull String property, @Nullable String value) {
if (value == null) {
value = "";
}
--
2.25.1

View File

@@ -0,0 +1,28 @@
From 10b2cd4edfefad6f2bff633ade040cfa796be8ec Mon Sep 17 00:00:00 2001
From: Alberto Ponces <ponces26@gmail.com>
Date: Tue, 2 Feb 2021 10:20:51 +0000
Subject: [PATCH 18/24] Fix Wakelock issue
Prevent SystemUI crash due to "WakeLock under-locked Doze" (issue #12) by only releasing a wakelock that was not already released
---
.../src/com/android/systemui/util/wakelock/WakeLock.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java b/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java
index 8d77c4a194a9..e9f253433740 100644
--- a/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java
+++ b/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java
@@ -110,7 +110,9 @@ public interface WakeLock {
} else {
mActiveClients.put(why, count - 1);
}
- inner.release();
+ if (inner.isHeld()) {
+ inner.release();
+ }
}
/** @see PowerManager.WakeLock#wrap(Runnable) */
--
2.25.1

View File

@@ -0,0 +1,30 @@
From afb9dc934893cffcb4710beac437d0b618277305 Mon Sep 17 00:00:00 2001
From: Arne Coucheron <arco68@gmail.com>
Date: Thu, 5 Nov 2020 05:38:44 +0100
Subject: [PATCH 19/24] SystemUI: Use AVCProfileMain for screen recorder
Some devices don't support the High profile very well.
Use Main profile, which is more compatible, so they
can use screen recorder too.
Change-Id: Iac23480e080edf4300e6f411c3394c0b41030daa
---
.../com/android/systemui/screenrecord/ScreenMediaRecorder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java
index 26781f4ccf09..9a6e657876f0 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java
@@ -135,7 +135,7 @@ public class ScreenMediaRecorder {
* VIDEO_FRAME_RATE_TO_RESOLUTION_RATIO;
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setVideoEncodingProfileLevel(
- MediaCodecInfo.CodecProfileLevel.AVCProfileHigh,
+ MediaCodecInfo.CodecProfileLevel.AVCProfileMain,
MediaCodecInfo.CodecProfileLevel.AVCLevel3);
mMediaRecorder.setVideoSize(width, height);
mMediaRecorder.setVideoFrameRate(refreshRate);
--
2.25.1

View File

@@ -0,0 +1,49 @@
From 04ed3039c7f353b57d61436c79676be048ab634c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 20 Mar 2021 14:31:01 +0100
Subject: [PATCH 20/24] Automatically detect pick up sensor, so that an overlay
is required for the sole purpose of enabling pulse doze on pick up sensor
---
.../display/AmbientDisplayConfiguration.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/core/java/android/hardware/display/AmbientDisplayConfiguration.java b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
index a1f7aa12264b..5f6201bbb18c 100644
--- a/core/java/android/hardware/display/AmbientDisplayConfiguration.java
+++ b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
@@ -23,6 +23,9 @@ import android.os.SystemProperties;
import android.provider.Settings;
import android.text.TextUtils;
+import android.hardware.SensorManager;
+import android.hardware.Sensor;
+
import com.android.internal.R;
/**
@@ -76,7 +79,20 @@ public class AmbientDisplayConfiguration {
/** {@hide} */
public boolean dozePickupSensorAvailable() {
- return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
+ SensorManager sm = mContext.getSystemService(SensorManager.class);
+ boolean found = false;
+ if(sm == null) {
+ android.util.Log.d("PHH", "Failed getting sensor manager, can't detect pickup sensor");
+ } else {
+ java.util.List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor s : sensors) {
+ if(Sensor.STRING_TYPE_PICK_UP_GESTURE.equals(s.getStringType())) {
+ found = true;
+ break;
+ }
+ }
+ }
+ return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup) || found;
}
/** {@hide} */
--
2.25.1

View File

@@ -0,0 +1,48 @@
From e512110dd600e59f89408789263a926a47a09d6e 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 21/24] 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
Change-Id: I03b6e78bac2cc38f3a623c8add801405ad6ba7ba
---
core/java/android/view/DisplayCutout.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/core/java/android/view/DisplayCutout.java b/core/java/android/view/DisplayCutout.java
index e1a4402d8964..25282b50cc45 100644
--- a/core/java/android/view/DisplayCutout.java
+++ b/core/java/android/view/DisplayCutout.java
@@ -881,10 +881,17 @@ public final class DisplayCutout {
*/
public static DisplayCutout fromResourcesRectApproximation(Resources res, int displayWidth,
int displayHeight) {
- return pathAndDisplayCutoutFromSpec(res.getString(R.string.config_mainBuiltInDisplayCutout),
- res.getString(R.string.config_mainBuiltInDisplayCutoutRectApproximation),
- displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
- loadWaterfallInset(res)).second;
+ try {
+ return pathAndDisplayCutoutFromSpec(res.getString(R.string.config_mainBuiltInDisplayCutout),
+ res.getString(R.string.config_mainBuiltInDisplayCutoutRectApproximation),
+ displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
+ loadWaterfallInset(res)).second;
+ } catch(Throwable t) {
+ return pathAndDisplayCutoutFromSpec(res.getString(R.string.config_mainBuiltInDisplayCutout),
+ null,
+ displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
+ loadWaterfallInset(res)).second;
+ }
}
/**
--
2.25.1

View File

@@ -0,0 +1,121 @@
From e9eddb9bfbc3d23e6538046cbd006e63ca0a40c1 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 22/24] 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 | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index 91f14de040fe..8fa9c4f3a698 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -31,6 +31,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemProperties;
import android.os.Trace;
import android.provider.Settings;
import android.util.Slog;
@@ -294,6 +295,51 @@ public class LightsService extends SystemService {
return;
}
int brightnessInt = BrightnessSynchronizer.brightnessFloatToInt(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

View File

@@ -0,0 +1,161 @@
From 6efec3a6f3f2dfbe89fb7b2b72d24110a94aa2d6 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Sat, 16 Oct 2021 05:27:57 -0700
Subject: [PATCH 23/24] 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
Changes made for Android 12:
- Moved mayFakeSignature into lock-free Computer subclass
- Always get permissions for packages that request signature spoofing
(otherwise permissions are usually ommitted and thus the permission
check doesn't work properly)
- Optimize mayFakeSignature check order to improve performance
Link: https://github.com/microg/GmsCore/pull/1586
Change-Id: Ied7d6ce0b83a2d2345c3abba0429998d86494a88
---
core/api/current.txt | 2 ++
core/res/AndroidManifest.xml | 15 +++++++++
core/res/res/values/strings.xml | 12 +++++++
.../server/pm/PackageManagerService.java | 31 +++++++++++++++++--
4 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/core/api/current.txt b/core/api/current.txt
index 1de47b548a5c..52c7ea2e1321 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -84,6 +84,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";
@@ -199,6 +200,7 @@ package android {
field public static final String CALL_LOG = "android.permission-group.CALL_LOG";
field public static final String CAMERA = "android.permission-group.CAMERA";
field public static final String CONTACTS = "android.permission-group.CONTACTS";
+ field public static final String FAKE_PACKAGE = "android.permission-group.FAKE_PACKAGE";
field public static final String LOCATION = "android.permission-group.LOCATION";
field public static final String MICROPHONE = "android.permission-group.MICROPHONE";
field public static final String NEARBY_DEVICES = "android.permission-group.NEARBY_DEVICES";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index bad79eb13749..e4475497b12e 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3186,6 +3186,21 @@
android:description="@string/permdesc_getPackageSize"
android:protectionLevel="normal" />
+ <!-- Dummy user-facing group for faking package signature -->
+ <permission-group android:name="android.permission-group.FAKE_PACKAGE"
+ android:label="@string/permgrouplab_fake_package_signature"
+ android:description="@string/permgroupdesc_fake_package_signature"
+ android:request="@string/permgrouprequest_fake_package_signature"
+ android:priority="100" />
+
+ <!-- Allows an application to change the package signature as
+ seen by applications -->
+ <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
+ android:permissionGroup="android.permission-group.UNDEFINED"
+ 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/strings.xml b/core/res/res/values/strings.xml
index a99a22009e3b..81ca9b23ae70 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -880,6 +880,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/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 46b0b600960d..a88e518eb624 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3299,6 +3299,29 @@ public class PackageManagerService extends IPackageManager.Stub
return result;
}
+ private boolean requestsFakeSignature(AndroidPackage p) {
+ return p.getMetaData() != null &&
+ p.getMetaData().getString("fake-signature") != null;
+ }
+
+ private PackageInfo mayFakeSignature(AndroidPackage p, PackageInfo pi,
+ Set<String> permissions) {
+ try {
+ if (p.getMetaData() != null &&
+ p.getTargetSdkVersion() > Build.VERSION_CODES.LOLLIPOP_MR1) {
+ String sig = p.getMetaData().getString("fake-signature");
+ if (sig != null &&
+ permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")) {
+ 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;
+ }
+
public final PackageInfo generatePackageInfo(PackageSetting ps, int flags, int userId) {
if (!mUserManager.exists(userId)) return null;
if (ps == null) {
@@ -3327,12 +3350,14 @@ public class PackageManagerService extends IPackageManager.Stub
final int[] gids = (flags & PackageManager.GET_GIDS) == 0 ? EMPTY_INT_ARRAY
: mPermissionManager.getGidsForUid(UserHandle.getUid(userId, ps.appId));
// Compute granted permissions only if package has requested permissions
- final Set<String> permissions = ((flags & PackageManager.GET_PERMISSIONS) == 0
+ final Set<String> permissions = (((flags & PackageManager.GET_PERMISSIONS) == 0
+ && !requestsFakeSignature(p))
|| ArrayUtils.isEmpty(p.getRequestedPermissions())) ? Collections.emptySet()
: mPermissionManager.getGrantedPermissions(ps.name, userId);
- 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;
--
2.25.1

View File

@@ -0,0 +1,35 @@
From 3b5b5acf725b96498f7ad7d613c689ab80486a5b Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Sat, 4 Sep 2021 08:26:30 +0000
Subject: [PATCH 24/24] Revert "Switch long-press power behavior in AOSP."
This reverts commit 803c77a0a24624111944832098c6f65158051dc4.
---
core/res/res/values/config.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index db43b5b31e7e..8cf90cb4b240 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -955,7 +955,7 @@
4 - Go to voice assist
5 - Go to assistant (Settings.Secure.ASSISTANT)
-->
- <integer name="config_longPressOnPowerBehavior">5</integer>
+ <integer name="config_longPressOnPowerBehavior">1</integer>
<!-- Whether the setting to change long press on power behaviour from default to assistant (5)
is available in Settings.
@@ -973,7 +973,7 @@
1 - Mute toggle
2 - Global actions menu
-->
- <integer name="config_keyChordPowerVolumeUp">2</integer>
+ <integer name="config_keyChordPowerVolumeUp">1</integer>
<!-- Control the behavior when the user long presses the back button. Non-zero values are only
valid for watches as part of CDD/CTS.
--
2.25.1

View File

@@ -0,0 +1,37 @@
From 0153bec21c46eab87c37fb0f5c3139567460f546 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 1/7] On Samsung, we need to send a hack-message to HAL to get
all Sensors
Change-Id: Id6a1fa48340de61c418493668e9abd22c2599376
---
services/sensorservice/SensorDevice.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index c233bf06cf..623ba66364 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;
@@ -132,6 +134,8 @@ SensorDevice::SensorDevice()
}
void SensorDevice::initializeSensorList() {
+ 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.29.2

View File

@@ -0,0 +1,39 @@
From d206a6984ac2d40d182a2b89abbb263d022cdf93 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 2/7] 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 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 56e9d27f14..f804383fed 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -405,6 +405,16 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(HWC2::Layer* hwcLayer,
sourceCrop.bottom, to_string(error).c_str(), static_cast<int32_t>(error));
}
+ 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(), z,
to_string(error).c_str(), static_cast<int32_t>(error));
--
2.29.2

View File

@@ -0,0 +1,121 @@
From 2579f0a4d5f45d8f6d4edcaa1727c06649b26c5a 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 3/7] 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 6b6d43425d..7b78c7277a 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -27,6 +27,7 @@
#include <compositionengine/LayerFECompositionState.h>
#include <gui/BufferQueueConsumer.h>
#include <system/window.h>
+#include <cutils/properties.h>
#include "LayerRejecter.h"
#include "SurfaceInterceptor.h"
@@ -35,6 +36,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 {
using PresentState = frametimeline::SurfaceFrame::PresentState;
@@ -505,6 +514,7 @@ void BufferQueueLayer::onFirstRef() {
mConsumer =
mFlinger->getFactory().createBufferLayerConsumer(consumer, mFlinger->getRenderEngine(),
mTextureName, this);
+ init_fod_props();
mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
mContentsChangedListener = new ContentsChangedListener(this);
@@ -525,9 +535,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 f804383fed..2b7bf25dc7 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -24,6 +24,7 @@
#include <compositionengine/impl/OutputLayer.h>
#include <compositionengine/impl/OutputLayerCompositionState.h>
#include <cstdint>
+#include <cutils/properties.h>
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic push
@@ -34,6 +35,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;
@@ -405,14 +410,30 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(HWC2::Layer* hwcLayer,
sourceCrop.bottom, to_string(error).c_str(), 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);
+ }
+
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.29.2

View File

@@ -0,0 +1,35 @@
From 1cc2bcbb73c4664c9731260ebe39a776fab9e46e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 22 Oct 2020 23:22:46 +0200
Subject: [PATCH 4/7] Matching an input with a display uses uniqueId
Not all devices have a `location`, notably bluetooth devices.
However, we might still want to associate them with a screen,
so match them with uniqueId indeed.
This is useful to have bluetooth keyboard in desktop mode for instance.
Change-Id: Ifcbc8329d54386f58e013270d9888316c0f516b6
---
services/inputflinger/reader/InputDevice.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index 7af014cb34..53ef86f1c9 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -303,7 +303,10 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config
mAssociatedDisplayUniqueId = std::nullopt;
mAssociatedViewport = std::nullopt;
// Find the display port that corresponds to the current input port.
- const std::string& inputPort = mIdentifier.location;
+ std::string inputPort = mIdentifier.location;
+ if (inputPort.empty()) {
+ inputPort = mIdentifier.uniqueId;
+ }
if (!inputPort.empty()) {
const std::unordered_map<std::string, uint8_t>& ports = config->portAssociations;
const auto& displayPort = ports.find(inputPort);
--
2.29.2

View File

@@ -0,0 +1,26 @@
From 53d1d85b857bc668da93b6b264c3fa3093eb1e58 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 5 Jan 2021 23:44:00 +0100
Subject: [PATCH 5/7] unshared_oob didn't exist in O/P, so detect its supported
based on vndk version
---
cmds/installd/migrate_legacy_obb_data.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmds/installd/migrate_legacy_obb_data.sh b/cmds/installd/migrate_legacy_obb_data.sh
index 7399681c3e..9d5b73eae2 100644
--- a/cmds/installd/migrate_legacy_obb_data.sh
+++ b/cmds/installd/migrate_legacy_obb_data.sh
@@ -18,7 +18,7 @@
rm -rf /data/media/0/Android/obb/test_probe
mkdir -p /data/media/0/Android/obb/
touch /data/media/0/Android/obb/test_probe
-if ! test -f /data/media/0/Android/obb/test_probe ; then
+if ! test -f /data/media/0/Android/obb/test_probe || [ "$(adb shell getprop ro.vndk.version)" -le 28 ]; then
log -p i -t migrate_legacy_obb_data "No support for 'unshared_obb'. Not migrating"
rm -rf /data/media/0/Android/obb/test_probe
exit 0
--
2.29.2

View File

@@ -0,0 +1,37 @@
From 9c752c1b718a7f027da3cd647b88d1dc3af202f7 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 31 Mar 2021 23:36:03 +0200
Subject: [PATCH 6/7] Remove Samsung system permission on sensors
---
libs/sensor/Sensor.cpp | 1 +
libs/sensor/include/sensor/Sensor.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/libs/sensor/Sensor.cpp b/libs/sensor/Sensor.cpp
index 0a49008584..012b87c6ed 100644
--- a/libs/sensor/Sensor.cpp
+++ b/libs/sensor/Sensor.cpp
@@ -409,6 +409,7 @@ const String8& Sensor::getStringType() const {
}
const String8& Sensor::getRequiredPermission() const {
+ if (mRequiredPermission == "com.samsung.permission.SSENSOR") return mFakeRequiredPermission;
return mRequiredPermission;
}
diff --git a/libs/sensor/include/sensor/Sensor.h b/libs/sensor/include/sensor/Sensor.h
index 374b68fab5..ffc715fc07 100644
--- a/libs/sensor/include/sensor/Sensor.h
+++ b/libs/sensor/include/sensor/Sensor.h
@@ -128,6 +128,7 @@ private:
uint32_t mFifoMaxEventCount;
String8 mStringType;
String8 mRequiredPermission;
+ String8 mFakeRequiredPermission;
bool mRequiredPermissionRuntime = false;
int32_t mRequiredAppOp;
int32_t mMaxDelay;
--
2.29.2

View File

@@ -0,0 +1,64 @@
From 9b3166a5bdba49f210b1a9dac1c7a27f5e2cfdd2 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 20 Oct 2021 09:39:47 -0400
Subject: [PATCH 7/7] Try to fallback mCallingSid to getpidcon
This is needed because old vendors (before April 2019 ~) don't support
reporting SELinux context of the caller.
This doesn't work for all processes, because it requires some additional
SELinux permissions. At the moment, only keystore2 requires this
Change-Id: I3b6c4dac9d0e20a3d66f931b283e3a535ab499cd
---
libs/binder/IPCThreadState.cpp | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 445df9eeff..a5c4a7e106 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -36,6 +36,7 @@
#include <sched.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <unistd.h>
@@ -1246,6 +1247,25 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
mCallingUid = tr.sender_euid;
mLastTransactionBinderFlags = tr.flags;
+ // This is recoding libselinux's getpidcon()
+ // We are in a NDK lib, so we need to keep changes to a minimum
+ bool allocatedSid = false;
+ if(mCallingSid == nullptr && mCallingPid != 0) {
+ char buf[4096];
+ char *path = NULL;
+ (void)asprintf(&path, "/proc/%d/attr/current", mCallingPid);
+ int fd = open(path, O_RDONLY | O_CLOEXEC);
+ if(fd != -1) {
+ int readRet = read(fd, buf, sizeof(buf)-1);
+ if(readRet != -1) {
+ buf[readRet] = 0;
+ mCallingSid = strdup(buf);
+ allocatedSid = true;
+ }
+ close(fd);
+ }
+ }
+
// ALOGI(">>>> TRANSACT from pid %d sid %s uid %d\n", mCallingPid,
// (mCallingSid ? mCallingSid : "<N/A>"), mCallingUid);
@@ -1310,6 +1330,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
mServingStackPointer = origServingStackPointer;
mCallingPid = origPid;
+ if(allocatedSid) free((void*)mCallingSid);
mCallingSid = origSid;
mCallingUid = origUid;
mStrictModePolicy = origStrictModePolicy;
--
2.29.2

View File

@@ -0,0 +1,55 @@
From a8df36e780d5dd56d4d2c90be36e3a343abb1e49 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 1/2] 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 bd71b0b11d..146b26d62f 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -71,6 +71,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.WorkSource;
@@ -4773,7 +4774,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 5bfe15bca7..674789c979 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
@@ -2150,8 +2150,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.29.2

View File

@@ -0,0 +1,34 @@
From a5a6afc7a7dd2d402960b60b1a7b084b89e67b8c Mon Sep 17 00:00:00 2001
From: Artem Borisov <dedsa2002@gmail.com>
Date: Sat, 10 Nov 2018 17:19:17 +0000
Subject: [PATCH 2/2] Telephony: Don not call onUssdRelease for Huawei RIL
Huawei RIL doesn't seem to work properly with USSD_MODE_NW_RELEASE,
always releasing USSD when it should be finished instead.
Let's explicitly call onUssdFinished in this case.
Change-Id: I69faed1c51d4582834879975d6ab13daf7f48ad4
---
src/java/com/android/internal/telephony/GsmCdmaPhone.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
index a034392cee..c82af4c432 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -2723,7 +2723,11 @@ public class GsmCdmaPhone extends Phone {
if (found != null) {
// Complete pending USSD
if (isUssdRelease) {
- found.onUssdRelease();
+ if (SystemProperties.getBoolean("persist.sys.radio.huawei", false)) {
+ found.onUssdFinished(ussdMessage, isUssdRequest);
+ } else {
+ found.onUssdRelease();
+ }
} else if (isUssdError) {
found.onUssdFinishedError();
} else {
--
2.29.2

View File

@@ -0,0 +1,54 @@
From e408adb5e9f3cf907392b7af9080df588e4e5b26 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 03ba99ac2..20267d08a 100644
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -87,6 +87,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;
@@ -1549,6 +1552,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);
}
@@ -1689,10 +1698,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.29.2

View File

@@ -0,0 +1,32 @@
From e5a3d5022cac5006195485aca93bc621b6a68473 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 14 Aug 2018 21:48:19 +0200
Subject: [PATCH] Act as usb device when there is no hal, but we believe we are
a device
Change-Id: I036090738525fd8cc63534d52d02ab1852950a7d
---
.../usb/UsbConnectionBroadcastReceiver.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
index c5bcbed00c..77b6148fa6 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
@@ -81,6 +81,13 @@ public class UsbConnectionBroadcastReceiver extends BroadcastReceiver implements
mFunctions = functions;
mDataRole = mUsbBackend.getDataRole();
mPowerRole = mUsbBackend.getPowerRole();
+ //If we have no USB HAL, mDataRole is invalid
+ //But we can't be connected AND have none data_role, so it's safe.
+ //It would be better to fix UsbManager when no HAL is available, but that's more work
+ if(mDataRole == UsbPortStatus.DATA_ROLE_NONE &&
+ intent.getExtras().getBoolean(UsbManager.USB_CONNECTED) &&
+ !intent.getExtras().getBoolean(UsbManager.USB_HOST_CONNECTED))
+ mDataRole = UsbPortStatus.DATA_ROLE_DEVICE;
} else if (UsbManager.ACTION_USB_PORT_CHANGED.equals(intent.getAction())) {
UsbPortStatus portStatus = intent.getExtras()
.getParcelable(UsbManager.EXTRA_PORT_STATUS);
--
2.29.2

View File

@@ -0,0 +1,27 @@
From 1330ebebb1b56a9f98969f733bfa6e21aa02f93f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 14 Oct 2021 15:32:19 -0400
Subject: [PATCH] Boot wifi supplicant both with lazy-hal style and init style
Some Samsung Pie vendors can't do lazy-hal style init
Change-Id: Id6b93c43df84e7453aaca47d752d26b868235fed
---
service/java/com/android/server/wifi/SupplicantStaIfaceHal.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index ed0c0cc51..7fc59e043 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -719,6 +719,7 @@ public class SupplicantStaIfaceHal {
synchronized (mLock) {
if (isV1_1()) {
Log.i(TAG, "Starting supplicant using HIDL");
+ mFrameworkFacade.startSupplicant();
return startDaemon_V1_1();
} else {
Log.i(TAG, "Starting supplicant using init");
--
2.29.2

View File

@@ -0,0 +1,28 @@
From c65f007e838f3143b097e4e3e93623d2e64e328c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 13 Oct 2021 10:56:52 -0400
Subject: [PATCH] Support no-bpf usecase
Change-Id: I75a427a2a41aa4ab1104ad88a891bef0dc2d9c91
---
bpfloader/BpfLoader.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp
index 7a68894..2d491a3 100644
--- a/bpfloader/BpfLoader.cpp
+++ b/bpfloader/BpfLoader.cpp
@@ -121,8 +121,8 @@ int main() {
ALOGE("If this triggers randomly, you might be hitting some memory allocation "
"problems or startup script race.");
ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---");
- sleep(20);
- return 2;
+ android::base::SetProperty("bpf.progs_loaded", "1");
+ return 0;
}
}
--
2.29.2

View File

@@ -0,0 +1,134 @@
From fd05778417027b87e72374e5ce357537c483f2c1 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 1/5] 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
Change-Id: I418aa605786153df4fdc544067ece59c12feccbf
---
hci/src/hci_packet_parser.cc | 56 ++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/hci/src/hci_packet_parser.cc b/hci/src/hci_packet_parser.cc
index 6bd6a52335..06964c3571 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,29 @@ 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));
+ }
+ }
+}
+
+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 +148,8 @@ 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));
+ filter_supported_feature(feature_pages[*page_number_ptr].as_array);
+
buffer_allocator->free(response);
}
@@ -163,6 +190,19 @@ static void parse_ble_read_buffer_size_v2_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 =
@@ -171,9 +211,23 @@ static void parse_ble_read_supported_states_response(
CHECK(stream != NULL);
STREAM_TO_ARRAY(supported_states, stream, (int)supported_states_size);
+ filter_supported_states(supported_states, supported_states_size);
+
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(
@@ -183,6 +237,8 @@ static void parse_ble_read_local_supported_features_response(
STREAM_TO_ARRAY(supported_features->as_array, stream,
(int)sizeof(bt_device_features_t));
+ filter_supported_stdfeatures(supported_features->as_array);
+
buffer_allocator->free(response);
}
--
2.29.2

View File

@@ -0,0 +1,67 @@
From 08e1bdd47e599f4ac0e556676c934d344a11db0d 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 2/5] 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 50717d9eb4..7603ae2626 100644
--- a/btif/src/btif_av.cc
+++ b/btif/src/btif_av.cc
@@ -973,9 +973,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("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 a90c881087..e95d358f67 100644
--- a/stack/a2dp/a2dp_codec_config.cc
+++ b/stack/a2dp/a2dp_codec_config.cc
@@ -571,13 +571,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("Got a2dp offload status %s", a2dp_offload_status ? "on" : "off");
if (a2dp_offload_status) {
char value_cap[PROPERTY_VALUE_MAX];
@@ -666,7 +671,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.29.2

View File

@@ -0,0 +1,31 @@
From 01b912959acd48430696fa7c93ae86271c12c99b 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 3/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 06964c3571..c65f0c2a03 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.29.2

View File

@@ -0,0 +1,44 @@
From def975d51460f82a34c78a63ec46b36583f8fa7a Mon Sep 17 00:00:00 2001
From: Alberto Ponces <ponces26@gmail.com>
Date: Thu, 17 Jun 2021 15:48:53 +0100
Subject: [PATCH 4/5] Add option to change eSCO Transport Unit Size
Fixes Bluetooth calls on some Samsung devices if set to 16.
It's still unknown if other Treble devices need other values so it's preferred to leave this able to be configured with another integer.
This applies to mSBC T2, T1 and CVSD codecs
Change-Id: I3e5897c2ce983042b9a4bef9def6744ba4253bcb
---
device/src/esco_parameters.cc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/device/src/esco_parameters.cc b/device/src/esco_parameters.cc
index e2a6eeccef..c553205906 100644
--- a/device/src/esco_parameters.cc
+++ b/device/src/esco_parameters.cc
@@ -20,7 +20,8 @@
#include "device/include/esco_parameters.h"
-static const enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = {
+#include <cutils/properties.h>
+static enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = {
// CVSD D1
{
.transmit_bandwidth = TXRX_64KBITS_RATE,
@@ -213,5 +214,10 @@ enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec) {
CHECK(codec >= 0) << "codec index " << (int)codec << "< 0";
CHECK(codec < ESCO_NUM_CODECS) << "codec index " << (int)codec << " > "
<< ESCO_NUM_CODECS;
+ int escoTransportUnitSize = property_get_int32("persist.sys.bt.esco_transport_unit_size", 0);
+ if(escoTransportUnitSize) {
+ default_esco_parameters[codec].input_transport_unit_size = escoTransportUnitSize;
+ default_esco_parameters[codec].output_transport_unit_size = escoTransportUnitSize;
+ }
return default_esco_parameters[codec];
}
--
2.29.2

View File

@@ -0,0 +1,98 @@
From 969b5a218adbed842d76b3ff195a3cafbeed7c1d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 17 Oct 2021 17:17:13 -0400
Subject: [PATCH 5/5] Don't abort when failing to get real-time priority
On some devices (like OP6), for unknown reason, trying to go to realtime
fails with EPERM.
There is no good reason to actually require real-time, so don't fail
when we don't get it
This fixes gabeldorsche on OP6
Not yet legacy bluetooth stack
Change-Id: Id25dac186628e933185bdfd640498004459b375a
---
btif/src/btif_a2dp_sink.cc | 2 +-
btif/src/btif_a2dp_source.cc | 2 +-
hci/src/hci_layer.cc | 1 -
osi/src/alarm.cc | 12 +++++++++++-
stack/btu/btu_task.cc | 2 +-
5 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/btif/src/btif_a2dp_sink.cc b/btif/src/btif_a2dp_sink.cc
index fa02a8682d..9610720db5 100644
--- a/btif/src/btif_a2dp_sink.cc
+++ b/btif/src/btif_a2dp_sink.cc
@@ -192,7 +192,7 @@ bool btif_a2dp_sink_init() {
/* Schedule the rest of the operations */
if (!btif_a2dp_sink_cb.worker_thread.EnableRealTimeScheduling()) {
- LOG(FATAL) << __func__
+ LOG(ERROR) << __func__
<< ": Failed to increase A2DP decoder thread priority";
}
btif_a2dp_sink_cb.worker_thread.DoInThread(
diff --git a/btif/src/btif_a2dp_source.cc b/btif/src/btif_a2dp_source.cc
index 19bf998ab2..57b665af7a 100644
--- a/btif/src/btif_a2dp_source.cc
+++ b/btif/src/btif_a2dp_source.cc
@@ -358,7 +358,7 @@ bool btif_a2dp_source_startup(void) {
static void btif_a2dp_source_startup_delayed() {
LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());
if (!btif_a2dp_source_thread.EnableRealTimeScheduling()) {
- LOG(FATAL) << __func__ << ": unable to enable real time scheduling";
+ LOG(ERROR) << __func__ << ": unable to enable real time scheduling";
}
if (!bluetooth::audio::a2dp::init(&btif_a2dp_source_thread)) {
if (btif_av_is_a2dp_offload_enabled()) {
diff --git a/hci/src/hci_layer.cc b/hci/src/hci_layer.cc
index 1cd3a49a39..860be04460 100644
--- a/hci/src/hci_layer.cc
+++ b/hci/src/hci_layer.cc
@@ -234,7 +234,6 @@ static future_t* hci_module_start_up(void) {
}
if (!hci_thread.EnableRealTimeScheduling()) {
LOG_ERROR("%s unable to make thread RT.", __func__);
- goto error;
}
commands_pending_response = list_new(NULL);
diff --git a/osi/src/alarm.cc b/osi/src/alarm.cc
index 6e5d22f43e..6f6c7a4248 100644
--- a/osi/src/alarm.cc
+++ b/osi/src/alarm.cc
@@ -678,7 +678,17 @@ static bool timer_create_internal(const clockid_t clock_id, timer_t* timer) {
sigevent.sigev_notify = SIGEV_THREAD;
sigevent.sigev_notify_function = (void (*)(union sigval))timer_callback;
sigevent.sigev_notify_attributes = &thread_attr;
- if (timer_create(clock_id, &sigevent, timer) == -1) {
+
+ int ret = timer_create(clock_id, &sigevent, timer);
+ if (ret == -1) {
+ LOG_ERROR("%s failed to create timer with RT err %s... Try again without RT", __func__, strerror(errno));
+ // Recreate timer without RT priority
+ memset(&sigevent, 0, sizeof(sigevent));
+ sigevent.sigev_notify = SIGEV_THREAD;
+ sigevent.sigev_notify_function = (void (*)(union sigval))timer_callback;
+ ret = timer_create(clock_id, &sigevent, timer);
+ }
+ if (ret == -1) {
LOG_ERROR("%s unable to create timer with clock %d: %s", __func__, clock_id,
strerror(errno));
if (clock_id == CLOCK_BOOTTIME_ALARM) {
diff --git a/stack/btu/btu_task.cc b/stack/btu/btu_task.cc
index 5e83e4d07e..33e7264fdb 100644
--- a/stack/btu/btu_task.cc
+++ b/stack/btu/btu_task.cc
@@ -121,7 +121,7 @@ void main_thread_start_up() {
LOG(FATAL) << __func__ << ": unable to start btu message loop thread.";
}
if (!main_thread.EnableRealTimeScheduling()) {
- LOG(FATAL) << __func__ << ": unable to enable real time scheduling";
+ LOG(ERROR) << __func__ << ": unable to enable real time scheduling";
}
}
--
2.29.2

View File

@@ -0,0 +1,27 @@
From bec8dc46031766ec06bbdf5364dda19ed1c27e4e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 7 Oct 2021 15:48:11 -0400
Subject: [PATCH 1/5] Stop overriding system properties from vendor
This is annoying to disable apexes, or force adb
Change-Id: Ifd0072c631349b23945df4ab401ba26eca07131f
---
init/property_service.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 2d67bf5d7..5974065f5 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -725,7 +725,6 @@ static void LoadProperties(char* data, const char* filter, const char* filename,
} else if (it->second != value) {
LOG(WARNING) << "Overriding previous property '" << key << "':'" << it->second
<< "' with new value '" << value << "'";
- it->second = value;
}
} else {
LOG(ERROR) << "Do not have permissions to set '" << key << "' to '" << value
--
2.29.2

View File

@@ -0,0 +1,46 @@
From 6cb2b52642892379df490dc44ff977e55e9bde02 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 2/5] [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 | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index f5c10bbd4..9562af35d 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -888,10 +888,17 @@ bool DoFirstStageMount(bool create_devices) {
}
if (create_devices) {
- if (!(*fsm)->DoCreateDevices()) return false;
+ if (!(*fsm)->DoCreateDevices()) LOG(ERROR) << "Failed to create devices";
}
- return (*fsm)->DoFirstStageMount();
+ if(!(*fsm)->DoFirstStageMount()) {
+ *fsm = nullptr;
+ auto fstab = ReadFirstStageFstab();
+ auto v = std::make_unique<FirstStageMountVBootV1>(std::move(*fstab));
+ v->DoCreateDevices();
+ return v->DoFirstStageMount();
+ }
+ return true;
}
void SetInitAvbVersionInRecovery() {
--
2.29.2

View File

@@ -0,0 +1,35 @@
From 9df676e24531b46250ac239879baa51163305823 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 18 Oct 2020 18:14:47 +0200
Subject: [PATCH 3/5] Don't abandon creating property tree if there is a
conflict, and hope for the best
Change-Id: I194c815fdd58bfb84aaf7db02b8f0d00b4db21e8
---
.../libpropertyinfoserializer/property_info_serializer.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/property_service/libpropertyinfoserializer/property_info_serializer.cpp b/property_service/libpropertyinfoserializer/property_info_serializer.cpp
index 803657ab8..ecdd0be20 100644
--- a/property_service/libpropertyinfoserializer/property_info_serializer.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_serializer.cpp
@@ -19,6 +19,7 @@
#include "property_info_parser/property_info_parser.h"
#include <set>
+#include <iostream>
#include "trie_builder.h"
#include "trie_serializer.h"
@@ -34,7 +35,7 @@ bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info,
for (const auto& [name, context, type, is_exact] : property_info) {
if (!trie_builder.AddToTrie(name, context, type, is_exact, error)) {
- return false;
+ std::cerr << "Failed adding " << name << " to property trie... let's hope for the best" << std::endl;
}
}
--
2.29.2

View File

@@ -0,0 +1,43 @@
From 86431a4936479bf7f80b982a12d64732f494b14f 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 4/5] Detect allowed sdcard options based on vndk
Some kernel crashes when using too recent sdcardfs options
Change-Id: I632e485f9b2a09a46d4a1fde2ea15217f8d92eff
---
sdcard/sdcard.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp
index 622de5b7a..e580190e9 100644
--- a/sdcard/sdcard.cpp
+++ b/sdcard/sdcard.cpp
@@ -32,6 +32,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
+#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -103,11 +104,12 @@ static bool sdcardfs_setup(const std::string& source_path, const std::string& de
mode_t mask, bool derive_gid, bool default_normal, bool unshared_obb,
bool use_esdfs) {
// Add new options at the end of the vector.
+ int vndk = android::base::GetIntProperty<int>("ro.vndk.version", 29);
std::vector<std::string> new_opts_list;
if (multi_user) new_opts_list.push_back("multiuser,");
- if (derive_gid) new_opts_list.push_back("derive_gid,");
- if (default_normal) new_opts_list.push_back("default_normal,");
- if (unshared_obb) new_opts_list.push_back("unshared_obb,");
+ if (derive_gid && vndk >= 27) new_opts_list.push_back("derive_gid,");
+ if (default_normal && vndk >= 28) new_opts_list.push_back("default_normal,");
+ if (unshared_obb && vndk >= 29) 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) {
--
2.29.2

View File

@@ -0,0 +1,32 @@
From 8807d3ac8c9fe662a6d5610b421bb54d0e05603e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 1 Nov 2019 18:22:13 +0100
Subject: [PATCH 5/5] Ugly but secure: Set /dev/uinput as 0666 to fix
fingerprint sensor on some devices
cf https://github.com/phhusson/device_phh_treble/pull/122/commits/e000d69c286b6686777ea6f1867f379e30273e48
This is safe because even though it's 0666, its SELinux policy is very
tight, and only bluetooth HAL, shell (and fingerprint HAL on Xiaomi) can
access it.
Change-Id: Id374e781957927d5604cb96c7a39b3fb28b3a6c5
---
rootdir/ueventd.rc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index 56e774bdc..67230e051 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -52,7 +52,7 @@ subsystem dma_heap
# these should not be world writable
/dev/uhid 0660 uhid uhid
-/dev/uinput 0660 uhid uhid
+/dev/uinput 0666 uhid uhid
/dev/rtc0 0640 system system
/dev/tty0 0660 root system
/dev/graphics/* 0660 root graphics
--
2.29.2

View File

@@ -0,0 +1,35 @@
From a0b3e3c319c03fcf75c4ae3de7969dc9d55534eb Mon Sep 17 00:00:00 2001
From: Luca Stefani <luca.stefani.ge1@gmail.com>
Date: Wed, 9 Sep 2020 12:43:54 +0200
Subject: [PATCH] libfscrypt: Bail out if we can't open directory
* On QCOM Q vendor init.qcom.rc has a 'mkdir' entry
for /data/system
* While the encryption policy matches and is applied properly in
permissive, vendor_init doesn't have enough perms to open
and run ioctl over system_data_file to check its policy
* Instead of opening the possiblity to vendors, just
bail out if we fail to open the directory
Test: m, boot r-gsi on Zenfone 6
Change-Id: I5ea37019221cd0887b8a5d7454f5a42ac01335c7
---
libfscrypt/fscrypt.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libfscrypt/fscrypt.cpp b/libfscrypt/fscrypt.cpp
index f6e97f11..bbf40c3c 100644
--- a/libfscrypt/fscrypt.cpp
+++ b/libfscrypt/fscrypt.cpp
@@ -326,7 +326,7 @@ bool EnsurePolicy(const EncryptionPolicy& policy, const std::string& directory)
android::base::unique_fd fd(open(directory.c_str(), O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC));
if (fd == -1) {
PLOG(ERROR) << "Failed to open directory " << directory;
- return false;
+ return true;
}
bool already_encrypted = fscrypt_is_encrypted(fd);
--
2.29.2

View File

@@ -0,0 +1,26 @@
From 3e0a225a2266e7096a0dd7265614a57bac20baba Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 27 Oct 2021 14:40:26 -0400
Subject: [PATCH] Disable vndklite handling
Change-Id: I4a132512471a68891f2efb59539267c35a3c3e56
---
modules/environment.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/environment.cc b/modules/environment.cc
index 82801f3..e05341b 100644
--- a/modules/environment.cc
+++ b/modules/environment.cc
@@ -29,7 +29,7 @@ bool IsLegacyDevice() {
}
bool IsVndkLiteDevice() {
- return Variables::GetValue("ro.vndk.lite").value_or("") == "true";
+ return false;
}
bool IsVndkInSystemNamespace() {
--
2.29.2

View File

@@ -0,0 +1,28 @@
From ffe0c464a2466a4a20ced24f2197af4de9c22c49 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 13 Oct 2021 10:59:09 -0400
Subject: [PATCH 1/3] Support no-bpf usecase
Change-Id: I639e15bdc321666c64683ea7ccfd42b2ba317cd2
---
server/Controllers.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/Controllers.cpp b/server/Controllers.cpp
index 1f2bac22..02a87a1b 100644
--- a/server/Controllers.cpp
+++ b/server/Controllers.cpp
@@ -289,8 +289,8 @@ void Controllers::init() {
// The expected reason we get here is a major kernel or other code bug, as such
// the probability that things will succeed on restart of netd is pretty small.
// So, let's wait a minute to at least try to limit the log spam a little bit.
- sleep(60);
- exit(1);
+ //sleep(60);
+ //exit(1);
}
gLog.info("Initializing traffic control: %" PRId64 "us", s.getTimeAndResetUs());
--
2.29.2

View File

@@ -0,0 +1,30 @@
From ec7d6c92018cf34c51ee2a2d7a4816d37f82178e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 2 Jul 2018 22:01:43 +0200
Subject: [PATCH 2/3] [device] ::Huawei Kirin 960:: accept broken rpfilter
match
How bad a security flaw is this?
People lived with rpfilter on IPv4 for a very long time...
Change-Id: I9aa63d18e54a8254133adf97bf757c03d6b66757
---
server/TetherController.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 325fc413..7b106933 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -719,7 +719,7 @@ int TetherController::setForwardRules(bool add, const char *intIface, const char
"*raw\n"
"%s %s -i %s -m rpfilter --invert ! -s fe80::/64 -j DROP\n"
"COMMIT\n", op, LOCAL_RAW_PREROUTING, intIface);
- if (iptablesRestoreFunction(V6, rpfilterCmd, nullptr) == -1 && add) {
+ if (iptablesRestoreFunction(V6, rpfilterCmd, nullptr) == -1 && add && false) {
return -EREMOTEIO;
}
--
2.29.2

View File

@@ -0,0 +1,45 @@
From 0db2b933659bb71fc5873dd09b1d2be5ce8843ca Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 29 Jul 2019 18:09:12 +0200
Subject: [PATCH 3/3] Don't fail on FTP conntracking failing
The issue has been seen on some Samsung devices.
See https://github.com/phhusson/treble_experimentations/issues/425
Thanks @zamrih for pin-pointing the issue and validating fix
Change-Id: I3d9c865eb5a4b421f9983210c2ceae62b4906234
---
server/TetherController.cpp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 7b106933..0c666b9c 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -723,13 +723,19 @@ int TetherController::setForwardRules(bool add, const char *intIface, const char
return -EREMOTEIO;
}
- std::vector<std::string> v4 = {
+ std::vector<std::string> v4Ftp = {
"*raw",
- StringPrintf("%s %s -p tcp --dport 21 -i %s -j CT --helper ftp", op,
- LOCAL_RAW_PREROUTING, intIface),
+ StringPrintf("%s %s -p tcp --dport 21 -i %s -j CT --helper ftp",
+ op, LOCAL_RAW_PREROUTING, intIface),
StringPrintf("%s %s -p tcp --dport 1723 -i %s -j CT --helper pptp", op,
LOCAL_RAW_PREROUTING, intIface),
"COMMIT",
+ };
+ if(iptablesRestoreFunction(V4, Join(v4Ftp, '\n'), nullptr) == -1) {
+ ALOGE("Failed adding iptables CT target on FTP.");
+ }
+
+ std::vector<std::string> v4 = {
"*filter",
StringPrintf("%s %s -i %s -o %s -m state --state ESTABLISHED,RELATED -g %s", op,
LOCAL_FORWARD, extIface, intIface, LOCAL_TETHER_COUNTERS_CHAIN),
--
2.29.2

View File

@@ -0,0 +1,29 @@
From 7d2b408a6aec714a5b1e64c755c54b049c6423e6 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 21 Dec 2020 19:36:54 +0100
Subject: [PATCH] Let vendor have priority over NFC config file, rather than
GSI
Thanks @mikalovtch
Change-Id: Iaee468f3b8e5c8ec90ca7e856a6526d1cbcaa33e
---
src/adaptation/nfc_config.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/adaptation/nfc_config.cc b/src/adaptation/nfc_config.cc
index 264968e..9260697 100644
--- a/src/adaptation/nfc_config.cc
+++ b/src/adaptation/nfc_config.cc
@@ -30,7 +30,7 @@ using namespace ::android::base;
namespace {
std::string searchConfigPath(std::string file_name) {
const std::vector<std::string> search_path = {
- "/product/etc/", "/odm/etc/", "/vendor/etc/", "/system_ext/etc/", "/etc/",
+ "/odm/etc/", "/vendor/etc/", "/product/etc/", "/system_ext/etc/", "/etc/",
};
for (std::string path : search_path) {
path.append(file_name);
--
2.29.2

View File

@@ -0,0 +1,54 @@
From 30e1b738f07d636015d0a4f6b4c3fd214b7b474f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 5 Oct 2021 16:17:15 -0400
Subject: [PATCH 1/6] Fallback to non-rollback resistant keys if not available
Boot on Mediatek devices was broken with:
~ Add ROLLBACK_RESISTANCE tag to key usage
Change-Id: I0ab7103c317c70779dee03dce25ba9c9da1629f4
---
KeyStorage.cpp | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/KeyStorage.cpp b/KeyStorage.cpp
index 93c5c29..ef089ad 100644
--- a/KeyStorage.cpp
+++ b/KeyStorage.cpp
@@ -378,12 +378,15 @@ static KeymasterOperation BeginKeymasterOp(Keymaster& keymaster, const std::stri
static bool encryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir,
const km::AuthorizationSet& keyParams,
const KeyBuffer& message, std::string* ciphertext) {
- km::AuthorizationSet opParams =
+ auto opParams =
km::AuthorizationSetBuilder()
- .Authorization(km::TAG_ROLLBACK_RESISTANCE)
.Authorization(km::TAG_PURPOSE, km::KeyPurpose::ENCRYPT);
+ auto opParamsWithRollback = opParams;
+ opParamsWithRollback.Authorization(km::TAG_ROLLBACK_RESISTANCE);
+
km::AuthorizationSet outParams;
- auto opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParams, &outParams);
+ auto opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParamsWithRollback, &outParams);
+ if (!opHandle) opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParams, &outParams);
if (!opHandle) return false;
auto nonceBlob = outParams.GetTagValue(km::TAG_NONCE);
if (!nonceBlob) {
@@ -410,9 +413,12 @@ static bool decryptWithKeymasterKey(Keymaster& keymaster, const std::string& dir
auto bodyAndMac = ciphertext.substr(GCM_NONCE_BYTES);
auto opParams = km::AuthorizationSetBuilder()
.Authorization(km::TAG_NONCE, nonce)
- .Authorization(km::TAG_ROLLBACK_RESISTANCE)
.Authorization(km::TAG_PURPOSE, km::KeyPurpose::DECRYPT);
- auto opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParams, nullptr);
+ auto opParamsWithRollback = opParams;
+ opParamsWithRollback.Authorization(km::TAG_ROLLBACK_RESISTANCE);
+
+ auto opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParamsWithRollback, nullptr);
+ if (!opHandle) opHandle = BeginKeymasterOp(keymaster, dir, keyParams, opParams, nullptr);
if (!opHandle) return false;
if (!opHandle.updateCompletely(bodyAndMac, message)) return false;
if (!opHandle.finish(nullptr)) return false;
--
2.29.2

View File

@@ -0,0 +1,25 @@
From a4ae95a2de9f912a4e4aca075a28aa4d0ff886b9 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 17 Feb 2018 19:39:38 +0100
Subject: [PATCH 2/6] Allow deletion of symlink
Change-Id: I9731895f88729072297f753088583aabbe6990f4
---
FsCrypt.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/FsCrypt.cpp b/FsCrypt.cpp
index 04def5c..c7de48e 100644
--- a/FsCrypt.cpp
+++ b/FsCrypt.cpp
@@ -315,6 +315,7 @@ static bool prepare_dir(const std::string& dir, mode_t mode, uid_t uid, gid_t gi
static bool destroy_dir(const std::string& dir) {
LOG(DEBUG) << "Destroying: " << dir;
if (rmdir(dir.c_str()) != 0 && errno != ENOENT) {
+ if(unlink(dir.c_str()) == 0) return true;
PLOG(ERROR) << "Failed to destroy " << dir;
return false;
}
--
2.29.2

View File

@@ -0,0 +1,44 @@
From 07bbca4e931e960e25f714079f176f31ca218b41 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 3/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 7782dd3..91a4c50 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.29.2

View File

@@ -0,0 +1,38 @@
From 33b5d2f1da3e8c775baf042f734c899af68a8a75 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 91a4c50..6c49c10 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.29.2

View File

@@ -0,0 +1,38 @@
From c8c2f84551ba8cf706b5ca1e880f216261f78100 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 7 Mar 2020 14:49:09 +0100
Subject: [PATCH 5/6] Failing to create facedata shouldn't be fatal
Some Pie vendors create it on their own, so SELinux would deny that
Also not all devices have face unlock anyway
See https://github.com/phhusson/treble_experimentations/issues/1119
---
vold_prepare_subdirs.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/vold_prepare_subdirs.cpp b/vold_prepare_subdirs.cpp
index e2afb81..de863ff 100644
--- a/vold_prepare_subdirs.cpp
+++ b/vold_prepare_subdirs.cpp
@@ -193,7 +193,7 @@ static bool prepare_subdirs(const std::string& volume_uuid, int user_id, int fla
}
auto facedata_path = vendor_de_path + "/facedata";
if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, facedata_path)) {
- return false;
+ LOG(ERROR) << "Failed preparing folder for de facedata";
}
}
}
@@ -224,7 +224,7 @@ static bool prepare_subdirs(const std::string& volume_uuid, int user_id, int fla
auto vendor_ce_path = android::vold::BuildDataVendorCePath(user_id);
auto facedata_path = vendor_ce_path + "/facedata";
if (!prepare_dir(sehandle, 0700, AID_SYSTEM, AID_SYSTEM, facedata_path)) {
- return false;
+ LOG(ERROR) << "Failed preparing folder for de facedata";
}
}
}
--
2.29.2

View File

@@ -0,0 +1,25 @@
From 425cd7837ca789af3eb79e659851b67edb87d431 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 11 Mar 2020 14:02:35 +0100
Subject: [PATCH 6/6] Every voldmanaged storage is adoptable
---
main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.cpp b/main.cpp
index 1f85fb5..52aa896 100644
--- a/main.cpp
+++ b/main.cpp
@@ -257,7 +257,7 @@ static int process_config(VolumeManager* vm, VoldConfigs* configs) {
std::string nickname(entry.label);
int flags = 0;
- if (entry.is_encryptable()) {
+ if (entry.is_encryptable() || true) {
flags |= android::vold::Disk::Flags::kAdoptable;
configs->has_adoptable = true;
}
--
2.29.2