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

83 lines
2.7 KiB
Java
Raw Normal View History

package com.topjohnwu.magisk;
2017-11-06 04:47:24 +08:00
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
2017-11-06 04:47:24 +08:00
import android.os.Build;
import android.os.Bundle;
2017-11-06 04:47:24 +08:00
import com.topjohnwu.magisk.asyncs.CheckUpdates;
import com.topjohnwu.magisk.asyncs.LoadModules;
import com.topjohnwu.magisk.asyncs.ParallelTask;
import com.topjohnwu.magisk.asyncs.UpdateRepos;
2017-02-07 02:01:32 +08:00
import com.topjohnwu.magisk.components.Activity;
2017-11-06 04:41:23 +08:00
import com.topjohnwu.magisk.utils.Const;
2017-11-06 04:47:24 +08:00
import com.topjohnwu.magisk.utils.Utils;
2018-01-21 06:07:24 +08:00
import com.topjohnwu.superuser.Shell;
2017-11-06 04:47:24 +08:00
2017-08-30 02:28:24 +08:00
public class SplashActivity extends Activity {
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-11-06 04:47:24 +08:00
MagiskManager mm = getMagiskManager();
2017-12-20 12:14:46 +08:00
mm.loadMagiskInfo();
mm.getDefaultInstallFlags();
2017-12-20 12:14:46 +08:00
Utils.loadPrefs();
2017-11-06 04:47:24 +08:00
// Dynamic detect all locales
new LoadLocale().exec();
// Create notification channel on Android O
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(Const.ID.NOTIFICATION_CHANNEL,
getString(R.string.magisk_updates), NotificationManager.IMPORTANCE_DEFAULT);
getSystemService(NotificationManager.class).createNotificationChannel(channel);
}
LoadModules loadModuleTask = new LoadModules();
if (Utils.checkNetworkStatus()) {
// Fire update check
new CheckUpdates().exec();
// Add repo update check
loadModuleTask.setCallBack(() -> new UpdateRepos(false).exec());
}
// Magisk working as expected
if (Shell.rootAccess() && mm.magiskVersionCode > 0) {
2018-02-20 00:39:17 +08:00
// Update check service
mm.setupUpdateCheck();
2017-11-06 04:47:24 +08:00
// Fire asynctasks
loadModuleTask.exec();
2017-11-15 04:39:05 +08:00
// Check dtbo status
Utils.patchDTBO();
2017-11-06 04:47:24 +08:00
}
// Write back default values
2017-12-27 01:07:33 +08:00
mm.writeConfig();
2017-11-06 04:47:24 +08:00
mm.hasInit = true;
2017-07-20 02:54:34 +08:00
Intent intent = new Intent(this, MainActivity.class);
2017-11-06 05:36:20 +08:00
intent.putExtra(Const.Key.OPEN_SECTION, getIntent().getStringExtra(Const.Key.OPEN_SECTION));
intent.putExtra(Const.Key.INTENT_PERM, getIntent().getStringExtra(Const.Key.INTENT_PERM));
2017-05-23 16:51:23 +08:00
startActivity(intent);
finish();
}
2017-11-06 04:47:24 +08:00
static class LoadLocale extends ParallelTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
MagiskManager.get().locales = Utils.getAvailableLocale();
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
MagiskManager.get().localeDone.publish();
}
}
}