diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2022-06-18 18:36:01 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-18 18:36:01 +1000 |
commit | 5857f3324aeda54f129b1ff9be93bc1eb3aee8e9 (patch) | |
tree | bb1f5d8deb17d9502cea0330d25d4ceb57dde19d | |
parent | 0dc0e93bc9ed0f986a1264225206ef2a6430bbee (diff) | |
parent | c9a50f006d2db466e52b4e67eba16e2b30eafdb6 (diff) |
Merge pull request #21570 from fuzzard/master_androidsdkbump
[Android] SDK30 bump
-rw-r--r-- | cmake/platform/android/android.cmake | 5 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/AndroidManifest.xml.in | 5 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/build.gradle.in | 6 | ||||
-rw-r--r-- | tools/android/packaging/xbmc/src/Splash.java.in | 58 |
4 files changed, 67 insertions, 7 deletions
diff --git a/cmake/platform/android/android.cmake b/cmake/platform/android/android.cmake index 7e3300426d..8250d49f81 100644 --- a/cmake/platform/android/android.cmake +++ b/cmake/platform/android/android.cmake @@ -1,2 +1,7 @@ set(PLATFORM_REQUIRED_DEPS LibAndroidJNI OpenGLES EGL Zip) set(APP_RENDER_SYSTEM gles) + +# Store SDK compile version +set(TARGET_SDK 30) +# Minimum supported SDK version +set(TARGET_MINSDK 21) diff --git a/tools/android/packaging/xbmc/AndroidManifest.xml.in b/tools/android/packaging/xbmc/AndroidManifest.xml.in index c871d1c391..b342c3715d 100644 --- a/tools/android/packaging/xbmc/AndroidManifest.xml.in +++ b/tools/android/packaging/xbmc/AndroidManifest.xml.in @@ -6,10 +6,11 @@ android:versionName="@APP_VERSION@"> <uses-sdk - android:minSdkVersion="21" - android:targetSdkVersion="29" /> + android:minSdkVersion="@TARGET_MINSDK@" + android:targetSdkVersion="@TARGET_SDK@" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.GET_TASKS" /> diff --git a/tools/android/packaging/xbmc/build.gradle.in b/tools/android/packaging/xbmc/build.gradle.in index a1f1a3ac74..97a1a9bb18 100644 --- a/tools/android/packaging/xbmc/build.gradle.in +++ b/tools/android/packaging/xbmc/build.gradle.in @@ -1,11 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 29 + compileSdkVersion @TARGET_SDK@ defaultConfig { applicationId "@APP_PACKAGE@" - minSdkVersion 21 - targetSdkVersion 29 + minSdkVersion @TARGET_MINSDK@ + targetSdkVersion @TARGET_SDK@ versionCode @APP_VERSION_CODE_ANDROID@ versionName "@APP_VERSION@" } diff --git a/tools/android/packaging/xbmc/src/Splash.java.in b/tools/android/packaging/xbmc/src/Splash.java.in index c96330e321..61e6c943ed 100644 --- a/tools/android/packaging/xbmc/src/Splash.java.in +++ b/tools/android/packaging/xbmc/src/Splash.java.in @@ -1,5 +1,6 @@ package @APP_PACKAGE@; +import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import android.Manifest; @@ -21,6 +22,7 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; +import android.provider.Settings; import android.text.Html; import android.text.method.LinkMovementMethod; import android.util.Log; @@ -134,8 +136,25 @@ public class Splash extends Activity mSplash.mTextView.setText("Asking for permissions..."); mSplash.mProgress.setVisibility(View.INVISIBLE); - requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO}, + if ((Build.VERSION.SDK_INT >= 30) && !isAndroidTV()) + { + try + { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); + intent.setData(Uri.parse(String.format("package:%s", getPackageName()))); + startActivityForResult(intent, PERMISSION_RESULT_CODE); + } + catch (Exception e) + { + Log.d(TAG, "Exception asking for permissions: " + e.getMessage()); + } + } + else + { + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_RESULT_CODE); + } break; case CheckingPermissionsDone: if (mPermissionOK) @@ -734,7 +753,14 @@ public class Splash extends Activity private boolean CheckPermissions() { boolean retVal = false; - if (android.os.Build.VERSION.SDK_INT > 22) + if ((Build.VERSION.SDK_INT >= 30) && !isAndroidTV()) + { + if (Environment.isExternalStorageManager()) + { + retVal = true; + } + } + else if (Build.VERSION.SDK_INT > 22) { int permissionCheck; permissionCheck = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); @@ -765,6 +791,20 @@ public class Splash extends Activity mStateMachine.sendEmptyMessage(CheckingPermissionsDone); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) + { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == PERMISSION_RESULT_CODE) + { + if (Environment.isExternalStorageManager()) + { + mPermissionOK = true; + } + mStateMachine.sendEmptyMessage(CheckingPermissionsDone); + } + } + void updateExternalStorageState() { String state = Environment.getExternalStorageState(); @@ -963,4 +1003,18 @@ public class Splash extends Activity } } + private boolean isAndroidTV() + { + if (getPackageManager().hasSystemFeature(FEATURE_LEANBACK)) + { + Log.d(TAG, "Running on an Android TV Device"); + return true; + } + else + { + Log.d(TAG, "Running on a non Android TV Device"); + return false; + } + } + } |