Compare commits

...
Sign in to create a new pull request.

16 commits

Author SHA1 Message Date
e1f3a82a4f gsi: init: Support reading OS version and SPL from vbmeta
This allows installing a non-stock GSI kernel without also breaking
keymaster / keymint.
2025-06-07 17:00:47 -04:00
5ee1973ddf gsi: Rename keylayouts so they don't get picked up automatically 2025-03-16 13:47:49 -04:00
25c1317174 sysbta: Update vintf manifests to use modules 2025-03-16 13:47:35 -04:00
e759d9cc2c gsi: init: Treat virtual sensors as real on Unihertz Jelly Max 2024-12-21 11:24:31 -05:00
6f8c4c3b7e gsi: Update trustkernel hack for A15 vendor 2024-10-09 17:56:24 -04:00
7af0ffe86a gsi: Add global overlay to enable vibration strength settings 2024-10-08 19:31:50 -04:00
79077d4941 gsi: Ignore predefined vibrator effects on Jelly Max
This allows the framework to fall back to software ones.
2024-10-07 22:09:04 -04:00
b1c61482d0 gsi: Enable MTK GED KPI to stop laaaaaag 2024-10-06 16:24:54 -04:00
660c21e707 gsi: Install sensitive_spn.xml from Lineage 2024-10-06 14:28:57 -04:00
ca90bb20c2 Revert "gsi: Set default dialer to org.fossify.phone"
This reverts commit c9dde19f0a.
2024-10-06 14:06:36 -04:00
1062c77ff9 gsi: init: Exclude sysbta for AIDL audio HAL
It won't work for them. Hopefully they don't need it. If they do, we'll
have to figure something out later.
2024-10-06 10:18:51 -04:00
566d310f02 gsi: Ignore gravity sensor on Jelly Max
MTK's sensor fusion is broken somehow for this one sensor. Ignore it to
use AOSP SensorFusion.
2024-10-06 09:08:39 -04:00
bebcfb86db gsi: Expose all cameras to user apps
Requires phh's f/av patch
2024-10-05 16:41:17 -04:00
c9dde19f0a gsi: Set default dialer to org.fossify.phone 2024-10-05 10:51:10 -04:00
ec7ea246d8 Enable qemu.hw.mainkeys on Jelly Max 2024-10-05 07:58:00 -04:00
66ae7c11e3 init: Watchdog MTK RIL daemon
On G99 devices the RIL daemon may crash and fail to restart because the
interface is not registered to init properly. As a workaround, we
basically watchdog the daemon in init.
2024-09-22 11:01:23 -04:00
15 changed files with 122 additions and 20 deletions

View file

