mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 22:26:06 +02:00
Check granted URI permisions
This commit is contained in:
@@ -41,6 +41,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.UriPermission;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -2611,6 +2612,23 @@ public class Helper {
|
||||
return (Looper.myLooper() == Looper.getMainLooper());
|
||||
}
|
||||
|
||||
static boolean isPersisted(Context context, Uri uri, boolean read, boolean write) {
|
||||
try {
|
||||
List<UriPermission> uperms = context.getContentResolver().getPersistedUriPermissions();
|
||||
for (UriPermission uperm : uperms)
|
||||
if (uperm.getUri().equals(uri)) {
|
||||
boolean canRead = uperm.isReadPermission();
|
||||
boolean canWrite = uperm.isWritePermission();
|
||||
Log.i(uri + " read=" + read + "/" + canRead + " write=" + write + "/" + canWrite);
|
||||
return (!read || canRead) && (!write || canWrite);
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
return !BuildConfig.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
// Cryptography
|
||||
|
||||
static String sha256(String data) throws NoSuchAlgorithmException {
|
||||
|
||||
Reference in New Issue
Block a user