Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More compatibility with Android 9…11 #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions limbo-android-lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Expand All @@ -17,6 +18,10 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-feature android:glEsVersion="0x00020000" />

<application
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"

</manifest>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,25 @@ private static int getASFFileManagerRequestCode(int requestCode) {
}
}

private static void requestStorageManager(Activity activity, int requestCode) {
if (android.os.Build.VERSION.SDK_INT >= 30) { // Android 11
try {
if(!Environment.isExternalStorageManager()) {
Intent i = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
i.setData(Uri.fromParts("package", activity.getPackageName(), null));
activity.startActivityForResult(i, requestCode);
}
} catch (Exception e) {
Log.e(TAG, "Error requesting storage manager permission: " +
e.getMessage());
}
}
}

public static void promptLegacyStorageAccess(Activity activity, LimboActivity.FileType fileType, int requestCode, String lastDir) {

requestStorageManager(activity, requestCode);

String dir = null;
try {

Expand Down Expand Up @@ -192,6 +209,9 @@ public static Intent getFileManIntent(Activity activity) {
}

protected static void promptOpenFileASF(Activity context, LimboActivity.FileType fileType, int requestCode, String lastDir) {

requestStorageManager(activity, requestCode);

Intent intent = null;
if (isFileTypeDirectory(fileType))
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
Expand Down