Compare commits
No commits in common. "a7c98d28de93ddd2f2fbbbfa263840b91e6bec98" and "c4eed5b7bfeff6beac2ce1f2294ca03f75fe2373" have entirely different histories.
a7c98d28de
...
c4eed5b7bf
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 896 B |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 8.8 KiB |
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
package="io.dcloud.uni_modules.fdm_keepalive">
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
||||||
</manifest>
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"minSdkVersion": "23"
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package uts.sdk.modules.fdmKeepalive;
|
|
||||||
import io.dcloud.uniapp.*;
|
|
||||||
import io.dcloud.uniapp.extapi.*;
|
|
||||||
import io.dcloud.uts.*;
|
|
||||||
import io.dcloud.uts.Map;
|
|
||||||
import io.dcloud.uts.Set;
|
|
||||||
import kotlinx.coroutines.CoroutineScope;
|
|
||||||
import kotlinx.coroutines.Deferred;
|
|
||||||
import kotlinx.coroutines.Dispatchers;
|
|
||||||
import kotlinx.coroutines.async;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import io.dcloud.uts.UTSAndroid;
|
|
||||||
import android.net.Uri;
|
|
||||||
open class WakeLockHelper {
|
|
||||||
open var context: Context;
|
|
||||||
private var wakeLock: PowerManager.WakeLock? = null;
|
|
||||||
constructor(context: Context){
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
open fun acquireWakeLock() {
|
|
||||||
var powerManager = this.context.getSystemService(Context.POWER_SERVICE) as PowerManager;
|
|
||||||
this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyApp::TestWakeLock");
|
|
||||||
this.wakeLock?.acquire();
|
|
||||||
}
|
|
||||||
open fun releaseWakeLock() {
|
|
||||||
this.wakeLock?.release();
|
|
||||||
this.wakeLock = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun addKeepalive() {
|
|
||||||
val context = UTSAndroid.getAppContext();
|
|
||||||
val pageName = context!!.getPackageName();
|
|
||||||
val manager = context!!.getSystemService(Context.POWER_SERVICE) as PowerManager;
|
|
||||||
if (!manager.isIgnoringBatteryOptimizations(pageName)) {
|
|
||||||
var jumpUrl: Uri = Uri.parse("package:" + pageName);
|
|
||||||
var intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, jumpUrl);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
UTSAndroid.getAppContext()!!.startActivity(intent);
|
|
||||||
}
|
|
||||||
var wakeCtrl = WakeLockHelper(context);
|
|
||||||
wakeCtrl.acquireWakeLock();
|
|
||||||
console.log(manager.isInteractive(), " at uni_modules/fdm-keepalive/utssdk/app-android/index.uts:39");
|
|
||||||
}
|
|
||||||
fun addKeepaliveByJs() {
|
|
||||||
return addKeepalive();
|
|
||||||
}
|
|