2016-09-24 18:54:12 +02:00
|
|
|
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;
|
2016-09-24 18:54:12 +02:00
|
|
|
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;
|
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
public class SplashActivity extends AppCompatActivity {
|
2016-09-30 23:21:24 +02:00
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2016-09-25 15:31:38 +02:00
|
|
|
|
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")) {
|
2016-09-25 07:16:28 +02:00
|
|
|
setTheme(R.style.AppTheme_dh);
|
|
|
|
}
|
2016-09-24 18:54:12 +02:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
// 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)
|
2016-09-28 12:05:55 +02:00
|
|
|
.putBoolean("update_check_done", false)
|
2016-09-27 16:57:20 +02:00
|
|
|
.apply();
|
2016-09-28 12:05:55 +02:00
|
|
|
|
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
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
}
|
|
|
|
}
|