version:4.4
fix: update:增加截图时亮屏
This commit is contained in:
@@ -13,6 +13,7 @@ import android.media.MediaPlayer;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -507,7 +508,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
break;
|
||||
case MSG_ONEPACKAGES:
|
||||
ToastUtil.betaShow("收到管控:");
|
||||
settingOneNet(extras);
|
||||
settingOneNet(extras);
|
||||
break;
|
||||
case GET_APP_USEDTIME:
|
||||
ToastUtil.betaShow("收到管控:获取应用使用时间");
|
||||
@@ -945,6 +946,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
public void screenshot(String s) {
|
||||
JSONObject jSONObject = JSON.parseObject(s);
|
||||
long createTime = jSONObject.getLong("createTime");
|
||||
PowerManager.WakeLock mWakeLock = JGYUtils.acquireWakeLock(mContext, 2 * 60 * 1000);
|
||||
JGYUtils.release(mWakeLock);
|
||||
if (createTime != 0) {
|
||||
Log.e("createTime", String.valueOf(createTime));
|
||||
doscreenshot(createTime);
|
||||
|
||||
@@ -28,6 +28,8 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
@@ -230,6 +232,56 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略电池优化
|
||||
*/
|
||||
private void ignoreBatteryOptimization(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());
|
||||
// 判断当前APP是否有加入电池优化的白名单,如果没有,弹出加入电池优化的白名单的设置对话框。
|
||||
if (!hasIgnored) {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getScreenStatus(Context context) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
//true为打开,false为关闭
|
||||
return powerManager.isScreenOn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点亮屏幕
|
||||
*
|
||||
* @param timeout The timeout after which to release the wake lock, in milliseconds.
|
||||
*/
|
||||
@Nullable
|
||||
public static PowerManager.WakeLock acquireWakeLock(@NonNull Context context, long timeout) {
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
if (pm == null)
|
||||
return null;
|
||||
PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |
|
||||
PowerManager.FULL_WAKE_LOCK |
|
||||
PowerManager.ON_AFTER_RELEASE,
|
||||
context.getClass().getName());
|
||||
wakeLock.acquire(timeout);
|
||||
return wakeLock;
|
||||
}
|
||||
|
||||
public static void release(@Nullable PowerManager.WakeLock wakeLock) {
|
||||
if (wakeLock != null && wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 应用自启升级和网络权限管理
|
||||
*
|
||||
@@ -1491,24 +1543,6 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略电池优化
|
||||
*/
|
||||
private void ignoreBatteryOptimization(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());
|
||||
// 判断当前APP是否有加入电池优化的白名单,如果没有,弹出加入电池优化的白名单的设置对话框。
|
||||
if (!hasIgnored) {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void killPackage(String pkg) {
|
||||
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
|
||||
Reference in New Issue
Block a user