[ASUS ZenFone 8] bnsmb:
How to use the Hardware Test App from ASUS on a Zenfone running a CustomROM

The Hardware Test App from ASUS for the Zenfone 8 can also be used on a ASUS Zenfone 8 running a CustomROM.

But to get the App working on a CustomROM some efforts are neccessary.

The ASUS Hardware Test App needs the permission to modify system settings. To get this permission the app must be signed with the platform certificate used for the running Android OS.

And because these certificates are not available for the public for all public available CustomROMs (for some very good reasons ...) you must compile your own CustomROM for using the ASUS Hardware Test App on a CustomROM.

So -- for those who still want to continue: Here are the steps neccessary to run the Hardware Test App from ASUS for the Zenfone 8 on a phone running a CustomROM :

First copy the apk with the ASUS Hardware Test App from a Zenfone 8 running the original Android 12 from ASUS to your PC.

This is the file

/system/apps/SMMI_TEST/SMMI_TEST.apk

on the phone running the ASUS Android OS.

Now it's neccessary to sign the App with the platform key from your CustomROM:

In the OmniROM (and I assume that's also true for other AOSP based CustomROMs) the neccessary files, platform.pk8 and platform.x509.pem, are in the directory

./build/make/target/product/security

in your build tree for the CustomROM, e.g.

[xtrnaw7@t15g /data/develop/android/OmniROM]$ ls -l ./build/make/target/product/security/platform.*
-rw-------. 1 xtrnaw7 xtrnaw7 1219 Jun 25 09:39 ./build/make/target/product/security/platform.pk8
-rw-rw-r--. 1 xtrnaw7 xtrnaw7 1460 Jun 25 09:39 ./build/make/target/product/security/platform.x509.pem
[xtrnaw7@t15g /data/develop/android/OmniROM]$

Now re-sign the apk file using these commands:

# remove the current certificate files from the apk (probably not neccessary -- but shouldn't harm)
#
zip -d SMMI_TEST.apk META-INF/CERT.SF META-INF/CERT.RSA

# do a zip align for the apk and write the output to SMMI_TEST1.apk
#
# (zipalign is part of the OTA tools)
#
/data/develop/android/otatools/bin/zipalign 4 SMMI_TEST.apk SMMI_TEST1.apk

# test the result (there should be NO output from this command)
#
/data/develop/android/otatools/bin/zipalign -c 4 SMMI_TEST1.ap

# and now sign the apk with the platform key from the development tree for your self compiled CustomROM
# (apksigner.jar is part of the Sdk from Google for Android)
#
java -jar ./Android/Sdk/build-tools/33.0.0/lib/apksigner.jar sign --key platform.pk8 --cert platform.x509.pem SMMI_TEST1.apk

That's it . The re-signed apk file SMMI_TEST1.apk should work on your CustomROM

To test it:

To test the signed apk do:

Copy the signed apk to the phone running your self compiled CustomROM and issue

ls -l /sdcard/Download/SMMI_TEST1.apk

# 25733396 in the next command is the size of the file /sdcard/Download/SMMI_TEST1.apk in byte
#
cat /sdcard/Download/SMMI_TEST1.apk | pm install -S 25733396

If you get an error like this

130|ASUS_I006D:/ # ls -l /sdcard/Download/SMMI_TEST1.apk
-rw-rw---- 1 u0_a111 media_rw 25733396 2022-08-04 19:02 /sdcard/Download/SMMI_TEST1.apk
ASUS_I006D:/ #
ASUS_I006D:/ # cat /sdcard/Download/SMMI_TEST1.apk | pm install -S 25733396
Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Reconciliation failed...: Reconcile failed: Package com.asus.atd.smmitest has no signatures that match those in shared user android.uid.system; ignoring!]
1|ASUS_I006D:/ #

something went wrong signing the apk. Just do it again.

To install the apk do:

If not already done:

Compile your own CustomROM (using the certificates used to sign the ASUS Hardware Test App!) and install it on the ASUS Zenfone 8. (see How to compile the OmniROM for the ASUS Zenfone 8 for how to compile the OmniROM)

