fixed permission check
This commit is contained in:
parent
652b1723a9
commit
7c867f81bb
3 changed files with 11 additions and 10 deletions
|
@ -1,9 +1,7 @@
|
|||
package deckers.thibault.aves.model.provider;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -11,7 +9,6 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Matrix;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.MediaStore;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package deckers.thibault.aves.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.UriPermission;
|
||||
import android.net.Uri;
|
||||
|
@ -20,7 +19,6 @@ import androidx.core.app.ActivityCompat;
|
|||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PermissionManager {
|
||||
private static final String LOG_TAG = Utils.createLogTag(PermissionManager.class);
|
||||
|
|
|
@ -45,7 +45,10 @@ public class StorageUtils {
|
|||
* Volume paths
|
||||
*/
|
||||
|
||||
// volume paths, with trailing "/"
|
||||
private static String[] mStorageVolumePaths;
|
||||
|
||||
// primary volume path, with trailing "/"
|
||||
private static String mPrimaryVolumePath;
|
||||
|
||||
private static String getPrimaryVolumePath() {
|
||||
|
@ -90,8 +93,8 @@ public class StorageUtils {
|
|||
|
||||
private static String findPrimaryVolumePath() {
|
||||
String primaryVolumePath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
if (!primaryVolumePath.endsWith("/")) {
|
||||
primaryVolumePath += "/";
|
||||
if (!primaryVolumePath.endsWith(File.separator)) {
|
||||
primaryVolumePath += File.separator;
|
||||
}
|
||||
return primaryVolumePath;
|
||||
}
|
||||
|
@ -167,8 +170,8 @@ public class StorageUtils {
|
|||
String[] paths = rv.toArray(new String[0]);
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
String path = paths[i];
|
||||
if (path.endsWith(File.separator)) {
|
||||
paths[i] = path.substring(0, path.length() - 1);
|
||||
if (!path.endsWith(File.separator)) {
|
||||
paths[i] = path + File.separator;
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
|
@ -361,8 +364,11 @@ public class StorageUtils {
|
|||
*/
|
||||
|
||||
public static boolean requireAccessPermission(@NonNull String anyPath) {
|
||||
// on Android R, we should always require access permission, even on primary volume
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||
return true;
|
||||
}
|
||||
boolean onPrimaryVolume = anyPath.startsWith(getPrimaryVolumePath());
|
||||
// TODO TLAD on Android R, we should require access permission even on primary
|
||||
return !onPrimaryVolume;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue