[Android] [PATCH] benchmark: ask write permission before screenshots

Duncan McNamara dcn.mcnamara at gmail.com
Tue Jul 17 13:26:40 CEST 2018


---
 .../org/videolan/vlc/gui/video/benchmark/BenchActivity.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.java
index f5e8b6727..2ec17012d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.java
@@ -20,9 +20,11 @@
 
 package org.videolan.vlc.gui.video.benchmark;
 
+import android.Manifest;
 import android.annotation.TargetApi;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
 import android.graphics.PixelFormat;
 import android.graphics.Point;
@@ -34,6 +36,7 @@ import android.media.projection.MediaProjectionManager;
 import android.os.Bundle;
 import android.os.Environment;
 import android.os.Handler;
+import android.support.v4.app.ActivityCompat;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.View;
@@ -129,6 +132,9 @@ public class BenchActivity extends ShallowVideoPlayer {
         }
         mIsBenchmark = true;
 
+        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
+            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
+
         if (!intent.hasExtra(INTENT_SCREENSHOT_DIR)) {
             errorFinish("Failed to get screenshot directory location");
         }
-- 
2.18.0



More information about the Android mailing list