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.services.MonitorService;
|
|
|
|
import com.topjohnwu.magisk.utils.Async;
|
|
|
|
import com.topjohnwu.magisk.utils.Logger;
|
2016-09-25 09:16:10 +02:00
|
|
|
import com.topjohnwu.magisk.utils.Shell;
|
2016-09-24 18:54:12 +02:00
|
|
|
import com.topjohnwu.magisk.utils.Utils;
|
|
|
|
|
2016-09-25 15:31:38 +02:00
|
|
|
import java.io.File;
|
2016-09-24 18:54:12 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
public class SplashActivity extends AppCompatActivity {
|
|
|
|
@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);
|
|
|
|
SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
2016-09-25 15:31:38 +02:00
|
|
|
if (defaultPrefs.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
|
|
|
//setups go here
|
|
|
|
|
|
|
|
// Set up default preferences,make sure we add "extra" blacklist entries.
|
2016-09-26 20:16:11 +02:00
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
|
2016-09-25 15:31:38 +02:00
|
|
|
|
|
|
|
if (!defaultPrefs.contains("auto_blacklist")) {
|
2016-09-26 20:16:11 +02:00
|
|
|
Logger.dh("SplashActivity: Setting default preferences for application");
|
2016-09-25 15:31:38 +02:00
|
|
|
SharedPreferences.Editor editor = defaultPrefs.edit();
|
2016-09-24 18:54:12 +02:00
|
|
|
Set<String> set = new HashSet<>();
|
|
|
|
set.add("com.google.android.apps.walletnfcrel");
|
|
|
|
set.add("com.google.android.gms");
|
|
|
|
set.add("com.google.commerce.tapandpay");
|
|
|
|
editor.putStringSet("auto_blacklist", set);
|
2016-09-26 20:16:11 +02:00
|
|
|
editor.putBoolean("autoRootEnable",false);
|
|
|
|
editor.putBoolean("root",Utils.rootEnabled());
|
2016-09-24 18:54:12 +02:00
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up toggle states based on preferences, start services, disable root if set
|
|
|
|
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
2016-09-25 08:16:08 +02:00
|
|
|
if (!Utils.hasServicePermission(getApplicationContext())) {
|
2016-09-25 15:31:38 +02:00
|
|
|
Utils.toggleAutoRoot(false, getApplicationContext());
|
2016-09-25 08:16:08 +02:00
|
|
|
}
|
2016-09-25 15:59:54 +02:00
|
|
|
}
|
|
|
|
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
2016-09-24 18:54:12 +02:00
|
|
|
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
|
|
|
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
|
|
|
getApplication().startService(myIntent);
|
|
|
|
}
|
2016-09-25 15:31:38 +02:00
|
|
|
} else if (defaultPrefs.getBoolean("keep_root_off", false)) {
|
|
|
|
Utils.toggleRoot(false, getApplication());
|
2016-09-24 18:54:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set up quick settings tile
|
2016-09-25 15:59:54 +02:00
|
|
|
Utils.SetupQuickSettingsTile(getApplicationContext());
|
2016-09-24 18:54:12 +02:00
|
|
|
|
|
|
|
// Initialize
|
2016-09-25 15:31:38 +02:00
|
|
|
Utils.init(this);
|
|
|
|
new Async.CheckUpdates(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
|
|
new Async.LoadModules(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
|
|
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
|
|
new Async.BusyboxEnv(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2016-09-25 07:16:28 +02:00
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
// Start main activity
|
|
|
|
Intent intent = new Intent(this, MainActivity.class);
|
|
|
|
startActivity(intent);
|
2016-09-24 20:46:42 +02:00
|
|
|
|
2016-09-24 18:54:12 +02:00
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|