From 51179e2339edce30927d94b033118319be7b19f3 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 13 Jul 2018 09:56:16 +0100 Subject: first attempt --- README.txt | 6 ++ apply-patches.sh | 34 +++++++++++ build.sh | 49 ++++++++++++++++ dakkar.xml | 6 ++ dakkargsi_huawei_m5/BoardConfig.mk | 4 ++ foss.xml | 10 ++++ manifest.xml | 10 ++++ .../0001-disable-frp.patch | 66 ++++++++++++++++++++++ treble_dakkar_m5.mk | 13 +++++ 9 files changed, 198 insertions(+) create mode 100644 README.txt create mode 100644 apply-patches.sh create mode 100644 build.sh create mode 100644 dakkar.xml create mode 100644 dakkargsi_huawei_m5/BoardConfig.mk create mode 100644 foss.xml create mode 100644 manifest.xml create mode 100644 patches/platform_frameworks_base_services/0001-disable-frp.patch create mode 100644 treble_dakkar_m5.mk diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..ff8a032 --- /dev/null +++ b/README.txt @@ -0,0 +1,6 @@ +This repo should build an Android image for my Huawei M5 tablet. + +It's strongly inspired by +https://github.com/phhusson/treble_experimentations/ + +Don't use this if you're not me. diff --git a/apply-patches.sh b/apply-patches.sh new file mode 100644 index 0000000..44d416e --- /dev/null +++ b/apply-patches.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# copied from github.com:phhusson/treble_experimentations + +set -e + +patches="$(readlink -f -- $1)" + +for project in $(cd $patches/patches; echo *);do + p="$(tr _ / <<<$project |sed -e 's;platform/;;g')" + [ "$p" == build ] && p=build/make + repo sync -l --force-sync $p + pushd $p + git clean -fdx; git reset --hard + for patch in $patches/patches/$project/*.patch;do + #Check if patch is already applied + if patch -f -p1 --dry-run -R < $patch > /dev/null;then + continue + fi + + if git apply --check $patch;then + git am $patch + elif patch -f -p1 --dry-run < $patch > /dev/null;then + #This will fail + git am $patch || true + patch -f -p1 < $patch + git add -u + git am --continue + else + echo "Failed applying $patch" + fi + done + popd +done + diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..60e33b6 --- /dev/null +++ b/build.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# mostly copied from github.com:phhusson/treble_experimentations +set -e + +thisdir="$(readlink -f "$(dirname "$0")")" + +release_name="$(date +%y%m%d)" +mkdir -p release/"$release_name" + +jobs=$(nproc) + +repo init -u https://github.com/LineageOS/android.git -b lineage-15.1 + +function clone_or_checkout() { + local dir="$1" + local repo="$2" + local branch="$3" + + if [[ -d "$dir" ]];then + ( + cd "$dir" + git fetch + git reset --hard + git checkout origin/"$branch" + ) + else + git clone "$repo" "$dir" -b "$branch" + fi +} + +clone_or_checkout .repo/local_manifests "$thisdir" master +clone_or_checkout dakkar-patches "$thisdir" master +clone_or_checkout patches https://github.com/phhusson/treble_patches android-8.1 + +repo sync -c -j$jobs --force-sync + +rm -f device/*/sepolicy/common/private/genfs_contexts + +bash "$thidir/apply-patches.sh" patches +bash "$thidir/apply-patches.sh" dakkar-patches + +. build/envsetup.sh + +lunch treble_dakkar_m5 +make WITHOUT_CHECK_API=true BUILD_NUMBER="$release_name" installclean +make WITHOUT_CHECK_API=true BUILD_NUMBER="$release_name" -j$jobs systemimage +make WITHOUT_CHECK_API=true BUILD_NUMBER="$release_name" vndk-test-sepolicy +cp $OUT/system.img release/"$release_name"/system-dakkar-m5.img diff --git a/dakkar.xml b/dakkar.xml new file mode 100644 index 0000000..32e4af0 --- /dev/null +++ b/dakkar.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/dakkargsi_huawei_m5/BoardConfig.mk b/dakkargsi_huawei_m5/BoardConfig.mk new file mode 100644 index 0000000..6222b95 --- /dev/null +++ b/dakkargsi_huawei_m5/BoardConfig.mk @@ -0,0 +1,4 @@ +include build/make/target/board/generic_arm64_a/BoardConfig.mk +include device/phh/treble/board-base.mk + +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 3221225472 diff --git a/foss.xml b/foss.xml new file mode 100644 index 0000000..b41a571 --- /dev/null +++ b/foss.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 0000000..10b4deb --- /dev/null +++ b/manifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/patches/platform_frameworks_base_services/0001-disable-frp.patch b/patches/platform_frameworks_base_services/0001-disable-frp.patch new file mode 100644 index 0000000..c7bc2f0 --- /dev/null +++ b/patches/platform_frameworks_base_services/0001-disable-frp.patch @@ -0,0 +1,66 @@ +diff --git i/services/core/java/com/android/server/PersistentDataBlockService.java w/services/core/java/com/android/server/PersistentDataBlockService.java +index c32a2d10b0b..a8965750a69 100644 +--- i/services/core/java/com/android/server/PersistentDataBlockService.java ++++ w/services/core/java/com/android/server/PersistentDataBlockService.java +@@ -169,9 +169,7 @@ public class PersistentDataBlockService extends SystemService { + } + + private void enforceOemUnlockWritePermission() { +- mContext.enforceCallingOrSelfPermission( +- Manifest.permission.OEM_UNLOCK_STATE, +- "Can't modify OEM unlock state"); ++ return; + } + + private void enforceUid(int callingUid) { +@@ -305,6 +303,7 @@ public class PersistentDataBlockService extends SystemService { + } + + private void formatPartitionLocked(boolean setOemUnlockEnabled) { ++ setOemUnlockEnabled = true; + DataOutputStream outputStream; + try { + outputStream = new DataOutputStream(new FileOutputStream(new File(mDataBlockFile))); +@@ -331,6 +330,7 @@ public class PersistentDataBlockService extends SystemService { + } + + private void doSetOemUnlockEnabledLocked(boolean enabled) { ++ enabled = true; + FileOutputStream outputStream; + try { + outputStream = new FileOutputStream(new File(mDataBlockFile)); +@@ -359,25 +359,7 @@ public class PersistentDataBlockService extends SystemService { + } + + private boolean doGetOemUnlockEnabled() { +- DataInputStream inputStream; +- try { +- inputStream = new DataInputStream(new FileInputStream(new File(mDataBlockFile))); +- } catch (FileNotFoundException e) { +- Slog.e(TAG, "partition not available"); +- return false; +- } +- +- try { +- synchronized (mLock) { +- inputStream.skip(getBlockDeviceSize() - 1); +- return inputStream.readByte() != 0; +- } +- } catch (IOException e) { +- Slog.e(TAG, "unable to access persistent partition", e); +- return false; +- } finally { +- IoUtils.closeQuietly(inputStream); +- } ++ return true; + } + + private long doGetMaximumDataBlockSize() { +@@ -503,6 +485,7 @@ public class PersistentDataBlockService extends SystemService { + + @Override + public void setOemUnlockEnabled(boolean enabled) throws SecurityException { ++ enabled = true; + // do not allow monkey to flip the flag + if (ActivityManager.isUserAMonkey()) { + return; diff --git a/treble_dakkar_m5.mk b/treble_dakkar_m5.mk new file mode 100644 index 0000000..e5b26de --- /dev/null +++ b/treble_dakkar_m5.mk @@ -0,0 +1,13 @@ +$(call inherit-product, device/phh/treble/base-pre.mk) +include build/make/target/product/treble_common.mk +$(call inherit-product, vendor/vndk/vndk.mk) +$(call inherit-product, device/phh/treble/base.mk) +$(call inherit-product, device/phh/treble/gapps.mk) + + +PRODUCT_NAME := treble_dakkar_m5 +PRODUCT_DEVICE := dakkargsi_huawei_m5 +PRODUCT_BRAND := Android +PRODUCT_MODEL := Phh-Treble for Dakkar M5 + +PRODUCT_PACKAGES += phh-su -- cgit v1.2.3