Compare commits

...

5 commits

Author SHA1 Message Date
Simon
c9922b1d94 Proper External SDCARD access
No need to use scoped storage
2024-05-06 19:49:08 +01:00
Simon
cf5f737f53 Various version upgrades
Gradle 8
API level 32
Using Scoped Storage
NDK version 25
2024-05-01 22:40:39 +01:00
Simon
6832052d78 Update version number to latest release 2023-05-10 21:45:13 +01:00
Simon
54c38e489f Ensure screen layer appears in front of player 2023-05-10 21:21:12 +01:00
Simon
1d7aecfa26 Fix crash on quest firmware v53 2023-04-28 19:47:55 +01:00
13 changed files with 184 additions and 362 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.quakequest"
android:versionCode="24"
android:versionName="1.5.5"
android:versionCode="26"
android:versionName="1.5.7"
android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
@ -14,7 +14,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="false"
@ -25,12 +25,14 @@
<!-- META QUEST -->
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
<meta-data android:name="com.oculus.vr.focusaware" android:value="true" />
<!-- PICO XR -->
<meta-data android:name="pvr.app.type" android:value="vr" />
<activity
android:exported="true"
android:name="com.drbeef.quakequest.GLES3JNIActivity"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:label="@string/quakequest"
@ -38,8 +40,10 @@
android:screenOrientation="landscape"
android:excludeFromRecents="true"
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode">
<!-- Tell NativeActivity the name of the .so -->
<meta-data android:name="android.app.lib_name" android:value="quakequest" />
<!-- This filter lets the apk show up as a launchable icon. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -1,7 +1,20 @@
buildscript {
repositories {
google() // For Gradle 4.0+
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
}
}
apply plugin: 'com.android.application'
apply from: "${rootProject.projectDir}/XrApp.gradle"
android {
namespace = "com.drbeef.quakequest"
// This is the name of the generated apk file, which will have
// -debug.apk or -release.apk appended to it.
// The filename doesn't effect the Android installation process.
@ -15,19 +28,84 @@ android {
applicationId "com.drbeef." + project.archivesBaseName
// override app plugin abiFilters for both 32 and 64-bit support
externalNativeBuild {
ndk {
abiFilters 'arm64-v8a'
}
ndkBuild {
abiFilters 'arm64-v8a'
}
}
externalNativeBuild {
ndk {
abiFilters 'arm64-v8a'
}
ndkBuild {
def numProcs = Runtime.runtime.availableProcessors()
arguments "V=0", "-j$numProcs", "-C$project.buildDir.parent", "APP_PLATFORM=android-29", "NDK_TOOLCHAIN_VERSION=clang", "APP_STL=c++_static"
abiFilters 'arm64-v8a'
}
}
minSdkVersion 26
targetSdkVersion 26
minSdkVersion 32
targetSdkVersion 32
}
externalNativeBuild {
ndkBuild {
path file('jni/Android.mk')
}
}
signingConfigs {
def keystorePath = (project.hasProperty('key.store')) ?
new File(project.getProperty('key.store')) :
project.file('android.debug.keystore')
def keystorePassword = (project.hasProperty('key.store.password')) ?
project.getProperty('key.store.password') : 'android'
def keystoreKeyAlias = (project.hasProperty('key.alias')) ?
project.getProperty('key.alias') : 'androiddebugkey'
def keystoreKeyPassword = (project.hasProperty('key.alias.password')) ?
project.getProperty('key.alias.password') : 'android'
debug {
storeFile keystorePath
storePassword keystorePassword
keyAlias keystoreKeyAlias
keyPassword keystoreKeyPassword
v2SigningEnabled true
}
release {
storeFile keystorePath
storePassword keystorePassword
keyAlias keystoreKeyAlias
keyPassword keystoreKeyPassword
v2SigningEnabled true
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
debuggable true
jniDebuggable true
externalNativeBuild {
ndkBuild {
arguments "NDK_DEBUG=1","USE_ASAN=1"
}
}
}
release {
signingConfig signingConfigs.release
debuggable false
jniDebuggable false
externalNativeBuild {
ndkBuild {
arguments "NDK_DEBUG=0","USE_ASAN=0"
}
}
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
@ -42,25 +120,40 @@ android {
targetCompatibility = '1.8'
}
lintOptions {
checkReleaseBuilds false
disable 'ExpiredTargetSdkVersion'
}
packagingOptions {
exclude 'lib/arm64-v8a/libopenxr_loader.so'
}
compileSdkVersion = 32
compileSdkVersion = 26
buildToolsVersion = '29.0.1'
buildToolsVersion = '29.0.3'
ndkVersion '25.1.8937393'
}
dependencies {
implementation "com.android.support:support-compat:26.1.0"
implementation "com.android.support:support-core-utils:26.1.0"
implementation "com.android.support:support-compat:28.0.0"
implementation "com.android.support:support-core-utils:28.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
repositories {
google()
}
buildscript {
repositories {
google()
}
}
// Workaround to fix issue in Android Studio Chipmunk 2021.2.1 and later
// where opening a project would result in a 'prepareKotlinBuildScriptModel'
// not found error
if (!tasks.findByName("prepareKotlinBuildScriptModel")) {
tasks.register("prepareKotlinBuildScriptModel") {}
}

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip

View file

@ -16,7 +16,7 @@ XrResult CheckXrResult(XrResult res, const char* originator) {
#define SIDE_COUNT 2
XrActionSet actionSet;
XrActionSet actionSet = NULL;
XrAction grabAction = 0;
XrAction poseAction = 0;
XrAction vibrateAction = 0;
@ -63,11 +63,13 @@ XrActionStateBoolean GetActionStateBoolean(XrAction action, int hand) {
XrActionStateGetInfo getInfo = {};
getInfo.type = XR_TYPE_ACTION_STATE_GET_INFO;
getInfo.action = action;
getInfo.next = NULL;
if (hand >= 0)
getInfo.subactionPath = handSubactionPath[hand];
XrActionStateBoolean state = {};
state.type = XR_TYPE_ACTION_STATE_BOOLEAN;
state.next = NULL;
CHECK_XRCMD(xrGetActionStateBoolean(gAppState.Session, &getInfo, &state));
return state;
}
@ -76,11 +78,13 @@ XrActionStateFloat GetActionStateFloat(XrAction action, int hand) {
XrActionStateGetInfo getInfo = {};
getInfo.type = XR_TYPE_ACTION_STATE_GET_INFO;
getInfo.action = action;
getInfo.next = NULL;
if (hand >= 0)
getInfo.subactionPath = handSubactionPath[hand];
XrActionStateFloat state = {};
state.type = XR_TYPE_ACTION_STATE_FLOAT;
state.next = NULL;
CHECK_XRCMD(xrGetActionStateFloat(gAppState.Session, &getInfo, &state));
return state;
}
@ -89,11 +93,13 @@ XrActionStateVector2f GetActionStateVector2(XrAction action, int hand) {
XrActionStateGetInfo getInfo = {};
getInfo.type = XR_TYPE_ACTION_STATE_GET_INFO;
getInfo.action = action;
getInfo.next = NULL;
if (hand >= 0)
getInfo.subactionPath = handSubactionPath[hand];
XrActionStateVector2f state = {};
state.type = XR_TYPE_ACTION_STATE_VECTOR2F;
state.next = NULL;
CHECK_XRCMD(xrGetActionStateVector2f(gAppState.Session, &getInfo, &state));
return state;
}
@ -131,6 +137,7 @@ void TBXR_InitActions( void )
strcpy(actionSetInfo.actionSetName, "gameplay");
strcpy(actionSetInfo.localizedActionSetName, "Gameplay");
actionSetInfo.priority = 0;
actionSetInfo.next = NULL;
CHECK_XRCMD(xrCreateActionSet(gAppState.Instance, &actionSetInfo, &actionSet));
}
@ -324,6 +331,7 @@ void TBXR_InitActions( void )
suggestedBindings.interactionProfile = picoMixedRealityInteractionProfilePath;
suggestedBindings.suggestedBindings = bindings;
suggestedBindings.countSuggestedBindings = currBinding;
suggestedBindings.next = NULL;
result = xrSuggestInteractionProfileBindings(gAppState.Instance, &suggestedBindings);
}
@ -375,6 +383,7 @@ void TBXR_InitActions( void )
suggestedBindings.interactionProfile = touchControllerInteractionProfilePath;
suggestedBindings.suggestedBindings = bindings;
suggestedBindings.countSuggestedBindings = currBinding;
suggestedBindings.next = NULL;
result = xrSuggestInteractionProfileBindings(gAppState.Instance, &suggestedBindings);
}
@ -391,25 +400,31 @@ void TBXR_InitActions( void )
actionSpaceInfo.subactionPath = handSubactionPath[SIDE_LEFT];
CHECK_XRCMD(xrCreateActionSpace(gAppState.Session, &actionSpaceInfo, &aimSpace[SIDE_LEFT]));
actionSpaceInfo.subactionPath = handSubactionPath[SIDE_RIGHT];
actionSpaceInfo.next = NULL;
CHECK_XRCMD(xrCreateActionSpace(gAppState.Session, &actionSpaceInfo, &aimSpace[SIDE_RIGHT]));
XrSessionActionSetsAttachInfo attachInfo = {};
attachInfo.type = XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO;
attachInfo.countActionSets = 1;
attachInfo.actionSets = &actionSet;
attachInfo.next = NULL;
CHECK_XRCMD(xrAttachSessionActionSets(gAppState.Session, &attachInfo));
}
void TBXR_SyncActions( void )
{
XrActiveActionSet activeActionSet = {};
activeActionSet.actionSet = actionSet;
activeActionSet.subactionPath = XR_NULL_PATH;
XrActionsSyncInfo syncInfo;
syncInfo.type = XR_TYPE_ACTIONS_SYNC_INFO;
syncInfo.countActiveActionSets = 1;
syncInfo.activeActionSets = &activeActionSet;
CHECK_XRCMD(xrSyncActions(gAppState.Session, &syncInfo));
if (actionSet)
{
XrActiveActionSet activeActionSet = {};
activeActionSet.actionSet = actionSet;
activeActionSet.subactionPath = XR_NULL_PATH;
XrActionsSyncInfo syncInfo;
syncInfo.type = XR_TYPE_ACTIONS_SYNC_INFO;
syncInfo.countActiveActionSets = 1;
syncInfo.activeActionSets = &activeActionSet;
syncInfo.next = NULL;
CHECK_XRCMD(xrSyncActions(gAppState.Session, &syncInfo));
}
}
void TBXR_UpdateControllers( )

