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

88 lines
3.2 KiB
Java
Raw Normal View History

package com.topjohnwu.magisk;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger;
2016-10-22 20:04:58 +02:00
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
2016-10-22 20:04:58 +02:00
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class SplashActivity extends AppCompatActivity {
2016-09-30 23:21:24 +02:00
@Override
protected void onCreate(Bundle savedInstanceState) {
2016-09-26 20:16:11 +02:00
super.onCreate(savedInstanceState);
2016-09-30 23:21:24 +02:00
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
2016-10-22 20:04:58 +02:00
if (prefs.getString("theme", "").equals("Dark")) {
setTheme(R.style.AppTheme_dh);
}
2016-09-30 23:21:24 +02:00
Logger.devLog = prefs.getBoolean("developer_logging", false);
Logger.logShell = prefs.getBoolean("shell_logging", false);
2016-09-30 05:35:46 +02:00
2016-10-22 18:05:34 +02:00
// Set up default preferences,make sure we add "extra" blacklist entries.
2016-10-22 20:04:58 +02:00
int hideVersion = Utils.WhichHide(getApplication());
List<String> hideList;
Set<String> set = new HashSet<>();
switch (hideVersion) {
case 1:
hideList = Shell.su("/magisk/.core/magiskhide/list");
set.addAll(hideList);
break;
case 2:
hideList = Shell.su("/su/suhide/list");
break;
case 3:
hideList = Shell.su("/magisk/.core/magiskhide/list");
hideList.addAll(Shell.su("/su/suhide/list"));
set.addAll(hideList);
}
if (!prefs.contains("auto_blacklist")) {
2016-10-22 18:05:34 +02:00
Logger.dev("SplashActivity: Setting default preferences for application");
2016-10-22 20:04:58 +02:00
SharedPreferences.Editor editor = prefs.edit();
2016-10-22 18:05:34 +02:00
set.add("com.google.android.apps.walletnfcrel");
set.add("com.google.android.gms");
set.add("com.google.commerce.tapandpay");
editor.putStringSet("auto_blacklist", set);
editor.putBoolean("autoRootEnable", false);
editor.putBoolean("root", Utils.rootEnabled());
editor.apply();
}
// Initialize
2016-09-30 23:21:24 +02:00
prefs.edit()
2016-09-27 16:57:20 +02:00
.putBoolean("module_done", false)
.putBoolean("repo_done", false)
.putBoolean("update_check_done", false)
2016-09-27 16:57:20 +02:00
.apply();
2016-09-30 23:21:24 +02:00
new Async.CheckUpdates(prefs).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new Async.constructEnv(getApplicationInfo()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
new Async.LoadModules(prefs) {
@Override
protected void onPostExecute(Void v) {
super.onPostExecute(v);
new Async.LoadRepos(getApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// Start main activity
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
2016-09-24 20:46:42 +02:00
}
}