From 547d20aed363c4625be33558a8d3f424703d28b6 Mon Sep 17 00:00:00 2001 From: dgis Date: Sat, 24 Jun 2023 23:32:55 +0200 Subject: [PATCH] Prevent some calculator to sleep. Fix crash. Attempt to fix haptic feedback. --- ReadMe.txt | 16 ++++++++ app/build.gradle | 37 ++++++++----------- app/src/main/AndroidManifest.xml | 3 +- app/src/main/assets/calculators/CP_48G3.KML | 2 +- app/src/main/assets/calculators/CP_48S3.KML | 2 +- app/src/main/assets/calculators/DEFAUL38.KML | 2 +- app/src/main/assets/calculators/DEFAULTG.KML | 2 +- app/src/main/assets/calculators/DEFAULTS.KML | 2 +- app/src/main/assets/calculators/FLOAT_GX.KML | 2 +- app/src/main/assets/calculators/JEMAC.KML | 2 +- app/src/main/assets/calculators/PATCHES.38G | 2 + app/src/main/assets/calculators/PATCHES.39G | 3 ++ app/src/main/assets/calculators/PATCHES.48 | 2 + app/src/main/assets/calculators/PATCHES.49G | 4 ++ .../main/assets/calculators/Wombat3 48GX.kml | 2 +- .../main/assets/calculators/Wombat3 48SX.kml | 2 +- app/src/main/assets/calculators/calypso2k.kml | 1 + app/src/main/assets/calculators/calypso4k.kml | 1 + app/src/main/assets/calculators/real38g-l.kml | 1 + .../main/assets/calculators/real38g-lc.kml | 1 + app/src/main/assets/calculators/real39g-l.kml | 1 + .../main/assets/calculators/real39g-lc.kml | 1 + .../main/assets/calculators/real39gp-l.kml | 1 + .../main/assets/calculators/real39gp-lc.kml | 1 + .../main/assets/calculators/real39gs-l.kml | 1 + .../main/assets/calculators/real39gs-lc.kml | 1 + app/src/main/assets/calculators/real40g-l.kml | 1 + .../main/assets/calculators/real40g-lc.kml | 1 + .../main/assets/calculators/real40gs-l.kml | 1 + .../main/assets/calculators/real40gs-lc.kml | 1 + .../main/assets/calculators/real48gx-l.kml | 1 + .../main/assets/calculators/real48gx-lc.kml | 1 + .../main/assets/calculators/real48sx-l.kml | 1 + .../main/assets/calculators/real48sx-lc.kml | 1 + app/src/main/cpp/emu-jni.c | 23 +++++++----- app/src/main/cpp/win32-layer.c | 2 + .../emulator/calculator/EmuApplication.java | 3 +- .../org/emulator/calculator/InfoFragment.java | 8 +--- .../calculator/PrinterSimulatorFragment.java | 2 +- .../org/emulator/calculator/Settings.java | 8 ++-- .../java/org/emulator/calculator/Utils.java | 24 ++++++++++-- .../emulator/forty/eight/MainActivity.java | 6 +-- app/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- gradle.properties | 4 ++ gradle/wrapper/gradle-wrapper.properties | 6 +-- 46 files changed, 127 insertions(+), 65 deletions(-) create mode 100644 app/src/main/assets/calculators/PATCHES.38G create mode 100644 app/src/main/assets/calculators/PATCHES.39G create mode 100644 app/src/main/assets/calculators/PATCHES.48 create mode 100644 app/src/main/assets/calculators/PATCHES.49G diff --git a/ReadMe.txt b/ReadMe.txt index 28d7fc5..da59e7b 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -58,6 +58,14 @@ LINKS CHANGES +Version 2.7 (2022-09-XX) + +- Attempt to fix haptic feedback with Android 13 (API deprecation). +- Patch the ROM files to prevent the calculator to sleep for HP38G, HP39G, HP40G, HP48SX and HP48GX. + There is an issue with this patch and the Flashcard for the HP49/50 because an already existing Flashcard embed the non patched ROM file, + and the CRC check failed and make a CPU reset! +- Fix a potential crash about the permission to access the files. + Version 2.6 (2022-08-19) - Updated source code from Eric Rechlin's Emu48 version 1.64+ that was merged from Christoph Gießelink's Emu48 version 1.65. This new version improve the serial communication. @@ -252,8 +260,16 @@ The Eric's Real scripts ("real*.kml" and "real*.bmp/png") are embedded in this a Portions of this source code (about the usb-serial) were originally created by Google Inc. in 2011-2013 and Mike Wakerly in 2013. +FAQ + +* Can you do something about Android removing access permissions to the state file? I can't run the app for more than a week before the OS takes it away and then I have to create a new state file. + > It should be possible to prevent Android from forgetting the permissions in Google Play Store app, Account/Play Protect/App permissions removed/See apps/All apps/Emu48/"Remove permissions if app isn't used" uncheck. + TODO +- Test XSEND. +- Haptic feedback does not seems to work on Android 13, should check (J. Majors). +- Add an "haptic" feedback with a sound instead of a vibration (F. Giampietro). - Add a Cancel button to the HP48 memory card creator dialog. - Manage the HP 48 port 2 with the same kind of interface for the memory card. - The render pixels are very nice. A solution to obtain uniform pixel size could be a preset (a multiplier, auto) so the user could decide and upscale/downscale (Michael P). diff --git a/app/build.gradle b/app/build.gradle index 622eb4d..bf20d42 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,22 +28,16 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion 32 + namespace 'org.emulator.forty.eight' + compileSdk 33 defaultConfig { applicationId "org.emulator.forty.eight" - minSdkVersion 19 - targetSdkVersion 32 - versionCode 25 - versionName "2.6" + minSdk 19 + targetSdk 33 + versionCode 26 + versionName "2.7" setProperty("archivesBaseName", "Emu48-v$versionName") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - externalNativeBuild { - cmake { - //abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64' - //abiFilters 'x86_64' - //version "3.10.2" - } - } } if (canSign) { @@ -71,25 +65,26 @@ android { } } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } externalNativeBuild { cmake { - path "CMakeLists.txt" + path file('CMakeLists.txt') + //version '3.18.1' } } - compileOptions { - sourceCompatibility = '1.8' - targetCompatibility = '1.8' - } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.preference:preference:1.2.0' - implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.documentfile:documentfile:1.0.1' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test:runner:1.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d260787..c07e59e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/app/src/main/assets/calculators/CP_48G3.KML b/app/src/main/assets/calculators/CP_48G3.KML index c1858da..e692ab8 100644 --- a/app/src/main/assets/calculators/CP_48G3.KML +++ b/app/src/main/assets/calculators/CP_48G3.KML @@ -21,7 +21,7 @@ Global Author "Casey Patterson && Sebastien Carlier" Model "G" Rom "rom.48g" - Patch "BEEP.48" + Patch "PATCHES.48" Bitmap "cp_48g3.bmp" Debug 0 End diff --git a/app/src/main/assets/calculators/CP_48S3.KML b/app/src/main/assets/calculators/CP_48S3.KML index bd1a17a..be75173 100644 --- a/app/src/main/assets/calculators/CP_48S3.KML +++ b/app/src/main/assets/calculators/CP_48S3.KML @@ -13,7 +13,7 @@ Global Author "Casey Patterson" Model "S" Rom "rom.48s" - Patch "BEEP.48" + Patch "PATCHES.48" Bitmap "cp_48s3.bmp" Debug 0 End diff --git a/app/src/main/assets/calculators/DEFAUL38.KML b/app/src/main/assets/calculators/DEFAUL38.KML index f10d1ec..fea2a60 100644 --- a/app/src/main/assets/calculators/DEFAUL38.KML +++ b/app/src/main/assets/calculators/DEFAUL38.KML @@ -9,7 +9,7 @@ Global Author "Christoph Giesselink" Model "A" Rom "rom.38g" - Patch "BEEP.38G" + Patch "PATCHES.38G" Debug 0 Bitmap "DEFAUL38.BMP" End diff --git a/app/src/main/assets/calculators/DEFAULTG.KML b/app/src/main/assets/calculators/DEFAULTG.KML index c87df68..a02b128 100644 --- a/app/src/main/assets/calculators/DEFAULTG.KML +++ b/app/src/main/assets/calculators/DEFAULTG.KML @@ -3,7 +3,7 @@ Global Author "Sebastien Carlier" Model "G" Rom "rom.48g" - Patch "BEEP.48" + Patch "PATCHES.48" Debug 0 Bitmap "DEFAULTG.BMP" End diff --git a/app/src/main/assets/calculators/DEFAULTS.KML b/app/src/main/assets/calculators/DEFAULTS.KML index 49f3c4d..7745dcd 100644 --- a/app/src/main/assets/calculators/DEFAULTS.KML +++ b/app/src/main/assets/calculators/DEFAULTS.KML @@ -3,7 +3,7 @@ Global Author "Sebastien Carlier" Model "S" Rom "rom.48s" - Patch "BEEP.48" + Patch "PATCHES.48" Debug 0 Bitmap "DEFAULTS.BMP" End diff --git a/app/src/main/assets/calculators/FLOAT_GX.KML b/app/src/main/assets/calculators/FLOAT_GX.KML index 6cae974..50a7126 100644 --- a/app/src/main/assets/calculators/FLOAT_GX.KML +++ b/app/src/main/assets/calculators/FLOAT_GX.KML @@ -13,7 +13,7 @@ Global Author "Casey Patterson" Model "G" Rom "rom.48g" - Patch "BEEP.48" + Patch "PATCHES.48" Debug 0 Bitmap "float_gx.bmp" End diff --git a/app/src/main/assets/calculators/JEMAC.KML b/app/src/main/assets/calculators/JEMAC.KML index e2622ca..60ae714 100644 --- a/app/src/main/assets/calculators/JEMAC.KML +++ b/app/src/main/assets/calculators/JEMAC.KML @@ -3,7 +3,7 @@ Global Author "Jeffery L. McMahan" Model "G" Rom "rom.48g" - Patch "BEEP.48" + Patch "PATCHES.48" Bitmap "jemac.bmp" Debug 0 End diff --git a/app/src/main/assets/calculators/PATCHES.38G b/app/src/main/assets/calculators/PATCHES.38G new file mode 100644 index 0000000..cf09288 --- /dev/null +++ b/app/src/main/assets/calculators/PATCHES.38G @@ -0,0 +1,2 @@ +014A1:6300; disable 10 min auto off (internal, undocumented) +;017D0:81B1; =makebeep (internal, undocumented) diff --git a/app/src/main/assets/calculators/PATCHES.39G b/app/src/main/assets/calculators/PATCHES.39G new file mode 100644 index 0000000..1a65c5b --- /dev/null +++ b/app/src/main/assets/calculators/PATCHES.39G @@ -0,0 +1,3 @@ +0148D:6300; disable 10 min auto off (internal, undocumented) +;017BC:81B1; =makebeep (internal, undocumented) +0212D:000; set =BounceTiming to 0 (internal, undocumented) diff --git a/app/src/main/assets/calculators/PATCHES.48 b/app/src/main/assets/calculators/PATCHES.48 new file mode 100644 index 0000000..6e92554 --- /dev/null +++ b/app/src/main/assets/calculators/PATCHES.48 @@ -0,0 +1,2 @@ +01477:6300; disable 10 min auto off (internal, undocumented) +;017A6:81B1; =makebeep diff --git a/app/src/main/assets/calculators/PATCHES.49G b/app/src/main/assets/calculators/PATCHES.49G new file mode 100644 index 0000000..59c7cd4 --- /dev/null +++ b/app/src/main/assets/calculators/PATCHES.49G @@ -0,0 +1,4 @@ +;41262:6300; disable 10 min auto off (internal for 1.19-6, undocumented) +412B9:6300; disable 10 min auto off (internal for 1.24/2.09, undocumented) +;4157A:81B1; =makebeep (internal for 1.18/1.19-5/1.19-6, undocumented) +;41609:81B1; =makebeep (internal for 1.24/2.01/2.09, undocumented) diff --git a/app/src/main/assets/calculators/Wombat3 48GX.kml b/app/src/main/assets/calculators/Wombat3 48GX.kml index 3095261..e579a45 100644 --- a/app/src/main/assets/calculators/Wombat3 48GX.kml +++ b/app/src/main/assets/calculators/Wombat3 48GX.kml @@ -10,7 +10,7 @@ Global Hardware "Yorke" Model "G" Rom "rom.48g" - Patch "BEEP.48" + Patch "PATCHES.48" Bitmap "Wombat3 48GX.bmp" Debug 0 End diff --git a/app/src/main/assets/calculators/Wombat3 48SX.kml b/app/src/main/assets/calculators/Wombat3 48SX.kml index 8dfa316..0cdfa0b 100644 --- a/app/src/main/assets/calculators/Wombat3 48SX.kml +++ b/app/src/main/assets/calculators/Wombat3 48SX.kml @@ -10,7 +10,7 @@ Global Hardware "Yorke" Model "S" Rom "rom.48s" - Patch "BEEP.48" + Patch "PATCHES.48" Bitmap "Wombat3 48SX.bmp" Debug 0 End diff --git a/app/src/main/assets/calculators/calypso2k.kml b/app/src/main/assets/calculators/calypso2k.kml index 0ea4a12..ce6b4b9 100644 --- a/app/src/main/assets/calculators/calypso2k.kml +++ b/app/src/main/assets/calculators/calypso2k.kml @@ -11,6 +11,7 @@ Global Model "Q" Class 50 Rom "rom.49g" + Patch "PATCHES.49G" Bitmap "calypso2k.png" Color 0 0 0 0 #Scale 3 9 diff --git a/app/src/main/assets/calculators/calypso4k.kml b/app/src/main/assets/calculators/calypso4k.kml index 3318b6d..af1eec8 100644 --- a/app/src/main/assets/calculators/calypso4k.kml +++ b/app/src/main/assets/calculators/calypso4k.kml @@ -11,6 +11,7 @@ Global Model "Q" Class 50 Rom "rom.49g" + Patch "PATCHES.49G" Bitmap "calypso4k.png" Color 0 0 0 0 #Scale 3 18 diff --git a/app/src/main/assets/calculators/real38g-l.kml b/app/src/main/assets/calculators/real38g-l.kml index 9dc9804..3e230b1 100644 --- a/app/src/main/assets/calculators/real38g-l.kml +++ b/app/src/main/assets/calculators/real38g-l.kml @@ -15,6 +15,7 @@ Global Author "Eric Rechlin" Model "6" # 6 for 64K RAM, A for 32K RAM Rom "rom.38g" + Patch "PATCHES.38G" Bitmap "real38g-l.png" Icon "38g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real38g-lc.kml b/app/src/main/assets/calculators/real38g-lc.kml index 21bc957..83c5c0d 100644 --- a/app/src/main/assets/calculators/real38g-lc.kml +++ b/app/src/main/assets/calculators/real38g-lc.kml @@ -15,6 +15,7 @@ Global Author "Eric Rechlin" Model "6" # 6 for 64K RAM, A for 32K RAM Rom "rom.38g" + Patch "PATCHES.38G" Bitmap "real38g-lc.png" Icon "38g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real39g-l.kml b/app/src/main/assets/calculators/real39g-l.kml index 2082272..8a0a292 100644 --- a/app/src/main/assets/calculators/real39g-l.kml +++ b/app/src/main/assets/calculators/real39g-l.kml @@ -14,6 +14,7 @@ Global Model "E" Class 39 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39g-l.png" Icon "39g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real39g-lc.kml b/app/src/main/assets/calculators/real39g-lc.kml index 90c56c8..d52fb7b 100644 --- a/app/src/main/assets/calculators/real39g-lc.kml +++ b/app/src/main/assets/calculators/real39g-lc.kml @@ -14,6 +14,7 @@ Global Model "E" Class 39 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39g-lc.png" Icon "39g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real39gp-l.kml b/app/src/main/assets/calculators/real39gp-l.kml index c7c9fcd..fd25166 100644 --- a/app/src/main/assets/calculators/real39gp-l.kml +++ b/app/src/main/assets/calculators/real39gp-l.kml @@ -14,6 +14,7 @@ Global Model "E" Class 39 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39gp-l.png" Icon "39gp.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real39gp-lc.kml b/app/src/main/assets/calculators/real39gp-lc.kml index 157ed15..3d0b87f 100644 --- a/app/src/main/assets/calculators/real39gp-lc.kml +++ b/app/src/main/assets/calculators/real39gp-lc.kml @@ -14,6 +14,7 @@ Global Model "E" Class 39 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39gp-lc.png" Icon "39gp.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real39gs-l.kml b/app/src/main/assets/calculators/real39gs-l.kml index 25f8c29..ea34659 100644 --- a/app/src/main/assets/calculators/real39gs-l.kml +++ b/app/src/main/assets/calculators/real39gs-l.kml @@ -14,6 +14,7 @@ Global Model "E" Class 39 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39gs-l.png" Icon "39gs.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real39gs-lc.kml b/app/src/main/assets/calculators/real39gs-lc.kml index 000b5a9..5a32d5d 100644 --- a/app/src/main/assets/calculators/real39gs-lc.kml +++ b/app/src/main/assets/calculators/real39gs-lc.kml @@ -14,6 +14,7 @@ Global Model "E" Class 39 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39gs-lc.png" Icon "39gs.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real40g-l.kml b/app/src/main/assets/calculators/real40g-l.kml index 3594bc7..4c91595 100644 --- a/app/src/main/assets/calculators/real40g-l.kml +++ b/app/src/main/assets/calculators/real40g-l.kml @@ -14,6 +14,7 @@ Global Model "E" Class 40 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real40g-l.png" Icon "39g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real40g-lc.kml b/app/src/main/assets/calculators/real40g-lc.kml index a5cc521..a07dfae 100644 --- a/app/src/main/assets/calculators/real40g-lc.kml +++ b/app/src/main/assets/calculators/real40g-lc.kml @@ -14,6 +14,7 @@ Global Model "E" Class 40 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real39g-lc.png" Icon "40g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real40gs-l.kml b/app/src/main/assets/calculators/real40gs-l.kml index ccac6ce..4491319 100644 --- a/app/src/main/assets/calculators/real40gs-l.kml +++ b/app/src/main/assets/calculators/real40gs-l.kml @@ -14,6 +14,7 @@ Global Model "E" Class 40 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real40gs-l.png" Icon "40gs.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real40gs-lc.kml b/app/src/main/assets/calculators/real40gs-lc.kml index 085945f..de7ac63 100644 --- a/app/src/main/assets/calculators/real40gs-lc.kml +++ b/app/src/main/assets/calculators/real40gs-lc.kml @@ -14,6 +14,7 @@ Global Model "E" Class 40 Rom "rom.39g" + Patch "PATCHES.39G" Bitmap "real40gs-lc.png" Icon "40gs.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real48gx-l.kml b/app/src/main/assets/calculators/real48gx-l.kml index 1f39bf7..ab155dd 100644 --- a/app/src/main/assets/calculators/real48gx-l.kml +++ b/app/src/main/assets/calculators/real48gx-l.kml @@ -14,6 +14,7 @@ Global Author "Eric Rechlin" Model "G" Rom "rom.48g" + Patch "PATCHES.48" Bitmap "real48gx-l.png" Icon "48gx.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real48gx-lc.kml b/app/src/main/assets/calculators/real48gx-lc.kml index c6243c4..1af6756 100644 --- a/app/src/main/assets/calculators/real48gx-lc.kml +++ b/app/src/main/assets/calculators/real48gx-lc.kml @@ -14,6 +14,7 @@ Global Author "Eric Rechlin" Model "G" Rom "rom.48g" + Patch "PATCHES.48" Bitmap "real48gx-lc.png" Icon "48gx.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real48sx-l.kml b/app/src/main/assets/calculators/real48sx-l.kml index bd7528f..6782fef 100644 --- a/app/src/main/assets/calculators/real48sx-l.kml +++ b/app/src/main/assets/calculators/real48sx-l.kml @@ -14,6 +14,7 @@ Global Author "Eric Rechlin" Model "S" Rom "rom.48s" + Patch "PATCHES.48" Bitmap "real48sx-l.png" Icon "48sx.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real48sx-lc.kml b/app/src/main/assets/calculators/real48sx-lc.kml index f87cbae..523c186 100644 --- a/app/src/main/assets/calculators/real48sx-lc.kml +++ b/app/src/main/assets/calculators/real48sx-lc.kml @@ -14,6 +14,7 @@ Global Author "Eric Rechlin" Model "S" Rom "rom.48s" + Patch "PATCHES.48" Bitmap "real48sx-lc.png" Icon "48sx.ico" Color 0 190 190 190 diff --git a/app/src/main/cpp/emu-jni.c b/app/src/main/cpp/emu-jni.c index 28fa9cd..4089002 100644 --- a/app/src/main/cpp/emu-jni.c +++ b/app/src/main/cpp/emu-jni.c @@ -521,16 +521,19 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_stop(JNIEnv *env, hWindowDC = NULL; // hWindowDC isn't valid any more hWnd = NULL; - DeleteCriticalSection(&csGDILock); - DeleteCriticalSection(&csLcdLock); - DeleteCriticalSection(&csKeyLock); - DeleteCriticalSection(&csIOLock); - DeleteCriticalSection(&csT1Lock); - DeleteCriticalSection(&csT2Lock); - DeleteCriticalSection(&csTxdLock); - DeleteCriticalSection(&csRecvLock); - DeleteCriticalSection(&csSlowLock); - DeleteCriticalSection(&csDbgLock); + // Prevent crash+++ + // FORTIFY: pthread_mutex_destroy called on a destroyed mutex (0x) + // DeleteCriticalSection(&csGDILock); + // DeleteCriticalSection(&csLcdLock); + // DeleteCriticalSection(&csKeyLock); + // DeleteCriticalSection(&csIOLock); + // DeleteCriticalSection(&csT1Lock); + // DeleteCriticalSection(&csT2Lock); + // DeleteCriticalSection(&csTxdLock); + // DeleteCriticalSection(&csRecvLock); + // DeleteCriticalSection(&csSlowLock); + // DeleteCriticalSection(&csDbgLock); + // Prevent crash--- SoundClose(); // close waveform-audio output device soundEnabled = FALSE; diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index abbf7e1..60de078 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -1879,6 +1879,8 @@ HPALETTE CreatePalette(CONST LOGPALETTE * plpal) { return handle; } HPALETTE SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd) { + if(!hdc) + return NULL; HPALETTE hOldPal = hdc->selectedPalette; hdc->selectedPalette = hPal; return hOldPal; diff --git a/app/src/main/java/org/emulator/calculator/EmuApplication.java b/app/src/main/java/org/emulator/calculator/EmuApplication.java index 650cb78..68d12a0 100644 --- a/app/src/main/java/org/emulator/calculator/EmuApplication.java +++ b/app/src/main/java/org/emulator/calculator/EmuApplication.java @@ -27,8 +27,7 @@ public class EmuApplication extends Application { @Override public void onCreate() { - super.onCreate(); - customPreferenceDataStore = new Settings(PreferenceManager.getDefaultSharedPreferences(this)); + super.onCreate(); } } diff --git a/app/src/main/java/org/emulator/calculator/InfoFragment.java b/app/src/main/java/org/emulator/calculator/InfoFragment.java index 2e97f07..6d43245 100644 --- a/app/src/main/java/org/emulator/calculator/InfoFragment.java +++ b/app/src/main/java/org/emulator/calculator/InfoFragment.java @@ -15,8 +15,6 @@ package org.emulator.calculator; import android.app.Dialog; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.method.ScrollingMovementMethod; import android.text.util.Linkify; @@ -64,9 +62,7 @@ public class InfoFragment extends AppCompatDialogFragment { Toolbar toolbar = view.findViewById(Utils.resId(this, "id", "my_toolbar")); toolbar.setTitle(title); Utils.colorizeDrawableWithColor(requireContext(), toolbar.getNavigationIcon(), android.R.attr.colorForeground); - toolbar.setNavigationOnClickListener(v -> { - dismiss(); - }); + toolbar.setNavigationOnClickListener(v -> dismiss()); // Programmatically load text from an asset and place it into the // text view. Note that the text we are loading is ASCII, so we @@ -92,7 +88,7 @@ public class InfoFragment extends AppCompatDialogFragment { TextView textViewInfo = view.findViewById(Utils.resId(this, "id", "textViewInfo")); textViewInfo.setMovementMethod(new ScrollingMovementMethod()); textViewInfo.setText(text); - Linkify.addLinks(textViewInfo, Linkify.ALL); + Linkify.addLinks(textViewInfo, Linkify.WEB_URLS); } catch (IOException ignored) { } return view; } diff --git a/app/src/main/java/org/emulator/calculator/PrinterSimulatorFragment.java b/app/src/main/java/org/emulator/calculator/PrinterSimulatorFragment.java index 96074df..58a888b 100644 --- a/app/src/main/java/org/emulator/calculator/PrinterSimulatorFragment.java +++ b/app/src/main/java/org/emulator/calculator/PrinterSimulatorFragment.java @@ -91,7 +91,7 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment { // Toolbar Toolbar toolbar = view.findViewById(Utils.resId(this, "id", "my_toolbar")); - toolbar.setTitle(title); + toolbar.setTitle(title); Utils.colorizeDrawableWithColor(requireContext(), toolbar.getNavigationIcon(), android.R.attr.colorForeground); toolbar.setNavigationOnClickListener( v -> dismiss() diff --git a/app/src/main/java/org/emulator/calculator/Settings.java b/app/src/main/java/org/emulator/calculator/Settings.java index b58a2af..e0c1e8f 100644 --- a/app/src/main/java/org/emulator/calculator/Settings.java +++ b/app/src/main/java/org/emulator/calculator/Settings.java @@ -51,7 +51,7 @@ public class Settings extends PreferenceDataStore { private final SharedPreferences androidSettings; // Defined the setting keys which are only defined at the application level. - private List applicationSettingKeys = Arrays.asList("settings_kml_default", "settings_kml_folder", "lastDocument", "MRU"); + private final List applicationSettingKeys = Arrays.asList("settings_kml_default", "settings_kml_folder", "lastDocument", "MRU"); // The settings only defined at the application level. private final HashMap applicationSettings = new HashMap<>(); @@ -68,7 +68,7 @@ public class Settings extends PreferenceDataStore { void onOneKeyChanged(String keyChanged); } private OnOneKeyChangedListener oneKeyChangedListener; - private static String magic = "MYHP"; + private static final String magic = "MYHP"; @@ -307,7 +307,7 @@ public class Settings extends PreferenceDataStore { HashMap settings = fromJSON(json); embeddedStateSettings.putAll(settings); } - } catch (IOException e) { + } catch (IOException | SecurityException e) { e.printStackTrace(); } } @@ -316,7 +316,7 @@ public class Settings extends PreferenceDataStore { commonSettings.clear(); Map keyValuePairs = androidSettings.getAll(); for (String key : keyValuePairs.keySet()) { - if (applicationSettingKeys.indexOf(key) != -1) + if (applicationSettingKeys.contains(key)) applicationSettings.put(key, keyValuePairs.get(key)); else commonSettings.put(key, keyValuePairs.get(key)); diff --git a/app/src/main/java/org/emulator/calculator/Utils.java b/app/src/main/java/org/emulator/calculator/Utils.java index 9201a68..ab6a8cc 100644 --- a/app/src/main/java/org/emulator/calculator/Utils.java +++ b/app/src/main/java/org/emulator/calculator/Utils.java @@ -24,6 +24,7 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; +import android.os.VibrationAttributes; import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.OpenableColumns; @@ -101,12 +102,26 @@ public class Utils { public static void makeUriPersistable(Context context, Intent data, Uri uri) { int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - context.getContentResolver().takePersistableUriPermission(uri, takeFlags); + try { + context.getContentResolver().takePersistableUriPermission(uri, takeFlags); + } catch (SecurityException e) { + Utils.showAlert(context, + context.getString(Utils.resId(context, "string", "message_persisting_security_error")) + + e.getMessage(), + true); + } } public static void makeUriPersistableReadOnly(Context context, Intent data, Uri uri) { int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - context.getContentResolver().takePersistableUriPermission(uri, takeFlags); + try { + context.getContentResolver().takePersistableUriPermission(uri, takeFlags); + } catch (SecurityException e) { + Utils.showAlert(context, + context.getString(Utils.resId(context, "string", "message_persisting_security_error")) + + e.getMessage(), + true); + } } public static String getFileName(Context context, String url) { @@ -205,7 +220,10 @@ public class Utils { public static void vibrate(Vibrator vibrator, int durationInMilliSecond) { if(vibrator != null && durationInMilliSecond > 0) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) + if (Build.VERSION.SDK_INT >= 33) + // https://developer.android.com/reference/android/os/Vibrator#vibrate(android.os.VibrationEffect,%20android.os.VibrationAttributes) + vibrator.vibrate(VibrationEffect.createOneShot(durationInMilliSecond, VibrationAttributes.USAGE_TOUCH)); + else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) // https://developer.android.com/reference/android/os/Vibrator#vibrate(android.os.VibrationEffect,%20android.media.AudioAttributes) vibrator.vibrate(VibrationEffect.createOneShot(durationInMilliSecond, VibrationEffect.DEFAULT_AMPLITUDE)); else diff --git a/app/src/main/java/org/emulator/forty/eight/MainActivity.java b/app/src/main/java/org/emulator/forty/eight/MainActivity.java index d5e9eba..96f69a2 100644 --- a/app/src/main/java/org/emulator/forty/eight/MainActivity.java +++ b/app/src/main/java/org/emulator/forty/eight/MainActivity.java @@ -1393,7 +1393,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On private String extractROMFilename(InputStream inputStream) { String romFilename = null; - if(inputStream != null) { + if(inputStream != null) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { // do reading, usually loop until end of file reading Pattern patternGlobalROM = Pattern.compile("\\s*Rom\\s+\"(.*)\""); @@ -1620,7 +1620,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On setPort1Settings(NativeLib.getPort1Plugged(), NativeLib.getPort1Writable()); // State file successfully opened. String currentKml = NativeLib.getCurrentKml(); - if(kmlScriptFolder == null || currentKml.startsWith("document:")) { + if(kmlScriptFolder == null || currentKml.startsWith("document:")) { // Needed for compatibility: // The KML folder is not in the JSON settings embedded in the state file, // so, we need to extract it and change the variable szCurrentKml. @@ -2014,7 +2014,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On return 1; } } - showAlert(getString(R.string.message_open_kml_not_found_alert), true); + showAlert(getString(R.string.message_open_kml_not_found_alert), true); return 0; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 87b00ce..404912b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -130,6 +130,7 @@ Out of paper error for the graphic printer (max line: %d, max pixel line: %d). The overlapping LCD mode has been changed to "Manual". The overlapping LCD mode has been changed to "Auto". + Permission issue: USB Devices USB Devices diff --git a/build.gradle b/build.gradle index d55aa7e..a7c0f53 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.0.2' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties index 06966a0..837d298 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,9 +6,13 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.defaults.buildfeatures.buildconfig=true android.enableJetifier=true +android.nonFinalResIds=false +android.nonTransitiveRClass=false android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m +org.gradle.unsafe.configuration-cache=true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 223c5eb..3a4aa84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Oct 30 22:52:03 CET 2020 +#Sat Jan 28 21:16:38 CET 2023 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +zipStoreBase=GRADLE_USER_HOME