use of com.topjohnwu.magisk.database.RepoDatabaseHelper in project MagiskManager by topjohnwu.
the class MagiskManager method onCreate.
@Override
public void onCreate() {
super.onCreate();
Shell.setFlags(Shell.FLAG_MOUNT_MASTER);
Shell.verboseLogging(BuildConfig.DEBUG);
BusyBox.BB_PATH = new File(Const.BUSYBOX_PATH);
Shell.setInitializer(new Shell.Initializer() {
@Override
public void onRootShellInit(@NonNull Shell shell) {
try (InputStream utils = getAssets().open(Const.UTIL_FUNCTIONS);
InputStream sudb = getResources().openRawResource(R.raw.sudb)) {
shell.loadInputStream(null, null, utils);
shell.loadInputStream(null, null, sudb);
} catch (IOException e) {
e.printStackTrace();
}
shell.run(null, null, "mount_partitions", "run_migrations");
}
});
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Handle duplicate package
if (!getPackageName().equals(Const.ORIG_PKG_NAME)) {
try {
getPackageManager().getApplicationInfo(Const.ORIG_PKG_NAME, 0);
Intent intent = getPackageManager().getLaunchIntentForPackage(Const.ORIG_PKG_NAME);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return;
} catch (PackageManager.NameNotFoundException ignored) {
/* Expected */
}
}
suDB = SuDatabaseHelper.getInstance(this);
String pkg = suDB.getStrings(Const.Key.SU_REQUESTER, Const.ORIG_PKG_NAME);
if (getPackageName().equals(Const.ORIG_PKG_NAME) && !pkg.equals(Const.ORIG_PKG_NAME)) {
suDB.setStrings(Const.Key.SU_REQUESTER, null);
Utils.uninstallPkg(pkg);
suDB = SuDatabaseHelper.getInstance(this);
}
repoDB = new RepoDatabaseHelper(this);
defaultLocale = Locale.getDefault();
setLocale();
loadConfig();
}
Aggregations