Skip to content

Instantly share code, notes, and snippets.

@dady8889
Last active August 8, 2017 15:22
Show Gist options
  • Save dady8889/07d8bdcffceb0538b4774fe5ca37c9ab to your computer and use it in GitHub Desktop.
Save dady8889/07d8bdcffceb0538b4774fe5ca37c9ab to your computer and use it in GitHub Desktop.
#!/bin/bash
# Copyright (C) 2017 dady8889@github
#DEBUG="--dry-run"
PATCH=$(cat << EOF
153a
# Autopatch
if [[ \$AUTOPATCH == true ]]; then
echo -e "\${CLR_BLD_BLU}Autopatch\${CLR_RST}"
cd device/huawei/hi6250/patches && ./patchtool -p aospa
else
echo -ne "\${CLR_BLD_BLU}Autopatch\${CLR_RST}"
echo "\${CLR_BLD_RED} NOT ENABLED!!!\${CLR_RST}"
echo -e "Patch manually:\n cd device/huawei/hi6250/patches && ./patchtool -p aospa"
echo "OR:"
echo -e "Enable autopatch:\n export AUTOPATCH=true && ./rom-build.sh \$DEVICE"
echo "----------------------------------------------"
fi
cd \$DIR_ROOT
echo -e "Continuing in 5 sec...\n"
sleep 5
.
EOF
)
if [[ ! $(cat 'rom-build.sh' | grep -c "AUTOPATCH") -gt 0 ]] ; then
chmod +w rom-build.sh
RESULT=$(echo "$PATCH" | patch '--verbose' $DEBUG '-e' '--read-only=ignore' 'rom-build.sh' 2>&1)
if [[ $(echo $RESULT | grep -c "done") -gt 0 ]] ; then
echo "rom-build patch OK"
else
echo "rom-build patch FAILED!"
fi
else
echo "rom-build ALREADY PATCHED!"
fi
PATCH="
diff --git a/main.mk b/main.mk
index a5dd6f4..b69f4bb 100644
--- a/main.mk
+++ b/main.mk
@@ -90,7 +90,7 @@ PRODUCT_COPY_FILES += \\
vendor/pa/prebuilt/etc/hostapd/hostapd.accept:system/etc/hostapd/hostapd.accept
# Build Chromium for Snapdragon (PA Browser)
-PRODUCT_PACKAGES += PABrowser
+# PRODUCT_PACKAGES += PABrowser
# Build Snapdragon apps
PRODUCT_PACKAGES += \\
@@ -101,7 +101,7 @@ PRODUCT_PACKAGES += \\
PRODUCT_PACKAGES += SoundRecorder
# Build ParanoidHub
-PRODUCT_PACKAGES += ParanoidHub
+# PRODUCT_PACKAGES += ParanoidHub
# Build WallpaperPicker
PRODUCT_PACKAGES += WallpaperPicker
diff --git a/products/AndroidProducts.mk b/products/AndroidProducts.mk
index 21c811d..d02d53f 100644
--- a/products/AndroidProducts.mk
+++ b/products/AndroidProducts.mk
@@ -33,3 +33,7 @@
\$(LOCAL_DIR)/bullhead/pa_bullhead.mk \\
\$(LOCAL_DIR)/marlin/pa_marlin.mk \\
\$(LOCAL_DIR)/sailfish/pa_sailfish.mk
+
+# Huawei
+ PRODUCT_MAKEFILES += \\
+ \$(LOCAL_DIR)/hi6250/pa_hi6250.mk
diff --git a/products/hi6250/pa.dependencies b/products/hi6250/pa.dependencies
new file mode 100644
index 0000000..0f329ed
--- /dev/null
+++ b/products/hi6250/pa.dependencies
@@ -0,0 +1,44 @@
+[
+ {
+ \"target_path\": \"device/huawei/hi6250\",
+ \"repository\": \"dady8889/android_device_huawei_hi6250\",
+ \"remote\": \"github\",
+ \"revision\": \"aospa-n\"
+ },
+ {
+ \"target_path\": \"vendor/huawei/hi6250\",
+ \"repository\": \"Meticulus/android_vendor_huawei_hi6250\",
+ \"remote\": \"github\",
+ \"revision\": \"master\"
+ },
+ {
+ \"target_path\": \"kernel/huawei/hi6250\",
+ \"repository\": \"dady8889/android_kernel_hisi_hi6250\",
+ \"remote\": \"github\",
+ \"revision\": \"patch\"
+ },
+ {
+ \"target_path\": \"packages/apps/Launcher3\",
+ \"repository\": \"dady8889/android_packages_apps_Launcher3\",
+ \"remote\": \"github\",
+ \"revision\": \"nougat-mr2\"
+ },
+ {
+ \"target_path\": \"packages/services/Telephony\",
+ \"repository\": \"dady8889/android_packages_services_Telephony\",
+ \"remote\": \"github\",
+ \"revision\": \"nougat-mr2\"
+ },
+ {
+ \"target_path\": \"external/exfat\",
+ \"repository\": \"LineageOS/android_external_exfat\",
+ \"remote\": \"github\",
+ \"revision\": \"cm-14.1\"
+ },
+ {
+ \"target_path\": \"external/fuse\",
+ \"repository\": \"LineageOS/android_external_fuse\",
+ \"remote\": \"github\",
+ \"revision\": \"cm-14.1\"
+ }
+]
diff --git a/products/hi6250/pa_hi6250.mk b/products/hi6250/pa_hi6250.mk
new file mode 100644
index 0000000..2e431aa
--- /dev/null
+++ b/products/hi6250/pa_hi6250.mk
@@ -0,0 +1,52 @@
+# Copyright (C) 2016-2017 Paranoid Android
+#
+# Licensed under the Apache License, Version 2.0 (the \"License\");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an \"AS IS\" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Check for target product
+ifeq (pa_hi6250,\$(TARGET_PRODUCT))
+
+# Inherit from those products. Most specific first.
+\$(call inherit-product, \$(SRC_TARGET_DIR)/product/core_64_bit.mk)
+\$(call inherit-product, \$(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+\$(call inherit-product, \$(SRC_TARGET_DIR)/product/languages_full.mk)
+
+# Inherit device tree
+\$(call inherit-product, device/huawei/hi6250/device.mk)
+
+# Get the defaults going.
+TARGET_BOOT_ANIMATION_RES := 1080
+
+# Paranoid Android platform
+include vendor/pa/main.mk
+
+# Override AOSP defaults that we want changed.
+PRODUCT_NAME := pa_hi6250
+PRODUCT_DEVICE := hi6250
+PRODUCT_BRAND := huawei
+PRODUCT_MODEL := Huawei_P9_Lite
+PRODUCT_MANUFACTURER := Huawei
+PRODUCT_RESTRICT_VENDOR_FILES := false
+
+# Additional packages
+# Additional packages
+PRODUCT_PACKAGES += \\
+ messaging \\
+ charger_res_images \\
+ fsck.exfat \\
+ mkfs.exfat \\
+ mount.exfat
+
+# Disable pre-optimization
+WITH_DEXPREOPT := false
+
+endif
diff --git a/vendorsetup.sh b/vendorsetup.sh
index d3127dc..9a8d23a 100644
--- a/vendorsetup.sh
+++ b/vendorsetup.sh
@@ -18,3 +18,6 @@ add_lunch_combo pa_angler-userdebug
add_lunch_combo pa_bullhead-userdebug
add_lunch_combo pa_marlin-userdebug
add_lunch_combo pa_sailfish-userdebug
+
+# Huawei
+add_lunch_combo pa_hi6250-userdebug
"
cd vendor/pa/
RESULT=$(echo -e "$PATCH" | patch '-p1' '--follow-symlinks' $DEBUG '--merge' '--no-backup-if-mismatch' 2>&1)
if [[ $(echo "$RESULT" | grep -E -i -c "reversed|already") -gt 0 ]] ; then
echo "$RESULT"
echo "vendor/pa ALREADY PATCHED!"
elif [[ $(echo "$RESULT" | grep -E -i -c "find|failed|saving|garbage|malformed|fail") -gt 0 ]] ; then
echo "$RESULT"
echo "vendor/pa patch FAILED!"
else
echo "vendor/pa patch OK"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment