pipa:vendorsetup: Add automatic Tablet FWB patch application
* To Fix the bug in which the device forgets orientation after locking the device.
This commit is contained in:
31
patches/tablet-fwb.patch
Executable file
31
patches/tablet-fwb.patch
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java
|
||||||
|
index 4d68c8c5094f..1b12fbf3a54b 100644
|
||||||
|
--- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java
|
||||||
|
+++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java
|
||||||
|
@@ -734,7 +734,7 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
|
||||||
|
if (getExpanded()) {
|
||||||
|
return onHeader || (yDiff < 0 && isTouchInQsArea(x, y));
|
||||||
|
} else {
|
||||||
|
- return onHeader;
|
||||||
|
+ return onHeader || (yDiff > mTouchSlop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
|
||||||
|
index f7d88d2b5eed..6190e9610833 100644
|
||||||
|
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
|
||||||
|
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
|
||||||
|
@@ -552,6 +552,13 @@ public class DisplayRotation {
|
||||||
|
final int lastOrientation = mLastOrientation;
|
||||||
|
@Surface.Rotation
|
||||||
|
int rotation = rotationForOrientation(lastOrientation, oldRotation);
|
||||||
|
+ //Preserve locked user rotation across screen off/on and keyguard
|
||||||
|
+ if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) {
|
||||||
|
+ rotation = mUserRotation;
|
||||||
|
+ ProtoLog.v(WM_DEBUG_ORIENTATION,
|
||||||
|
+ "Forcing locked user rotation=%s (%d)",
|
||||||
|
+ Surface.rotationToString(rotation), rotation);
|
||||||
|
+ }
|
||||||
|
// Use the saved rotation for tabletop mode, if set.
|
||||||
|
if (mFoldController != null && mFoldController.shouldRevertOverriddenRotation()) {
|
||||||
|
int prevRotation = rotation;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# ?? Terminal Colors
|
# Terminal Colors
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
@@ -18,7 +18,7 @@ divider() { echo -e "${BOLD}─────────────────
|
|||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# clone_if_missing + clean_clone
|
# clone_if_missing + clean_clone
|
||||||
# ──────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
clone_if_missing() {
|
clone_if_missing() {
|
||||||
local repo_url=$1 branch=$2 target_dir=$3
|
local repo_url=$1 branch=$2 target_dir=$3
|
||||||
[ -z "$repo_url" ] || [ -z "$branch" ] || [ -z "$target_dir" ] && {
|
[ -z "$repo_url" ] || [ -z "$branch" ] || [ -z "$target_dir" ] && {
|
||||||
@@ -58,7 +58,7 @@ clean_clone() {
|
|||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# Kernel Repo (fixed to Normal Perf)
|
# Kernel Repo (fixed to Normal Perf)
|
||||||
# ──────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
divider
|
divider
|
||||||
info "Cloning kernel into kernel/xiaomi/sm8250..."
|
info "Cloning kernel into kernel/xiaomi/sm8250..."
|
||||||
clone_if_missing "https://github.com/gensis01/android_kernel_xiaomi_sm8250" "bpf-ksu" "kernel/xiaomi/sm8250"
|
clone_if_missing "https://github.com/gensis01/android_kernel_xiaomi_sm8250" "bpf-ksu" "kernel/xiaomi/sm8250"
|
||||||
@@ -66,7 +66,7 @@ divider
|
|||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# Other Repos
|
# Other Repos
|
||||||
# ──────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
info "Setting up other repositories..."
|
info "Setting up other repositories..."
|
||||||
clone_if_missing "https://github.com/gensis01/android_device_xiaomi_sm8250-common" "16" "device/xiaomi/sm8250-common"
|
clone_if_missing "https://github.com/gensis01/android_device_xiaomi_sm8250-common" "16" "device/xiaomi/sm8250-common"
|
||||||
clone_if_missing "https://github.com/gensis01/vendor_xiaomi_sm8250-common" "16" "vendor/xiaomi/sm8250-common"
|
clone_if_missing "https://github.com/gensis01/vendor_xiaomi_sm8250-common" "16" "vendor/xiaomi/sm8250-common"
|
||||||
@@ -74,13 +74,15 @@ clone_if_missing "https://github.com/gensis01/vendor_xiaomi_pipa" "16" "vendor/x
|
|||||||
clone_if_missing "https://github.com/LineageOS/android_hardware_lineage_compat" "lineage-23.0" "hardware/lineage/compat"
|
clone_if_missing "https://github.com/LineageOS/android_hardware_lineage_compat" "lineage-23.0" "hardware/lineage/compat"
|
||||||
clone_if_missing "https://github.com/LineageOS/android_hardware_lineage_interfaces" "lineage-23.0" "hardware/lineage/interfaces"
|
clone_if_missing "https://github.com/LineageOS/android_hardware_lineage_interfaces" "lineage-23.0" "hardware/lineage/interfaces"
|
||||||
clone_if_missing "https://github.com/LineageOS/android_hardware_lineage_livedisplay" "lineage-23.0" "hardware/lineage/livedisplay"
|
clone_if_missing "https://github.com/LineageOS/android_hardware_lineage_livedisplay" "lineage-23.0" "hardware/lineage/livedisplay"
|
||||||
clean_clone "https://github.com/PocoF3Releases/hardware_xiaomi.git" "aosp-16" "hardware/xiaomi"
|
clone_if_missing "https://github.com/PocoF3Releases/device_qcom_wfd.git" "bka" "device/qcom/wfd"
|
||||||
|
clone_if_missing "https://github.com/PocoF3Releases/vendor_qcom_wfd.git" "bka" "vendor/qcom/wfd"
|
||||||
|
clean_clone "https://github.com/gensis01/hardware_xiaomi.git" "aosp-16" "hardware/xiaomi"
|
||||||
clean_clone "https://github.com/PocoF3Releases/packages_resources_devicesettings.git" "aosp-16" "packages/resources/devicesettings"
|
clean_clone "https://github.com/PocoF3Releases/packages_resources_devicesettings.git" "aosp-16" "packages/resources/devicesettings"
|
||||||
divider
|
divider
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# Apply Recovery Patch (non-fatal warning only)
|
# Apply Recovery Patch (non-fatal warning only)
|
||||||
# ──────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
apply_recovery_patch() {
|
apply_recovery_patch() {
|
||||||
local root_dir
|
local root_dir
|
||||||
root_dir=$(pwd)
|
root_dir=$(pwd)
|
||||||
@@ -100,10 +102,8 @@ apply_recovery_patch() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean DOS line endings from the patch file
|
|
||||||
tr -d '\r' < "$patch_file" > "$temp_patch"
|
tr -d '\r' < "$patch_file" > "$temp_patch"
|
||||||
|
|
||||||
# Check if the patch is already applied by looking for its commit
|
|
||||||
local patch_fingerprint
|
local patch_fingerprint
|
||||||
patch_fingerprint=$(sha1sum "$temp_patch" | awk '{print $1}')
|
patch_fingerprint=$(sha1sum "$temp_patch" | awk '{print $1}')
|
||||||
if git log -1 --pretty=%B | grep -q "$patch_fingerprint"; then
|
if git log -1 --pretty=%B | grep -q "$patch_fingerprint"; then
|
||||||
@@ -113,7 +113,6 @@ apply_recovery_patch() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Attempt to apply the patch. If it fails, warn the user and continue.
|
|
||||||
if git apply --check --ignore-whitespace "$temp_patch" >/dev/null 2>&1; then
|
if git apply --check --ignore-whitespace "$temp_patch" >/dev/null 2>&1; then
|
||||||
git apply --ignore-whitespace "$temp_patch"
|
git apply --ignore-whitespace "$temp_patch"
|
||||||
git add .
|
git add .
|
||||||
@@ -123,15 +122,13 @@ apply_recovery_patch() {
|
|||||||
warn "White recovery patch is skipped, may cause problems in recovery."
|
warn "White recovery patch is skipped, may cause problems in recovery."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup and return to the original directory
|
|
||||||
rm -f "$temp_patch"
|
rm -f "$temp_patch"
|
||||||
cd "$root_dir"
|
cd "$root_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# Setup firmware: download, extract, move whole 'radio' folder
|
# Setup firmware
|
||||||
# (runs after apply_recovery_patch)
|
# ──────────────────────────────────────────────────────────────
|
||||||
# ──────────────────────────────────────────────
|
|
||||||
setup_firmware() {
|
setup_firmware() {
|
||||||
local root_dir
|
local root_dir
|
||||||
root_dir=$(pwd)
|
root_dir=$(pwd)
|
||||||
@@ -142,13 +139,11 @@ setup_firmware() {
|
|||||||
|
|
||||||
info "Setting up firmware..."
|
info "Setting up firmware..."
|
||||||
|
|
||||||
# Ensure target directory exists
|
|
||||||
mkdir -p "$target_dir" || {
|
mkdir -p "$target_dir" || {
|
||||||
error "Failed to create target directory: $target_dir"
|
error "Failed to create target directory: $target_dir"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove old radio folder if present
|
|
||||||
if [ -d "$target_dir/radio" ]; then
|
if [ -d "$target_dir/radio" ]; then
|
||||||
warn "Removing existing radio folder..."
|
warn "Removing existing radio folder..."
|
||||||
rm -rf "$target_dir/radio" || {
|
rm -rf "$target_dir/radio" || {
|
||||||
@@ -157,7 +152,6 @@ setup_firmware() {
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download firmware zip
|
|
||||||
if command -v curl >/dev/null 2>&1; then
|
if command -v curl >/dev/null 2>&1; then
|
||||||
info "Downloading firmware (curl)..."
|
info "Downloading firmware (curl)..."
|
||||||
curl -L --fail -o "$tmp_zip" "$firmware_url" || {
|
curl -L --fail -o "$tmp_zip" "$firmware_url" || {
|
||||||
@@ -177,7 +171,6 @@ setup_firmware() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare temp extract dir
|
|
||||||
rm -rf "$tmp_extract"
|
rm -rf "$tmp_extract"
|
||||||
mkdir -p "$tmp_extract" || {
|
mkdir -p "$tmp_extract" || {
|
||||||
error "Failed to create temp extract dir: $tmp_extract"
|
error "Failed to create temp extract dir: $tmp_extract"
|
||||||
@@ -185,7 +178,6 @@ setup_firmware() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extract to temp dir
|
|
||||||
if command -v unzip >/dev/null 2>&1; then
|
if command -v unzip >/dev/null 2>&1; then
|
||||||
info "Extracting firmware into temporary location..."
|
info "Extracting firmware into temporary location..."
|
||||||
unzip -q -o "$tmp_zip" -d "$tmp_extract" || {
|
unzip -q -o "$tmp_zip" -d "$tmp_extract" || {
|
||||||
@@ -209,7 +201,6 @@ setup_firmware() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find the radio directory inside the extracted tree
|
|
||||||
local radio_dir
|
local radio_dir
|
||||||
radio_dir=$(find "$tmp_extract" -type d -name radio -print -quit)
|
radio_dir=$(find "$tmp_extract" -type d -name radio -print -quit)
|
||||||
|
|
||||||
@@ -220,7 +211,6 @@ setup_firmware() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Move the whole radio directory into target_dir
|
|
||||||
info "Moving radio directory into $target_dir..."
|
info "Moving radio directory into $target_dir..."
|
||||||
mv "$radio_dir" "$target_dir"/ || {
|
mv "$radio_dir" "$target_dir"/ || {
|
||||||
error "Failed to move radio directory to $target_dir"
|
error "Failed to move radio directory to $target_dir"
|
||||||
@@ -229,25 +219,53 @@ setup_firmware() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cleanup leftover extracted files (the moved radio dir is no longer in tmp_extract)
|
|
||||||
rm -f "$tmp_zip"
|
rm -f "$tmp_zip"
|
||||||
rm -rf "$tmp_extract"
|
rm -rf "$tmp_extract"
|
||||||
|
|
||||||
success "Firmware setup complete: moved 'radio' directory to $target_dir/radio"
|
success "Firmware setup complete: moved 'radio' directory to $target_dir/radio"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────
|
||||||
|
# Apply FWB Patch (Tablet, Local)
|
||||||
|
# ──────────────────────────────────────────────────────────────
|
||||||
|
apply_fwb_patch() {
|
||||||
|
local root_dir
|
||||||
|
root_dir=$(pwd)
|
||||||
|
local target_dir="frameworks/base"
|
||||||
|
local patch_file="$root_dir/device/xiaomi/pipa/patches/tablet-fwb.patch"
|
||||||
|
|
||||||
|
info "Applying Tablet FWB patch from local repo..."
|
||||||
|
|
||||||
|
if [ ! -f "$patch_file" ]; then
|
||||||
|
error "Patch file not found: $patch_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! cd "$target_dir"; then
|
||||||
|
error "Could not enter $target_dir to apply patch."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if git apply --check --ignore-whitespace "$patch_file" >/dev/null 2>&1; then
|
||||||
|
git apply --ignore-whitespace "$patch_file"
|
||||||
|
success "Tablet FWB patch applied successfully."
|
||||||
|
else
|
||||||
|
warn "Tablet FWB patch could not be applied (may already be applied or conflict)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$root_dir"
|
||||||
|
}
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
# Run Patch Setup
|
# Run Patch Setup
|
||||||
# ──────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
ROOT_DIR=$(pwd)
|
ROOT_DIR=$(pwd)
|
||||||
DEVICE_PATH="${ROOT_DIR}/device/xiaomi/pipa"
|
DEVICE_PATH="${ROOT_DIR}/device/xiaomi/pipa"
|
||||||
mkdir -p "$DEVICE_PATH/source-patches"
|
mkdir -p "$DEVICE_PATH/source-patches"
|
||||||
|
|
||||||
# Apply patch for white screen recovery issue
|
|
||||||
apply_recovery_patch
|
apply_recovery_patch
|
||||||
|
|
||||||
# Download fw and place it correctly
|
|
||||||
setup_firmware
|
setup_firmware
|
||||||
|
apply_fwb_patch
|
||||||
|
|
||||||
echo "-------------------------------------"
|
echo "-------------------------------------"
|
||||||
echo " Setup complete! "
|
echo " Setup complete! "
|
||||||
|
|||||||
Reference in New Issue
Block a user