Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06b93912 authored by Dan Willemsen's avatar Dan Willemsen
Browse files

CtsShim: Support building with tapas

This way the build server can build these apks, instead of the manual
process that was described in the README.

Bug: 29122339
Change-Id: I2d3d9924da908d501d3b1b07b4a317f8ad6f413f
parent fd6e7e67
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53,3 +53,4 @@ LOCAL_SRC_FILES := CtsShim.apk

include $(BUILD_PREBUILT)

include $(call all-makefiles-under,$(LOCAL_PATH))
+16 −8
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
LOCAL_PATH := $(my-dir)

###########################################################
# Variant: Privileged app
# Variant: Privileged app upgrade

include $(CLEAR_VARS)
# this needs to be a privileged application
@@ -28,15 +28,15 @@ LOCAL_SDK_VERSION := current
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false

LOCAL_PACKAGE_NAME := CtsShimPriv
LOCAL_PACKAGE_NAME := CtsShimPrivUpgrade

LOCAL_MANIFEST_FILE := shim_priv/AndroidManifest.xml
LOCAL_MANIFEST_FILE := shim_priv_upgrade/AndroidManifest.xml

include $(BUILD_PACKAGE)

my_shim_priv_upgrade_apk := $(LOCAL_BUILT_MODULE)

###########################################################
# Variant: Privileged app upgrade
# Variant: Privileged app

include $(CLEAR_VARS)
# this needs to be a privileged application
@@ -47,12 +47,20 @@ LOCAL_SDK_VERSION := current
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false

LOCAL_PACKAGE_NAME := CtsShimPrivUpgrade
LOCAL_PACKAGE_NAME := CtsShimPriv

LOCAL_MANIFEST_FILE := shim_priv_upgrade/AndroidManifest.xml
# Generate the upgrade key by taking the hash of the built CtsShimPrivUpgrade apk
gen := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),,true)/AndroidManifest.xml
$(gen): PRIVATE_CUSTOM_TOOL = sed -e "s/__HASH__/`sha512sum $(PRIVATE_INPUT_APK) | cut -d' ' -f1`/" $< >$@
$(gen): PRIVATE_INPUT_APK := $(my_shim_priv_upgrade_apk)
$(gen): $(LOCAL_PATH)/shim_priv/AndroidManifest.xml $(my_shim_priv_upgrade_apk)
	$(transform-generated-source)

include $(BUILD_PACKAGE)
my_shim_priv_upgrade_apk :=

LOCAL_FULL_MANIFEST_FILE := $(gen)

include $(BUILD_PACKAGE)

###########################################################
# Variant: System app
+8 −21
Original line number Diff line number Diff line
@@ -6,31 +6,18 @@ must specify the singular APK that can be used to upgrade it.
NOTE: The need to include a binary on the system image may be deprecated if a
solution involving a temporarily writable /system partition is implemented.

MAKING THE PREBUILTS
In order to generate the upgrade key, the shim directory needs to be built multiple
times. First to generate the upgrade APK [so its hash can be obtained] and again
once the hash has been included as part of the pre-installed APK.

build:
    $ mmm frameworks/base/packages/CtsShim/build

update the manifest:
    $ sed -i -e "s/__HASH__/`sha512sum out/target/product/shamu/system/priv-app/CtsShimPrivUpgrade/CtsShimPrivUpgrade.apk | cut -d' ' -f1`/" \
        frameworks/base/packages/CtsShim/build/shim_priv/AndroidManifest.xml
    $ tapas CtsShim CtsShimPriv CtsShimPrivUpgrade
    $ m

build:
    $ mmm frameworks/base/packages/CtsShim/build

update prebuilts:
    $ cp out/target/product/shamu/system/priv-app/CtsShimPrivUpgrade/CtsShimPrivUpgrade.apk \
local testing:
    $ cp $OUT/system/priv-app/CtsShimPrivUpgrade/CtsShimPrivUpgrade.apk \
        cts/hostsidetests/appsecurity/test-apps/PrivilegedUpdateApp
    $ cp out/target/product/shamu/system/priv-app/CtsShimPriv/CtsShimPriv.apk \
    $ cp $OUT/system/priv-app/CtsShimPriv/CtsShimPriv.apk \
        frameworks/base/packages/CtsShim
    $ cp out/target/product/shamu/system/app/CtsShim/CtsShim.apk \
    $ cp $OUT/system/app/CtsShim/CtsShim.apk \
        frameworks/base/packages/CtsShim

revert manifest:
    $ pushd frameworks/base && git checkout -- packages/CtsShim/build/shim_priv/AndroidManifest.xml && popd

Finally, upload and submit both the cts/ and frameworks/base/ repos.
For final submission, the APKs should be downloaded from the build server, then
submitted to the cts/ and frameworks/base/ repos.