Magisk/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java

59 lines
2.1 KiB
Java
Raw Normal View History

package com.topjohnwu.magisk;
2017-02-17 08:51:51 +08:00
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
2017-05-23 16:51:23 +08:00
import android.text.TextUtils;
2017-02-12 19:49:46 +08:00
import com.topjohnwu.magisk.asyncs.GetBootBlocks;
import com.topjohnwu.magisk.asyncs.LoadApps;
import com.topjohnwu.magisk.asyncs.LoadModules;
import com.topjohnwu.magisk.asyncs.LoadRepos;
2017-02-07 02:01:32 +08:00
import com.topjohnwu.magisk.components.Activity;
2017-02-17 08:51:51 +08:00
import com.topjohnwu.magisk.services.UpdateCheckService;
2017-05-23 16:51:23 +08:00
import com.topjohnwu.magisk.utils.Utils;
2017-02-07 07:32:40 +08:00
2017-02-17 08:51:51 +08:00
public class SplashActivity extends Activity{
private static final int UPDATE_SERVICE_ID = 1;
2016-10-31 11:13:48 +08:00
@Override
protected void onCreate(Bundle savedInstanceState) {
2016-09-26 13:16:11 -05:00
super.onCreate(savedInstanceState);
2017-02-05 22:02:14 +08:00
// Init the info and configs and root shell
getApplicationContext().init();
2017-02-07 07:32:40 +08:00
2017-02-05 22:02:14 +08:00
// Now fire all async tasks
2017-02-12 19:49:46 +08:00
new GetBootBlocks(this).exec();
new LoadModules(this).setCallBack(() -> new LoadRepos(this).exec()).exec();
2017-02-12 19:49:46 +08:00
new LoadApps(this).exec();
2017-05-23 16:51:23 +08:00
if (Utils.checkNetworkStatus(this)) {
// Initialize the update check service, notify every 12 hours
if (!TextUtils.equals("install", getIntent().getStringExtra(MagiskManager.INTENT_SECTION))) {
ComponentName service = new ComponentName(this, UpdateCheckService.class);
2017-05-23 16:51:23 +08:00
JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true)
.setPeriodic(12 * 60 * 60 * 1000)
.build();
JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(jobInfo);
2017-02-17 08:51:51 +08:00
}
2017-05-23 16:51:23 +08:00
}
Intent intent = new Intent(this, MainActivity.class);
2017-05-23 16:51:23 +08:00
String section = getIntent().getStringExtra(MagiskManager.INTENT_SECTION);
if (section != null) {
intent.putExtra(MagiskManager.INTENT_SECTION, section);
}
startActivity(intent);
finish();
}
}