This guide is currently updated to Sailfish 4.6. Some things have changed, so check the history if you need guide for an older version.
Devices I have tested the guide:
- Xperia 10 II
- Currently not working: Xperia XA2
You need unzip
, wget
and squashfs-tools
.
If you have Debian/Ubuntu/etc. run the following:
sudo apt install unzip wget squashfs-tools
In the host Linux machine
-
retrieve OGApps full from: https://opengapps.org/
- Xperia 10 II: ARM64 / Android 11.0
- Xperia XA 2: ARM / Android 10.0 (interestingly, the hardware supports 64bit..)
The full version is required for Trichrome Library, which is required by Chrome
-
download also md5 checksum
-
copy
/opt/appsupport/system.img
to a Linux, e.g.:scp defaultuser@PHONE_IP:/opt/appsupport/system.img system-original.img
-
extract required apps and support files, i.e, run the following in bash/zsh/ksh:
zip=$(ls open_gapps-arm*-*-full-*.zip | sort -rn -k3,5 -t- | head -n1)
echo "USING PACKAGE $zip, CHECK THAT IT HAS CORRECT ANDROID VERSION\!"
if md5sum -c "$zip.md5"; then
mkdir -p to-system/
for f in \
Core/defaultetc-common.tar.lz \
Core/defaultframework-common.tar.lz \
'Core/gmscore-*.tar.lz' \
Core/googlebackuptransport-all.tar.lz \
Core/googleonetimeinitializer-all.tar.lz \
Core/googlepartnersetup-all.tar.lz \
Core/gsfcore-all.tar.lz \
'Core/setupwizarddefault-*.tar.lz' \
'Core/vending-*.tar.lz' \
GApps/trichromelibrary-arm64.tar.lz \
; do
echo ".. $f:"
unzip -p "$zip" "$f" | tar -vx --lzip --strip-components 2 -C to-system/
done
# remove execute from data files
find to-system/ -type f -print0 | xargs -r0 chmod -x
# extract shared libs
if [ "$zip" = "${zip#*-arm64-}" ]; then native=armeabi-v7a; else native=arm64-v8a; fi
for apk in to-system/priv-app/*/*.apk; do
pushd "${apk%/*}"
rm -rf lib/*/
unzip -x "${apk##*/}" "lib/$native/*"
[ -e lib/armeabi-v7a ] && mv lib/armeabi-v7a lib/arm
popd
done
fi
-
open squashfs image, fix, copy apps and repackage (requries
squashfs-tools
)NOTE: If you find a better method to keep file owners and permissions than sudo, let me know!
sudo bash -c " # unpack root=/dev/shm/sailfish-android unsquashfs -d \$root system-original.img # copy cp -vr to-system/* \$root/system/ # fix ownership of new files find to-system -type f | while read f; do chown 500000:500000 \"\$root/system/\${f#*/}\"; done # repackage mksquashfs \$root/ system.img -comp lz4 -Xhc -noappend -no-exports -no-duplicates -no-fragments # clean chown $USER:$(id -ng) system.img rm -rf \$root "
-
upload image
scp system.img defaultuser@PHONE_IP:/tmp/
-
cleaup
rm -rf to-system system.img
(note: let's keep original-system.img as a backup)
In your phone, e.g. ssh defaultuser@PHONE_IP
. Remember to be a root devel-su
.
-
Install the new image:
# stop appsupport systemctl stop appsupport # backup system.img cp /opt/appsupport/system.img /home/appsupport-system.img # replace it cp /tmp/system.img /opt/appsupport/system.img rm /tmp/system.img # clear system app cache rm -vrf /home/.android/data/system/package_cache/*/Settings-* # remove updated google apps rm -vrf /home/.android/data/app/com.android.vending-* rm -vrf /home/.android/data/app/com.google.android.gms-* # fix android bootup with Sailfish 4.1 rm -vrf /home/.android/data/misc/audioserver/ # force rerunning permission and storage migrations rm /home/defaultuser/android_storage/.privilege_migration_done rm /home/defaultuser/android_storage/.storage_migration_done # you can start appsupport now systemctl start appsupport
-
Note that startup after the installation will take a long time as the Android is caching and compiling files. You can follow the progress with the following command. However, it will show a lot of errors and warnings, so it might be alarming, even though everything is ok.
appsupport-attach /system/bin/logcat
When you install google play services for the first time:
-
open google play and sign in
-
retrieve GSF ID:
Sadly, neither Sailfish 4 or Android contains
sqlite3
anymore, so you need to do some manual work. Either copy the database to your computer or install sqlite3 to your phone.Copy:
# on sailfish after devel-su cp /home/.android/data/data/com.google.android.gsf/databases/gservices.db /tmp/ chmod a+r /tmp/gservices.db # on your computer scp defaultuser@PHONE_IP:/tmp/gservices.db sqlite gservices.db 'select * from main where name = "android_id";' # copy the id from the output rm gservices.db # on sailfish after devel-su rm /tmp/gservices.db
Or Install:
# on sailfish after devel-su pkcon install python3-sqlite python3 -c 'import sqlite3; c = sqlite3.connect("/home/.android/data/data/com.google.android.gsf/databases/gservices.db").cursor(); c.execute("select value from main where name=\"android_id\";"); print(c.fetchone()[0])'
-
Register your device: https://www.google.com/android/uncertified/
- Android/apps believe the device is rooted (well, it is, but they shouldn't know that).
- Fast location doesn't work with wi-fi polling
- Google Backup Transport doesn't seem to work (requires investication)
- Xperia XA2:
- Google Play Store can't install applications. Seems android biometric interface is not implemented (at least up to SFOS 4.1, works in Xperia 10 II SFOS 4.2)
-
for location service, disable google wi-fi checking, it doesn't work. This means that accurate location will take some time, of course (e.g. Jodel will take few minutes to login).
-
when appsupport is running, you can stream android logs with
appsupport-attach /system/bin/logcat
-
If google backup is disabled, you can re-enable it:
# enter Android shell appsupport-attach /system/bin/sh # in Android system bmgr transport com.google.android.backup/.BackupTransportService
Hmm, I reinstalled complete aliendavik and appsupport-system-unprivileged to recreate the /opt/alien/system.img.
Then restarted from scratch the steps above. By the way I also restarting the phone after that my old installed apps like whatsapp are running, but no google play store available. Is it possible I must install it first but where it is? Maybe can I simply use install the apk from the pico image but whats the name of the apk?
I tried also to reinit my android storage by moving /home/.android to another place. But then no play icon appears on sfos app screen. But installing aptoide and fdroid app from sf store is working well.
I think there is a mistake in my brain, hopefully you can find my fault.