[General Topics] a_testi:
Sadly I'm not an Android developer or hacker. The last time I deeply played around with custom ROMs was when the Samsung Galaxy S6 was current. Anyway I wasted an entire afternoon and evening on what follows. Now I'm tired and stuck. I just want a working phone, and I did this stuff purely out of self defence, because technology has become hostile.

Modify ROM

To edit the ROM, this is roughly how I did it:

I use 7-Zip to open "Than.img" - 7-Zip can actually understand some of the ROM dumps and extract them

I switch to a junk Debian VM where I have the folder with extracted files set as a shared folder (with VMware 17 and the latest Debian, this works right of the box)

Then I do this:

# All of the below as root, because YOLO

cd ~/
wget http://newandroidbook.com/tools/imjtool.tgz
wget https://ci.android.com/builds/submitted/9401535/aosp_cf_x86_64_phone-userdebug/latest/cvd-host_package.tar.gz
tar xzf imjtool.tgz
tar xzf cvd-host_package.tar.gz

# Go to where extracted files are
cd /mnt/hgfs/rom/work
mkdir /mnt/product
mkdir /mnt/system
mount product_a.ext /mnt/product/
mount system_a.ext /mnt/system/

# Now you can play around!
# You don't have much space to work with, but it's OK for small patches.
# /dev/loop0 188M 176M 8.0M 96% /mnt/product
# /dev/loop1 1.7G 1.7G 13M 100% /mnt/system
# Out of space?
# You can grow the ext4 partition images a bit.
# umount /mnt/system
# e2fsck -f /mnt/hgfs/rom/work/system_a.ext
# resize2fs /mnt/hgfs/rom/work/system_a.ext 2G
# mount system_a.ext /mnt/system/
# Now you have 300 MB more space.

# To finish up
umount /mnt/product
umount /mnt/system
e2fsck -yf system_a.ext
e2fsck -yf product_a.ext

~/bin/lpmake --metadata-size 65536 --device-size=8589934592 --metadata-slots=3 \
--group=google_system_dynamic_partitions_a:2802081792 \
--partition=product_a:none:196341760:google_system_dynamic_partitions_a \
--partition=system_a:none:2147483648:google_system_dynamic_partitions_a \
--partition=vendor_a:none:458256384:google_system_dynamic_partitions_a \
--image=product_a=./product_a.ext \
--image=system_a=./system_a.ext \
--image=vendor_a=./vendor_a.img \
--group=google_system_dynamic_partitions_b:88780800 \
--partition=product_b:none:0:google_system_dynamic_partitions_b \
--partition=system_b:none:88780800:google_system_dynamic_partitions_b \
--partition=vendor_b:none:0:google_system_dynamic_partitions_b \
--image=product_b=./product_b \
--image=system_b=./system_b.img \
--image=vendor_b=./vendor_b \
--sparse --output ./super.new.img

# you need to edit the numbers in above command as follows:
# device-size = size of all files (or just 8589934592 for 8GB partition)
# group = size of the files in that group
# partition = size of the image file
# find the sizes using command "stat -c '%n %s' *"

# If it complains about "vendor_b" being strange, just set its image file
# to vendor_a.img and adjust the numbers again. It doesn't matter.
# Slot B is normally never used.

WiFi Calling Crash

For the Settings app crashing when trying to enable VoWiFi, it's caused by an oversight by the original ROM developers.

The APK is at /system/system_ext/priv-app/MtkSettings/MtkSettings.apk

The crash is:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.Settings$WifiCallingSettingsActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set android:windowActionBar to false in your theme to use a Toolbar instead.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3675)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3832)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2247)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7881)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

The workaround could be as simple as:

Decompile it with apktool (use "apktool -r" because it cannot reassemble resources correctly)

Open this file: smali/com/android/settings/Settings\$WifiCallingSettingsActivity.smali

Comment out this line, save, recompile (apktool b), and sign:

.line 280
# invoke-virtual {p0, p1}, Lcom/android/settings/core/SettingsBaseActivity;->setActionBar(Landroid/widget/Toolbar;)V

But if you put the patched settings app into the ROM you will brick the phone. All system apps need to be signed with the same platform key, and that key is somewhere in China. I don't know how to bypass the signature check for system apps. I think you can resign all system apps with a custom key but unless someone could tell me how, I don't know. I think because of this also you can't just translate the missing strings in the Phone app.

Cleaned ROM

Here's my attempt to clean up the NVT ROM. This is currently running on my phone but if it bricks your phone then I am sorry. You may need to wipe userdata. Maybe not. I don't know. I wiped it.

Restored factory boot logo and charge animation

Restored factory boot Android animation

Removed "Mod\ Bởi\ Nguyễn\ Văn\ Thản" folder

Removed NVT's hacked QinSystemUpdate, so he can't remotely destroy phones (NOTICE Settings app will crash if you try to check for updates, because the APK it needs is now no longer there)

Removed "Gbroad" which didn't work because poor NVT could not spell "GBoard" correctly

Removed Samsung Music

Removed Zalo (Vietnamese social network)

Removed SprdQuickSearchBox

Removed Facebook Messenger

Removed third-party IR Blaster app

Removed Baidu App and Baidu Location Service

Removed "MtkCalendar" which NVT actually replaced with his own Vietnam Lunar Calendar. sigh

Restored Sound Recorder from 1.0.7 Qin China ROM to undo NVT's hardcoded Vietnamese translation of it

Replaced build.prop with the one from the clean Google ROM to restore the phone identifying itself as a Duoqin F22 Pro, to remove various ricer style "performance tweaks"/"speed optimizations", and to get rid of more references to "NVT" (as a bonus the phone no longer defaults to Vietnamese after wiping userdata)

NVT is such a strange person. He even renamed the logo partition to "super.bin", probably hoped that people don't remove his branding. Also the phone reported itself as an Infinix HOT 12, not Duoqin F22 Pro. NVT also changed one of the stock wallpapers, but I have not yet found out how to undo it. Really, the only thing missing from his ROM that the phone starts playing a sound file of someone shouting "Nguyen Van Then" at maximum volume every 30 seconds. Anyway, while NVT still haunts the wallpaper selector, he should be pretty much gone elsewhere. I'm glad the guy did all of this work, but it's always better to become famous by what you do rather than by who you are.

Download patched ROM: https://anonfiles.com/n5vfCfMey7/ThanCleaned_7z Use V2 below

The ROM is pretty much naked, so you need to replace a lot of missing stock apps with custom ones. I recommend using F-Droid (search "Simple Mobile Tools"). They are not perfect, but decent enough, and free without ads. Music player can be replaced with the excellent app "Musicolet" from Google Play. A better romaji T9 keyboard and 10key Japanese keyboard can be taken from https://github.com/shuuryou/f22pro/

I have really mixed feelings about the NVT version, cleaned or not. It's more like the Chinese ROM and the hardware features of the phone are now working essentially without flaws, but the software experience feels so mediocre. Like, it can be tolerated, but it could be so much better with a few little tweaks and changes overall. Not being able to modify the system APKs is a pity.

Edit: I may have accidentally removed all keyboards. Just install one via adb.

Edit2: Of course NVT also replaced all the ringtones. I will have to clean the cleaned ROM even more and will try to fix the keyboard issue then also.

Edit3: Second attempt now available.