version:2.0.2.1
update:2020.08.14 fix:修复管控日历隐藏失效,优化待机亮屏卡顿 add:
This commit is contained in:
@@ -104,7 +104,7 @@ public class MyApplication extends MultiDexApplication {
|
||||
private Calendar mCurrentCalendar = null;
|
||||
private SimpleDateFormat mDateFormat = null;
|
||||
private static List<Activity> activityList = new LinkedList();
|
||||
|
||||
private Handler mHandler;
|
||||
|
||||
public static Context getAppContext() {
|
||||
return context;
|
||||
@@ -161,6 +161,7 @@ public class MyApplication extends MultiDexApplication {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
catchException();
|
||||
}
|
||||
mHandler = new Handler();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// 8.0之后需要在
|
||||
registmNewAppReceiver();
|
||||
@@ -193,6 +194,8 @@ public class MyApplication extends MultiDexApplication {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private NewAppReceiver mNewAppReceiver;
|
||||
|
||||
private void registmNewAppReceiver() {
|
||||
@@ -215,6 +218,8 @@ public class MyApplication extends MultiDexApplication {
|
||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
filter.addAction(Intent.ACTION_USER_UNLOCKED);
|
||||
filter.addAction("android.intent.action.FACTORY_RESET");
|
||||
filter.addAction("android.intent.action.MASTER_CLEAR");
|
||||
registerReceiver(receiver, filter);
|
||||
}
|
||||
|
||||
@@ -223,10 +228,13 @@ public class MyApplication extends MultiDexApplication {
|
||||
Long time1 = 0L;
|
||||
Long time2 = 0L;
|
||||
|
||||
Long time3 = 0L;
|
||||
Long time4 = 0L;
|
||||
|
||||
public class receiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("fht", "receiver action:" + action);
|
||||
if (action.equals(Intent.ACTION_SCREEN_ON)) {
|
||||
@@ -237,32 +245,54 @@ public class MyApplication extends MultiDexApplication {
|
||||
/*在8.0以上 除了开机广播其他广播基本上没有用
|
||||
*当静默安装升级时,app不会被唤醒,只有通过显示广播唤醒
|
||||
* */
|
||||
|
||||
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
|
||||
// 携带数据
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
|
||||
// 携带数据
|
||||
// intent1.putExtra("test", "我是来测 A 应用的Android 8.0 系统静态广播的测试数据");
|
||||
// 启动发送广播
|
||||
sendBroadcast(intent1);
|
||||
// 启动发送广播
|
||||
sendBroadcast(intent1);
|
||||
|
||||
time2 = System.currentTimeMillis();
|
||||
if ((time2 - time1) > 60 * 1000) {
|
||||
//可能会多次触发,1分钟之内不执行
|
||||
//application中启动服务,startcommand执行会两次
|
||||
startService(new Intent(context, InitJpushServer.class));
|
||||
startService(new Intent(context, StepService.class));
|
||||
startService(new Intent(context, GuardService.class));
|
||||
time1 = time2;
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
time2 = System.currentTimeMillis();
|
||||
if ((time2 - time1) > 60 * 1000) {
|
||||
//可能会多次触发,1分钟之内不执行
|
||||
//application中启动服务,startcommand执行会两次
|
||||
startService(new Intent(context, InitJpushServer.class));
|
||||
startService(new Intent(context, StepService.class));
|
||||
startService(new Intent(context, GuardService.class));
|
||||
time1 = time2;
|
||||
}
|
||||
}
|
||||
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
long time = System.currentTimeMillis();
|
||||
getLockState("1", String.valueOf(time));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
|
||||
sendBroadcast(intent1);
|
||||
}
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long time = System.currentTimeMillis();
|
||||
getLockState("1", String.valueOf(time));
|
||||
if (time3 - System.currentTimeMillis() >= 10000) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
|
||||
sendBroadcast(intent1);
|
||||
}
|
||||
}
|
||||
time3 = System.currentTimeMillis();
|
||||
}
|
||||
}, 10000);
|
||||
} else if (action.equals("android.intent.action.FACTORY_RESET")
|
||||
|| action.equals("android.intent.action.MASTER_CLEAR")
|
||||
//MASTER_CLEAR 7.0可以监听
|
||||
|| action.equals("android.intent.action.MASTER_CLEAR_NOTIFICATION")
|
||||
|| action.equals("android.intent.action.FORCE_FACTORY_RESET")
|
||||
) {
|
||||
Log.e("receiver", "MASTER_CLEAR");
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user