From 856c7a2f2afd9b96740de48aa40824dc6d56023c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 22 Oct 2020 23:54:50 +1100 Subject: [PATCH] Bump android SDK version back up to 26 to avoid 'this app was built for an older version of android and doesn't include the latest privacy protections' message when installing I also set StrictMode.disableDeathOnFileUriExposure using some disgusting reflection so screenshots can continue to use file:// urls instead of content:// urls --- android/app/build.gradle | 4 ++-- .../app/src/main/java/com/classicube/MainActivity.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 600008538..3b66ff80b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 + compileSdkVersion 26 defaultConfig { applicationId = 'com.classicube.android.client' minSdkVersion 13 - targetSdkVersion 23 + targetSdkVersion 26 externalNativeBuild { cmake { arguments '-DANDROID_STL=c++_static' diff --git a/android/app/src/main/java/com/classicube/MainActivity.java b/android/app/src/main/java/com/classicube/MainActivity.java index 068db60d7..76b941015 100644 --- a/android/app/src/main/java/com/classicube/MainActivity.java +++ b/android/app/src/main/java/com/classicube/MainActivity.java @@ -1,6 +1,7 @@ package com.classicube; import java.io.File; import java.io.InputStream; +import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; @@ -20,6 +21,7 @@ import android.content.res.Configuration; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Bundle; +import android.os.StrictMode; import android.text.Editable; import android.text.InputType; import android.text.Selection; @@ -140,6 +142,14 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); requestWindowFeature(Window.FEATURE_NO_TITLE); // TODO: semaphore for destroyed and surfaceDestroyed + + // avoid FileUriExposed exceptions when taking screenshots + try { + Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure"); + m.invoke(null); + } catch (Exception ex) { + ex.printStackTrace(); + } Log.i("CC_WIN", "handing off to native.."); System.loadLibrary("classicube");