Target Android SDK 29.

Includes a nasty SDK bug workaround.
This commit is contained in:
Henrik Rydgård 2020-03-30 22:43:45 +02:00
parent 8e99263949
commit a2da6ceb47
3 changed files with 30 additions and 6 deletions

View file

@ -39,7 +39,8 @@
android:label="@string/app_name"
android:logo="@drawable/ic_banner"
android:isGame="true"
android:banner="@drawable/tv_banner">
android:banner="@drawable/tv_banner"
android:requestLegacyExternalStorage="true">
<meta-data android:name="android.max_aspect" android:value="2.4" />
<activity
android:name=".PpssppActivity"

View file

@ -34,8 +34,8 @@ android {
}
}
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
applicationId 'org.ppsspp.ppsspp'
if (androidGitVersion.name() != "unknown" && androidGitVersion.code() >= 14000000) {
@ -51,7 +51,7 @@ android {
new File("versioncode.txt").write(androidGitVersion.code().toString())
minSdkVersion 9
targetSdkVersion 28
targetSdkVersion 29
if (project.hasProperty("ANDROID_VERSION_CODE") && project.hasProperty("ANDROID_VERSION_NAME")) {
versionCode ANDROID_VERSION_CODE
versionName ANDROID_VERSION_NAME

View file

@ -13,6 +13,8 @@ import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
class LocationHelper implements LocationListener {
@ -25,6 +27,8 @@ class LocationHelper implements LocationListener {
private GpsStatus.NmeaListener mNmeaListener;
private float mAltitudeAboveSeaLevel = 0f;
private float mHdop = 0f;
private Method addNmeaListenerMethod = null;
private Method removeNmeaListenerMethod = null;
LocationHelper(Context context) {
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
@ -70,7 +74,17 @@ class LocationHelper implements LocationListener {
onNmea(nmea);
}
};
mLocationManager.addNmeaListener(mNmeaListener);
// Use reflection to work around a bug in the Android 29 SDK.
// https://stackoverflow.com/questions/57975969/accessing-nmea-on-android-api-level-24-when-compiled-for-target-api-level-29
try {
if (addNmeaListenerMethod == null) {
addNmeaListenerMethod = LocationManager.class.getMethod("addNmeaListener", GpsStatus.NmeaListener.class);
}
addNmeaListenerMethod.invoke(mLocationManager, mNmeaListener);
} catch (Exception e) {
Log.w(TAG, "Couldn't get the nmea add method: " + e.toString());
}
}
mLocationEnable = true;
} catch (SecurityException e) {
@ -100,7 +114,16 @@ class LocationHelper implements LocationListener {
mGpsStatusListener = null;
}
if (mNmeaListener != null) {
mLocationManager.removeNmeaListener(mNmeaListener);
// Use reflection to work around a bug in the Android 29 SDK.
// https://stackoverflow.com/questions/57975969/accessing-nmea-on-android-api-level-24-when-compiled-for-target-api-level-29
try {
if (removeNmeaListenerMethod == null) {
removeNmeaListenerMethod = LocationManager.class.getMethod("removeNmeaListener", GpsStatus.NmeaListener.class);
}
removeNmeaListenerMethod.invoke(mLocationManager, mNmeaListener);
} catch (Exception e) {
Log.w(TAG, "Couldn't get the nmea remove method: " + e.toString());
}
mNmeaListener = null;
}
}