diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-12-06 18:23:59 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-12-07 13:24:41 +0100 |
commit | c3e8fb3446237dee34bf49436076a10d07e2efdf (patch) | |
tree | 881bf04d964be1ebe99e1a4a0aafc5de53c46726 /src/main/java/eu/siacs/conversations/services | |
parent | 739a2d609d15be7472575adb937e9a0b164dd4a9 (diff) |
request storage permission when needed on Android 6.0
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java index 5def05dd..a1256250 100644 --- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java @@ -1,6 +1,9 @@ package eu.siacs.conversations.services; +import android.Manifest; import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.PowerManager; import android.util.Log; import android.util.Pair; @@ -51,6 +54,14 @@ public class AbstractConnectionManager { } } + public boolean hasStoragePermission() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return mXmppConnectionService.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; + } else { + return true; + } + } + public static Pair<InputStream,Integer> createInputStream(DownloadableFile file, boolean gcm) throws FileNotFoundException { FileInputStream is; int size; |