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

Backport 5.8.1 (Android-only) #14548

Merged
merged 21 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
85db253
Fix unittest failure for release versions (#14067)
grorp Dec 8, 2023
8bdd7f5
Fix touch input on Linux
grorp Dec 17, 2023
4bf621e
Fix TouchScreenGUI ignoring server-sent pitch changes
grorp Dec 19, 2023
b5decdf
Touchscreen: Make server-sent overrides of button textures work (#14145)
grorp Dec 23, 2023
63f08c4
Fix GameUI text staying visible during shutdown. (#14197)
FoxLoveFire Jan 4, 2024
c70738d
Android: Use the correct value for notification (#14209)
srifqi Jan 13, 2024
8099823
Save the settings in more cases to avoid losing setting changes (espe…
grorp Jan 23, 2024
1a60025
Bypass media transfer in single player
sfan5 Jan 20, 2024
1d76db0
Add unit tests for fs::CopyFileContents
sfan5 Jan 20, 2024
78d212c
Optimize fs::CopyFileContents on Linux and Windows
sfan5 Jan 20, 2024
82387f2
Drop valgrind from CI and instead enable ASan
sfan5 Jan 20, 2024
38a2cf7
Enable IPO/LTO by default except for debug builds (#14198)
okias Feb 8, 2024
3965ccb
Allow shaders with disabled post processing pipeline (#14338)
lhofhansl Feb 15, 2024
685988a
Skip Android deps download if they already exist
sfan5 Feb 18, 2024
241642f
Allow sync HTTP fetches to be interrupted to fix hanging (#14412)
grorp Mar 12, 2024
c6ed850
Fix all cached media being loaded at once on the main thread
grorp Apr 2, 2024
e2e934d
Fix local server startup and shutdown blocking the main thread
grorp Apr 2, 2024
4161c49
Fix some Game members not being freed after some startup errors (#14561)
grorp Apr 21, 2024
bacdc12
Android CI: Additionally make an AAB for uploading to the Play Store …
grorp Apr 24, 2024
1fcdea7
Fix Android build for 5.8.1
grorp Apr 15, 2024
012c5f2
Bump version to 5.8.1
grorp Apr 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gettext openjdk-11-jdk-headless
- name: Build with Gradle
- name: Build AAB with Gradle
# We build an AAB as well for uploading to the the Play Store.
run: cd android; ./gradlew bundlerelease
- name: Build APKs with Gradle
# "assemblerelease" is very fast after "bundlerelease".
run: cd android; ./gradlew assemblerelease
- name: Save AAB artifact
uses: actions/upload-artifact@v4
with:
name: Minetest-release.aab
path: android/app/build/outputs/bundle/release/app-release.aab
- name: Save armeabi artifact
uses: actions/upload-artifact@v3
with:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,20 @@ jobs:
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-7 valgrind
install_linux_deps clang-7 llvm

- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-7
CXX: clang++-7
CMAKE_FLAGS: '-DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address"'

- name: Unittest
run: |
./bin/minetest --run-unittests

- name: Valgrind
run: |
valgrind --leak-check=full --leak-check-heuristics=all --undef-value-errors=no --error-exitcode=9 ./bin/minetest --run-unittests

# Current clang version
clang_14:
runs-on: ubuntu-22.04
Expand Down
32 changes: 23 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
cmake_minimum_required(VERSION 3.5)

# Set policies up to 3.9 since we want to enable the IPO option
if(${CMAKE_VERSION} VERSION_LESS 3.9)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.9)
endif()
cmake_minimum_required(VERSION 3.12)

# This can be read from ${PROJECT_NAME} after project() is called
project(minetest)
Expand All @@ -19,7 +12,7 @@ set(CLANG_MINIMUM_VERSION "7.0.1")
# You should not need to edit these manually, use util/bump_version.sh
set(VERSION_MAJOR 5)
set(VERSION_MINOR 8)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")

# Change to false for releases
Expand All @@ -44,6 +37,13 @@ set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
set(BUILD_BENCHMARKS FALSE CACHE BOOL "Build benchmarks")
set(BUILD_DOCUMENTATION TRUE CACHE BOOL "Build documentation")

set(DEFAULT_ENABLE_LTO TRUE)
# by default don't enable on Debug builds to get faster builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEFAULT_ENABLE_LTO FALSE)
endif()
set(ENABLE_LTO ${DEFAULT_ENABLE_LTO} CACHE BOOL "Use Link Time Optimization")

set(DEFAULT_RUN_IN_PLACE FALSE)
if(WIN32)
set(DEFAULT_RUN_IN_PLACE TRUE)
Expand All @@ -66,6 +66,20 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
endif()

# FIXME: Windows build fails in multiple places to link, needs to be investigated.
if (ENABLE_LTO AND NOT WIN32)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT lto_output)
if(lto_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "LTO/IPO is enabled")
else()
message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
endif()
else()
message(STATUS "LTO/IPO is not enabled")
endif()

set(ENABLE_UPDATE_CHECKER (NOT ${DEVELOPMENT_BUILD}) CACHE BOOL
"Whether to enable update checks by default")

Expand Down
11 changes: 11 additions & 0 deletions android/app/src/main/java/net/minetest/minetest/GameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ protected void onResume() {
makeFullScreen();
}

private native void saveSettings();

@Override
protected void onStop() {
super.onStop();
// Avoid losing setting changes in case the app is onDestroy()ed later.
// Saving stuff in onStop() is recommended in the Android activity
// lifecycle documentation.
saveSettings();
}

@Override
public void onBackPressed() {
// Ignore the back press so Minetest can handle it
Expand Down
34 changes: 34 additions & 0 deletions android/app/src/main/java/net/minetest/minetest/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@

package net.minetest.minetest;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;

import static net.minetest.minetest.UnzipService.*;

public class MainActivity extends AppCompatActivity {
public static final String NOTIFICATION_CHANNEL_ID = "Minetest channel";

private final static int versionCode = BuildConfig.VERSION_CODE;
private static final String SETTINGS = "MinetestSettings";
private static final String TAG_VERSION_CODE = "versionCode";
Expand Down Expand Up @@ -81,12 +87,18 @@ public void onReceive(Context context, Intent intent) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

IntentFilter filter = new IntentFilter(ACTION_UPDATE);
registerReceiver(myReceiver, filter);

mProgressBar = findViewById(R.id.progressBar);
mTextView = findViewById(R.id.textView);
sharedPreferences = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);

checkAppVersion();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
createNotificationChannel();
}

private void checkAppVersion() {
Expand Down Expand Up @@ -114,6 +126,28 @@ private void startNative() {
startActivity(intent);
}

@RequiresApi(Build.VERSION_CODES.O)
private void createNotificationChannel() {
NotificationManager notifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notifyManager == null)
return;

NotificationChannel notifyChannel = new NotificationChannel(
NOTIFICATION_CHANNEL_ID,
getString(R.string.notification_channel_name),
NotificationManager.IMPORTANCE_LOW
);
notifyChannel.setDescription(getString(R.string.notification_channel_description));
// Configure the notification channel without sound set
notifyChannel.setSound(null, null);
notifyChannel.enableLights(false);
notifyChannel.enableVibration(false);

// It is fine to always create the notification channel because creating a channel
// with the same ID is the same as overriding it (only its name and description).
notifyManager.createNotificationChannel(notifyChannel);
}

@Override
public void onBackPressed() {
// Prevent abrupt interruption when copy game files from assets
Expand Down
28 changes: 7 additions & 21 deletions android/app/src/main/java/net/minetest/minetest/UnzipService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
Expand Down Expand Up @@ -58,9 +57,11 @@ public class UnzipService extends IntentService {
private String failureMessage;

private static boolean isRunning = false;

public static synchronized boolean getIsRunning() {
return isRunning;
}

private static synchronized void setIsRunning(boolean v) {
isRunning = v;
}
Expand Down Expand Up @@ -99,28 +100,13 @@ protected void onHandleIntent(Intent intent) {
}
}

@NonNull
private Notification.Builder createNotification() {
String name = "net.minetest.minetest";
String channelId = "Minetest channel";
String description = "notifications from Minetest";
Notification.Builder builder;
if (mNotifyManager == null)
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = null;
if (mNotifyManager != null)
mChannel = mNotifyManager.getNotificationChannel(channelId);
if (mChannel == null) {
mChannel = new NotificationChannel(channelId, name, importance);
mChannel.setDescription(description);
// Configure the notification channel, NO SOUND
mChannel.setSound(null, null);
mChannel.enableLights(false);
mChannel.enableVibration(false);
mNotifyManager.createNotificationChannel(mChannel);
}
builder = new Notification.Builder(this, channelId);
builder = new Notification.Builder(this, MainActivity.NOTIFICATION_CHANNEL_ID);
} else {
builder = new Notification.Builder(this);
}
Expand All @@ -135,9 +121,9 @@ private Notification.Builder createNotification() {
PendingIntent intent = PendingIntent.getActivity(this, 0,
notificationIntent, pendingIntentFlag);

builder.setContentTitle(getString(R.string.notification_title))
builder.setContentTitle(getString(R.string.unzip_notification_title))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText(getString(R.string.notification_description))
.setContentText(getString(R.string.unzip_notification_description))
.setContentIntent(intent)
.setOngoing(true)
.setProgress(0, 0, true);
Expand Down Expand Up @@ -198,7 +184,7 @@ boolean recursivelyDeleteDirectory(@NonNull File loc) {
}
}

private void publishProgress(@Nullable Notification.Builder notificationBuilder, @StringRes int message, int progress) {
private void publishProgress(@Nullable Notification.Builder notificationBuilder, @StringRes int message, int progress) {
Intent intentUpdate = new Intent(ACTION_UPDATE);
intentUpdate.putExtra(ACTION_PROGRESS, progress);
intentUpdate.putExtra(ACTION_PROGRESS_MESSAGE, message);
Expand Down
6 changes: 4 additions & 2 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<resources>
<string name="label">Minetest</string>
<string name="loading">Loading&#8230;</string>
<string name="notification_title">Loading Minetest</string>
<string name="notification_description">Less than 1 minute&#8230;</string>
<string name="notification_channel_name">General notification</string>
<string name="notification_channel_description">Notifications from Minetest</string>
<string name="unzip_notification_title">Loading Minetest</string>
<string name="unzip_notification_description">Less than 1 minute&#8230;</string>
<string name="ime_dialog_done">Done</string>
</resources>
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

project.ext.set("versionMajor", 5) // Version Major
project.ext.set("versionMinor", 8) // Version Minor
project.ext.set("versionPatch", 0) // Version Patch
project.ext.set("versionPatch", 1) // Version Patch
// ^ keep in sync with cmake
project.ext.set("versionCode", 46) // Android Version Code
project.ext.set("versionCode", 48) // Android Version Code
// NOTE: +2 after each release!
// +1 for ARM and +1 for ARM64 APK's, because
// each APK must have a larger `versionCode` than the previous
Expand Down
28 changes: 17 additions & 11 deletions android/native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,25 @@ android {
}

// get precompiled deps
task downloadDeps(type: Download) {
def depsDir = new File(buildDir.parent, 'deps')
def depsZip = new File(buildDir, 'deps.zip')
def depsDir = new File(buildDir.parent, 'deps')
if (new File(depsDir, 'armeabi-v7a').exists()) {
task getDeps {
doLast { logger.lifecycle('Using existing deps from {}', depsDir) }
}
} else {
task downloadDeps(type: Download) {
def depsZip = new File(buildDir, 'deps.zip')

src 'https://github.com/minetest/minetest_android_deps/releases/download/latest/deps.zip'
dest depsZip
overwrite false
src 'https://github.com/minetest/minetest_android_deps/releases/download/5.8.0/deps.zip'
dest depsZip
overwrite false

task getDeps(dependsOn: downloadDeps, type: Copy) {
depsDir.mkdir()
from zipTree(depsZip)
into depsDir
doFirst { logger.lifecycle('Extracting to {}', depsDir) }
task getDeps(dependsOn: downloadDeps, type: Copy) {
depsDir.mkdir()
from zipTree(depsZip)
into depsDir
doFirst { logger.lifecycle('Extracting to {}', depsDir) }
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions builtin/mainmenu/settings/dlg_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,16 @@ local function get_formspec(dialogdata)
end


-- On Android, closing the app via the "Recents screen" won't result in a clean
-- exit, discarding any setting changes made by the user.
-- To avoid that, we write the settings file in more cases on Android.
function write_settings_early()
if PLATFORM == "Android" then
core.settings:write()
end
end


local function buttonhandler(this, fields)
local dialogdata = this.data
dialogdata.leftscroll = core.explode_scrollbar_event(fields.leftscroll).value or dialogdata.leftscroll
Expand All @@ -622,12 +632,15 @@ local function buttonhandler(this, fields)
if fields.show_technical_names ~= nil then
local value = core.is_yes(fields.show_technical_names)
core.settings:set_bool("show_technical_names", value)
write_settings_early()

return true
end

if fields.show_advanced ~= nil then
local value = core.is_yes(fields.show_advanced)
core.settings:set_bool("show_advanced", value)
write_settings_early()

local suggested_page_id = update_filtered_pages(dialogdata.query)

Expand Down Expand Up @@ -672,12 +685,15 @@ local function buttonhandler(this, fields)

for i, comp in ipairs(dialogdata.components) do
if comp.on_submit and comp:on_submit(fields, this) then
write_settings_early()

-- Clear components so they regenerate
dialogdata.components = nil
return true
end
if comp.setting and fields["reset_" .. i] then
core.settings:remove(comp.setting.name)
write_settings_early()

-- Clear components so they regenerate
dialogdata.components = nil
Expand Down