Install Magisk on your phone running the self compiled CustomROM

Simulate a Magisk Module using these commands:

adb shell su - -c mkdir -p /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST

adb push SMMI_TEST1.apk /sdcard/Download/

adb shell su - -c cp /sdcard/Download/SMMI_TEST1.apk /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk

adb shell su - -c chmod o+r /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk

and reboot the phone

adb reboot

After the reboot the ASUS Hardware Test App should be visible in the directory /system/app, e.g.

130|ASUS_I006D:/ # find /system/app/SMMI_TEST/
/system/app/SMMI_TEST/
/system/app/SMMI_TEST/SMMI_TEST1.apk
ASUS_I006D:/ #

To execute the ASUS Hardware Test App do

# open a shell on the ASUS Zenfone 8 (either local or via "adb shell"), become root user

su -

and execute

# switch SELinux to permissive mode (I currently do not know the neccessary SELinux policies to avoid this step ...)
#
setenforce 0

# and start the ASUS Hardware Test App from within the shell
#
am start -n com.asus.atd.smmitest/com.asus.atd.smmitest.main.MAIN

Do not forget to enable SELinux enforcing mode after the tests are done (or reboot the phone ...)

# switch SELinux to permissive mode (I currenlty do not know the neccessary SELinux policies to avoid this step ...)
#
setenforce 1

Sample Script to start the ASUS Hardware Test App

# simple script to start the ASUS Hardware App

CUR_SELINUX_STATUS="$( getenforce )"
CUR_USERID=$( id -u -n )
RESTORE_SELINUX_STATE="false"

if [ "${CUR_SELINUX_STATUS}"x != "Permissive"x ] ; then

if [ "${CUR_USERID}"x != "root"x ] ; then
echo "Either start this script as user \"root\" or set the SELinux mode to \"permissive\" using the command \"setenforce 0\" before starting this script"
exit 1
fi
echo "Setting the SELinux mode to \"Permissive\" ..."
setenforce 0
RESTORE_SELINUX_STATE="true"
else
echo "The SELinux mode is already \"Permissive}\" "
fi

am start -n com.asus.atd.smmitest/com.asus.atd.smmitest.main.MAIN 2>&1 | tee /sdcard/Download/test.out

if [ ${RESTORE_SELINUX_STATE} = true ] ; then
echo "Press return when done with the tests .."
read USER_INPUT
echo "Setting the SElinux mode back to \"Enforcing\" ...."
setenforce 1
else
echo "Do not forget to set the SELinxu mode back to \"Enforcing\" using the command \"setenforce 1\" "
fi

Trouble Shooting

If the boot process of the phone hangs after adding the pseudo Magisk Module for the ASUS Hardware Test App do:

# connect to the phone via adb (that should work!)
#
adb shell

# become root user
#
su -

# delete the file with the AUS Hardware Test App
#
rm /data/adb/modules/SMMI_TEST/system/app/SMMI_TEST/SMMI_TEST1.apk

# and reboot the phone
#
reboot

Most probably something went wrong signing the app or you did not do the zip align (there should be some messages visible in logcat to find the reason for the boot loop; check the output of logcat before rebooting the phone)

A useful test to find reason for the boot loop is :

# try to install the apk as root user
#
su -

# and then
#
setenforce 0
pm install /sdcard/Download/SMMI_TEST.apk

If booting the phone works but the App does not start make sure that the SELinux status is permissive.

Update 26.06.2022

The adb commands to create the "simulated" Magisk Module must be executed by the user root - fixed.

Added a sample script to start the ASUS Hardware Test Tool

Update 04.08.2022

Added instructions to to test if signing the apk was successfull

Update 15.05.2024

see How to add the ASUS Hardware TestTool as prebuild app for a Custom ROM for adding th Hardware TestTool as prebuild app to a self compiled ROM

the instructions to add the necessary SELinux policies for the ASUS Hardware TestTool are listed in the 3rd post of this thread