View file

@ -38,7 +38,7 @@ char **argv;
int argc=0;
float playerHeight;
float playerYaw;
float playerYaw = -999.0f;
extern float worldPosition[3];
float hmdPosition[3];
@ -186,7 +186,7 @@ void VR_SetHMDOrientation(float pitch, float yaw, float roll)
{
VectorSet(hmdorientation, pitch, yaw, roll);
if (!VR_UseScreenLayer())
if (!VR_UseScreenLayer() || playerYaw == -999.0f)
{
playerYaw = yaw;
}
@ -221,7 +221,7 @@ void VR_Init()
//init randomiser
srand(time(NULL));
chdir("/sdcard/QuakeQuest");
chdir((char*)getenv("QUAKEQUEST_DIR"));
}
extern int runStatus;

View file

@ -3597,7 +3597,7 @@ static void M_Credits_Draw (void)
" QQQQQQQQ QQQQQQQQ ",
" QQQ QQQ ",
" Q Q ",
" Q Q v1.5.5");
" Q Q v1.5.7");
int i, l, linelength, firstline, lastline, lines;
for (i = 0, linelength = 0, firstline = 9999, lastline = -1;m_credits_message[i];i++)

View file

@ -5,5 +5,4 @@
# For customization when using a Version Control System, please read the
# header note.
#Thu Dec 12 20:21:11 GMT 2019
ndk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\Sdk\\ndk\\21.1.6352462
sdk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\Sdk

