Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for targeting API 33 #151

Open
wants to merge 9 commits into
base: sdl_android
Choose a base branch
from
Open
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@
[submodule "project/jni/sdl2"]
path = project/jni/sdl2
url = https://github.com/libsdl-org/SDL.git
branch = main
branch = SDL2
[submodule "project/jni/sdl2_image"]
path = project/jni/sdl2_image
url = https://github.com/libsdl-org/SDL_image
branch = main
branch = SDL2
[submodule "project/jni/sdl2_ttf"]
path = project/jni/sdl2_ttf
url = https://github.com/libsdl-org/SDL_ttf.git
branch = main
branch = SDL2
[submodule "project/jni/sdl2_mixer"]
path = project/jni/sdl2_mixer
url = https://github.com/libsdl-org/SDL_mixer.git
branch = master
branch = SDL2
5 changes: 4 additions & 1 deletion project/AndroidManifestTemplate.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="100"
android:versionName="1.0.0"
android:installLocation="auto"
Expand All @@ -12,6 +13,7 @@
android:extractNativeLibs="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true"
>
<activity android:name="MainActivity"
android:label="@string/app_name"
Expand Down Expand Up @@ -65,7 +67,8 @@
</application>

<!-- ==INTERNET== --> <uses-permission android:name="android.permission.INTERNET" />
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" tools:ignore="ScopedStorage" />
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <!-- App has write access to it's own dir on SD card without this permission on Android 4.4 and above -->
Expand Down
13 changes: 11 additions & 2 deletions project/java/DummyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ public int onStartCommand(Intent intent, int flags, int startId)
.setTicker(getString(getApplicationInfo().labelRes))
.setOngoing(true)
.build();
PendingIntent killIntent = PendingIntent.getService(this, 5, new Intent(Intent.ACTION_DELETE, null, this, DummyService.class), PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent showIntent = PendingIntent.getActivity(this, 0, new Intent("", null, this, MainActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);
int killIntentFlags = 0, showIntentFlags = 0, FLAG_MUTABLE = 0x02000000;
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ) {
killIntentFlags = FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT;
showIntentFlags = FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT;
}
else {
killIntentFlags = PendingIntent.FLAG_CANCEL_CURRENT;
showIntentFlags = PendingIntent.FLAG_CANCEL_CURRENT;
}
PendingIntent killIntent = PendingIntent.getService(this, 5, new Intent(Intent.ACTION_DELETE, null, this, DummyService.class), killIntentFlags);
PendingIntent showIntent = PendingIntent.getActivity(this, 0, new Intent("", null, this, MainActivity.class), showIntentFlags);
ntf.deleteIntent = killIntent;
RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
view.setCharSequence(R.id.notificationText, "setText", getString(R.string.notification_app_is_running, getString(getApplicationInfo().labelRes)));
Expand Down
19 changes: 18 additions & 1 deletion project/java/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Java source code (C) 2009-2014 Sergii Pylypenko
import java.util.Arrays;
import java.util.zip.ZipFile;
import java.util.ArrayList;
import android.os.Environment;
import android.net.Uri;


public class MainActivity extends Activity
Expand Down Expand Up @@ -310,13 +312,28 @@ public void run()
Log.v("SDL", "SD card permission 1: " + getPackageName() + " perms " + info.requestedPermissions + " name " + info.packageName + " ver " + info.versionName);
if( info.requestedPermissions != null && Arrays.asList(info.requestedPermissions).contains(Manifest.permission.WRITE_EXTERNAL_STORAGE) )
{
Log.v("SDL", "SD card permission 4: REQUEST");
Log.v("SDL", "SD card permission 4 (WRITE): REQUEST");
int permissionCheck = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED && !writeExternalStoragePermissionDialogAnswered)
{
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
}
}
// For Android 11+
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && !Environment.isExternalStorageManager() )
{
Log.v("SDL", "SD card permission 4 (MANAGE): REQUEST");
try {
Intent permissionRequestIntent = new Intent(
android.provider.Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
Uri.parse("package:" + getApplicationContext().getPackageName())
);
startActivity(permissionRequestIntent);
} catch (Exception ex) {
Intent permissionRequestIntent = new Intent(android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
startActivity(permissionRequestIntent);
}
}
}
}
catch(Exception e) {}
Expand Down
3 changes: 3 additions & 0 deletions project/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ SUPPORT_MID_TIMIDITY := 0
SUPPORT_JPG := true
SUPPORT_PNG := true

# Enable ogg module inside sdl2_mixer (common dependency for both v1.2 and v2 mixers)
SUPPORT_OGG := true

NDK_VERSION := $(strip $(patsubst android-ndk-%,%,$(filter android-ndk-%, $(subst /, ,$(dir $(TARGET_CC))))))
#$(info NDK version $(NDK_VERSION)) # This warning puzzles ndk-gdb
ifneq ($(filter r1 r2 r3 r4 r5 r6 r7 r8,$(NDK_VERSION)),)
Expand Down
2 changes: 1 addition & 1 deletion project/jni/application/CustomBuildScript.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TARGET_GCC_PREFIX_x86_64 := x86_64-linux-android

LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))

LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
LOCAL_SHARED_LIBRARIES := $(if $(filter 1.2, $(SDL_VERSION)), sdl-1.2, SDL2) $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))

LOCAL_SHARED_LIBRARIES := $(patsubst crypto, crypto.so.sdl.1, $(LOCAL_SHARED_LIBRARIES))
LOCAL_SHARED_LIBRARIES := $(patsubst ssl, ssl.so.sdl.1, $(LOCAL_SHARED_LIBRARIES))
Expand Down
2 changes: 1 addition & 1 deletion project/jni/mpg123/include/fmt123.h
2 changes: 1 addition & 1 deletion project/jni/mpg123/include/mpg123.h
2 changes: 1 addition & 1 deletion project/jni/ogg/include/ogg/config_types.h
2 changes: 1 addition & 1 deletion project/jni/ogg/include/ogg/ogg.h
2 changes: 1 addition & 1 deletion project/jni/ogg/include/ogg/os_types.h
2 changes: 1 addition & 1 deletion project/jni/sdl2
Submodule sdl2 updated 1450 files
2 changes: 1 addition & 1 deletion project/jni/sdl2_image
Submodule sdl2_image updated 119 files
2 changes: 1 addition & 1 deletion project/jni/sdl2_mixer
Submodule sdl2_mixer updated 3152 files
2 changes: 1 addition & 1 deletion project/jni/sdl2_ttf
Submodule sdl2_ttf updated 1474 files