TIMAI2
September 9, 2023, 8:42am
1
From an Android point of view there are an β Internal Storage and an β External Storage .
1. Internal Storage
The Internal Storage can only be accessed with a rooted device.
1.1 The app package is saved in
/data/data/<packageName>/
In order to be able to debug your app, AI2 saves the assets for β Companion on devices with
Android β₯ 10 (API β₯ 29):
/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/
Android < 10 :
/storage/emulated/0/Android/data/edu.mitβ¦
Hi Anke
I have an extension that currently declares permissions like this in the manifest:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Has apparently been working OK for users.
With the arrival of the new media permissions do I change to this to achieve the same result ?
<uses-permission android:maxSdkVersion="32" android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="34" android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:maxSdkVersion="34" android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:maxSdkVersion="34" android:name="android.permission.READ_MEDIA_VIDEO"/>
Thanks
Tim
Anke
September 9, 2023, 9:05am
2
Basically it doesn't matter whether "maxSdkVersion" is defined, because the respective permissions are not available above this maxSdkVersion anyway. In other words, if for example WRITE
permission is requested on Android 11+, you will receive an error message. The same applies to READ
on Android 13+. In this respect it would simply declare like this (following the AI2 approach, although with WRITE
, as I said, the maxSdk cannot also be omitted):
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
Incidentally, it can hardly be assumed that the READ_MEDIA_...
permissions will no longer be available from Android 15. In this respect, android:maxSdkVersion="34"
wouldn't make any sense anyway.
TIMAI2
September 9, 2023, 10:47am
3
OK, thanks, will try it out.
Hmmm
Intellij tells me that the attribute: android:maxSdkVersion
is not allowed here (manifest.xml file)
I use Visual Studio Code to edit my extensions, and the error is not reported. Managed to compile a Rush extension with these permissions successfully, and the permissions are reflected in the app manifest.
Extension manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.simpletest">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<application>
</application>
</manifest>
App manifest: (decompiled with APK Editor Studio)
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="33" android:compileSdkVersionCodename="13" package="appinventor.ai_EMAILREMOVED.Hello" platformBuildVersionCode="33" platformBuildVersionName="13">
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="Hello" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:exported="true" android:name=".Screen1" android:screenOrientation="unspecified" android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<provider android:authorities="appinventor.ai_EMAILREMOVED.Hello.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>
TIMAI2
September 9, 2023, 11:48am
6
Hmmm, extension builds OK with the maxSdkVersion in place. Will test it.
I see you have your permissions inside <application>...</application>
which intelliJ does not like either!
1 Like
I apologize. You are correct, the permissions are supposed to be placed outside of the application
tag, but Rush seems to build fine anyway. Will edit my post.
1 Like
Anke
September 9, 2023, 12:06pm
8
Btw, if DefaultFileScope is set to Legacy the APK's Manifest does not declare
<uses-permission android:maxSdkVersion="29" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
but
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
So like I said, it doesn't matter if you set android:maxSdkVersion
.
2 Likes
TIMAI2
September 14, 2023, 3:02pm
9
I have gone with this for now in the manifest of the extension:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
will have to see what issues may arise in the wild....
Thanks to Anke and Gordon for help and advice
Anke
September 14, 2023, 4:29pm
10
I think there won't be any problems with declaring permissions this way.
However, problems will most likely arise with (correctly) requesting permissions (at the respective API levels).
1 Like
TIMAI2
Closed
September 21, 2023, 4:30pm
11
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.