API 30 introduced some new limitations. These limitations have not yet been completely implemented in AI2, so many components/extensions don't work as expected, or at all.
Contents:
-
API 30 doesn't support
WRITE_EXTERNAL_STORAGE
permission.
If you need to write to the external storage, you must use a shared folder.Affected components/extensions:
Camera component: doesn't work (relies on
WRITE_EXTERNAL_STORAGE
).
File component: doesn't work for writing to external storage (same reason).
Any other extension/component that relies onWRITE_EXTERNAL_STORAGE
(same reason). -
API 30 introduced Package Visibility limitations.
Apps can't see/interact with other installed apps. This can have severe implications if your app relies on interacting or checking another's apps info, version, etc.Affected components/extensions:
Taifun Package Manager extension: works only with some basic apps like settings, calculator, etc.
PkgUtils extension (same problem).
Any other query on other installed packages either through components, extensions, or activity starters (same problem).
Luckily there are workarounds:
1. Writing to external storage without write permissions
1-1. Use the Shared Folders
The right way to write to external storage is to use specific directories, known as shared folders. These folders don't require WRITE_EXTERNAL_STORAGE
permission, therefore the new API limitation has almost no effect on them. You can write freely inside them. These are the directories:
- /storage/emulated/0/Documents
- /storage/emulated/0/Download
- /storage/emulated/0/Pictures
- /storage/emulated/0/DCIM
- /storage/emulated/0/Music
- /storage/emulated/0/Movies
There may be more (for example /Ringtones or /Alarms).
You can also create subdirectories in these. No write permissions required.
The file component doesn't work for writing to external storage, luckily you can use the TaifunFile extension, which doesn't rely on WRITE_EXTERNAL_STORAGE
permission. Just follow those rules:
Rule 1: Use the Android File API:
Try with
file://
first, as it invokes the File API, which is supported in API 30.Use whole paths (no relative dirs) when writing to external storage:
file:///storage/emulated/0/Music/song.mp3
(works with Taifun File extension)Note that other extensions/components work without
file://
//storage/emulated/0/Pictures/my-photo.jpg
(works with Pro Camera extension)
Rule 2: You can only write in the Shared Folders:
file:///storage/emulated/0/RandomFolder/song.mp3
(doesn't work in non-shared folders)
Components & extensions that don't rely on WRITE_EXTERNAL_STORAGE
will work if you follow these two rules.
Note that because AI2 has not yet implemented the necessary changes, some problems exist even with shared folders. Check out this if you want to work with shared folders. Also this. Then check my guide Working with shared folders to understand this one (important):
1-2. The camera component
The camera component doesn't work (it relies on
WRITE_EXTERNAL_STORAGE
), but luckily there are some alternatives:
Method 1: Use Pro camera extension (see working example)
This camera extension doesn't rely onWRITE_EXTERNAL_STORAGE
permission.
Note that you can only write to Shared Folders.
Note that you must not usefile://
in the paths.
Note: Don't rely on overwriting files in shared folders!Method 2: Set Screen1
DefaultFileScope
to Legacy
This somehow enables writing with the old models or something, I didn't fully understand, but it definitely is not the future of android. Your app may or may not get approved on Play Store.
edit: Turns out it is harmless. But personally I have all my current apps on scope:App and I just work with the rules of API 30.
2. Query installed packages
Due to Package Visibility changes in API 30, applications can't see other applications without specific permissions. Many apps rely on checking for other installed apps though.
There are two ways to overcome this;
-
Queries
This means you have to explicitly define all the packages that your app is going to check/communicate with, in your app's manifest.
If you know how to do this, go ahead. Get more information on queries here. -
QUERY_ALL_PACKAGES
The other way is to add the
QUERY_ALL_PACKAGES
permission in your app's manifest. This will make all apps visible to your app. Note that Google Play doesn't likeQUERY_ALL_PACKAGES
and recommends using queries instead. But if there is good reason for using it (for something that's counter-intuitive to do with queries, like an app manager, or an app store), they will let you use it.Add this line in your app's manifest:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
Or import my extension, tsf.QueryAllPackages.aix which does this automatically.
You will find info on how to use (or build your own) on github.This is definitely useful for those who don't know how to edit their manifest. I used to be one of them. More info on github.
With this workaround you can use PkgUtils and TaifunPM extensions, without getting limited results. Just make sure to ask for the permission
android.permission.QUERY_ALL_PACKAGES
in your Screen1 too.
That's it for now. Feel free to mention other temporary workarounds that may help troubleshooting/development. Thank you and have a good day