From cbc327a5f0b9983e9785034319a2a58cfaaf0890 Mon Sep 17 00:00:00 2001 From: mochangming Date: Wed, 26 Oct 2016 20:49:32 +0800 Subject: [PATCH 1/3] Update mk files Change-Id: I6d0fed46d803b15b6e67d1d70dcf875a0711ea5f --- apps.mk | 64 ++++++++++++++++++++++++++++++ config.mk | 11 +++++- localvar.mk | 6 +-- miui_apps.mk | 21 ---------- porting.mk | 108 +-------------------------------------------------- 5 files changed, 78 insertions(+), 132 deletions(-) create mode 100644 apps.mk delete mode 100644 miui_apps.mk diff --git a/apps.mk b/apps.mk new file mode 100644 index 0000000..f28cea5 --- /dev/null +++ b/apps.mk @@ -0,0 +1,64 @@ + +# +# Copyright (C) 2016 The Miui Patchrom +# + +MIUI_APP_BLACKLIST += InputDevices MusicFX SharedStorageBackup OneTimeInitializer ProxyHandler GooglePinyinIME \ + Shell FusedLocation BackupRestoreConfirmation ExternalStorageProvider PhotoTable PrintSpooler \ + WAPPushManager MagicSmokeWallpapers VisualizationWallpapers BasicDreams PhaseBeam HoloSpiralWallpaper \ + Bluetooth Galaxy4 LiveWallpapers PicoTts CertInstaller KeyChain NoiseField PacProcessor Camera2 \ + TrafficControl + + +ALL_MIUI_PRIV_APPS := +$(foreach app, $(subst .apk,,$(shell find $(PREBUILT_PRIV_APP_APK_DIR) -name "*.apk" -exec basename {} \;)), \ + $(eval ALL_MIUI_PRIV_APPS += $(app))) + +MIUI_PRIV_APPS := $(filter-out $(MIUI_APP_BLACKLIST),$(ALL_MIUI_PRIV_APPS)) + + +ALL_MIUI_APPS := +$(foreach app, $(subst .apk,,$(shell find $(PREBUILT_APP_APK_DIR) -name "*.apk" -exec basename {} \;)), \ + $(eval ALL_MIUI_APPS += $(app))) + +MIUI_APPS := $(filter-out $(MIUI_APP_BLACKLIST),$(ALL_MIUI_APPS)) + +TARGET_APPS := $(foreach app_name, $(MIUI_APPS),$(TARGET_APP_DIR)/$(app_name)/$(app_name).apk) \ + $(foreach app_name, $(MIUI_PRIV_APPS),$(TARGET_PRIV_APP_DIR)/$(app_name)/$(app_name).apk) \ + +# Define a rule to modify miui app. For use via $(eval). +# $1: the apk name, such as LogsProvider +define miui_app_mod_template +ifeq ($(wildcard $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk),) +prebuilt-apk-path := $(PREBUILT_PRIV_APP_APK_DIR)/$(1)/$(1).apk +else +prebuilt-apk-path := $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk +endif +source-files-for-$(1) := $$(call all-files-under-dir,$(1)) +apkcert := $$(shell $(GET_APK_CERT) $(1).apk $(MIUI_APK_CERT_TXT)) + +$(TARGET_OUT_DIR)/$(1): $$(prebuilt-apk-path) $(APKTOOL_INCLUDE_MIUI_RES) $(APKTOOL_INCLUDE_VENDOR_RES) + $(APKTOOL) d -p $(TARGET_OUT_DIR)/apktool -t miui -f $$< -o $(TARGET_OUT_DIR)/$(1) + $(hide) sed -i "/tag:/d" $$@/apktool.yml + $(hide) sed -i "s/isFrameworkApk: true/isFrameworkApk: false/g" $$@/apktool.yml + $(hide) sed -i "s/package=\"com.miui.core\"/package=\"miui\"/g" $$@/AndroidManifest.xml + $(PATCH_MIUI_APP) $(1) $$@ + +$(TARGET_OUT_DIR)/$(1).apk: $$(source-files-for-$(1)) $(TARGET_OUT_DIR)/$(1) + @echo ">>> build $$@..." +ifneq ($(wildcard $(1)),) + $(hide) cp -r $(1) $(TARGET_OUT_DIR) +endif + $(APKTOOL) b -p $(TARGET_OUT_DIR)/apktool -a $(AAPT) $(TARGET_OUT_DIR)/$(1) -o $$@ + @echo "9Patch png fix $$@..." + $(FIX_9PATCH_PNG) $(1) $$(dir $$(prebuilt-apk-path)) $(TARGET_OUT_DIR) $(1)/res + @echo "sign $$(apkcert) key for $$@..." + $(hide) java -jar $(TOOLS_DIR)/signapk.jar $(CERTIFICATE_DIR)/$$(apkcert).x509.pem $(CERTIFICATE_DIR)/$$(apkcert).pk8 $$@ $$@.signed + $(hide) mv $$@.signed $$@ + @echo "<<< build $$@ completed!" + +TARGET_APPS += $(TARGET_OUT_DIR)/$(1).apk +endef + +$(foreach app, $(MOD_MIUI_APPS) , \ + $(eval $(call miui_app_mod_template,$(app)))) diff --git a/config.mk b/config.mk index 60c632f..285966d 100644 --- a/config.mk +++ b/config.mk @@ -35,6 +35,9 @@ RELEASE_BOOT_DIR := $(RELEASE_DIR)/boot # Src dirs MIUI_SRC_DIR := $(ANDROID_TOP)/miui + +# Miui apk cert txt +MIUI_APK_CERT_TXT := $(shell find $ANDROID_OUT/obj/PACKAGING/apkcerts_intermediates/ -name "*.txt" | head -n 1) else # Prebuilt dirs PREBUILT_SYS_DIR := $(PORT_ROOT)/miui/system @@ -45,6 +48,9 @@ PREBUILT_BOOT_DIR := $(PORT_ROOT)/miui/boot # Src dirs MIUI_SRC_DIR := $(PORT_ROOT)/miui/src + +# Miui apk cert txt +MIUI_APK_CERT_TXT := $(PORT_ROOT)/miui/metadata/apkcert.txt endif # Prebuilt dirs @@ -88,6 +94,9 @@ MKBOOTIMG := $(TOOLS_DIR)/$(HOST_OS)-x86/mkbootimg APKTOOL := $(TOOLS_DIR)/apktool $(APK_VERBOSE) PATCH_BOOTIMG_SH := $(TOOLS_DIR)/patch_bootimg.sh UNIQ_FIRST_PY := $(TOOLS_DIR)/uniq_first.py +GET_APK_CERT := $(TOOLS_DIR)/get_apk_cert.py +PATCH_MIUI_APP := $(TOOLS_DIR)/patch_miui_app.sh $(VERBOSE) +FIX_9PATCH_PNG := $(TOOLS_DIR)/fix_9patch_png.sh $(VERBOSE) # Config files BUILD_PROP := $(TARGET_SYS_DIR)/build.prop @@ -99,8 +108,6 @@ APKTOOL_INCLUDE_RES_DIR := $(TARGET_OUT_DIR)/apktool APKTOOL_INCLUDE_VENDOR_RES := $(APKTOOL_INCLUDE_RES_DIR)/1.apk APKTOOL_INCLUDE_MIUI_RES := $(APKTOOL_INCLUDE_RES_DIR)/1-miui.apk -include $(PORT_BUILD)/miui_apps.mk - MIUI_JARS := framework services telephony-common wifi-service MIUI_EXT_RES_APKS := $(PREBUILT_APP_APK_DIR)/miui/miui.apk \ $(PREBUILT_RES_DIR)/framework-ext-res/framework-ext-res.apk \ diff --git a/localvar.mk b/localvar.mk index 81fda05..bb1e205 100644 --- a/localvar.mk +++ b/localvar.mk @@ -53,9 +53,9 @@ ifeq ($(OUT_ZIP_FILE),) OUT_ZIP_FILE:= update.zip endif -APPS := $(strip $(local-modified-apps)) -MIUI_MOD_APPS := $(strip $(local-miui-modified-apps)) -MIUI_APPS_BLACKLIST := $(MIUI_MOD_APPS) $(strip $(local-miui-removed-apps)) +MOD_APPS := $(strip $(local-modified-apps)) +MOD_MIUI_APPS := $(strip $(local-miui-modified-apps)) +MIUI_APPS_BLACKLIST := $(MOD_MIUI_APPS) $(strip $(local-miui-removed-apps)) PHONE_JARS := $(strip $(local-modified-jars)) diff --git a/miui_apps.mk b/miui_apps.mk deleted file mode 100644 index 89d3ef0..0000000 --- a/miui_apps.mk +++ /dev/null @@ -1,21 +0,0 @@ - -MIUI_APP_BLACKLIST += InputDevices MusicFX SharedStorageBackup OneTimeInitializer ProxyHandler GooglePinyinIME \ - Shell FusedLocation BackupRestoreConfirmation ExternalStorageProvider PhotoTable PrintSpooler \ - WAPPushManager MagicSmokeWallpapers VisualizationWallpapers BasicDreams PhaseBeam HoloSpiralWallpaper \ - Bluetooth Galaxy4 LiveWallpapers PicoTts CertInstaller KeyChain NoiseField PacProcessor Camera2 \ - TrafficControl - - -ALL_MIUI_PRIV_APPS := -$(foreach app, $(subst .apk,,$(shell find $(PREBUILT_PRIV_APP_APK_DIR) -name "*.apk" -exec basename {} \;)), \ - $(eval ALL_MIUI_PRIV_APPS += $(app))) - -MIUI_PRIV_APPS := $(filter-out $(MIUI_APP_BLACKLIST),$(ALL_MIUI_PRIV_APPS)) - - -ALL_MIUI_APPS := -$(foreach app, $(subst .apk,,$(shell find $(PREBUILT_APP_APK_DIR) -name "*.apk" -exec basename {} \;)), \ - $(eval ALL_MIUI_APPS += $(app))) - -MIUI_APPS := $(filter-out $(MIUI_APP_BLACKLIST),$(ALL_MIUI_APPS)) - diff --git a/porting.mk b/porting.mk index 024f6b4..9f5c0cb 100644 --- a/porting.mk +++ b/porting.mk @@ -1,5 +1,6 @@ include $(PORT_BUILD)/config.mk include $(PORT_BUILD)/definitions.mk +include $(PORT_BUILD)/apps.mk include $(PORT_BUILD)/release.mk include $(PORT_BUILD)/prebuilt.mk @@ -130,41 +131,6 @@ $(TARGET_OUT_DIR)/$(1).jar: $$(source-files-for-$(1)) | $(TARGET_OUT_DIR) endef -# -# To apktool build one apk from the decoded dirctory under .build -# $1: the apk name, such as LogsProvider -# $2: the dir name, might be different from apk name -# $3: to specify if the smali files should be decoded from MIUI first -# $4: to specify app dir, for kitkat only -define APP_template -source-files-for-$(2) := $$(call all-files-under-dir,$(2)) -$(TARGET_OUT_DIR)/$(1).apk: $$(source-files-for-$(2)) $(3) | $(TARGET_OUT_DIR) - @echo ">>> build $$@..." -ifneq ($(wildcard $(2)),) - $(hide) cp -r $(2) $(TARGET_OUT_DIR) - $(hide) find $(TARGET_OUT_DIR)/$(2) -name "*.part" -exec rm {} \; - $(hide) find $(TARGET_OUT_DIR)/$(2) -name "*.smali.method" -exec rm {} \; -endif - $(APKTOOL) b -p $(TARGET_OUT_DIR)/apktool -a $(AAPT) $(TARGET_OUT_DIR)/$(2) -o $$@ - #@echo "9Patch png fix $$@..." -#ifeq ($(3),) -# $(FIX_9PATCH_PNG) $(1) $(STOCKROM_DIR)/system/$(4) $(TARGET_OUT_DIR) -#else -# $(FIX_9PATCH_PNG) $(1) $(OUT_APK_PATH:app=$(4)) $(TARGET_OUT_DIR) $(1)/res -#endif - @echo "fix $$@ completed!" - @echo "<<< build $$@ completed!" - -$(3): $(OUT_APK_PATH:app=$(4))/$(1)/$(1).apk $(TARGET_OUT_DIR)/apktool - $(hide) rm -rf $(3) - $(APKTOOL) d -p $(TARGET_OUT_DIR)/apktool -t miui -f $$< -o $(3) - $(hide) sed -i "/tag:/d" $(3)/apktool.yml - $(hide) sed -i "s/isFrameworkApk: true/isFrameworkApk: false/g" $(3)/apktool.yml - $(hide) sed -i "s/package=\"com.miui.core\"/package=\"miui\"/g" $(3)/AndroidManifest.xml - $(PATCH_MIUI_APP) $(2) $(3) - -endef - # Target to build framework-res.apk # copy the framework-res, add the miui overlay then build #TODO need to add changed files for all related, and re-install framework-res.apk make sense? @@ -203,66 +169,6 @@ $(1): $(ZIP_FILE) $(hide) rm -f $(TARGET_OUT_DIR)/system/$(2)/$(1).apk endef -# To decide dir of the apk -# $1 the apk name -define MOD_DIR_template -ifeq ($(USE_ANDROID_OUT),true) -ifeq ($(wildcard $(ANDROID_OUT)/system/priv-app/$(1).apk),$(wildcard $(STOCKROM_DIR)/system/priv-app/$(1).apk)) - $(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/app/$(1).apk) -else - $(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/priv-app/$(1).apk) -endif -else -ifeq ($(wildcard $(RELEASE_DIR)/$(DENSITY)/system/priv-app/$(1).apk),$(wildcard $(STOCKROM_DIR)/system/priv-app/$(1).apk)) - $(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/app/$(1).apk) -else - $(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/priv-app/$(1).apk) -endif -endif -endef - -# To decide dir of the apk -# $1 the apk name -# $2: to specify if the smali files should be decoded from MIUI first -define APP_DIR_template -ifeq ($(USE_ANDROID_OUT),true) -ifeq ($(wildcard $(ANDROID_OUT)/system/priv-app/$(1).apk),) - $(call APP_template,$(1),$(1),$(2),app) -else - $(call APP_template,$(1),$(1),$(2),priv-app) -endif -else -ifeq ($(wildcard $(RELEASE_DIR)/$(DENSITY)/system/priv-app/$(1).apk),) - $(call APP_template,$(1),$(1),$(2),app) -else - $(call APP_template,$(1),$(1),$(2),priv-app) -endif -endif -endef - -# -# Used to sign one single file, e.g: make .build/LogsProvider.apk.sign -# for zipfile target, just to copy the unsigned file to correct ZIP-directory. -# also create a seperate target for command line, such as : make LogsProvider.apk.sign -# $1: the apk file need to be signed -# $2: the path/filename in the phone -define SIGN_template -SIGNAPKS += $(1).sign -$(notdir $(1)).sign $(1).sign: $(1) - @echo sign apk $(1) and push to phone as $(2)... - #java -jar $(TOOL_DIR)/signapk.jar $(PORT_ROOT)/build/security/platform.x509.pem $(PORT_ROOT)/build/security/platform.pk8 $(1) $(1).signed - java -jar $(TOOL_DIR)/signapk.jar $(PORT_ROOT)/build/security/testkey.x509.pem $(PORT_ROOT)/build/security/testkey.pk8 $(1) $(1).signed - $(ADB) remount - $(ADB) push $(1).signed $(2) - -mark-tozip-for-$(1) := $(TARGET_OUT_DIR)/$$(shell basename $(1))-tozip -TOZIP_APKS += $$(mark-tozip-for-$(1)) -$$(mark-tozip-for-$(1)) : $(1) - $(hide) mkdir -p $(shell dirname $(ZIP_DIR)$(2)) - $(hide) cp $(1) $(ZIP_DIR)$(2) - @touch $$@ -endef - zipone: zipfile $(ACT_AFTER_ZIP) otapackage: metadata target_files @@ -274,15 +180,6 @@ $(foreach jar, $(MIUI_JARS), \ $(foreach jar, $(PHONE_JARS), \ $(eval $(call JAR_PHONE_template,$(jar)))) -#$(foreach app, $(APPS), \ - $(eval $(call APP_DIR_template,$(app),))) - -#$(foreach app, $(MIUI_APPS) , \ - $(eval $(call APP_DIR_template,$(app),$(TARGET_OUT_DIR)/$(app)))) - -#$(foreach app, $(APPS) $(MIUI_APPS_MOD), \ - $(eval $(call MOD_DIR_template,$(app)))) - $(call copy-apks-to-target, $(MIUI_APPS), $(PREBUILT_APP_APK_DIR), $(TARGET_APP_DIR)) $(call copy-apks-to-target, $(MIUI_PRIV_APPS), $(PREBUILT_PRIV_APP_APK_DIR), $(TARGET_PRIV_APP_DIR)) $(eval $(call copy-one-file,$(TARGET_OUT_DIR)/framework-ext-res.apk,$(TARGET_FRAMEWORK_DIR)/framework-ext-res/framework-ext-res.apk)) @@ -403,8 +300,7 @@ patch-bootimg: $(PATCH_BOOTIMG_SH) $(UNPACKBOOTIMG) $(MKBOOTFS) $(MKBOOTIMG) $(T target_files: $(STOCKROM_DIR) | $(ZIP_DIR) target_files: add-miui-prebuilt -target_files: $(foreach app_name, $(MIUI_APPS),$(TARGET_APP_DIR)/$(app_name)/$(app_name).apk) -target_files: $(foreach app_name, $(MIUI_PRIV_APPS),$(TARGET_PRIV_APP_DIR)/$(app_name)/$(app_name).apk) +target_files: $(TARGET_APPS) target_files: $(TARGET_FRAMEWORK_DIR)/framework-res.apk $(TARGET_FRAMEWORK_DIR)/framework-ext-res/framework-ext-res.apk target_files: $(ZIP_BLDJARS) $(ACT_PRE_ZIP) From f908a92831330560de92990fed25f9e144ebd25b Mon Sep 17 00:00:00 2001 From: wuxianlin Date: Wed, 26 Oct 2016 23:26:18 +0800 Subject: [PATCH 2/3] fix build break when we use *.part --- apps.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps.mk b/apps.mk index f28cea5..e50f0cf 100644 --- a/apps.mk +++ b/apps.mk @@ -48,6 +48,8 @@ $(TARGET_OUT_DIR)/$(1).apk: $$(source-files-for-$(1)) $(TARGET_OUT_DIR)/$(1) @echo ">>> build $$@..." ifneq ($(wildcard $(1)),) $(hide) cp -r $(1) $(TARGET_OUT_DIR) + $(hide) find $(TARGET_OUT_DIR)/$(1) -name "*.part" -exec rm {} \; + $(hide) find $(TARGET_OUT_DIR)/$(1) -name "*.smali.method" -exec rm {} \; endif $(APKTOOL) b -p $(TARGET_OUT_DIR)/apktool -a $(AAPT) $(TARGET_OUT_DIR)/$(1) -o $$@ @echo "9Patch png fix $$@..." From f497c44334bf54469aa717a7a06426e801c3720e Mon Sep 17 00:00:00 2001 From: wuxianlin Date: Wed, 26 Oct 2016 23:30:25 +0800 Subject: [PATCH 3/3] fix when we have more than one modified miui app --- apps.mk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps.mk b/apps.mk index e50f0cf..24ed915 100644 --- a/apps.mk +++ b/apps.mk @@ -30,14 +30,14 @@ TARGET_APPS := $(foreach app_name, $(MIUI_APPS),$(TARGET_APP_DIR)/$(app_name)/$( # $1: the apk name, such as LogsProvider define miui_app_mod_template ifeq ($(wildcard $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk),) -prebuilt-apk-path := $(PREBUILT_PRIV_APP_APK_DIR)/$(1)/$(1).apk +prebuilt-apk-path-$(1) := $(PREBUILT_PRIV_APP_APK_DIR)/$(1)/$(1).apk else -prebuilt-apk-path := $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk +prebuilt-apk-path-$(1) := $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk endif source-files-for-$(1) := $$(call all-files-under-dir,$(1)) -apkcert := $$(shell $(GET_APK_CERT) $(1).apk $(MIUI_APK_CERT_TXT)) +apkcert-$(1) := $$(shell $(GET_APK_CERT) $(1).apk $(MIUI_APK_CERT_TXT)) -$(TARGET_OUT_DIR)/$(1): $$(prebuilt-apk-path) $(APKTOOL_INCLUDE_MIUI_RES) $(APKTOOL_INCLUDE_VENDOR_RES) +$(TARGET_OUT_DIR)/$(1): $$(prebuilt-apk-path-$(1)) $(APKTOOL_INCLUDE_MIUI_RES) $(APKTOOL_INCLUDE_VENDOR_RES) $(APKTOOL) d -p $(TARGET_OUT_DIR)/apktool -t miui -f $$< -o $(TARGET_OUT_DIR)/$(1) $(hide) sed -i "/tag:/d" $$@/apktool.yml $(hide) sed -i "s/isFrameworkApk: true/isFrameworkApk: false/g" $$@/apktool.yml @@ -53,9 +53,9 @@ ifneq ($(wildcard $(1)),) endif $(APKTOOL) b -p $(TARGET_OUT_DIR)/apktool -a $(AAPT) $(TARGET_OUT_DIR)/$(1) -o $$@ @echo "9Patch png fix $$@..." - $(FIX_9PATCH_PNG) $(1) $$(dir $$(prebuilt-apk-path)) $(TARGET_OUT_DIR) $(1)/res - @echo "sign $$(apkcert) key for $$@..." - $(hide) java -jar $(TOOLS_DIR)/signapk.jar $(CERTIFICATE_DIR)/$$(apkcert).x509.pem $(CERTIFICATE_DIR)/$$(apkcert).pk8 $$@ $$@.signed + $(FIX_9PATCH_PNG) $(1) $$(dir $$(prebuilt-apk-path-$(1))) $(TARGET_OUT_DIR) $(1)/res + @echo "sign $$(apkcert-$(1)) key for $$@..." + $(hide) java -jar $(TOOLS_DIR)/signapk.jar $(CERTIFICATE_DIR)/$$(apkcert-$(1)).x509.pem $(CERTIFICATE_DIR)/$$(apkcert-$(1)).pk8 $$@ $$@.signed $(hide) mv $$@.signed $$@ @echo "<<< build $$@ completed!"