Hi GrapheneOS team and community,
Currently, I encountered an error I couldn't fix in my pixel 6, android 13. Which didn't happen during android 12.1.

In my secondary profile I installed Element (Matrix) and Jami from fdroid, later decided to uninstall them. Each time I click the uninstall button, it does nothing and just keep crashing. I haven't tried everything but almost all my other apps can be uninstalled as usual except these two apps which is weird.

Do you guys know what is the cause and solution?

Here is the error log

type: crash
osVersion: google/oriole/oriole:13/TP1A.220624.021/2022083000:user/release-keys
package: com.android.packageinstaller:33
process: com.android.packageinstaller

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.packageinstaller/com.android.packageinstaller.UninstallerActivity}: java.lang.SecurityException: Package com.android.packageinstaller from UID 1410045 blocked by mode 1
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3677)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3814)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
	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:2309)
	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:7904)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ExecInit.main(ExecInit.java:49)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
Caused by: java.lang.SecurityException: Package com.android.packageinstaller from UID 1410045 blocked by mode 1
	at android.os.Parcel.createExceptionOrNull(Parcel.java:3012)
	at android.os.Parcel.createException(Parcel.java:2996)
	at android.os.Parcel.readException(Parcel.java:2979)
	at android.os.Parcel.readException(Parcel.java:2921)
	at android.app.usage.IStorageStatsManager$Stub$Proxy.queryStatsForPackage(IStorageStatsManager.java:504)
	at android.app.usage.StorageStatsManager.queryStatsForPackage(StorageStatsManager.java:221)
	at com.android.packageinstaller.handheld.UninstallAlertDialogFragment.getAppDataSizeForUser(UninstallAlertDialogFragment.java:72)
	at com.android.packageinstaller.handheld.UninstallAlertDialogFragment.getAppDataSize(UninstallAlertDialogFragment.java:105)
	at com.android.packageinstaller.handheld.UninstallAlertDialogFragment.onCreateDialog(UninstallAlertDialogFragment.java:178)
	at android.app.DialogFragment.onGetLayoutInflater(DialogFragment.java:418)
	at android.app.Fragment.performGetLayoutInflater(Fragment.java:1322)
	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1303)
	at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2431)
	at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2210)
	at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2166)
	at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2067)
	at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3057)
	at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3004)
	at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:185)
	at android.app.Activity.performCreate(Activity.java:8309)
	at android.app.Activity.performCreate(Activity.java:8280)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1389)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3658)
	... 14 more
Caused by: android.os.RemoteException: Remote stack trace:
	at com.android.server.usage.StorageStatsService.enforceStatsPermission(StorageStatsService.java:210)
	at com.android.server.usage.StorageStatsService.queryStatsForPackage(StorageStatsService.java:350)
	at android.app.usage.IStorageStatsManager$Stub.onTransact(IStorageStatsManager.java:264)
	at android.os.Binder.execTransactInternal(Binder.java:1302)
	at android.os.Binder.execTransact(Binder.java:1265)

Update: I tried to create a new profile to install Element and Jami, then uninstalling them in that new profile works fine. But it's not working for my current secondary profile.

Thanks retired-mod-account for your feedback.

When I checked for permissions for Package installer from App info, only Sensor permission is listed which wasn't relevant to the issue. Then I recalled it could be hidden somewhere in Special app access and bingo! I remember trying to limit as much permissions as possible. So basically Element and likely Jami was parsing for StorageStats and asking if you wish keep its app data before uninstalling. That's why it kept crashing.

Here's how I solved the issue:
Go to Settings > Apps > Special app access > Usage access > Package installer (Enable: Show system) > Permit usage access

I hope AOSP will include and list the permissions from Special app access into App info. As its existence is probably unknown for most users.

Forum moderator please help to add the solved tag. Thanks!