@ -1,6 +1,6 @@
cc_binary {
name: "android.hardware.bluetooth.audio-service-system",
vintf_fragments: ["bluetooth_audio_system.xml"],
vintf_fragment_modules: ["bluetooth_audio_system.xml"],
init_rc: ["android.hardware.bluetooth.audio-service-system.rc"],
relative_install_path: "hw",
srcs: [
@ -45,3 +45,8 @@ cc_binary {
"android.hardware.audio@7.1-impl-system",
],
}
vintf_fragment {
name: "bluetooth_audio_system.xml",
src: "bluetooth_audio_system.xml",
}

View file

@ -29,7 +29,8 @@ SELINUX_IGNORE_NEVERALLOWS := true
# Overlay
PRODUCT_PACKAGES += \
GsiFrameworkResTarget \
GsiLauncher3Target
GsiLauncher3Target \
GsiSettingsTarget
# Device-specific overlays from phhusson
include vendor/hardware_overlay/overlay.mk
@ -91,3 +92,8 @@ PRODUCT_PACKAGES += \
# Iwlan (VoWiFi)
PRODUCT_PACKAGES += \
Iwlan
# Lineage SensitivePhoneNumbers
PRODUCT_PACKAGES += \
sensitive_pn.xml

View file

@ -5,6 +5,8 @@ cc_binary {
"init_gsi.cpp",
"quirks.cpp",
"quirks/no_sysbta.cpp",
// Per-device / SoC preset properties
"quirks/preset_props.cpp",

View file

@ -10,3 +10,16 @@ on load_persist_props_action
on property:persist.sys.gsi.hw.mainkeys=*
setprop qemu.hw.mainkeys ${persist.sys.gsi.hw.mainkeys}
# Some MTK RIL implementations crash and fail to restart because they aren't associated
# with the HIDL interface properly.
# As a workaround, we basically watchdog the ril daemon service here.
# Note that we shall only bounce the service after it has been started for the first time
# by vendor code. We use a property to record that.
on property:init.svc.vendor.ril-daemon-mtk=running
setprop init.svc.vendor.ril-daemon-mtk-first-started true
setprop init.svc.vendor.ril-daemon-mtk-restarting false
on property:init.svc.zygote=running && property:init.svc.vendor.ril-daemon-mtk-first-started=true && property:init.svc.vendor.ril-daemon-mtk-restarting=false && property:init.svc.vendor.ril-daemon-mtk=stopped
setprop init.svc.vendor.ril-daemon-mtk-restarting true
exec_background u:r:init_gsi:s0 root -- /system/bin/sh -c "sleep 15 && setprop ctl.start vendor.ril-daemon-mtk"

21
init/quirks/no_sysbta.cpp Normal file
View file

@ -0,0 +1,21 @@
#include "../quirks.h"
#include <android-base/properties.h>
#include <filesystem>
using namespace std;
// sysbta is unsupported for AIDL audio HAL -- hopefully they won't need it either
// If they do, we'll figure something out later...
class NoSysbtaForAidl : DeviceQuirk {
public:
bool ShouldRun() {
// AIDL audio HAL has no audio_policy_configuration.xml
return !filesystem::exists("/vendor/etc/audio_policy_configuration.xml");
}
void Run() {
android::base::SetProperty("persist.bluetooth.system_audio_hal.enabled", "false");
}
};
LOAD_QUIRK(NoSysbtaForAidl);

View file

@ -4,10 +4,20 @@
// Disable navbar by default on devices known to have physical keys
PRESET_PROPS(
FP_STARTS_WITH("Unihertz/Jelly") || FP_STARTS_WITH("Unihertz/Atom"),
(FP_STARTS_WITH("Unihertz/Jelly") && !FP_STARTS_WITH("Unihertz/Jelly_Max")) || FP_STARTS_WITH("Unihertz/Atom"),
"persist.sys.gsi.hw.mainkeys", "1"
);
// Unihertz Jelly Max: Broken "fake" gravity sensor. Ignore it to use AOSP's SensorFusion
// Also ignore broken inbuilt vibrator effects
// Also it uses "/virtual" instance name for real biometric sensors, for some reason.
PRESET_PROPS(
FP_STARTS_WITH("Unihertz/Jelly_Max"),
"persist.sys.phh.sensor_filter", "mtk:gravity",
"persist.sys.phh.ignore_vibrator_effects", "true",
"persist.sys.phh.virtual_sensors_are_real", "true"
);
// Some xiaomi devices: Override default network mode to enable 5G
PRESET_PROPS(
FP_STARTS_WITH("Redmi/gauguin"),
@ -19,3 +29,9 @@ PRESET_PROPS(
PROP_STARTS_WITH("ro.boot.hardware", "qcom"),
"persist.sys.phh.disable_stereo_voip", "true"
);
// MediaTek GED
PRESET_PROPS(
PROP_STARTS_WITH("ro.hardware.hwcomposer", "mtk"),
"persist.sys.phh.mtk_ged_kpi", "1"
);

View file

@ -16,16 +16,13 @@
using namespace std;
#define AVB_PROP_OS_VERSION "com.android.build.boot.os_version"
#define AVB_PROP_SPL "com.android.build.boot.security_patch"
map<int, string> api_to_version{
{30, "11"}, {31, "12"}, {32, "12L"},
{33, "13"}, {34, "14"}
{33, "13"}, {34, "14"}, {35, "15"},
};
optional<pair<string, string>> try_get_spl() {
string boot_part = "/dev/block/by-name/boot" + android::base::GetProperty("ro.boot.slot_suffix", "");
optional<pair<string, string>> try_get_spl(string part_name, string os_version_prop, string spl_prop) {
string boot_part = "/dev/block/by-name/" + part_name + android::base::GetProperty("ro.boot.slot_suffix", "");
// Read from AVB footer, https://github.com/TrebleDroid/device_phh_treble/blob/android-13.0/fixSPL/getSPL.c
// First read into memory
@ -36,23 +33,43 @@ optional<pair<string, string>> try_get_spl() {
read(fd, buf, size);
// Search for AVB footer property directly in the binary
char* p = (char *) memmem(buf, size, AVB_PROP_OS_VERSION, sizeof(AVB_PROP_OS_VERSION));
char* p = (char *) memmem(buf, size, os_version_prop.c_str(), os_version_prop.length() + 1);
if (p == nullptr)
return nullopt;
p += sizeof(AVB_PROP_OS_VERSION);
p += os_version_prop.length() + 1;
string os_version(p);
p = (char *) memmem(buf, size, AVB_PROP_SPL, sizeof(AVB_PROP_SPL));
p = (char *) memmem(buf, size, spl_prop.c_str(), spl_prop.length() + 1);
if (p == nullptr)
return nullopt;
p += sizeof(AVB_PROP_SPL);
p += spl_prop.length() + 1;
string spl(p);
return make_pair(os_version, spl);
}
optional<pair<string, string>> get_spl() {
// Read init_boot SPL and version from vbmeta
// Some MTK devices's "root of trust" is boot, but we sometimes can't access boot
// VBMETA does not contain info about boot either; the next best thing is init_boot
auto res = try_get_spl("vbmeta", "com.android.build.init_boot.os_version", "com.android.build.init_boot.security_patch");
if (res) {
return res;
}
// If init_boot doesn't exist, use the system partition's info from vbmeta
// Note that this might not be accepted on some MTK devices
res = try_get_spl("vbmeta", "com.android.build.system.os_version", "com.android.build.system.security_patch");
if (res) {
return res;
}
// Try reading OS version and SPL from boot as a final fallback
return try_get_spl("boot", "com.android.build.boot.os_version", "com.android.build.boot.security_patch");
}
class MtkTkQuirk : DeviceQuirk {
public:
bool ShouldRun() {
@ -65,16 +82,19 @@ public:
android::base::SetProperty("ro.keymaster.brn", "Android");
android::base::SetProperty("ro.keymaster.mod", "AOSP on ARM64");
string release = android::base::GetProperty("ro.vendor.build.version.release", "11");
string spl = android::base::GetProperty("ro.vendor.build.version.security_patch", "2023-01-05");
auto res = try_get_spl();
string release = android::base::GetProperty("ro.vendor.build.version.release", "11");
string spl = android::base::GetProperty("ro.vendor.build.version.security_patch", "2023-01-05");
// Try reading version and SPL from vbmeta or boot
auto res = get_spl();
if (res) {
release = res->first;
spl = res->second;
}
}
// With GRF, release version from vendor or boot may not be what we need
// Because the actual first release version might not be the vendor's API level
int first_api_level = android::base::GetIntProperty("ro.product.first_api_level", 30);
if (api_to_version.count(first_api_level) > 0) {
string release_from_first_api = api_to_version[first_api_level];

View file

@ -0,0 +1,5 @@
runtime_resource_overlay {
name: "GsiSettingsTarget",
sdk_version: "current",
product_specific: true,
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.settings.overlay.gsi.target">
<overlay
android:isStatic="true"
android:priority="350"
android:targetPackage="com.android.settings" />
</manifest>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<integer name="config_vibration_supported_intensity_levels">3</integer>
</resources>

View file

@ -2,6 +2,6 @@ LOCAL_PATH := device/peter/gsi/quirks
# Keylayout quirks
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/keylayout/unihertz-fingerprint_key.kl:$(TARGET_COPY_OUT_SYSTEM_EXT)/quirks/keylayout/unihertz-fingerprint_key.kl \
$(LOCAL_PATH)/keylayout/unihertz-mtk-kpd.kl:$(TARGET_COPY_OUT_SYSTEM_EXT)/quirks/keylayout/unihertz-mtk-kpd.kl \
$(LOCAL_PATH)/keylayout/unihertz-mtk-tpd.kl:$(TARGET_COPY_OUT_SYSTEM_EXT)/quirks/keylayout/unihertz-mtk-tpd.kl \
$(LOCAL_PATH)/keylayout/unihertz-fingerprint_key.kl.raw:$(TARGET_COPY_OUT_SYSTEM_EXT)/quirks/keylayout/unihertz-fingerprint_key.kl \
$(LOCAL_PATH)/keylayout/unihertz-mtk-kpd.kl.raw:$(TARGET_COPY_OUT_SYSTEM_EXT)/quirks/keylayout/unihertz-mtk-kpd.kl \
$(LOCAL_PATH)/keylayout/unihertz-mtk-tpd.kl.raw:$(TARGET_COPY_OUT_SYSTEM_EXT)/quirks/keylayout/unihertz-mtk-tpd.kl \

View file

@ -10,6 +10,8 @@ persist.dbg.wfc_avail_ovr=1
persist.dbg.allow_ims_off=1
# Enable hw keys by default (unless overridden by user)
persist.sys.gsi.hw.mainkeys=0
# Expose all cameras to user apps
persist.sys.phh.include_all_cameras=true
# Enable system-side generic bluetooth audio HAL
persist.bluetooth.system_audio_hal.enabled=true
# Set commonly-supported Bluetooth profiles to enabled