Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.3'
classpath 'com.android.tools.build:gradle:8.10.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -26,12 +26,12 @@ allprojects {

ext {
android = [
compileSdkVersion: 30,
compileSdkVersion: 35, // Updated to support Android 15 for 16KB page sizes
buildToolsVersion: '34.0.0',
minSdkVersion : 21,
targetSdkVersion : 25, // higher target version needs more storage permission request.
versionCode : 2,
versionName : "3.1.0",
versionName : "3.1.1",
applicationId : "org.wysaid.cgeDemo",
appcompatX : "1.2.0",
ndkVersion : "26.3.11579264",
Expand Down
7 changes: 6 additions & 1 deletion cgeDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def usingCMakeCompileDebug() {
return gradle.ext != null && gradle.ext.has("usingCMakeCompileDebug") && gradle.ext.usingCMakeCompileDebug;
}

def enable16kPageSizes() {
return gradle.ext != null && gradle.ext.has("enable16kPageSizes") && gradle.ext.enable16kPageSizes;
}

android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
Expand All @@ -22,7 +26,8 @@ android {
defaultConfig {
applicationId rootProject.ext.android.applicationId
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
// Use Android 15+ (API 35) when 16KB page sizes are enabled, otherwise use default
targetSdkVersion enable16kPageSizes() ? 35 : rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
signingConfig signingConfigs.debug
Expand Down
13 changes: 7 additions & 6 deletions cgeDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal"
tools:ignore="ReservedSystemPermission" />
<!-- Request flashlight usage instead of declaring system permission which causes install error
Declaring android.permission.FLASHLIGHT as a <permission> attempts to define a system permission
(and reference android.permission-group.HARDWARE_CONTROLS) which doesn't exist for third-party apps
on newer Android versions. Use uses-permission to request the permission from the platform. -->
<uses-permission android:name="android.permission.FLASHLIGHT" />

<application
android:allowBackup="true"
Expand All @@ -26,7 +26,8 @@
<activity android:name=".MultiInputActivity"></activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name">
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ android.enableJetifier=true
android.injected.testOnly=false
#android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jan 05 14:44:46 CST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
1 change: 1 addition & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/


import android.annotation.SuppressLint;
import android.content.Context;
import android.media.AudioFormat;
import android.media.AudioRecord;
Expand Down Expand Up @@ -162,6 +163,7 @@ class AudioRecordRunnable implements Runnable {
ShortBuffer audioBuffer;
StartRecordingCallback recordingCallback;

@SuppressLint("MissingPermission")
private AudioRecordRunnable(StartRecordingCallback callback) {
recordingCallback = callback;
try {
Expand Down
1 change: 1 addition & 0 deletions library/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ target_link_libraries(CGE PUBLIC
if(DEFINED ENABLE_16K_PAGE_SIZES AND ENABLE_16K_PAGE_SIZES)
# 16KB elf: <https://developer.android.com/guide/practices/page-sizes#cmake>
target_link_options(CGE PUBLIC -Wl,-z,max-page-size=16384,-z,common-page-size=16384)
target_compile_definitions(CGE PRIVATE ENABLE_16K_PAGE_SIZES=1)
message("ENABLE_16K_PAGE_SIZES=${ENABLE_16K_PAGE_SIZES}")
endif()

Expand Down
53 changes: 53 additions & 0 deletions library/src/main/jni/interface/cgeNativeLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,69 @@
#include <android/bitmap.h>
#include <ctime>
#include <jni.h>
#include <unistd.h>
#include <sys/mman.h>
#include <android/api-level.h>

using namespace CGE;

// Function to check 16KB page size status
static void cgeCheck16kPageSize() {
const char* status = "Unknown";
const char* details = "";

// 1. Check compile-time support
#ifdef ENABLE_16K_PAGE_SIZES
bool compileTimeSupport = true;
#else
bool compileTimeSupport = false;
#endif

// 2. Check runtime Android version (16KB pages are supported from Android 15, API 35)
int apiLevel = android_get_device_api_level();
bool systemSupport = (apiLevel >= 35);

// 3. Check actual page size being used
long pageSize = sysconf(_SC_PAGESIZE);
bool activelyUsing16k = (pageSize == 16384);

// Determine status and details
if (!compileTimeSupport) {
status = "DISABLED";
details = "16KB page size support not enabled at compile time";
} else if (!systemSupport) {
status = "COMPILE_READY";
details = "16KB support compiled in, but Android version < 35 (Android 15)";
} else if (activelyUsing16k) {
status = "ACTIVE";
details = "16KB page size is fully active and working";
} else {
status = "SUPPORTED_BUT_INACTIVE";
details = "16KB support available but current page size is not 16KB";
}

// Log comprehensive status - use CGE_LOG_KEEP for important status info
CGE_LOG_KEEP("=== CGE 16KB Page Size Status ===");
CGE_LOG_KEEP("Status: %s", status);
CGE_LOG_KEEP("Details: %s", details);
CGE_LOG_INFO("Compile-time support: %s", compileTimeSupport ? "YES" : "NO");
CGE_LOG_INFO("Android API Level: %d (16KB support needs API 35+)", apiLevel);
CGE_LOG_INFO("Current page size: %ld bytes", pageSize);
CGE_LOG_INFO("16KB pages active: %s", activelyUsing16k ? "YES" : "NO");
CGE_LOG_KEEP("================================");
}

extern "C"
{
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
cgeGl3StubInit();
cgeGl31StubInit();
CGE_LOG_INFO("JNI_OnLoad called. cgeGl3StubInit called.\n");

// Check and report 16KB page size status
cgeCheck16kPageSize();

return JNI_VERSION_1_6;
}

Expand Down