- 重复请求拦截器改为请求前去重并复用真实响应,避免服务端收到重复请求 - 新增 PowerOffAlarmUtils 通过 AlarmManager 精确调度定时关机 - 设备重启、服务启动、系统时间变更后重新安排关机闹钟 - 重写定时关机时间计算逻辑,修复循环关机跨天与时间格式问题 - 黑名单/白名单缓存过期时间改用默认值 - 运行应用列表排除 DX11、MX11 系统应用 - 版本号升级至 1.6.0915
35 lines
1.1 KiB
Java
35 lines
1.1 KiB
Java
package com.aoleyun.sn.receiver;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.util.Log;
|
|
|
|
import com.aoleyun.sn.utils.JgyUtils;
|
|
import com.aoleyun.sn.utils.PowerOffAlarmUtils;
|
|
|
|
/**
|
|
* 定时关机广播接收器
|
|
* <p>
|
|
* 由 {@link PowerOffAlarmUtils} 通过 AlarmManager 的精确闹钟触发。
|
|
* 使用 manifest 静态注册,应用进程被杀掉后依然能被系统拉起并执行关机。
|
|
*
|
|
* @author aoleyun
|
|
*/
|
|
public class PowerOffReceiver extends BroadcastReceiver {
|
|
private static final String TAG = "PowerOffReceiver";
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
String action = null == intent ? null : intent.getAction();
|
|
Log.e(TAG, "onReceive: " + action);
|
|
if (!PowerOffAlarmUtils.ACTION_POWER_OFF_ALARM.equals(action)) {
|
|
return;
|
|
}
|
|
//先安排下一次(循环定时关机),再关机,避免关机过程中闹钟安排失败
|
|
PowerOffAlarmUtils.schedule(context);
|
|
Log.e(TAG, "onReceive: 设备关机");
|
|
JgyUtils.getInstance().shutdown();
|
|
}
|
|
}
|