Skip to content

Instantly share code, notes, and snippets.

@phhusson
phhusson / gist:e36d47beedd8bb9eeac01d1258ae18d7
Created January 5, 2024 16:28
Booting Android over USB
From e3e5afef1f357a86c1c5bc1386910ed3ed095d7b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 18 Jul 2023 15:01:17 +0200
Subject: [PATCH] Allow booting USB
This fixes boot USB (assuming androidboot.boot_device=ff500000.dwc3 in cmdline):
- Do prefix match rather than full match, because full path includes USB path which might be problematic
- Only take boot_devices' list of partitions to confirm that partitions are ready
(without it internal emmc's partitions will be enough to tell system that it's ready to boot, even though it isn't)
@phhusson
phhusson / generate-security-patchset.sh
Created January 2, 2024 14:20
Generating security patch zip from tags
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later
set -eux
toClean=""
cleanup() {
rm -Rf $toClean
}
trap cleanup EXIT
@phhusson
phhusson / gist:a466a56ed58475fb31ae08815d67bc16
Created December 20, 2023 15:10
pstore and logcat to usb gadget
diff --git a/device/phh/treble/vndk.rc b/device/phh/treble/vndk.rc
index fa84375..ab2ddf8 100644
--- a/device/phh/treble/vndk.rc
+++ b/device/phh/treble/vndk.rc
@@ -4,6 +4,9 @@ on post-fs
mount none /system/etc/usb_audio_policy_configuration.xml /vendor/etc/usb_audio_policy_configuration.xml bind
setprop ro.vndk.version ${persist.sys.vndk}
+on early-init
+ exec_background u:r:phhsu_daemon:s0 root -- /system/bin/logcat -f /dev/aa
@phhusson
phhusson / Caddyfile
Last active December 31, 2023 15:51
Caddy + docker-compose mastodon + ntfy for the IPv6 world
# You'll notice that webfinger is redundant with the main reverse_proxy.
# That's here in case you want to have your home page on something other than mastodon
phh.me www.phh.me {
reverse_proxy mastodon_web:3000
handle_path /ntfy/* {
rewrite * {path}
reverse_proxy ntfy:80
}
handle /.well-known/webfinger {
reverse_proxy mastodon_web:3000
@phhusson
phhusson / gist:e28eb236da6d9a1e653fcf4431f3804c
Last active September 11, 2023 16:20
Streaming AB OTA on Android
var h = URL(otaUrl).openConnection() as HttpsURLConnection
var zis = ZipInputStream(h.inputStream)
var props = ""
var offset = 0L
val FIXED_HEADER_SIZE = 30
var payload_offset = 0L
var payload_size = 0L
while(true) {
val entry = zis.nextEntry
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 0bb4022d9289..dfeb80cdb768 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -216,6 +216,8 @@ public class DisplayPolicy {
private boolean mCanSystemBarsBeShownByUser;
private boolean mNavButtonForcedVisible;
+ private vendor.mediatek.hardware.mtkpower.V1_1.IMtkPerf mMtkPerf;
+
@phhusson
phhusson / gist:4bf5a5bcc910c3d1a372b1fb19e71daf
Created November 26, 2022 14:51
phh's GPU passthrough setup
#!/bin/bash
systemctl stop nvidia-persistenced.service
echo 0000:23:00.0 > /sys/bus/pci/devices/0000:23:00.0/driver/unbind
echo 0000:23:00.1 > /sys/bus/pci/devices/0000:23:00.1/driver/unbind
modprobe macvtap
ip link add link enp39s0 name eth0.3 type macvtap mode bridge
ip link set eth0.3 up
@phhusson
phhusson / hello.sh
Created October 24, 2022 08:44
Upscaling/Improving BDs in CBZ/CBR format using Real-CUGAN
#!/bin/bash
set -ex
rm -Rf in out list-all-files global-dead
v="$(readlink -f -- "$1")"
ext="$(echo "$v" |rev | cut -d . -f 1 |rev)"
outdir="$(dirname "$v" |sed -E 's;/where/are/originals/;;g')"
@phhusson
phhusson / kernel.diff
Created October 14, 2022 12:40
[Amlogic s905x2] Remuxing serial/uart port over sdcard/microsd connector
diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
index 45947c1031c4..95006ae7c33a 100644
--- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
@@ -1536,6 +1556,14 @@ mux {
bias-disable;
};
};
+
+ uart_ao_a_c_pins: uart-a-ao-c {
@phhusson
phhusson / gist:662af3573ad4fc91bb62e5fe7cde7250
Created March 14, 2022 13:12
Add rickroll Dialer option. Add rick.webm in assets
From f07ca2a26dcb0cc797dcc6fc0d2d4f16b89c481e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Mon, 14 Mar 2022 09:09:28 -0400
Subject: [PATCH] Add a rickroll button in heads-up notification to rickroll
caller
Change-Id: Ibe72535fb3e93f69a531723dc96ede05663ee251
---
assets/rick.webm | Bin 0 -> 1232413 bytes
.../NotificationBroadcastReceiver.java | 145 ++++++++++++++++++