diff --git a/patchForAndroid15/apply-patch.sh b/patchForAndroid15/apply-patch.sh index 1e0bacf201373f76bd8f3f5ebf20c28a83272b0c..daeb6426807a60958585edfb8b5ad979f35498d9 100755 --- a/patchForAndroid15/apply-patch.sh +++ b/patchForAndroid15/apply-patch.sh @@ -1,13 +1,12 @@ # To apply all android patches to aosp code. -# ./apply-patch.sh [aosp path] aosp15r17-patch +# ./apply-patch.sh [aosp path] #!/bin/bash -TAG="$2" -TARGET_DIR="$1" -SOURCE_DIR="$(pwd)/${TAG}" +AOSP_DIR="$1" +SOURCE_DIR="$(pwd)" -if [ ! -d "$TARGET_DIR" ];then - echo "Error: Target directory $TARGET_DIR does not exist" +if [ ! -d "$AOSP_DIR" ];then + echo "Error: Target directory $AOSP_DIR does not exist" exit 1 fi @@ -16,7 +15,7 @@ find "$SOURCE_DIR" -type f -name "*.patch" | while read -r patch_file; do rel_path="${subdir#$SOURCE_DIR/}" - target_subdir="$TARGET_DIR/$rel_path" + target_subdir="$AOSP_DIR/$rel_path" patch_name=$(basename "$patch_file") diff --git a/patchForAndroid15/frameworks/native/frameworks-native-0001.patch b/patchForAndroid15/frameworks/native/frameworks-native-0001.patch index 7b6d69fb3e1910df9fd92abe9d8dd743d6bd5489..97bf2733efeccd07e86b32bbe623e4d9655a6b98 100644 --- a/patchForAndroid15/frameworks/native/frameworks-native-0001.patch +++ b/patchForAndroid15/frameworks/native/frameworks-native-0001.patch @@ -44,21 +44,19 @@ index 5e7f1510bc..83bae2c75f 100644 if (result != 0) { android_errorWriteLog(0x534e4554, "121035042"); diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp -index 1ebe597..2bcd4db 100644 +index 1ebe5973fa..2b3ac1c949 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp -@@ -142,9 +142,11 @@ auto GraphicBufferAllocator::allocate(const AllocationRequest& request) -> Alloc - (int)mMapper.getMapperVersion()); - return result; - } -+ // 解决AOSP15黑屏问题 -+ const uint64_t usage = (request.usage & ~static_cast((1 << 10) | (1 << 13))); - // If there's no additional options, fall back to previous allocate getMapperVersion - result.status = mAllocator->allocate(request.requestorName, request.width, request.height, -- request.format, request.layerCount, request.usage, -+ request.format, request.layerCount, usage, - &result.stride, &result.handle, request.importBuffer); - } +@@ -143,8 +143,9 @@ auto GraphicBufferAllocator::allocate(const AllocationRequest& request) -> Alloc + return result; + } + // If there's no additional options, fall back to previous allocate version ++ const uint64_t usage = (request.usage & ~static_cast((1 << 10) | (1 << 13))) + result.status = mAllocator->allocate(request.requestorName, request.width, request.height, +- request.format, request.layerCount, request.usage, ++ request.format, request.layerCount, usage, + &result.stride, &result.handle, request.importBuffer); + } diff --git a/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp b/services/surfaceflinger/Scheduler/RefreshRateSelector.cpp index ab9014e418..8bce49cb41 100644 diff --git a/patchForAndroid15/reverse-patch.sh b/patchForAndroid15/reverse-patch.sh index 982bac90b0d1255a096fcb1f516368511858f374..e22d223fc33d14ffb00590b576873d32d5770c38 100755 --- a/patchForAndroid15/reverse-patch.sh +++ b/patchForAndroid15/reverse-patch.sh @@ -1,29 +1,59 @@ -# To reverse all android patches from aosp code. -# ./reverse-patch.sh [aosp path] aosp15r17-patch +# To reverse all modifications from aosp code. +# ./reverse-patch.sh [aosp path] patch: remove modification of repositories in AOSP based on existed patches +# ./reverse-patch.sh [aosp path] all: remove all modification of repositories in AOSP + #!/bin/bash -TAG="$2" -TARGET_DIR="$1" -SOURCE_DIR="$(pwd)/${TAG}" +reverse_by_patch() { + SOURCE_DIR="$(pwd)" + find "$SOURCE_DIR" -type f -name "*.patch" | while read -r patch_file; do + subdir=$(dirname "$patch_file") + + rel_path="${subdir#$SOURCE_DIR/}" + + target_subdir="$AOSP_DIR/$rel_path" + + if [ ! -d "$target_subdir" ];then + echo "Warning: Target Subdirectory $target_subdir does not exist, skipping" + continue + fi + + echo "Reversing directory $target_subdir" -if [ ! -d "$TARGET_DIR" ];then - echo "Error: Target directory $TARGET_DIR does not exist" - exit 1 -fi + (cd "$target_subdir" && git reset --hard >/dev/null 2>&1 && git clean -fdx >/dev/null 2>&1) + done +} -find "$SOURCE_DIR" -type f -name "*.patch" | while read -r patch_file; do - subdir=$(dirname "$patch_file") +reverse_all_repository() { + REPO_DIR="$AOSP_DIR/.repo/projects" + find "$REPO_DIR" -maxdepth 10 -type d -name "*.git" | while read -r repo; do + if [[ "$repo" == *.git ]]; then + repo="${repo%.git}" - rel_path="${subdir#$SOURCE_DIR/}" + relative_path=$(realpath --relative-to="$REPO_DIR" "$repo") - target_subdir="$TARGET_DIR/$rel_path" + target_subdir="$AOSP_DIR/$relative_path" - if [ ! -d "$target_subdir" ];then - echo "Warning: Target Subdirectory $target_subdir does not exist, skipping" - continue + echo "Reversing directory $target_subdir" + + (cd "$target_subdir" && git reset --hard >/dev/null 2>&1 && git clean -fdx >/dev/null 2>&1) + fi + done +} + +main() { + AOSP_DIR="$1" + + if [ ! -d "$AOSP_DIR" ]; then + echo "Error: Target directory $AOSP_DIR does not exist" + exit 1 fi - echo "Reversing directory $target_subdir" + if [ $2 = "patch" ]; then + reverse_by_patch + elif [ $2 = "all" ]; then + reverse_all_repository + fi +} - (cd "$target_subdir" && git reset --hard >/dev/null 2>&1 && git clean -fdx >/dev/null 2>&1) -done +main $1 $2 diff --git a/patchForAndroid15/system/core/system-core-0001.patch b/patchForAndroid15/system/core/system-core-0001.patch index d823579a37aa78e0eb3881ce1b91fc2d6acfcaae..9a991df3bf96ad864a9281eaa4c25d2de6e0acfd 100644 --- a/patchForAndroid15/system/core/system-core-0001.patch +++ b/patchForAndroid15/system/core/system-core-0001.patch @@ -186,281 +186,6 @@ index 6c8089926..36fa8e4b7 100644 LOG(INFO) << "init second stage started!"; SelinuxSetupKernelLogging(); -diff --git a/init/ipconfigstore/Android.bp b/init/ipconfigstore/Android.bp -new file mode 100644 -index 000000000..34ed932dd ---- /dev/null -+++ b/init/ipconfigstore/Android.bp -@@ -0,0 +1,8 @@ -+cc_binary { -+ name: "ipconfigstore", -+ srcs: ["*.cc"], -+ cflags: ["-Wall", "-Werror"], -+ shared_libs: ["libbase"], -+ vendor: true, -+} -+ -diff --git a/init/ipconfigstore/data.cc b/init/ipconfigstore/data.cc -new file mode 100644 -index 000000000..b87e77069 ---- /dev/null -+++ b/init/ipconfigstore/data.cc -@@ -0,0 +1,65 @@ -+#include -+#include -+#include -+#include -+#include -+ -+#include "data.h" -+ -+uint16_t convertBigEndianUInt16(uint16_t value) -+{ -+ union { uint16_t value; unsigned char data[2]; } aux = { 0x4142 }; -+ -+ if (aux.data[0] == 0x41) -+ { -+ return value; -+ } -+ -+ aux.data[0] = (value >> 8) & 0xff; -+ aux.data[1] = value & 0xff; -+ -+ return aux.value; -+} -+ -+uint32_t convertBigEndianUInt32(uint32_t value) -+{ -+ union { uint32_t value; unsigned char data[4]; } aux = { 0x41424344 }; -+ -+ if (aux.data[0] == 0x41) -+ { -+ return value; -+ } -+ -+ aux.data[0] = (value >> 24) & 0xff; -+ aux.data[1] = (value >> 16) & 0xff; -+ aux.data[2] = (value >> 8) & 0xff; -+ aux.data[3] = value & 0xff; -+ -+ return aux.value; -+} -+ -+bool writePackedString(const std::string& str, FILE *stream) -+{ -+ const char *string = str.c_str(); -+ size_t stringLength = strlen(string); -+ -+ if (!writePackedUInt16(stringLength, stream)) -+ { -+ return false; -+ } -+ -+ return fwrite(string, stringLength, 1, stream) == 1; -+} -+ -+bool writePackedUInt16(uint16_t value, FILE *stream) -+{ -+ uint16_t buffer = convertBigEndianUInt16(value); -+ return fwrite(&buffer, sizeof buffer, 1, stream) == 1; -+} -+ -+bool writePackedUInt32(uint32_t value, FILE *stream) -+{ -+ uint32_t buffer = convertBigEndianUInt32(value); -+ return fwrite(&buffer, sizeof buffer, 1, stream) == 1; -+} -+ -diff --git a/init/ipconfigstore/data.h b/init/ipconfigstore/data.h -new file mode 100644 -index 000000000..12c3a1af9 ---- /dev/null -+++ b/init/ipconfigstore/data.h -@@ -0,0 +1,13 @@ -+#pragma once -+ -+#include -+#include -+ -+#include -+ -+uint16_t convertBigEndianUInt16(uint16_t value); -+uint32_t convertBigEndianUInt32(uint32_t value); -+ -+bool writePackedString(const std::string& str, FILE *stream); -+bool writePackedUInt16(uint16_t value, FILE *stream); -+bool writePackedUInt32(uint32_t value, FILE *stream); -diff --git a/init/ipconfigstore/main.cc b/init/ipconfigstore/main.cc -new file mode 100644 -index 000000000..ef4a2a5ae ---- /dev/null -+++ b/init/ipconfigstore/main.cc -@@ -0,0 +1,165 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include -+ -+#include "data.h" -+ -+using namespace android::base; -+ -+struct ipconfig { -+ uint32_t mask; -+ char ipv4[16]; -+ char gateway[16]; -+}; -+ -+static int get_gateway(char *dev, char *ret) { -+ FILE *fp; -+ char buf[256]; // 128 is enough for linux -+ char iface[16]; -+ unsigned long dest_addr, gate_addr; -+ fp = fopen("/proc/net/route", "r"); -+ if (fp == NULL) return -1; -+ /* Skip title line */ -+ fgets(buf, sizeof(buf), fp); -+ while (fgets(buf, sizeof(buf), fp)) { -+ if (sscanf(buf, "%s\t%lX\t%lX", iface, &dest_addr, &gate_addr) != 3 || dest_addr != 0 || strcmp(dev, iface)) continue; -+ inet_ntop(AF_INET, &gate_addr, ret, INET_ADDRSTRLEN); -+ break; -+ } -+ -+ fclose(fp); -+ return 0; -+} -+ -+static int bitcount(uint32_t n) -+{ -+ int count=0; -+ while (n) { -+ count++; -+ n &= (n - 1); -+ } -+ return count; -+} -+ -+static int get_conf(struct ipconfig *conf) { -+ struct ifaddrs *ifAddrStruct; -+ void *tmpAddrPtr=NULL; -+ getifaddrs(&ifAddrStruct); -+ while (ifAddrStruct != NULL) { -+ if (ifAddrStruct->ifa_addr->sa_family==AF_INET && !strcmp("eth0", ifAddrStruct->ifa_name)) { -+ tmpAddrPtr=&((struct sockaddr_in *)ifAddrStruct->ifa_addr)->sin_addr; -+ inet_ntop(AF_INET, tmpAddrPtr, conf->ipv4, INET_ADDRSTRLEN); -+ conf->mask = bitcount(((struct sockaddr_in *)ifAddrStruct->ifa_netmask)->sin_addr.s_addr); -+ break; -+ } -+ ifAddrStruct=ifAddrStruct->ifa_next; -+ } -+ freeifaddrs(ifAddrStruct); -+ get_gateway((char *) "eth0", conf->gateway); -+ return 0; -+} -+ -+static void write_dns(FILE *fp) { -+ std::set dnsList; -+ auto ndns = GetIntProperty("ro.boot.kbox_net_ndns", 0); -+ for (int i = 1; i <= ndns; ++i) { -+ dnsList.insert(GetProperty("ro.boot.kbox_net_dns" + std::to_string(i), "")); -+ } -+ if (dnsList.empty()) dnsList.insert("8.8.8.8"); -+ -+ for (auto& dns: dnsList) { -+ writePackedString("dns", fp); -+ writePackedString(dns.c_str(), fp); -+ } -+} -+ -+static void write_proxy(FILE *fp) { -+ // static | pac | none | unassigned -+ std::string proxy_type = GetProperty("ro.boot.kbox_net_proxy_type", ""); -+ if ("static" == proxy_type) { -+ writePackedString("proxySettings", fp); -+ writePackedString("STATIC", fp); -+ -+ writePackedString("proxyHost", fp); -+ writePackedString(GetProperty("ro.boot.kbox_net_proxy_host", "").c_str(), fp); -+ -+ writePackedString("proxyPort", fp); -+ writePackedUInt32(GetIntProperty("ro.boot.kbox_net_proxy_port", 3128), fp); -+ -+ writePackedString("exclusionList", fp); -+ writePackedString(GetProperty("ro.boot.kbox_net_proxy_exclude_list", "").c_str(), fp); -+ } else if ("pac" == proxy_type) { -+ writePackedString("proxySettings", fp); -+ writePackedString("PAC", fp); -+ -+ writePackedString("proxyPac", fp); -+ writePackedString(GetProperty("ro.boot.kbox_net_proxy_pac", "").c_str(), fp); -+ } else if ("none" == proxy_type) { -+ writePackedString("proxySettings", fp); -+ writePackedString("NONE", fp); -+ } else { -+ // ignored -+ } -+} -+ -+static int write_conf(struct ipconfig *conf, uint32_t v) { -+ FILE *fp = fopen("/data/misc/ethernet/ipconfig.txt", "w+"); -+ -+ writePackedUInt32(v, fp); // version -+ -+ writePackedString("ipAssignment", fp); -+ writePackedString("STATIC", fp); -+ -+ writePackedString("linkAddress", fp); -+ writePackedString(conf->ipv4, fp); -+ writePackedUInt32(conf->mask, fp); -+ -+ writePackedString("gateway", fp); -+ writePackedUInt32(1, fp); // Default route (dest). -+ writePackedString("0.0.0.0", fp); -+ writePackedUInt32(0, fp); -+ writePackedUInt32(1, fp); // Have a gateway. -+ writePackedString(conf->gateway, fp); -+ -+ write_dns(fp); -+ -+ write_proxy(fp); -+ -+ writePackedString("id", fp); -+ if (v == 2) writePackedUInt32(0, fp); -+ else writePackedString("eth0", fp); -+ -+ writePackedString("eos", fp); -+ -+ fclose(fp); -+ return 0; -+} -+ -+int main(int argc, char **argv) { -+ (void)argc; -+ (void)argv; -+ -+ uint32_t v = 3; -+ // use V2 for Android 8.1 -+ if (GetIntProperty("ro.build.version.sdk", 0) <= 27) v = 2; -+ -+ struct ipconfig conf; -+ get_conf(&conf); -+ printf("ipconfig: ipv4: %s, mask: %i, gateway: %s", conf.ipv4, conf.mask, conf.gateway); -+ write_conf(&conf, v); -+ return 0; -+} -+ diff --git a/init/property_service.cpp b/init/property_service.cpp index f2606e3c5..62f9c34ad 100644 --- a/init/property_service.cpp @@ -605,7 +330,7 @@ index 1acd63774..12d696a6d 100644 # Mount default storage into root namespace mount none /mnt/user/0 /storage bind rec diff --git a/rootdir/init.usb.rc b/rootdir/init.usb.rc -index b30d6d02c..c1aee14e7 100644 +index b30d6d02c..e9d84b63a 100644 --- a/rootdir/init.usb.rc +++ b/rootdir/init.usb.rc @@ -27,9 +27,10 @@ on property:vendor.sys.usb.adb.disabled=* @@ -620,21 +345,20 @@ index b30d6d02c..c1aee14e7 100644 stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/bDeviceClass 0 -@@ -39,6 +40,8 @@ on property:sys.usb.config=none && property:sys.usb.configfs=0 +@@ -39,6 +40,7 @@ on property:sys.usb.config=none && property:sys.usb.configfs=0 # This is the fallback configuration if the # USB manager fails to set a standard configuration on property:sys.usb.config=adb && property:sys.usb.configfs=0 -+ // 避免init中的start影响正常adb服务启动 -+ stop adbd ++ stop adb write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 write /sys/class/android_usb/android0/idProduct 4EE7 -@@ -107,7 +110,8 @@ on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.config +@@ -107,7 +109,7 @@ on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.config # Used to set USB configuration at boot and to switch the configuration # when changing the default configuration + on boot && property:persist.sys.usb.config=* - setprop sys.usb.config ${persist.sys.usb.config} -+ // 使user模式获取adb权限 + setprop sys.usb.config adb # - # USB type C \ No newline at end of file + # USB type C