[Samsung Galaxy A51 Themes, Apps, and Mods] gh0stza:
Hi,

This is my first post here.

Yesterday I rooted a Samsung A51 SM-A515F/N with android 11 [A515FxxU4EUD7] stock rom with twrp recovery, unlocked bootloader, and magisk.

As far as I can tell zero functionality loss on OS. Got everything to work just right.

Pass SafetyNet Test.

systemized FGL Pro and GPS Joystick as priv-apps.

Both applications recognize system mode but they both crash when you start the location mocking.

I believe I found what is making them crash.

Need confirmation/Advise on how to proceed.

Assume full rooted SM-515F with fully working Magisk 23.0 and Terminal Systemizer module installed

Systemizer command:

a51:/ $ su

a51:/ # systemize

! Busybox not detected

Please install one (@osm0sis' busybox recommended)

df: Unknown option 'm' (see "df --help")

df: Unknown option 'm' (see "df --help")

==============================================

App Systemizer (Terminal Emulator) v17.3.1(70)

by veez21

==============================================

BusyBox not found!

==============================================

Enter logs to upload logs

==============================================

Set SELinux Enabled: false

SELinux Status: Enforcing

==============================================

1 - Systemize Installed Apps (Listed)

2 - Systemize Installed Apps (Enter label)

3 - Systemize given APK

s - Set SELinux

0 - Exit

[CHOICE]: 3

Enter APK Path

Example: /sdcard/launcher.apk

x - Back to Menu

> /sdcard/Download/com.ltp.pro.fakelocation.apk

Checking if file exists - OK

Checking if file is an APK - OK

Checking package name - com.ltp.pro.fakelocation

Where to install?

< 1 - /system/app | 2 - /system/priv-app | 0 - cancel > : 2

df: Unknown option 'm' (see "df --help")

df: Unknown option 'm' (see "df --help")

Checking APK size - 5M

Transfering com.ltp.pro.fakelocation.apk(com.ltp.pro.fakelocation) to '/system/priv-app'...

Granting Permissions

com.ltp.pro.fakelocation - Done

1|a51:/ # mount -o rw,remount /

a51:/ # rm /etc/permissions/privapp-permissions-platform.xml

a51:/ # cp /sdcard/Download/privapp-permissions-platform.xml /etc/permissions/

a51:/ # chown root:root /etc/permissions/privapp-permissions-platform.xml

a51:/ # chmod 644 /etc/permissions/privapp-permissions-platform.xml

a51:/ # mount -o ro,remount /

a51:/ # reboot

Snippet of /etc/permissions/privapp-permissions-platform.xml:

...

<!-- CUSTOM Permissions -->

<privapp-permissions package="com.ltp.pro.fakelocation">

<permission name="android.permission.READ_EXTERNAL_STORAGE" />

<permission name="android.permission.WRITE_EXTERNAL_STORAGE" />

<permission name="android.permission.ACCESS_FOREGROUND_LOCATION" />

<permission name="android.permission.ACCESS_BACKGROUND_LOCATION" />

<permission name="android.permission.ACCESS_FINE_LOCATION" />

<permission name="android.permission.ACCESS_COARSE_LOCATION" />

<permission name="android.permission.INSTALL_LOCATION_PROVIDER" />

<permission name="android.permission.ACCESS_MOCK_LOCATION" />

<permission name="android.permission.ACCESS_MEDIA_LOCATION" />

</privapp-permissions>

<!-- END -->>

...

snippet from cmd dumpsys package com.ltp.pro.fakelocation:

Packages:

Package [com.ltp.pro.fakelocation] (1e331cd):

userId=10264

pkg=Package{876da82 com.ltp.pro.fakelocation}

codePath=/system/app/com.ltp.pro.fakelocation

resourcePath=/system/app/com.ltp.pro.fakelocation

legacyNativeLibraryDir=/system/app/com.ltp.pro.fakelocation/lib

primaryCpuAbi=null

secondaryCpuAbi=null

versionCode=67 minSdk=15 targetSdk=28

versionName=3.4.9.3

splits=[base]

apkSigningVersion=2

applicationInfo=ApplicationInfo{876da82 com.ltp.pro.fakelocation}

flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA LARGE_HEAP ]

privateFlags=[ PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING ]

forceQueryable=false

queriesPackages=[]

dataDir=/data/user/0/com.ltp.pro.fakelocation

supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]

usesLibraries:

android.test.base

android.hidl.manager-V1.0-java

android.hidl.base-V1.0-java

usesOptionalLibraries:

org.apache.http.legacy

usesLibraryFiles:

/system/framework/android.test.base.jar

/system/framework/android.hidl.manager-V1.0-java.jar

