Permissions for older phones

This commit is contained in:
offtkp 2023-11-28 18:45:00 +02:00
parent 200a884589
commit 9aded6e556
3 changed files with 12 additions and 1 deletions

View file

@ -49,8 +49,8 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_panda3ds_pandroid_AlberDriver_Has
extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_LoadRom(JNIEnv* env, jobject obj, jstring path) { extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_LoadRom(JNIEnv* env, jobject obj, jstring path) {
const char* pathStr = env->GetStringUTFChars(path, nullptr); const char* pathStr = env->GetStringUTFChars(path, nullptr);
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s", pathStr);
romLoaded = emulator->loadROM(pathStr); romLoaded = emulator->loadROM(pathStr);
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s, result: %d", pathStr, (int)romLoaded);
env->ReleaseStringUTFChars(path, pathStr); env->ReleaseStringUTFChars(path, pathStr);
} }

View file

@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage"/> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage"/>
<uses-feature <uses-feature
@ -9,6 +11,7 @@
android:glEsVersion="0x0030002"/> android:glEsVersion="0x0030002"/>
<application <application
android:requestLegacyExternalStorage="true"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"

View file

@ -10,12 +10,17 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import androidx.core.app.ActivityCompat;
import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.utils.Constants;
import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.R;
import com.panda3ds.pandroid.utils.PathUtils; import com.panda3ds.pandroid.utils.PathUtils;
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity {
private static final int PICK_3DS_ROM = 2; private static final int PICK_3DS_ROM = 2;
private static final int PERMISSION_REQUEST_CODE = 3;
private void openFile() { private void openFile() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
@ -32,6 +37,9 @@ public class MainActivity extends BaseActivity {
Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
startActivity(intent); startActivity(intent);
} }
} else {
ActivityCompat.requestPermissions(this, new String[]{READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
} }
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);