Expose the Android system version to the app. Useful to enable/disable android-only features like immersive mode

This commit is contained in:
Henrik Rydgard committed 2014-07-20 12:04:22 +02:00
1 parent ed04a0bf28
commit 2ab2016002
7 files changed
+24 -3

No files matched your search

+12 -1
View File
@@ -53,6 +53,7 @@ static float hat_joystick_y_async;
int optimalFramesPerBuffer = 0;
int optimalSampleRate = 0;
static int androidVersion;
// Android implementation of callbacks to the Java part of the app
void SystemToast(const char *text) {
@@ -103,6 +104,15 @@ std::string System_GetProperty(SystemProperty prop) {
}
}
int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_SYSTEMVERSION:
return androidVersion;
default:
return -1;
}
}
// Remember that all of these need initialization on init! The process
// may be reused when restarting the game. Globals are DANGEROUS.
@@ -154,7 +164,7 @@ extern "C" jstring Java_com_henrikrydgard_libnative_NativeApp_queryConfig
extern "C" void Java_com_henrikrydgard_libnative_NativeApp_init
(JNIEnv *env, jclass, jstring jdevicetype, jstring jlangRegion, jstring japkpath,
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jshortcutParam,
jstring jinstallID, jboolean juseNativeAudio) {
jstring jinstallID, jboolean juseNativeAudio, jint jAndroidVersion) {
jniEnvUI = env;
ILOG("NativeApp.init() -- begin");
@@ -162,6 +172,7 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_init
memset(&input_state, 0, sizeof(input_state));
renderer_inited = false;
first_lost = true;
androidVersion = jAndroidVersion;
g_buttonTracker.Reset();
@@ -211,7 +211,7 @@ public class NativeActivity extends Activity {
String languageRegion = Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate);
NativeApp.init(deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, shortcutParam, installID, useOpenSL());
NativeApp.init(deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, shortcutParam, installID, useOpenSL(), Build.VERSION.SDK_INT);
// OK, config should be initialized, we can query for screen rotation.
if (Build.VERSION.SDK_INT >= 9) {
@@ -9,7 +9,7 @@ public class NativeApp {
public final static int DEVICE_ID_MOUSE = 2;
public final static int DEVICE_ID_PAD_0 = 10;
public static native void init(String deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String shortcutParam, String installID, boolean useOpenSL);
public static native void init(String deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String shortcutParam, String installID, boolean useOpenSL, int androidVersion);
public static native void audioInit();
public static native void audioShutdown();
+2
View File
@@ -44,6 +44,8 @@ std::string System_GetProperty(SystemProperty prop) {
}
}
int System_GetPropertyInt(SystemProperty prop) {return -1;}
void System_SendMessage(const char *command, const char *parameter) {
if (!strcmp(command, "finish")) {
g_quitRequested = true;
+4
View File
@@ -123,6 +123,10 @@ enum SystemProperty {
SYSPROP_NAME,
SYSPROP_LANGREGION,
SYSPROP_CPUINFO,
// Available as Int:
SYSPROP_SYSTEMVERSION,
};
std::string System_GetProperty(SystemProperty prop);
int System_GetPropertyInt(SystemProperty prop);
+2
View File
@@ -286,6 +286,8 @@ std::string System_GetProperty(SystemProperty prop) {
}
}
int System_GetPropertyInt(SystemProperty prop) {return -1;}
InputState input_state;
static const int legacyKeyMap[] {
+2
View File
@@ -66,6 +66,8 @@ std::string System_GetProperty(SystemProperty prop) {
}
}
int System_GetPropertyInt(SystemProperty prop) {return -1;}
void System_SendMessage(const char *command, const char *parameter) {
if (!strcmp(command, "finish")) {
qApp->exit(0);