[Scummvm-git-logs] scummvm master -> 9c681ddd77a1aa48e737f65629791ff22e4aefe3
lephilousophe
noreply at scummvm.org
Wed May 1 09:44:17 UTC 2024
This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2522cba583 ANDROID: Don't use deprecated WiFi API
35e6c7a094 ANDROID: Introduce Compatibility helper class
c155e3dc3b ANDROID: Remove old compatibility code
5146495601 ANDROID: Don't use deprecated getDefaultDisplay and getMetrics
bed4b2ee0d ANDROID: Remove deprecated use of toggleSoftInputFromWindow
abca8ce013 ANDROID: Split deprecated code in its own function
bb2ebef540 ANDROID: Make a compatibility shim for AudioTrack construction
8475ef50da ANDROID: Add shim for AccessibilityEvent
9c681ddd77 ANDROID: Fix segmentation fault
Commit: 2522cba583296facd833b26eab6b41b8827df71d
https://github.com/scummvm/scummvm/commit/2522cba583296facd833b26eab6b41b8827df71d
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Don't use deprecated WiFi API
Use ConnectivityManager instead:
- it's more accurate
- it has been available since API level 16 which is the minimum we
require
- it removes a deprecation warning
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 00d56cfff1e..100e005656a 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -17,9 +17,8 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.media.AudioManager;
+import android.net.ConnectivityManager;
import android.net.Uri;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
@@ -750,13 +749,8 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
@Override
protected boolean isConnectionLimited() {
- // The WIFI Service must be looked up on the Application Context or memory will leak on devices < Android N (According to Android Studio warning)
- WifiManager wifiMgr = (WifiManager)getApplicationContext().getSystemService(Context.WIFI_SERVICE);
- if (wifiMgr != null && wifiMgr.isWifiEnabled()) {
- WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
- return (wifiInfo == null || wifiInfo.getNetworkId() == -1); //WiFi is on, but it's not connected to any network
- }
- return true;
+ ConnectivityManager cm = (ConnectivityManager)getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ return cm == null || cm.isActiveNetworkMetered();
}
@Override
Commit: 35e6c7a09484efa005159161b1d7d6d2b135b04a
https://github.com/scummvm/scummvm/commit/35e6c7a09484efa005159161b1d7d6d2b135b04a
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Introduce Compatibility helper class
It's kind of based on Androidx but is simpler and goes up to Jelly Bean.
This removes a bunch of warnings.
Changed paths:
A backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
backends/platform/android/org/scummvm/scummvm/SplashActivity.java
diff --git a/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java b/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
new file mode 100644
index 00000000000..f1baa559ac5
--- /dev/null
+++ b/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
@@ -0,0 +1,56 @@
+package org.scummvm.scummvm;
+
+import android.view.View;
+import android.view.Window;
+import android.view.WindowInsets;
+import android.view.WindowInsetsController;
+
+import androidx.annotation.RequiresApi;
+
+class CompatHelpers {
+ static class HideSystemStatusBar {
+
+ public static void hide(final Window window) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
+ HideSystemStatusBarR.hide(window);
+ } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
+ HideSystemStatusBarKitKat.hide(window);
+ } else {
+ HideSystemStatusBarJellyBean.hide(window);
+ }
+ }
+
+ @RequiresApi(android.os.Build.VERSION_CODES.JELLY_BEAN)
+ @SuppressWarnings("deprecation")
+ private static class HideSystemStatusBarJellyBean {
+ public static void hide(final Window window) {
+ View view = window.getDecorView();
+ view.setSystemUiVisibility(
+ view.getSystemUiVisibility() |
+ View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ }
+ }
+
+ @RequiresApi(android.os.Build.VERSION_CODES.KITKAT)
+ @SuppressWarnings("deprecation")
+ private static class HideSystemStatusBarKitKat {
+ public static void hide(final Window window) {
+ View view = window.getDecorView();
+ view.setSystemUiVisibility(
+ (view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_IMMERSIVE) |
+ View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ View.SYSTEM_UI_FLAG_FULLSCREEN);
+ }
+ }
+
+ @RequiresApi(android.os.Build.VERSION_CODES.R)
+ private static class HideSystemStatusBarR {
+ public static void hide(final Window window) {
+ WindowInsetsController insetsController = window.getInsetsController();
+ insetsController.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ insetsController.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
+ }
+ }
+ }
+}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 100e005656a..7d345fa688e 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -509,8 +509,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
// _inputManager.hideSoftInputFromWindow(_main_surface.getWindowToken(), 0);
_inputManager.hideSoftInputFromWindow(_main_surface.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
- DimSystemStatusBar.get().dim(_videoLayout);
- //DimSystemStatusBar.get().dim(_main_surface);
+ CompatHelpers.HideSystemStatusBar.hide(getWindow());
//Log.d(ScummVM.LOG_TAG, "showScreenKeyboardWithoutTextInputField - captureMouse(true)");
_main_surface.captureMouse(true);
//_main_surface.showSystemMouseCursor(false);
@@ -923,8 +922,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
safSyncObject = new Object();
- hideSystemUI();
-
_videoLayout = new FrameLayout(this);
SetLayerType.get().setLayerType(_videoLayout);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -962,9 +959,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
//_main_surface.captureMouse(true, true);
//_main_surface.showSystemMouseCursor(false);
- // TODO is this redundant since we call hideSystemUI() ?
- DimSystemStatusBar.get().dim(_videoLayout);
-
setVolumeControlStream(AudioManager.STREAM_MUSIC);
// TODO needed?
@@ -1074,6 +1068,8 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
super.onResume();
+ CompatHelpers.HideSystemStatusBar.hide(getWindow());
+
if (_scummvm != null)
_scummvm.setPause(false);
//_main_surface.showSystemMouseCursor(false);
@@ -1207,7 +1203,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
- hideSystemUI();
+ CompatHelpers.HideSystemStatusBar.hide(getWindow());
}
// showSystemMouseCursor(false);
// } else {
@@ -1243,30 +1239,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
}
}
- // TODO setSystemUiVisibility is introduced in API 11 and deprecated in API 30 - When we move to API 30 we will have to replace this code
- // https://developer.android.com/training/system-ui/immersive.html#java
- //
- // The code sample in the url below contains code to switch between immersive and default mode
- // https://github.com/android/user-interface-samples/tree/master/AdvancedImmersiveMode
- // We could do something similar by making it a Global UI option.
- @TargetApi(Build.VERSION_CODES.KITKAT)
- private void hideSystemUI() {
- // Enables regular immersive mode.
- // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
- // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- // Set the content to appear under the system bars so that the
- // content doesn't resize when the system bars hide and show.
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- // Hide the nav bar and status bar
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN);
- }
-
// // Shows the system bars by removing all the flags
// // except for the ones that make the content appear under the system bars.
// @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@@ -1357,7 +1329,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
@Override
public void onVisibilityChanged(boolean visible) {
// Toast.makeText(HomeActivity.this, visible ? "Keyboard is active" : "Keyboard is Inactive", Toast.LENGTH_SHORT).show();
- hideSystemUI();
+ CompatHelpers.HideSystemStatusBar.hide(getWindow());
}
@SuppressWarnings("deprecation")
@@ -2157,49 +2129,8 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
// End of SAF enabled code
// -------------------------------------------------------------------------------------------
-
} // end of ScummVMActivity
-// *** HONEYCOMB / ICS FIX FOR FULLSCREEN MODE, by lmak ***
-// TODO DimSystemStatusBar may be redundant for us
-abstract class DimSystemStatusBar {
-
- final boolean bGlobalsImmersiveMode = true;
-
- public static DimSystemStatusBar get() {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
- return DimSystemStatusBarHoneycomb.Holder.sInstance;
- } else {
- return DimSystemStatusBarDummy.Holder.sInstance;
- }
- }
-
- public abstract void dim(final View view);
-
- private static class DimSystemStatusBarHoneycomb extends DimSystemStatusBar {
- private static class Holder {
- private static final DimSystemStatusBarHoneycomb sInstance = new DimSystemStatusBarHoneycomb();
- }
-
- public void dim(final View view) {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT && bGlobalsImmersiveMode) {
- // Immersive mode, I already hear curses when system bar reappears mid-game from the slightest swipe at the bottom of the screen
- view.setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | android.view.View.SYSTEM_UI_FLAG_FULLSCREEN);
- } else {
- view.setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE);
- }
- }
- }
-
- private static class DimSystemStatusBarDummy extends DimSystemStatusBar {
- private static class Holder {
- private static final DimSystemStatusBarDummy sInstance = new DimSystemStatusBarDummy();
- }
-
- public void dim(final View view) { }
- }
-}
-
abstract class SetLayerType {
public static SetLayerType get() {
diff --git a/backends/platform/android/org/scummvm/scummvm/SplashActivity.java b/backends/platform/android/org/scummvm/scummvm/SplashActivity.java
index df2a4dfc0df..c9f7acdd3ae 100644
--- a/backends/platform/android/org/scummvm/scummvm/SplashActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/SplashActivity.java
@@ -31,9 +31,7 @@ public class SplashActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
- hideSystemUI();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
@@ -49,6 +47,12 @@ public class SplashActivity extends Activity {
}
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ CompatHelpers.HideSystemStatusBar.hide(getWindow());
+ }
+
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == MY_PERMISSION_ALL) {
@@ -73,35 +77,11 @@ public class SplashActivity extends Activity {
finish();
}
- // TODO setSystemUiVisibility is introduced in API 11 and deprecated in API 30 - When we move to API 30 we will have to replace this code
- // https://developer.android.com/training/system-ui/immersive.html#java
- //
- // The code sample in the url below contains code to switch between immersive and default mode
- // https://github.com/android/user-interface-samples/tree/master/AdvancedImmersiveMode
- // We could do something similar by making it a Global UI option.
- @TargetApi(Build.VERSION_CODES.KITKAT)
- private void hideSystemUI() {
- // Enables regular immersive mode.
- // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
- // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- View decorView = getWindow().getDecorView();
- decorView.setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- // Set the content to appear under the system bars so that the
- // content doesn't resize when the system bars hide and show.
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- // Hide the nav bar and status bar
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN);
- }
-
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
- hideSystemUI();
+ CompatHelpers.HideSystemStatusBar.hide(getWindow());
}
}
Commit: c155e3dc3b59dcbeaf4af0b7f311600b58ee3060
https://github.com/scummvm/scummvm/commit/c155e3dc3b59dcbeaf4af0b7f311600b58ee3060
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Remove old compatibility code
We don't support something like Honeycomb anymore
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 7d345fa688e..81889e93bcd 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -923,7 +923,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
safSyncObject = new Object();
_videoLayout = new FrameLayout(this);
- SetLayerType.get().setLayerType(_videoLayout);
+ _videoLayout.setLayerType(android.view.View.LAYER_TYPE_NONE, null);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(_videoLayout);
_videoLayout.setFocusable(true);
@@ -931,7 +931,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
_videoLayout.requestFocus();
_main_surface = new EditableSurfaceView(this);
- SetLayerType.get().setLayerType(_main_surface);
+ _main_surface.setLayerType(android.view.View.LAYER_TYPE_NONE, null);
_videoLayout.addView(_main_surface, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
@@ -2131,38 +2131,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
} // end of ScummVMActivity
-abstract class SetLayerType {
-
- public static SetLayerType get() {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
- return SetLayerTypeHoneycomb.Holder.sInstance;
- } else {
- return SetLayerTypeDummy.Holder.sInstance;
- }
- }
-
- public abstract void setLayerType(final View view);
-
- private static class SetLayerTypeHoneycomb extends SetLayerType {
- private static class Holder {
- private static final SetLayerTypeHoneycomb sInstance = new SetLayerTypeHoneycomb();
- }
-
- public void setLayerType(final View view) {
- view.setLayerType(android.view.View.LAYER_TYPE_NONE, null);
- //view.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
- }
- }
-
- private static class SetLayerTypeDummy extends SetLayerType {
- private static class Holder {
- private static final SetLayerTypeDummy sInstance = new SetLayerTypeDummy();
- }
-
- public void setLayerType(final View view) { }
- }
-}
-
// Used to define the interface for a callback after ScummVM thread has finished
interface MyScummVMDestroyedCallback {
public void handle(int exitResult);
Commit: 51464956015339f17fac2b0989fccadf72f10a62
https://github.com/scummvm/scummvm/commit/51464956015339f17fac2b0989fccadf72f10a62
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Don't use deprecated getDefaultDisplay and getMetrics
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 81889e93bcd..48c2a71a059 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -13,6 +13,7 @@ import android.content.UriPermission;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
@@ -684,9 +685,10 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
@Override
protected void getDPI(float[] values) {
- DisplayMetrics metrics = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(metrics);
- Configuration config = getResources().getConfiguration();
+ Resources resources = getResources();
+
+ DisplayMetrics metrics = resources.getDisplayMetrics();
+ Configuration config = resources.getConfiguration();
values[0] = metrics.xdpi;
values[1] = metrics.ydpi;
Commit: bed4b2ee0d0113038f7038d3990faf1e3f4a9f81
https://github.com/scummvm/scummvm/commit/bed4b2ee0d0113038f7038d3990faf1e3f4a9f81
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Remove deprecated use of toggleSoftInputFromWindow
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 48c2a71a059..665ae72ad87 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -184,7 +184,8 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
//_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
//_inputManager.showSoftInput(_main_surface, InputMethodManager.SHOW_FORCED);
- _inputManager.toggleSoftInputFromWindow(_main_surface.getWindowToken(), InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
+ // This is deprecated and we show the keyboard just below
+ //_inputManager.toggleSoftInputFromWindow(_main_surface.getWindowToken(), InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
_inputManager.showSoftInput(_main_surface, InputMethodManager.SHOW_IMPLICIT);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
} else {
Commit: abca8ce01335713fc1a1990fd79e9c1186167554
https://github.com/scummvm/scummvm/commit/abca8ce01335713fc1a1990fd79e9c1186167554
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Split deprecated code in its own function
This allows to remove deprecation warning on a limited part of code
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index fdd9294a4aa..87dea9af551 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -343,36 +343,8 @@ public class ScummVMEventsBase implements
}
}
- // The KeyEvent.ACTION_MULTIPLE constant was deprecated in API level 29 (Q).
- // No longer used by the input system.
- // getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
- // If the key code is not KEYCODE_UNKNOWN then the getRepeatCount() method returns the number of times the given key code should be executed.
- // Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters().
- // sequence of characters
- // getCharacters() is also deprecated in API level 29
- // For the special case of a ACTION_MULTIPLE event with key code of KEYCODE_UNKNOWN,
- // this is a raw string of characters associated with the event. In all other cases it is null.
- // TODO What is the use case for this?
- // Does it make sense to keep it with a Build.VERSION.SDK_INT < Build.VERSION_CODES.Q check?
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
- if (action == KeyEvent.ACTION_MULTIPLE
- && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
- final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
- final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
-
- if (es == null) {
- return true;
- }
-
- for (KeyEvent s : es) {
- _scummvm.pushEvent(JE_KEY,
- s.getAction(),
- s.getKeyCode(),
- eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
- s.getMetaState(),
- s.getRepeatCount(),
- 0);
- }
+ if (onKeyMultiple(action, keyCode, e)) {
return true;
}
}
@@ -470,6 +442,45 @@ public class ScummVMEventsBase implements
return true;
}
+ /**
+ * This gets called only on Android < Q
+ */
+ @SuppressWarnings("deprecation")
+ private boolean onKeyMultiple(int action, int keyCode, KeyEvent e) {
+ // The KeyEvent.ACTION_MULTIPLE constant was deprecated in API level 29 (Q).
+ // No longer used by the input system.
+ // getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
+ // If the key code is not KEYCODE_UNKNOWN then the getRepeatCount() method returns the number of times the given key code should be executed.
+ // Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters().
+ // sequence of characters
+ // getCharacters() is also deprecated in API level 29
+ // For the special case of a ACTION_MULTIPLE event with key code of KEYCODE_UNKNOWN,
+ // this is a raw string of characters associated with the event. In all other cases it is null.
+ // TODO What is the use case for this?
+ // Does it make sense to keep it with a Build.VERSION.SDK_INT < Build.VERSION_CODES.Q check?
+ if (action == KeyEvent.ACTION_MULTIPLE
+ && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+ final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
+ final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
+
+ if (es == null) {
+ return true;
+ }
+
+ for (KeyEvent s : es) {
+ _scummvm.pushEvent(JE_KEY,
+ s.getAction(),
+ s.getKeyCode(),
+ s.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
+ s.getMetaState(),
+ s.getRepeatCount(),
+ 0);
+ }
+ return true;
+ }
+
+ return false;
+ }
/** Aux method to provide a description for a MotionEvent action
* Given an action int, returns a string description
Commit: bb2ebef540491a655d36291b0295feaf52fc5d09
https://github.com/scummvm/scummvm/commit/bb2ebef540491a655d36291b0295feaf52fc5d09
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Make a compatibility shim for AudioTrack construction
Changed paths:
backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
backends/platform/android/org/scummvm/scummvm/ScummVM.java
diff --git a/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java b/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
index f1baa559ac5..5f52636f43f 100644
--- a/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
+++ b/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
@@ -1,5 +1,10 @@
package org.scummvm.scummvm;
+import android.media.AudioAttributes;
+import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.AudioTrack;
+
import android.view.View;
import android.view.Window;
import android.view.WindowInsets;
@@ -53,4 +58,84 @@ class CompatHelpers {
}
}
}
+
+ static class AudioTrackCompat {
+ public static class AudioTrackCompatReturn {
+ public AudioTrack audioTrack;
+ public int bufferSize;
+ }
+
+ public static AudioTrackCompatReturn make(int sample_rate, int buffer_size) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
+ return AudioTrackCompatM.make(sample_rate, buffer_size);
+ } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ return AudioTrackCompatLollipop.make(sample_rate, buffer_size);
+ } else {
+ return AudioTrackCompatOld.make(sample_rate, buffer_size);
+ }
+ }
+
+ /**
+ * Support for Android KitKat or lower
+ */
+ @SuppressWarnings("deprecation")
+ private static class AudioTrackCompatOld {
+ public static AudioTrackCompatReturn make(int sample_rate, int buffer_size) {
+ AudioTrackCompatReturn ret = new AudioTrackCompatReturn();
+ ret.audioTrack = new AudioTrack(
+ AudioManager.STREAM_MUSIC,
+ sample_rate,
+ AudioFormat.CHANNEL_OUT_STEREO,
+ AudioFormat.ENCODING_PCM_16BIT,
+ buffer_size,
+ AudioTrack.MODE_STREAM);
+ ret.bufferSize = buffer_size;
+ return ret;
+ }
+ }
+
+ @RequiresApi(android.os.Build.VERSION_CODES.LOLLIPOP)
+ private static class AudioTrackCompatLollipop {
+ public static AudioTrackCompatReturn make(int sample_rate, int buffer_size) {
+ AudioTrackCompatReturn ret = new AudioTrackCompatReturn();
+ ret.audioTrack = new AudioTrack(
+ new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_MEDIA)
+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
+ .build(),
+ new AudioFormat.Builder()
+ .setSampleRate(sample_rate)
+ .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
+ .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO).build(),
+ buffer_size,
+ AudioTrack.MODE_STREAM,
+ AudioManager.AUDIO_SESSION_ID_GENERATE);
+ ret.bufferSize = buffer_size;
+ return ret;
+ }
+ }
+
+ @RequiresApi(android.os.Build.VERSION_CODES.M)
+ private static class AudioTrackCompatM {
+ public static AudioTrackCompatReturn make(int sample_rate, int buffer_size) {
+ AudioTrackCompatReturn ret = new AudioTrackCompatReturn();
+ ret.audioTrack = new AudioTrack(
+ new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_MEDIA)
+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
+ .build(),
+ new AudioFormat.Builder()
+ .setSampleRate(sample_rate)
+ .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
+ .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO).build(),
+ buffer_size,
+ AudioTrack.MODE_STREAM,
+ AudioManager.AUDIO_SESSION_ID_GENERATE);
+ // Keep track of the actual obtained audio buffer size, if supported.
+ // We just requested 16 bit PCM stereo pcm so there are 4 bytes per frame.
+ ret.bufferSize = ret.audioTrack.getBufferSizeInFrames() * 4;
+ return ret;
+ }
+ }
+ }
}
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 76e1e5cb693..bb0a0f38b71 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -4,7 +4,6 @@ import androidx.annotation.NonNull;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.PixelFormat;
-import android.media.AudioAttributes;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
@@ -291,11 +290,10 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
}
private void initAudio() throws Exception {
- _sample_rate = AudioTrack.getNativeOutputSampleRate(
- AudioManager.STREAM_MUSIC);
+ _sample_rate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
_buffer_size = AudioTrack.getMinBufferSize(_sample_rate,
- AudioFormat.CHANNEL_OUT_STEREO,
- AudioFormat.ENCODING_PCM_16BIT);
+ AudioFormat.CHANNEL_OUT_STEREO,
+ AudioFormat.ENCODING_PCM_16BIT);
// ~50ms
int buffer_size_want = (_sample_rate * 2 * 2 / 20) & ~1023;
@@ -310,33 +308,10 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
Log.i(LOG_TAG, String.format(Locale.ROOT, "Using %d bytes buffer for %dHz audio",
_buffer_size, _sample_rate));
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- _audio_track = new AudioTrack(
- new AudioAttributes.Builder()
- .setUsage(AudioAttributes.USAGE_MEDIA)
- .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
- .build(),
- new AudioFormat.Builder()
- .setSampleRate(_sample_rate)
- .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
- .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO).build(),
- _buffer_size,
- AudioTrack.MODE_STREAM,
- AudioManager.AUDIO_SESSION_ID_GENERATE);
-
- // Keep track of the actual obtained audio buffer size, if supported.
- // We just requested 16 bit PCM stereo pcm so there are 4 bytes per frame.
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
- _buffer_size = _audio_track.getBufferSizeInFrames() * 4;
- } else {
- //support for Android KitKat or lower
- _audio_track = new AudioTrack(AudioManager.STREAM_MUSIC,
- _sample_rate,
- AudioFormat.CHANNEL_OUT_STEREO,
- AudioFormat.ENCODING_PCM_16BIT,
- _buffer_size,
- AudioTrack.MODE_STREAM);
- }
+ CompatHelpers.AudioTrackCompat.AudioTrackCompatReturn audioTrackRet =
+ CompatHelpers.AudioTrackCompat.make(_sample_rate, _buffer_size);
+ _audio_track = audioTrackRet.audioTrack;
+ _buffer_size = audioTrackRet.bufferSize;
if (_audio_track.getState() != AudioTrack.STATE_INITIALIZED)
throw new Exception(
Commit: 8475ef50dac60dc4098308d3f4d30db59d6eb45f
https://github.com/scummvm/scummvm/commit/8475ef50dac60dc4098308d3f4d30db59d6eb45f
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Add shim for AccessibilityEvent
Changed paths:
backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
backends/platform/android/org/scummvm/scummvm/CustomKeyboardView.java
diff --git a/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java b/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
index 5f52636f43f..8561abd7868 100644
--- a/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
+++ b/backends/platform/android/org/scummvm/scummvm/CompatHelpers.java
@@ -9,6 +9,7 @@ import android.view.View;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
+import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.RequiresApi;
@@ -138,4 +139,31 @@ class CompatHelpers {
}
}
}
+
+ static class AccessibilityEventConstructor {
+ public static AccessibilityEvent make(int eventType) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
+ return AccessibilityEventConstructorR.make(eventType);
+ } else {
+ return AccessibilityEventConstructorOld.make(eventType);
+ }
+
+ }
+
+ @SuppressWarnings("deprecation")
+ private static class AccessibilityEventConstructorOld {
+ public static AccessibilityEvent make(int eventType) {
+ return AccessibilityEvent.obtain(eventType);
+ }
+ }
+
+ @RequiresApi(android.os.Build.VERSION_CODES.R)
+ private static class AccessibilityEventConstructorR {
+ public static AccessibilityEvent make(int eventType) {
+ return new AccessibilityEvent(eventType);
+ }
+ }
+
+
+ }
}
diff --git a/backends/platform/android/org/scummvm/scummvm/CustomKeyboardView.java b/backends/platform/android/org/scummvm/scummvm/CustomKeyboardView.java
index a45af0821b0..1bb04425292 100755
--- a/backends/platform/android/org/scummvm/scummvm/CustomKeyboardView.java
+++ b/backends/platform/android/org/scummvm/scummvm/CustomKeyboardView.java
@@ -1071,7 +1071,7 @@ public class CustomKeyboardView extends View implements View.OnClickListener {
private void sendAccessibilityEventForUnicodeCharacter(int eventType, int code) {
if (mAccessibilityManager.isEnabled()) {
- AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
+ AccessibilityEvent event = CompatHelpers.AccessibilityEventConstructor.make(eventType);
onInitializeAccessibilityEvent(event);
final String text;
switch (code) {
Commit: 9c681ddd77a1aa48e737f65629791ff22e4aefe3
https://github.com/scummvm/scummvm/commit/9c681ddd77a1aa48e737f65629791ff22e4aefe3
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-05-01T11:44:10+02:00
Commit Message:
ANDROID: Fix segmentation fault
We expect the array to be of even size so don't add the external data
title if there is no external data mount point
Changed paths:
backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
index 1ba69238b51..78a159254e6 100644
--- a/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
+++ b/backends/platform/android/org/scummvm/scummvm/ExternalStorage.java
@@ -481,8 +481,8 @@ public class ExternalStorage {
map.add(DATA_DIRECTORY_INT);
map.add(ctx.getFilesDir().getPath());
- map.add(DATA_DIRECTORY_EXT);
if (ctx.getExternalFilesDir(null) != null) {
+ map.add(DATA_DIRECTORY_EXT);
map.add(ctx.getExternalFilesDir(null).getPath());
}
More information about the Scummvm-git-logs
mailing list