This guide is currently updated to Sailfish 4.5. 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 pico from: https://opengapps.org/
- Xperia 10 II: ARM64 / Android 11.0
- Xperia XA 2: ARM / Android 10.0 (interestingly, the hardware supports 64bit..)
-
download also md5 checksum
-
copy
/opt/alien/system.img
to a Linux, e.g.:scp defaultuser@PHONE_IP:/opt/alien/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*-*-pico-*.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' \
; 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
-
optionally, you can include Aurora Store as system app at this point (fork of YalpStore)
Google Play store works with Xperia 10 II, so if you prefer that, no need to install this.
mkdir -p to-system/priv-app/AuroraStore wget \ -U 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36' \ -O to-system/priv-app/AuroraStore/AuroraStore.apk \ 'https://files.auroraoss.com/AuroraStore/Stable/AuroraStore_4.1.1.apk' echo "0c4a74b84c94deec64f68d75fd18e73fbaa8393fb324945e6c25cd8943418507 to-system/priv-app/AuroraStore/AuroraStore.apk" | sha256sum -c
If the last line, doesn't say
OK
, then there was a problem with the download, do not use the image! . -
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 alien systemctl stop aliendalvik # backup system.img cp /opt/alien/system.img /home/alien-system.img # replace it cp /tmp/system.img /opt/alien/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 alien now systemctl start aliendalvik
-
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 aliendalvik 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 didn't check the first time case. I would love to have another device for that (I could reset the Android). However, I did check that the db file is there in my phone, but it's hard to say if that is in use or left from before. So, if you get the Store working, but you won't find the file, then I or you need to do some debugging.
Any how, the Play Store icon should be visible as long as the correct image is in use. Every (or most) OS updates do reset the
/opt/alien/system.img
to the original version from Jolla, so the above steps need to be done after every update (well, not the first time part, but creating the image part).A script would be nice, but making it work for everyone is bit too much work. In addition, I prefer not to install too many packages in the phone. However, there exists some in forums (seems to attempt to work for everyone quite well), which you can check out. It seems to do mostly the same things. Didn't have
# force rerunning permission and storage migrations
step at the moment.Any how, my guess is that you don't have the correct image in use. Thus repeat from the start and try to keep track of files. Make extra copies or write notes where needed.