/system/framework/android.hidl.base-V1.0-java.jar

/system/framework/org.apache.http.legacy.jar

timeStamp=2021-05-30 19:29:31

firstInstallTime=2021-05-30 19:29:31

lastUpdateTime=2021-05-30 19:29:31

signatures=PackageSignatures{3bad593 version:2, signatures:[721026fa], past signatures:[]}

installPermissionsFixed=true

pkgFlags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA LARGE_HEAP ]

declared permissions:

com.ltp.pro.fakelocation.permission.MAPS_RECEIVE: prot=signature, INSTALLED

com.ltp.pro.fakelocation.permission.C2D_MESSAGE: prot=signature, INSTALLED

requested permissions:

android.permission.INTERNET

android.permission.ACCESS_NETWORK_STATE

android.permission.ACCESS_FINE_LOCATION

android.permission.ACCESS_COARSE_LOCATION

android.permission.SYSTEM_ALERT_WINDOW

com.google.android.providers.gsf.permission.READ_GSERVICES

android.permission.READ_EXTERNAL_STORAGE: restricted=true

android.permission.WRITE_EXTERNAL_STORAGE: restricted=true

android.permission.FOREGROUND_SERVICE

com.android.vending.BILLING

com.android.vending.CHECK_LICENSE

android.permission.WRITE_SETTINGS

android.permission.INSTALL_LOCATION_PROVIDER

android.permission.WRITE_SECURE_SETTINGS

android.permission.ACCESS_MOCK_LOCATION

android.permission.WAKE_LOCK

com.google.android.c2dm.permission.RECEIVE

com.ltp.pro.fakelocation.permission.C2D_MESSAGE

android.permission.ACCESS_BACKGROUND_LOCATION: restricted=true

android.permission.ACCESS_MEDIA_LOCATION

install permissions:

com.ltp.pro.fakelocation.permission.C2D_MESSAGE: granted=true

android.permission.WRITE_SETTINGS: granted=true

com.google.android.c2dm.permission.RECEIVE: granted=true

com.google.android.providers.gsf.permission.READ_GSERVICES: granted=true

android.permission.SYSTEM_ALERT_WINDOW: granted=true

android.permission.FOREGROUND_SERVICE: granted=true

android.permission.INTERNET: granted=true

com.android.vending.CHECK_LICENSE: granted=true

com.android.vending.BILLING: granted=true

android.permission.ACCESS_NETWORK_STATE: granted=true

android.permission.WAKE_LOCK: granted=true

User 0: ceDataInode=46342 installed=true hidden=false suspended=false distractionFlags=0 stopped=false notLaunched=false enabled=0 instant=false virtual=false

overlay paths:

/product/overlay/NavigationBarMode3Button/NavigationBarMode3ButtonOverlay.apk

gids=[3003]

runtime permissions:

android.permission.ACCESS_FINE_LOCATION: granted=true, flags=[ USER_SET]

android.permission.READ_EXTERNAL_STORAGE: granted=false, flags=[ APPLY_RESTRICTION]

android.permission.ACCESS_COARSE_LOCATION: granted=true, flags=[ USER_SET]

android.permission.WRITE_EXTERNAL_STORAGE: granted=false, flags=[ APPLY_RESTRICTION]

android.permission.ACCESS_BACKGROUND_LOCATION: granted=false, flags=[ REVOKE_WHEN_REQUESTED|APPLY_RESTRICTION]

android.permission.ACCESS_MEDIA_LOCATION: granted=true, flags=[ USER_SET|REVOKE_WHEN_REQUESTED]

Please direct your attention to the second last line: "android.permission.ACCESS_BACKGROUND_LOCATION: granted=false, flags=[ REVOKE_WHEN_REQUESTED|APPLY_RESTRICTION]"

This permission is restricted even though permission has been explicitly set with the xml file.

I believe this is due to: https://developer.android.com/training/location/permissions this update of the privacy policy on Android 11.

Now this thread says that the permission for ACCESS_FOREGROUND_LOCATION needs to be requested in the application.manifest file before ACCESS_BACKGROUND_LOCATION is called. This allows the user to select the always allow option that allows background threads to handle location permissions. This is where I believe the app crashes - the thread gets aborted and then crashes the app because it can't get background location access.

I'm thinking the only solution is to get the devs of FGL/GPSJoystick to add these permissions to their minifest files. Am I correct or am I missing something big?

EDIT: interestingly - installing the app as userapp(not system app), gives the "Allow all the time" option under location (Settings->Apps->Permissions->Location). I think I'm missing something, aldo I might be a little sleep deprived, 36 hours straight with this A51 :sleep:

Please let me know if you need any more info from me