v2.0.1: APK verification, stay awake fix, configurable auto-fix retries

This commit is contained in:
admin
2026-05-19 18:04:33 +04:00
Unverified
parent e7015b129a
commit 5572f2cb60
7 changed files with 88 additions and 33 deletions

View File

@@ -7,8 +7,8 @@ android {
applicationId "ai.z.chat"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 10
versionName "2.0.0"
versionCode 11
versionName "2.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'

View File

@@ -12,7 +12,8 @@ import com.getcapacitor.annotation.CapacitorPlugin;
@CapacitorPlugin(name = "Wake")
public class WakePlugin extends Plugin {
private PowerManager.WakeLock wakeLock;
private PowerManager.WakeLock screenWakeLock;
private PowerManager.WakeLock cpuWakeLock;
private boolean isHeld = false;
@Override
@@ -22,7 +23,7 @@ public class WakePlugin extends Plugin {
@PluginMethod
public void acquire(PluginCall call) {
if (isHeld && wakeLock != null) {
if (isHeld) {
call.resolve(new JSObject().put("held", true));
return;
}
@@ -33,10 +34,20 @@ public class WakePlugin extends Plugin {
});
PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "zai-chat:wakelock");
wakeLock.acquire(12 * 60 * 60 * 1000L);
isHeld = true;
screenWakeLock = pm.newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,
"zai-chat:screen"
);
screenWakeLock.acquire(24 * 60 * 60 * 1000L);
cpuWakeLock = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK,
"zai-chat:cpu"
);
cpuWakeLock.acquire(24 * 60 * 60 * 1000L);
isHeld = true;
call.resolve(new JSObject().put("held", true));
} catch (Exception e) {
call.reject("Wake lock failed: " + e.getMessage());
@@ -50,12 +61,17 @@ public class WakePlugin extends Plugin {
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
});
if (wakeLock != null && wakeLock.isHeld()) {
wakeLock.release();
if (screenWakeLock != null && screenWakeLock.isHeld()) {
screenWakeLock.release();
}
wakeLock = null;
isHeld = false;
screenWakeLock = null;
if (cpuWakeLock != null && cpuWakeLock.isHeld()) {
cpuWakeLock.release();
}
cpuWakeLock = null;
isHeld = false;
call.resolve(new JSObject().put("held", false));
} catch (Exception e) {
call.reject("Wake release failed: " + e.getMessage());