View file

@ -1,4 +1 @@
rootProject.projectDir = new File(settingsDir, '../..')
rootProject.name = "QuakeQuest"
include ':', 'Projects:Android'

View file

@ -1,238 +0,0 @@
import org.gradle.internal.os.OperatingSystem;
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.IDevice
import com.android.ddmlib.CollectingOutputReceiver
import org.apache.tools.ant.taskdefs.condition.Os
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
tasks.register("wrapper")
}
class XrAppPlugin implements Plugin<Project> {
Project project = null
void installApk( IDevice device, File apkFile, String applicationId ) {
project.logger.quiet "Installing ${applicationId} on device ${device.serialNumber}"
String toinstall = "/data/local/tmp/toinstall.apk"
try {
device.pushFile( apkFile.path, toinstall )
} catch ( Exception e ) {
throw new RuntimeException( "Failed to push ${apkFile.path} to ${toinstall}. ${e}", e )
}
while ( true ) {
try {
device.installRemotePackage( toinstall, true )
break
} catch ( Exception e ) {
project.logger.quiet "Failed to install ${applicationId} on device ${device.serialNumber} (${e}). Trying to uninstall first."
}
try {
device.uninstallPackage( applicationId )
} catch ( Exception e ) {
throw new RuntimeException( "Failed to uninstall ${applicationId}. ${e}", e )
}
}
}
void stopApk( IDevice device, String packageName ) {
CollectingOutputReceiver receiver = new CollectingOutputReceiver()
device.executeShellCommand( "am force-stop ${packageName}", receiver )
}
void runApk( IDevice device, manifestFile ) {
CollectingOutputReceiver receiver = new CollectingOutputReceiver()
def activityClass = new XmlSlurper().parse( manifestFile ).application.activity.find{ it.'intent-filter'.find{ filter ->
return filter.action .find{it.'@android:name'.text() == 'android.intent.action.MAIN' } \
&& ( filter.category.find{it.'@android:name'.text() == 'android.intent.category.LAUNCHER'} \
|| filter.category.find{it.'@android:name'.text() == 'android.intent.category.INFO'} )
}}.'@android:name'
def startActivity = "${project.android.defaultConfig.applicationId}/${activityClass}"
project.logger.quiet "Starting \'$startActivity\' on ${project.deviceMap.size()} devices:"
project.logger.quiet "- ${device.serialNumber}"
device.executeShellCommand( "am start $startActivity", receiver )
}
void apply( Project project ) {
this.project = project
// FIXME: The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
project.task( "cleanWorkAround" ) {
description "Workaround for .externalNativeBuild not being deleted on clean"
}.doLast {
project.delete project.file( ".externalNativeBuild" )
}
project.android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 24
targetSdkVersion 25
externalNativeBuild {
ndk {
}
ndkBuild {
def numProcs = Runtime.runtime.availableProcessors()
arguments "V=0", "-j$numProcs", "-C$project.buildDir.parent", "APP_PLATFORM=android-24", "NDK_TOOLCHAIN_VERSION=clang", "APP_STL=c++_static"
}
}
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
signingConfigs {
def keystorePath = (project.hasProperty('key.store')) ?
new File(project.getProperty('key.store')) :
project.file('android.debug.keystore')
def keystorePassword = (project.hasProperty('key.store.password')) ?
project.getProperty('key.store.password') : 'android'
def keystoreKeyAlias = (project.hasProperty('key.alias')) ?
project.getProperty('key.alias') : 'androiddebugkey'
def keystoreKeyPassword = (project.hasProperty('key.alias.password')) ?
project.getProperty('key.alias.password') : 'android'
debug {
storeFile keystorePath
storePassword keystorePassword
keyAlias keystoreKeyAlias
keyPassword keystoreKeyPassword
v2SigningEnabled true
}
release {
storeFile keystorePath
storePassword keystorePassword
keyAlias keystoreKeyAlias
keyPassword keystoreKeyPassword
v2SigningEnabled true
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
debuggable true
jniDebuggable true
externalNativeBuild {
ndkBuild {
arguments "NDK_DEBUG=1","USE_ASAN=1"
}
}
}
release {
signingConfig signingConfigs.release
debuggable false
jniDebuggable false
externalNativeBuild {
ndkBuild {
arguments "NDK_DEBUG=0","USE_ASAN=0"
}
}
}
}
}
// WORKAROUND: On Mac OS X, running ndk-build clean with a high num of parallel executions
// set may result in the following build error: rm: fts_read: No such file or directory.
// Currently, there isn't a good way to specify numProcs=1 only on clean. So, in order
// to work around the issue, delete the auto-generated .externalNativeBuild artifacts
// (where $numProcs specified) before executing the clean task.
project.clean.dependsOn project.cleanWorkAround
project.clean {
// remove the auto-generated debug keystore (currently generated by python build script)
// delete "android.debug.keystore"
}
project.afterEvaluate {
Task initDeviceList = project.task( "initDeviceList()" ).doLast {
project.ext.deviceMap = [ : ]
if (project.hasProperty( "should_install" ) == true) {
AndroidDebugBridge.initIfNeeded( false )
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge( project.android.getAdbExe().absolutePath, false )
long timeOut = 30000 // 30 sec
int sleepTime = 1000
while ( !bridge.hasInitialDeviceList() && timeOut > 0 ) {
sleep( sleepTime )
timeOut -= sleepTime
}
if ( timeOut <= 0 && !bridge.hasInitialDeviceList() ) {
throw new RuntimeException( "Timeout getting device list.", null )
}
// if a device is connected both physically and over the network, only include the physical ID
if ( project.hasProperty( "should_install" ) == true ) {
bridge.devices.split { it.getProperty( "ro.serialno" ) != it.serialNumber }.each {
it.collectEntries( project.deviceMap, { [ ( it.getProperty( "ro.serialno" )) : it ] } )
}
}
}
}
project.task( "stopApk", dependsOn: initDeviceList ) {
description "Stops app if currently running on device"
}.doLast {
project.deviceMap.each { deviceSerial, device ->
stopApk( device, android.defaultConfig.applicationId )
}
}
project.android.applicationVariants.all { variant ->
Task installAndRun = project.task( "installAndRun${variant.name.capitalize()}" ) {
dependsOn variant.assembleProvider.get()
dependsOn initDeviceList
onlyIf { project.hasProperty( "should_install" ) }
description "Installs and runs the APK file"
}.doLast { variant.outputs.each { output ->
if ( output.outputFile.exists() ) {
if ( project.deviceMap.size() == 0 ) {
project.logger.quiet "Install requested, but no devices found."
} else {
project.deviceMap.each { deviceSerial, device ->
installApk( device, output.outputFile, project.android.defaultConfig.applicationId )
runApk( device, new File(output.processManifest.manifestOutputDirectory.get().asFile, "AndroidManifest.xml"))
}
}
}
}
}
variant.assembleProvider.get().finalizedBy installAndRun
}
}
}
}
// Workaround to fix issue in Android Studio Chipmunk 2021.2.1 and later
// where opening a project would result in a 'prepareKotlinBuildScriptModel'
// not found error
if (!tasks.findByName("prepareKotlinBuildScriptModel")) {
tasks.register("prepareKotlinBuildScriptModel") {}
}
apply plugin: XrAppPlugin

