package com.jwipc.nodka_reboot_under;
|
|
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.Method;
|
import java.text.SimpleDateFormat;
|
import java.util.Calendar;
|
import java.util.Date;
|
|
import com.jwipc.nodka_reboot_under.utils.Utils;
|
|
import android.content.BroadcastReceiver;
|
import android.content.ComponentName;
|
import android.content.Context;
|
import android.content.Intent;
|
import android.hardware.spirit.AlarmPowerManager;
|
import android.os.PowerManager;
|
import android.util.Log;
|
|
|
|
public class BroadcastReceiver_Boot extends BroadcastReceiver{
|
|
|
|
Utils mUtils;
|
|
|
|
|
|
@Override
|
public void onReceive(final Context context, Intent intent) {
|
// TODO Auto-generated method stub
|
|
mUtils = new Utils(context);
|
|
String action = intent.getAction();
|
|
if(action.equals("android.intent.action.BOOT_COMPLETED"))
|
{
|
mUtils.thread_AlarmPower_Repeat_Poweroff();
|
|
if(!mUtils.get_time_reboot_isdone() || mUtils.get_time_reboot_isRepeat())
|
mUtils.set_time_reboot_by_xml();
|
|
if(!mUtils.isServiceRunning(context, The_Service.class.getName()))
|
{
|
context.startService(new Intent(context, The_Service.class));
|
}
|
|
|
String is_repeat = mUtils.get_String_From_SharedPreferences(mUtils.set_time_reboot_repeat);
|
if(!is_repeat.equals("true"))
|
{
|
if (mUtils.isSpiritVersion()) {
|
AlarmPowerManager mAlarmPowerManager = new AlarmPowerManager();
|
mAlarmPowerManager.removeAllalarmPower();
|
} else {
|
MyApplication.getApplication().getNodkaAPI().alarm_removeAllalarmPower();
|
}
|
|
mUtils.remove_String_From_SharedPreferences(mUtils.repeat_alarm_poweron_time);
|
mUtils.remove_String_From_SharedPreferences(mUtils.repeat_alarm_poweroff_time);
|
|
mUtils.remove_int_From_SharedPreferences(mUtils.set_time_reboot_h);
|
mUtils.remove_int_From_SharedPreferences(mUtils.set_time_reboot_m);
|
mUtils.remove_int_From_SharedPreferences(mUtils.set_time_reboot_s);
|
}
|
|
|
|
/*new Thread(new Runnable() {
|
|
@Override
|
public void run() {
|
// TODO Auto-generated method stub
|
|
try {
|
Thread.sleep(20*1000);
|
start_service(context);
|
Thread.sleep(60*1000);
|
start_service(context);
|
} catch (InterruptedException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
}
|
}).start();*/
|
|
}
|
}
|
|
|
private void start_service(Context context)
|
{
|
if(!mUtils.isServiceRunning(context, "com.pqlabs.updatefirmware.UpdateFirmwareService"))
|
{
|
Intent i = new Intent();
|
i.setComponent(new ComponentName("com.pqlabs.updatefirmware","com.pqlabs.updatefirmware.UpdateFirmwareService"));
|
context.startService(i);
|
}
|
|
|
|
if(!mUtils.isServiceRunning(context, "com.jw.sysupdate.service.The_Service"))
|
{
|
Intent intent_sysupdate = new Intent();
|
intent_sysupdate.setComponent(new ComponentName("com.jw.sysupdate","com.jw.sysupdate.service.The_Service"));
|
context.startService(intent_sysupdate);
|
|
}
|
|
if(!mUtils.isServiceRunning(context, "logcat_tools.LogService"))
|
{
|
Intent intent_Log = new Intent();
|
intent_Log.setComponent(new ComponentName("com.jwipc.toolbox","logcat_tools.LogService"));
|
context.startService(intent_Log);
|
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|