View file

@ -1,22 +0,0 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View file

@ -1,3 +1,8 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx1536M \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
org.gradle.caching=true
org.gradle.configureondemand=true

View file

@ -16,11 +16,16 @@ import java.util.Locale;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import android.system.ErrnoException;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@ -56,28 +61,26 @@ import android.support.v4.content.ContextCompat;
private static final String TAG = "QuakeQuest";
private int permissionCount = 0;
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
String commandLineParams;
private SurfaceView mView;
private SurfaceHolder mSurfaceHolder;
private SurfaceHolder mSurfaceHolder;
private long mNativeHandle;
private final boolean m_asynchronousTracking = false;
String dir;
@Override protected void onCreate( Bundle icicle )
{
Log.v( TAG, "----------------------------------------------------------------" );
Log.v( TAG, "GLES3JNIActivity::onCreate()" );
super.onCreate( icicle );
mView = new SurfaceView( this );
setContentView( mView );
SurfaceView mView = new SurfaceView(this);
setContentView(mView);
mView.getHolder().addCallback( this );
dir = "/sdcard/QuakeQuest";
//dir = getBaseContext().getExternalFilesDir(null).getAbsolutePath();
// Force the screen to stay on, rather than letting it dim and shut off
// while the user is watching a movie.
getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON );
@ -92,80 +95,47 @@ import android.support.v4.content.ContextCompat;
/** Initializes the Activity only if the permission has been granted. */
private void checkPermissionsAndInitialize() {
// Boilerplate for checking runtime permissions in Android.
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(
GLES3JNIActivity.this,
new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
WRITE_EXTERNAL_STORAGE_PERMISSION_ID);
if (!Environment.isExternalStorageManager()) {
//request for the permission
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityForResult(intent, 1);
}
else
{
permissionCount++;
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(
GLES3JNIActivity.this,
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
READ_EXTERNAL_STORAGE_PERMISSION_ID);
}
else
{
permissionCount++;
}
if (permissionCount == 2) {
// Permissions have already been granted.
create();
}
}
/** Handles the user accepting the permission. */
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) {
if (requestCode == READ_EXTERNAL_STORAGE_PERMISSION_ID) {
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
permissionCount++;
}
else
{
System.exit(0);
}
}
if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_ID) {
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
permissionCount++;
}
else
{
System.exit(0);
}
}
checkPermissionsAndInitialize();
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
create();
}
public void create()
{
public void create() {
//This will copy the shareware version of quake if user doesn't have anything installed
copy_asset("/sdcard/QuakeQuest/id1", "pak0.pak");
copy_asset("/sdcard/QuakeQuest/id1", "config.cfg");
copy_asset("/sdcard/QuakeQuest", "commandline.txt");
copy_asset(dir + "/id1", "pak0.pak");
copy_asset(dir + "/id1", "config.cfg");
copy_asset(dir, "commandline.txt");
try {
setenv("QUAKEQUEST_DIR", dir, true);
} catch (Exception ignored)
{
System.exit(-9);;
}
//Read these from a file and pass through
commandLineParams = new String("quake");
//See if user is trying to use command line params
if(new File("/sdcard/QuakeQuest/commandline.txt").exists()) // should exist!
if(new File(dir + "/commandline.txt").exists()) // should exist!
{
BufferedReader br;
try {
br = new BufferedReader(new FileReader("/sdcard/QuakeQuest/commandline.txt"));
br = new BufferedReader(new FileReader(dir + "/commandline.txt"));
String s;
StringBuilder sb=new StringBuilder(0);
while ((s=br.readLine())!=null)

View file

@ -5,5 +5,4 @@
# For customization when using a Version Control System, please read the
# header note.
#Thu Dec 12 20:21:11 GMT 2019
ndk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\Sdk\\ndk\\21.1.6352462
sdk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\Sdk