mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 12:17:38 +00:00
Various adjustments
This commit is contained in:
parent
4998ad6c7e
commit
d4a10e2873
@ -42,7 +42,7 @@ public class AboutActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getApplicationContext().isDarkTheme) {
|
||||
if (getMagiskManager().isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_Transparent_Dark);
|
||||
}
|
||||
setContentView(R.layout.activity_about);
|
||||
|
@ -88,7 +88,7 @@ public class FlashActivity extends Activity {
|
||||
break;
|
||||
case FLASH_MAGISK:
|
||||
String boot = intent.getStringExtra(SET_BOOT);
|
||||
if (getApplicationContext().remoteMagiskVersionCode < 1370) {
|
||||
if (getMagiskManager().remoteMagiskVersionCode < 1370) {
|
||||
// Use legacy installation method
|
||||
getShell().su_raw(
|
||||
"echo \"BOOTIMAGE=" + boot + "\" > /dev/.magisk",
|
||||
|
@ -59,7 +59,7 @@ public class MagiskFragment extends Fragment
|
||||
|
||||
private Container expandableContainer = new Container();
|
||||
|
||||
private MagiskManager magiskManager;
|
||||
private MagiskManager mm;
|
||||
private Unbinder unbinder;
|
||||
private static boolean shownDialog = false;
|
||||
|
||||
@ -115,17 +115,17 @@ public class MagiskFragment extends Fragment
|
||||
shownDialog = true;
|
||||
|
||||
// Show Manager update first
|
||||
if (magiskManager.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
||||
if (mm.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
||||
new AlertDialogBuilder(getActivity())
|
||||
.setTitle(getString(R.string.repo_install_title, getString(R.string.app_name)))
|
||||
.setMessage(getString(R.string.repo_install_msg,
|
||||
Utils.getLegalFilename("MagiskManager-v" +
|
||||
magiskManager.remoteManagerVersionString + ".apk")))
|
||||
mm.remoteManagerVersionString + ".apk")))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.install, (d, i) -> {
|
||||
Intent intent = new Intent(magiskManager, ManagerUpdate.class);
|
||||
intent.putExtra(MagiskManager.INTENT_LINK, magiskManager.managerLink);
|
||||
intent.putExtra(MagiskManager.INTENT_VERSION, magiskManager.remoteManagerVersionString);
|
||||
Intent intent = new Intent(mm, ManagerUpdate.class);
|
||||
intent.putExtra(MagiskManager.INTENT_LINK, mm.managerLink);
|
||||
intent.putExtra(MagiskManager.INTENT_VERSION, mm.remoteManagerVersionString);
|
||||
getActivity().sendBroadcast(intent);
|
||||
})
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
@ -135,12 +135,12 @@ public class MagiskFragment extends Fragment
|
||||
|
||||
String bootImage = null;
|
||||
if (Shell.rootAccess()) {
|
||||
if (magiskManager.bootBlock != null) {
|
||||
bootImage = magiskManager.bootBlock;
|
||||
if (mm.bootBlock != null) {
|
||||
bootImage = mm.bootBlock;
|
||||
} else {
|
||||
int idx = spinner.getSelectedItemPosition();
|
||||
if (idx > 0) {
|
||||
bootImage = magiskManager.blockList.get(idx - 1);
|
||||
bootImage = mm.blockList.get(idx - 1);
|
||||
} else {
|
||||
SnackbarMaker.make(getActivity(),
|
||||
R.string.manual_boot_image, Snackbar.LENGTH_LONG).show();
|
||||
@ -150,7 +150,7 @@ public class MagiskFragment extends Fragment
|
||||
}
|
||||
final String boot = bootImage;
|
||||
((NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll();
|
||||
String filename = "Magisk-v" + magiskManager.remoteMagiskVersionString + ".zip";
|
||||
String filename = "Magisk-v" + mm.remoteMagiskVersionString + ".zip";
|
||||
new AlertDialogBuilder(getActivity())
|
||||
.setTitle(getString(R.string.repo_install_title, getString(R.string.magisk)))
|
||||
.setMessage(getString(R.string.repo_install_msg, filename))
|
||||
@ -172,8 +172,8 @@ public class MagiskFragment extends Fragment
|
||||
DownloadReceiver receiver = null;
|
||||
switch (idx) {
|
||||
case 1:
|
||||
if (magiskManager.remoteMagiskVersionCode < 1370) {
|
||||
magiskManager.toast(R.string.no_boot_file_patch_support, Toast.LENGTH_LONG);
|
||||
if (mm.remoteMagiskVersionCode < 1370) {
|
||||
mm.toast(R.string.no_boot_file_patch_support, Toast.LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
@ -206,7 +206,7 @@ public class MagiskFragment extends Fragment
|
||||
Utils.dlAndReceive(
|
||||
getActivity(),
|
||||
receiver,
|
||||
magiskManager.magiskLink,
|
||||
mm.magiskLink,
|
||||
Utils.getLegalFilename(filename)
|
||||
);
|
||||
}
|
||||
@ -214,10 +214,10 @@ public class MagiskFragment extends Fragment
|
||||
}
|
||||
)
|
||||
.setNeutralButton(R.string.release_notes, (d, i) -> {
|
||||
if (magiskManager.releaseNoteLink != null) {
|
||||
Intent openReleaseNoteLink = new Intent(Intent.ACTION_VIEW, Uri.parse(magiskManager.releaseNoteLink));
|
||||
if (mm.releaseNoteLink != null) {
|
||||
Intent openReleaseNoteLink = new Intent(Intent.ACTION_VIEW, Uri.parse(mm.releaseNoteLink));
|
||||
openReleaseNoteLink.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
magiskManager.startActivity(openReleaseNoteLink);
|
||||
mm.startActivity(openReleaseNoteLink);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
@ -231,8 +231,8 @@ public class MagiskFragment extends Fragment
|
||||
.setMessage(R.string.uninstall_magisk_msg)
|
||||
.setPositiveButton(R.string.yes, (d, i) -> {
|
||||
try {
|
||||
InputStream in = magiskManager.getAssets().open(UNINSTALLER);
|
||||
File uninstaller = new File(magiskManager.getCacheDir(), UNINSTALLER);
|
||||
InputStream in = mm.getAssets().open(UNINSTALLER);
|
||||
File uninstaller = new File(mm.getCacheDir(), UNINSTALLER);
|
||||
FileOutputStream out = new FileOutputStream(uninstaller);
|
||||
byte[] bytes = new byte[1024];
|
||||
int read;
|
||||
@ -241,8 +241,8 @@ public class MagiskFragment extends Fragment
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
in = magiskManager.getAssets().open(UTIL_FUNCTIONS);
|
||||
File utils = new File(magiskManager.getCacheDir(), UTIL_FUNCTIONS);
|
||||
in = mm.getAssets().open(UTIL_FUNCTIONS);
|
||||
File utils = new File(mm.getCacheDir(), UTIL_FUNCTIONS);
|
||||
out = new FileOutputStream(utils);
|
||||
while ((read = in.read(bytes)) != -1) {
|
||||
out.write(bytes, 0, read);
|
||||
@ -283,7 +283,7 @@ public class MagiskFragment extends Fragment
|
||||
unbinder = ButterKnife.bind(this, v);
|
||||
getActivity().setTitle(R.string.magisk);
|
||||
|
||||
magiskManager = getApplication();
|
||||
mm = getApplication();
|
||||
|
||||
expandableContainer.expandLayout = expandLayout;
|
||||
setupExpandable();
|
||||
@ -296,7 +296,7 @@ public class MagiskFragment extends Fragment
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
magiskManager.getMagiskInfo();
|
||||
mm.getMagiskInfo();
|
||||
updateUI();
|
||||
|
||||
magiskUpdateText.setText(R.string.checking_for_updates);
|
||||
@ -305,16 +305,16 @@ public class MagiskFragment extends Fragment
|
||||
|
||||
safetyNetStatusText.setText(R.string.safetyNet_check_text);
|
||||
|
||||
magiskManager.safetyNetDone.hasPublished = false;
|
||||
magiskManager.updateCheckDone.hasPublished = false;
|
||||
magiskManager.remoteMagiskVersionString = null;
|
||||
magiskManager.remoteMagiskVersionCode = -1;
|
||||
mm.safetyNetDone.hasPublished = false;
|
||||
mm.updateCheckDone.hasPublished = false;
|
||||
mm.remoteMagiskVersionString = null;
|
||||
mm.remoteMagiskVersionCode = -1;
|
||||
collapse();
|
||||
|
||||
shownDialog = false;
|
||||
|
||||
// Trigger state check
|
||||
if (Utils.checkNetworkStatus(magiskManager)) {
|
||||
if (Utils.checkNetworkStatus(mm)) {
|
||||
new CheckUpdates(getActivity()).exec();
|
||||
} else {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
@ -338,24 +338,24 @@ public class MagiskFragment extends Fragment
|
||||
startActivity(intent);
|
||||
}
|
||||
},
|
||||
magiskManager.magiskLink,
|
||||
Utils.getLegalFilename("Magisk-v" + magiskManager.remoteMagiskVersionString + ".zip")
|
||||
mm.magiskLink,
|
||||
Utils.getLegalFilename("Magisk-v" + mm.remoteMagiskVersionString + ".zip")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicPublished(Topic topic) {
|
||||
if (topic == magiskManager.updateCheckDone) {
|
||||
if (topic == mm.updateCheckDone) {
|
||||
updateCheckUI();
|
||||
} else if (topic == magiskManager.safetyNetDone) {
|
||||
} else if (topic == mm.safetyNetDone) {
|
||||
updateSafetyNetUI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Topic[] getSubscription() {
|
||||
return new Topic[] { magiskManager.updateCheckDone, magiskManager.safetyNetDone };
|
||||
return new Topic[] { mm.updateCheckDone, mm.safetyNetDone };
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -374,7 +374,7 @@ public class MagiskFragment extends Fragment
|
||||
|
||||
boolean hasNetwork = Utils.checkNetworkStatus(getActivity());
|
||||
boolean hasRoot = Shell.rootAccess();
|
||||
boolean isUpToDate = magiskManager.magiskVersionCode > 1300;
|
||||
boolean isUpToDate = mm.magiskVersionCode > 1300;
|
||||
|
||||
magiskUpdateCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||
safetyNetCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||
@ -385,14 +385,14 @@ public class MagiskFragment extends Fragment
|
||||
|
||||
int image, color;
|
||||
|
||||
if (magiskManager.magiskVersionCode < 0) {
|
||||
if (mm.magiskVersionCode < 0) {
|
||||
color = colorBad;
|
||||
image = R.drawable.ic_cancel;
|
||||
magiskVersionText.setText(R.string.magisk_version_error);
|
||||
} else {
|
||||
color = colorOK;
|
||||
image = R.drawable.ic_check_circle;
|
||||
magiskVersionText.setText(getString(R.string.current_magisk_title, "v" + magiskManager.magiskVersionString));
|
||||
magiskVersionText.setText(getString(R.string.current_magisk_title, "v" + mm.magiskVersionString));
|
||||
}
|
||||
|
||||
magiskStatusIcon.setImageResource(image);
|
||||
@ -405,10 +405,10 @@ public class MagiskFragment extends Fragment
|
||||
rootStatusText.setText(R.string.not_rooted);
|
||||
break;
|
||||
case 1:
|
||||
if (magiskManager.suVersion != null) {
|
||||
if (mm.suVersion != null) {
|
||||
color = colorOK;
|
||||
image = R.drawable.ic_check_circle;
|
||||
rootStatusText.setText(magiskManager.suVersion);
|
||||
rootStatusText.setText(mm.suVersion);
|
||||
break;
|
||||
}
|
||||
case -1:
|
||||
@ -422,12 +422,12 @@ public class MagiskFragment extends Fragment
|
||||
rootStatusIcon.setColorFilter(color);
|
||||
|
||||
List<String> items = new ArrayList<>();
|
||||
if (magiskManager.bootBlock != null) {
|
||||
items.add(getString(R.string.auto_detect, magiskManager.bootBlock));
|
||||
if (mm.bootBlock != null) {
|
||||
items.add(getString(R.string.auto_detect, mm.bootBlock));
|
||||
spinner.setEnabled(false);
|
||||
} else {
|
||||
items.add(getString(R.string.cannot_auto_detect));
|
||||
items.addAll(magiskManager.blockList);
|
||||
items.addAll(mm.blockList);
|
||||
}
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(),
|
||||
android.R.layout.simple_spinner_item, items);
|
||||
@ -438,26 +438,26 @@ public class MagiskFragment extends Fragment
|
||||
private void updateCheckUI() {
|
||||
int image, color;
|
||||
|
||||
if (magiskManager.remoteMagiskVersionCode < 0) {
|
||||
if (mm.remoteMagiskVersionCode < 0) {
|
||||
color = colorNeutral;
|
||||
image = R.drawable.ic_help;
|
||||
magiskUpdateText.setText(R.string.cannot_check_updates);
|
||||
} else {
|
||||
color = colorOK;
|
||||
image = R.drawable.ic_check_circle;
|
||||
magiskUpdateText.setText(getString(R.string.install_magisk_title, "v" + magiskManager.remoteMagiskVersionString));
|
||||
magiskUpdateText.setText(getString(R.string.install_magisk_title, "v" + mm.remoteMagiskVersionString));
|
||||
}
|
||||
|
||||
if (magiskManager.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
||||
if (mm.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
||||
installText.setText(getString(R.string.update, getString(R.string.app_name)));
|
||||
} else if (magiskManager.magiskVersionCode > 0 && magiskManager.remoteMagiskVersionCode > magiskManager.magiskVersionCode) {
|
||||
} else if (mm.magiskVersionCode > 0 && mm.remoteMagiskVersionCode > mm.magiskVersionCode) {
|
||||
installText.setText(getString(R.string.update, getString(R.string.magisk)));
|
||||
} else {
|
||||
installText.setText(R.string.install);
|
||||
}
|
||||
|
||||
if (!shownDialog && (magiskManager.remoteMagiskVersionCode > magiskManager.magiskVersionCode
|
||||
|| magiskManager.remoteManagerVersionCode > BuildConfig.VERSION_CODE)) {
|
||||
if (!shownDialog && (mm.remoteMagiskVersionCode > mm.magiskVersionCode
|
||||
|| mm.remoteManagerVersionCode > BuildConfig.VERSION_CODE)) {
|
||||
install();
|
||||
}
|
||||
|
||||
@ -473,30 +473,30 @@ public class MagiskFragment extends Fragment
|
||||
int image, color;
|
||||
safetyNetProgress.setVisibility(View.GONE);
|
||||
safetyNetRefreshIcon.setVisibility(View.VISIBLE);
|
||||
if (magiskManager.SNCheckResult.failed) {
|
||||
safetyNetStatusText.setText(magiskManager.SNCheckResult.errmsg);
|
||||
if (mm.SNCheckResult.failed) {
|
||||
safetyNetStatusText.setText(mm.SNCheckResult.errmsg);
|
||||
collapse();
|
||||
} else {
|
||||
safetyNetStatusText.setText(R.string.safetyNet_check_success);
|
||||
if (magiskManager.SNCheckResult.ctsProfile) {
|
||||
if (mm.SNCheckResult.ctsProfile) {
|
||||
color = colorOK;
|
||||
image = R.drawable.ic_check_circle;
|
||||
} else {
|
||||
color = colorBad;
|
||||
image = R.drawable.ic_cancel;
|
||||
}
|
||||
ctsStatusText.setText("ctsProfile: " + magiskManager.SNCheckResult.ctsProfile);
|
||||
ctsStatusText.setText("ctsProfile: " + mm.SNCheckResult.ctsProfile);
|
||||
ctsStatusIcon.setImageResource(image);
|
||||
ctsStatusIcon.setColorFilter(color);
|
||||
|
||||
if (magiskManager.SNCheckResult.basicIntegrity) {
|
||||
if (mm.SNCheckResult.basicIntegrity) {
|
||||
color = colorOK;
|
||||
image = R.drawable.ic_check_circle;
|
||||
} else {
|
||||
color = colorBad;
|
||||
image = R.drawable.ic_cancel;
|
||||
}
|
||||
basicStatusText.setText("basicIntegrity: " + magiskManager.SNCheckResult.basicIntegrity);
|
||||
basicStatusText.setText("basicIntegrity: " + mm.SNCheckResult.basicIntegrity);
|
||||
basicStatusIcon.setImageResource(image);
|
||||
basicStatusIcon.setColorFilter(color);
|
||||
expand();
|
||||
|
@ -151,7 +151,7 @@ public class MagiskManager extends Application {
|
||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
public void loadConfig() {
|
||||
// Locale
|
||||
defaultLocale = Locale.getDefault();
|
||||
setLocale();
|
||||
|
@ -38,11 +38,11 @@ public class MainActivity extends Activity
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
getApplicationContext().startup();
|
||||
getMagiskManager().startup();
|
||||
|
||||
prefs = getApplicationContext().prefs;
|
||||
prefs = getMagiskManager().prefs;
|
||||
|
||||
if (getApplicationContext().isDarkTheme) {
|
||||
if (getMagiskManager().isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -108,21 +108,21 @@ public class MainActivity extends Activity
|
||||
|
||||
@Override
|
||||
public Topic[] getSubscription() {
|
||||
return new Topic[] { getApplicationContext().reloadActivity };
|
||||
return new Topic[] { getMagiskManager().reloadActivity };
|
||||
}
|
||||
|
||||
public void checkHideSection() {
|
||||
Menu menu = navigationView.getMenu();
|
||||
menu.findItem(R.id.magiskhide).setVisible(
|
||||
Shell.rootAccess() && getApplicationContext().magiskVersionCode >= 1300
|
||||
Shell.rootAccess() && getMagiskManager().magiskVersionCode >= 1300
|
||||
&& prefs.getBoolean("magiskhide", false));
|
||||
menu.findItem(R.id.modules).setVisible(
|
||||
Shell.rootAccess() && getApplicationContext().magiskVersionCode >= 0);
|
||||
Shell.rootAccess() && getMagiskManager().magiskVersionCode >= 0);
|
||||
menu.findItem(R.id.downloads).setVisible(Utils.checkNetworkStatus(this) &&
|
||||
Shell.rootAccess() && getApplicationContext().magiskVersionCode >= 0);
|
||||
Shell.rootAccess() && getMagiskManager().magiskVersionCode >= 0);
|
||||
menu.findItem(R.id.log).setVisible(Shell.rootAccess());
|
||||
menu.findItem(R.id.superuser).setVisible(
|
||||
Shell.rootAccess() && getApplicationContext().isSuClient);
|
||||
Shell.rootAccess() && getMagiskManager().isSuClient);
|
||||
}
|
||||
|
||||
public void navigate(String item) {
|
||||
|
@ -36,7 +36,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getApplicationContext().isDarkTheme) {
|
||||
if (getMagiskManager().isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_Transparent_Dark);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
|
||||
@Override
|
||||
public Topic[] getSubscription() {
|
||||
return new Topic[] { getApplicationContext().reloadActivity };
|
||||
return new Topic[] { getMagiskManager().reloadActivity };
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragment
|
||||
@ -80,7 +80,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
|
||||
private ListPreference updateChannel, suAccess, autoRes, suNotification,
|
||||
requestTimeout, multiuserMode, namespaceMode;
|
||||
private MagiskManager magiskManager;
|
||||
private MagiskManager mm;
|
||||
private PreferenceCategory generalCatagory;
|
||||
|
||||
@Override
|
||||
@ -89,7 +89,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
addPreferencesFromResource(R.xml.app_settings);
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
prefScreen = getPreferenceScreen();
|
||||
magiskManager = Utils.getMagiskManager(getActivity());
|
||||
mm = Utils.getMagiskManager(getActivity());
|
||||
|
||||
generalCatagory = (PreferenceCategory) findPreference("general");
|
||||
PreferenceCategory magiskCategory = (PreferenceCategory) findPreference("magisk");
|
||||
@ -141,10 +141,10 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
prefScreen.removePreference(suCategory);
|
||||
generalCatagory.removePreference(hideManager);
|
||||
} else {
|
||||
if (!magiskManager.isSuClient) {
|
||||
if (!mm.isSuClient) {
|
||||
prefScreen.removePreference(suCategory);
|
||||
}
|
||||
if (magiskManager.magiskVersionCode < 1300) {
|
||||
if (mm.magiskVersionCode < 1300) {
|
||||
prefScreen.removePreference(magiskCategory);
|
||||
}
|
||||
}
|
||||
@ -155,12 +155,12 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
if (isNew) {
|
||||
lp = new ListPreference(getActivity());
|
||||
}
|
||||
CharSequence[] entries = new CharSequence[magiskManager.locales.size() + 1];
|
||||
CharSequence[] entryValues = new CharSequence[magiskManager.locales.size() + 1];
|
||||
CharSequence[] entries = new CharSequence[mm.locales.size() + 1];
|
||||
CharSequence[] entryValues = new CharSequence[mm.locales.size() + 1];
|
||||
entries[0] = getString(R.string.system_default);
|
||||
entryValues[0] = "";
|
||||
int i = 1;
|
||||
for (Locale locale : magiskManager.locales) {
|
||||
for (Locale locale : mm.locales) {
|
||||
entries[i] = locale.getDisplayName(locale);
|
||||
entryValues[i++] = locale.toLanguageTag();
|
||||
}
|
||||
@ -196,9 +196,8 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
switch (key) {
|
||||
case "dark_theme":
|
||||
enabled = prefs.getBoolean("dark_theme", false);
|
||||
if (magiskManager.isDarkTheme != enabled) {
|
||||
magiskManager.isDarkTheme = enabled;
|
||||
magiskManager.reloadActivity.publish(false);
|
||||
if (mm.isDarkTheme != enabled) {
|
||||
mm.reloadActivity.publish(false);
|
||||
}
|
||||
break;
|
||||
case "disable":
|
||||
@ -231,41 +230,24 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
}
|
||||
break;
|
||||
case "su_access":
|
||||
magiskManager.suAccessState = Utils.getPrefsInt(prefs, "su_access");
|
||||
magiskManager.suDB.setSettings(SuDatabaseHelper.ROOT_ACCESS, magiskManager.suAccessState);
|
||||
mm.suDB.setSettings(SuDatabaseHelper.ROOT_ACCESS, Utils.getPrefsInt(prefs, "su_access"));
|
||||
break;
|
||||
case "multiuser_mode":
|
||||
magiskManager.multiuserMode = Utils.getPrefsInt(prefs, "multiuser_mode");
|
||||
magiskManager.suDB.setSettings(SuDatabaseHelper.MULTIUSER_MODE, magiskManager.multiuserMode);
|
||||
mm.suDB.setSettings(SuDatabaseHelper.MULTIUSER_MODE, Utils.getPrefsInt(prefs, "multiuser_mode"));
|
||||
break;
|
||||
case "mnt_ns":
|
||||
magiskManager.suNamespaceMode = Utils.getPrefsInt(prefs, "mnt_ns");
|
||||
magiskManager.suDB.setSettings(SuDatabaseHelper.MNT_NS, magiskManager.suNamespaceMode);
|
||||
break;
|
||||
case "su_request_timeout":
|
||||
magiskManager.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout");
|
||||
break;
|
||||
case "su_auto_response":
|
||||
magiskManager.suResponseType = Utils.getPrefsInt(prefs, "su_auto_response");
|
||||
break;
|
||||
case "su_notification":
|
||||
magiskManager.suNotificationType = Utils.getPrefsInt(prefs, "su_notification");
|
||||
break;
|
||||
case "developer_logging":
|
||||
MagiskManager.devLogging = prefs.getBoolean("developer_logging", false);
|
||||
break;
|
||||
case "shell_logging":
|
||||
MagiskManager.shellLogging = prefs.getBoolean("shell_logging", false);
|
||||
mm.suDB.setSettings(SuDatabaseHelper.MNT_NS, Utils.getPrefsInt(prefs, "mnt_ns"));
|
||||
break;
|
||||
case "locale":
|
||||
magiskManager.setLocale();
|
||||
magiskManager.reloadActivity.publish(false);
|
||||
mm.setLocale();
|
||||
mm.reloadActivity.publish(false);
|
||||
break;
|
||||
case "update_channel":
|
||||
magiskManager.updateChannel = Utils.getPrefsInt(prefs, "update_channel");
|
||||
new CheckUpdates(magiskManager, true).exec();
|
||||
mm.updateChannel = Utils.getPrefsInt(prefs, "update_channel");
|
||||
new CheckUpdates(mm, true).exec();
|
||||
break;
|
||||
}
|
||||
mm.loadConfig();
|
||||
setSummary();
|
||||
}
|
||||
|
||||
@ -275,19 +257,19 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
|
||||
private void setSummary() {
|
||||
updateChannel.setSummary(getResources()
|
||||
.getStringArray(R.array.update_channel)[magiskManager.updateChannel]);
|
||||
.getStringArray(R.array.update_channel)[mm.updateChannel]);
|
||||
suAccess.setSummary(getResources()
|
||||
.getStringArray(R.array.su_access)[magiskManager.suAccessState]);
|
||||
.getStringArray(R.array.su_access)[mm.suAccessState]);
|
||||
autoRes.setSummary(getResources()
|
||||
.getStringArray(R.array.auto_response)[magiskManager.suResponseType]);
|
||||
.getStringArray(R.array.auto_response)[mm.suResponseType]);
|
||||
suNotification.setSummary(getResources()
|
||||
.getStringArray(R.array.su_notification)[magiskManager.suNotificationType]);
|
||||
.getStringArray(R.array.su_notification)[mm.suNotificationType]);
|
||||
requestTimeout.setSummary(
|
||||
getString(R.string.request_timeout_summary, prefs.getString("su_request_timeout", "10")));
|
||||
multiuserMode.setSummary(getResources()
|
||||
.getStringArray(R.array.multiuser_summary)[magiskManager.multiuserMode]);
|
||||
.getStringArray(R.array.multiuser_summary)[mm.multiuserMode]);
|
||||
namespaceMode.setSummary(getResources()
|
||||
.getStringArray(R.array.namespace_summary)[magiskManager.suNamespaceMode]);
|
||||
.getStringArray(R.array.namespace_summary)[mm.suNamespaceMode]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -297,7 +279,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
|
||||
@Override
|
||||
public Topic[] getSubscription() {
|
||||
return new Topic[] { magiskManager.localeDone };
|
||||
return new Topic[] { mm.localeDone };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class SplashActivity extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getApplicationContext().startup();
|
||||
getMagiskManager().startup();
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
String section = getIntent().getStringExtra(MagiskManager.INTENT_SECTION);
|
||||
|
@ -24,7 +24,7 @@ public class SuLogFragment extends Fragment {
|
||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||
|
||||
private Unbinder unbinder;
|
||||
private MagiskManager magiskManager;
|
||||
private MagiskManager mm;
|
||||
private SuLogAdapter adapter;
|
||||
|
||||
@Override
|
||||
@ -45,8 +45,8 @@ public class SuLogFragment extends Fragment {
|
||||
// Inflate the layout for this fragment
|
||||
View v = inflater.inflate(R.layout.fragment_su_log, container, false);
|
||||
unbinder = ButterKnife.bind(this, v);
|
||||
magiskManager = getApplication();
|
||||
adapter = new SuLogAdapter(magiskManager.suDB);
|
||||
mm = getApplication();
|
||||
adapter = new SuLogAdapter(mm.suDB);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
updateList();
|
||||
@ -73,7 +73,7 @@ public class SuLogFragment extends Fragment {
|
||||
updateList();
|
||||
return true;
|
||||
case R.id.menu_clear:
|
||||
magiskManager.suDB.clearLogs();
|
||||
mm.suDB.clearLogs();
|
||||
updateList();
|
||||
return true;
|
||||
default:
|
||||
|
@ -32,15 +32,15 @@ public class SuperuserFragment extends Fragment {
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
|
||||
PackageManager pm = getActivity().getPackageManager();
|
||||
MagiskManager magiskManager = getApplication();
|
||||
MagiskManager mm = getApplication();
|
||||
|
||||
List<Policy> policyList = magiskManager.suDB.getPolicyList(pm);
|
||||
List<Policy> policyList = mm.suDB.getPolicyList(pm);
|
||||
|
||||
if (policyList.size() == 0) {
|
||||
emptyRv.setVisibility(View.VISIBLE);
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
} else {
|
||||
recyclerView.setAdapter(new PolicyAdapter(policyList, magiskManager.suDB, pm));
|
||||
recyclerView.setAdapter(new PolicyAdapter(policyList, mm.suDB, pm));
|
||||
emptyRv.setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return null;
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return null;
|
||||
String jsonStr;
|
||||
switch (magiskManager.updateChannel) {
|
||||
switch (mm.updateChannel) {
|
||||
case STABLE_CHANNEL:
|
||||
jsonStr = WebService.getString(STABLE_URL);
|
||||
break;
|
||||
@ -47,30 +47,30 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
|
||||
try {
|
||||
JSONObject json = new JSONObject(jsonStr);
|
||||
JSONObject magisk = json.getJSONObject("magisk");
|
||||
magiskManager.remoteMagiskVersionString = magisk.getString("version");
|
||||
magiskManager.remoteMagiskVersionCode = magisk.getInt("versionCode");
|
||||
magiskManager.magiskLink = magisk.getString("link");
|
||||
magiskManager.releaseNoteLink = magisk.getString("note");
|
||||
mm.remoteMagiskVersionString = magisk.getString("version");
|
||||
mm.remoteMagiskVersionCode = magisk.getInt("versionCode");
|
||||
mm.magiskLink = magisk.getString("link");
|
||||
mm.releaseNoteLink = magisk.getString("note");
|
||||
JSONObject manager = json.getJSONObject("app");
|
||||
magiskManager.remoteManagerVersionString = manager.getString("version");
|
||||
magiskManager.remoteManagerVersionCode = manager.getInt("versionCode");
|
||||
magiskManager.managerLink = manager.getString("link");
|
||||
mm.remoteManagerVersionString = manager.getString("version");
|
||||
mm.remoteManagerVersionCode = manager.getInt("versionCode");
|
||||
mm.managerLink = manager.getString("link");
|
||||
} catch (JSONException ignored) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return;
|
||||
if (showNotification && magiskManager.updateNotification) {
|
||||
if (BuildConfig.VERSION_CODE < magiskManager.remoteManagerVersionCode) {
|
||||
Utils.showManagerUpdate(magiskManager);
|
||||
} else if (magiskManager.magiskVersionCode < magiskManager.remoteMagiskVersionCode) {
|
||||
Utils.showMagiskUpdate(magiskManager);
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return;
|
||||
if (showNotification && mm.updateNotification) {
|
||||
if (BuildConfig.VERSION_CODE < mm.remoteManagerVersionCode) {
|
||||
Utils.showManagerUpdate(mm);
|
||||
} else if (mm.magiskVersionCode < mm.remoteMagiskVersionCode) {
|
||||
Utils.showMagiskUpdate(mm);
|
||||
}
|
||||
}
|
||||
magiskManager.updateCheckDone.publish();
|
||||
mm.updateCheckDone.publish();
|
||||
super.onPostExecute(v);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.magisk.utils.WebService;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -37,13 +38,14 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
|
||||
null
|
||||
);
|
||||
if (in == null) throw new IOException();
|
||||
BufferedInputStream bis = new BufferedInputStream(in);
|
||||
byte[] buffer = new byte[4096];
|
||||
int read;
|
||||
while ((read = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, read);
|
||||
int len;
|
||||
while ((len = bis.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
bis.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -58,14 +58,14 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return -1;
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return -1;
|
||||
try {
|
||||
mList.add("- Copying zip to temp directory");
|
||||
|
||||
mCachedFile.delete();
|
||||
try (
|
||||
InputStream in = magiskManager.getContentResolver().openInputStream(mUri);
|
||||
InputStream in = mm.getContentResolver().openInputStream(mUri);
|
||||
OutputStream out = new FileOutputStream(mCachedFile)
|
||||
) {
|
||||
if (in == null) throw new FileNotFoundException();
|
||||
@ -97,23 +97,23 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
|
||||
// -1 = error, manual install; 0 = invalid zip; 1 = success
|
||||
@Override
|
||||
protected void onPostExecute(Integer result) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return;
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return;
|
||||
getShell().su_raw(
|
||||
"rm -rf " + mCachedFile.getParent(),
|
||||
"rm -rf " + MagiskManager.TMP_FOLDER_PATH
|
||||
);
|
||||
switch (result) {
|
||||
case -1:
|
||||
mList.add(magiskManager.getString(R.string.install_error));
|
||||
mList.add(mm.getString(R.string.install_error));
|
||||
Utils.showUriSnack(getActivity(), mUri);
|
||||
break;
|
||||
case 0:
|
||||
mList.add(magiskManager.getString(R.string.invalid_zip));
|
||||
mList.add(mm.getString(R.string.invalid_zip));
|
||||
break;
|
||||
case 1:
|
||||
// Success
|
||||
new LoadModules(magiskManager).exec();
|
||||
new LoadModules(mm).exec();
|
||||
break;
|
||||
}
|
||||
super.onPostExecute(result);
|
||||
|
@ -27,14 +27,14 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null)
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null)
|
||||
return false;
|
||||
|
||||
// Generate a new unhide app with random package name
|
||||
File unhideAPK = new File(Environment.getExternalStorageDirectory() + "/MagiskManager", "unhide.apk");
|
||||
unhideAPK.getParentFile().mkdirs();
|
||||
String pkg = ZipUtils.generateUnhide(magiskManager, unhideAPK);
|
||||
String pkg = ZipUtils.generateUnhide(mm, unhideAPK);
|
||||
|
||||
// Install the application
|
||||
List<String> ret = getShell().su("pm install " + unhideAPK + ">/dev/null && echo true || echo false");
|
||||
@ -44,30 +44,30 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
|
||||
|
||||
try {
|
||||
// Allow the application to gain root by default
|
||||
PackageManager pm = magiskManager.getPackageManager();
|
||||
PackageManager pm = mm.getPackageManager();
|
||||
int uid = pm.getApplicationInfo(pkg, 0).uid;
|
||||
Policy policy = new Policy(uid, pm);
|
||||
policy.policy = Policy.ALLOW;
|
||||
policy.notification = false;
|
||||
policy.logging = false;
|
||||
magiskManager.suDB.addPolicy(policy);
|
||||
mm.suDB.addPolicy(policy);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hide myself!
|
||||
getShell().su_raw("pm hide " + magiskManager.getPackageName());
|
||||
getShell().su_raw("pm hide " + mm.getPackageName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean b) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null)
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null)
|
||||
return;
|
||||
if (!b) {
|
||||
magiskManager.toast(R.string.hide_manager_fail_toast, Toast.LENGTH_LONG);
|
||||
mm.toast(R.string.hide_manager_fail_toast, Toast.LENGTH_LONG);
|
||||
}
|
||||
super.onPostExecute(b);
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return false;
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return false;
|
||||
|
||||
File install = new File(magiskManager.getApplicationInfo().dataDir, "install");
|
||||
File install = new File(mm.getApplicationInfo().dataDir, "install");
|
||||
getShell().sh_raw("rm -rf " + install);
|
||||
|
||||
List<String> abis = Arrays.asList(Build.SUPPORTED_ABIS);
|
||||
@ -81,7 +81,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
try {
|
||||
// Unzip files
|
||||
mList.add("- Extracting files");
|
||||
try (InputStream in = magiskManager.getContentResolver().openInputStream(mZip)) {
|
||||
try (InputStream in = mm.getContentResolver().openInputStream(mZip)) {
|
||||
if (in == null) throw new FileNotFoundException();
|
||||
BufferedInputStream buf = new BufferedInputStream(in);
|
||||
buf.mark(Integer.MAX_VALUE);
|
||||
@ -106,7 +106,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
||||
boot = new File(install, "boot.img");
|
||||
// Copy boot image to local
|
||||
try (
|
||||
InputStream in = magiskManager.getContentResolver().openInputStream(mBootImg);
|
||||
InputStream in = mm.getContentResolver().openInputStream(mBootImg);
|
||||
OutputStream out = new FileOutputStream(boot);
|
||||
) {
|
||||
if (in == null) throw new FileNotFoundException();
|
||||
|
@ -17,17 +17,17 @@ public class LoadModules extends ParallelTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return null;
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return null;
|
||||
Logger.dev("LoadModules: Loading modules");
|
||||
|
||||
magiskManager.moduleMap = new ValueSortedMap<>();
|
||||
mm.moduleMap = new ValueSortedMap<>();
|
||||
|
||||
for (String path : Utils.getModList(getShell(), MagiskManager.MAGISK_PATH)) {
|
||||
Logger.dev("LoadModules: Adding modules from " + path);
|
||||
try {
|
||||
Module module = new Module(getShell(), path);
|
||||
magiskManager.moduleMap.put(module.getId(), module);
|
||||
mm.moduleMap.put(module.getId(), module);
|
||||
} catch (BaseModule.CacheModException ignored) {}
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ public class LoadModules extends ParallelTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return;
|
||||
magiskManager.moduleLoadDone.publish();
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return;
|
||||
mm.moduleLoadDone.publish();
|
||||
super.onPostExecute(v);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ public class MarkDownWindow extends ParallelTask<Void, Void, String> {
|
||||
Parser parser = Parser.builder().build();
|
||||
HtmlRenderer renderer = HtmlRenderer.builder().build();
|
||||
Node doc = parser.parse(md);
|
||||
return renderer.render(doc);
|
||||
return String.format(
|
||||
"<link rel='stylesheet' type='text/css' href='file:///android_asset/%s.css'/> %s",
|
||||
getMagiskManager().isDarkTheme ? "dark" : "light", renderer.render(doc));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,11 +38,6 @@ public class MarkDownWindow extends ParallelTask<Void, Void, String> {
|
||||
alert.setTitle(mTitle);
|
||||
|
||||
WebView wv = new WebView(getActivity());
|
||||
|
||||
html = String.format(
|
||||
"<link rel='stylesheet' type='text/css' href='file:///android_asset/%s.css'/> %s",
|
||||
getMagiskManager().isDarkTheme ? "dark" : "light", html);
|
||||
|
||||
wv.loadDataWithBaseURL("fake://", html, "text/html", "UTF-8", null);
|
||||
|
||||
alert.setView(wv);
|
||||
|
@ -156,8 +156,6 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return null;
|
||||
Logger.dev("UpdateRepos: Loading repos");
|
||||
|
||||
cached = repoDB.getRepoIDList();
|
||||
@ -184,9 +182,9 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
MagiskManager magiskManager = getMagiskManager();
|
||||
if (magiskManager == null) return;
|
||||
magiskManager.repoLoadDone.publish();
|
||||
MagiskManager mm = getMagiskManager();
|
||||
if (mm == null) return;
|
||||
mm.repoLoadDone.publish();
|
||||
super.onPostExecute(v);
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,7 @@ public class Activity extends AppCompatActivity {
|
||||
permissionGrantCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagiskManager getApplicationContext() {
|
||||
public MagiskManager getMagiskManager() {
|
||||
return (MagiskManager) super.getApplicationContext();
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,6 @@ import android.support.design.widget.Snackbar;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class SnackbarMaker {
|
||||
|
||||
public static Snackbar make(Activity activity, CharSequence text, int duration) {
|
||||
@ -32,7 +30,7 @@ public class SnackbarMaker {
|
||||
}
|
||||
|
||||
private static void setup(Snackbar snack) {
|
||||
TextView text = ButterKnife.findById(snack.getView(), android.support.design.R.id.snackbar_text);
|
||||
TextView text = snack.getView().findViewById(android.support.design.R.id.snackbar_text);
|
||||
text.setMaxLines(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
|
||||
onDownloadDone(uri);
|
||||
break;
|
||||
default:
|
||||
Toast.makeText(context, R.string.download_file_error, Toast.LENGTH_LONG).show();
|
||||
Utils.getMagiskManager(context).toast(R.string.download_file_error, Toast.LENGTH_LONG);
|
||||
break;
|
||||
}
|
||||
context.unregisterReceiver(this);
|
||||
|
@ -59,7 +59,7 @@ public class SuRequestActivity extends Activity {
|
||||
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
pm = getPackageManager();
|
||||
magiskManager = getApplicationContext();
|
||||
magiskManager = getMagiskManager();
|
||||
|
||||
Intent intent = getIntent();
|
||||
socketPath = intent.getStringExtra("socket");
|
||||
|
@ -1,18 +0,0 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class ByteArrayInOutStream extends ByteArrayOutputStream {
|
||||
public ByteArrayInputStream getInputStream() {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf, 0, count);
|
||||
count = 0;
|
||||
buf = new byte[32];
|
||||
return in;
|
||||
}
|
||||
|
||||
public void setBuffer(byte[] buffer) {
|
||||
buf = buffer;
|
||||
count = buffer.length;
|
||||
}
|
||||
}
|
@ -148,10 +148,10 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void clearRepoCache(Context context) {
|
||||
MagiskManager magiskManager = getMagiskManager(context);
|
||||
magiskManager.prefs.edit().remove(UpdateRepos.ETAG_KEY).apply();
|
||||
magiskManager.repoDB.clearRepo();
|
||||
magiskManager.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
|
||||
MagiskManager mm = getMagiskManager(context);
|
||||
mm.prefs.edit().remove(UpdateRepos.ETAG_KEY).apply();
|
||||
mm.repoDB.clearRepo();
|
||||
mm.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
public static String getNameFromUri(Context context, Uri uri) {
|
||||
@ -185,41 +185,41 @@ public class Utils {
|
||||
return networkInfo != null && networkInfo.isConnected();
|
||||
}
|
||||
|
||||
public static void showMagiskUpdate(MagiskManager magiskManager) {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager, MagiskManager.NOTIFICATION_CHANNEL);
|
||||
public static void showMagiskUpdate(MagiskManager mm) {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mm, MagiskManager.NOTIFICATION_CHANNEL);
|
||||
builder.setSmallIcon(R.drawable.ic_magisk)
|
||||
.setContentTitle(magiskManager.getString(R.string.magisk_update_title))
|
||||
.setContentText(magiskManager.getString(R.string.magisk_update_available, magiskManager.remoteMagiskVersionString))
|
||||
.setContentTitle(mm.getString(R.string.magisk_update_title))
|
||||
.setContentText(mm.getString(R.string.magisk_update_available, mm.remoteMagiskVersionString))
|
||||
.setVibrate(new long[]{0, 100, 100, 100})
|
||||
.setAutoCancel(true);
|
||||
Intent intent = new Intent(magiskManager, SplashActivity.class);
|
||||
Intent intent = new Intent(mm, SplashActivity.class);
|
||||
intent.putExtra(MagiskManager.INTENT_SECTION, "magisk");
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(magiskManager);
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mm);
|
||||
stackBuilder.addParentStack(SplashActivity.class);
|
||||
stackBuilder.addNextIntent(intent);
|
||||
PendingIntent pendingIntent = stackBuilder.getPendingIntent(MAGISK_UPDATE_NOTIFICATION_ID,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) magiskManager.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
(NotificationManager) mm.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(MAGISK_UPDATE_NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
public static void showManagerUpdate(MagiskManager magiskManager) {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager, MagiskManager.NOTIFICATION_CHANNEL);
|
||||
public static void showManagerUpdate(MagiskManager mm) {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(mm, MagiskManager.NOTIFICATION_CHANNEL);
|
||||
builder.setSmallIcon(R.drawable.ic_magisk)
|
||||
.setContentTitle(magiskManager.getString(R.string.manager_update_title))
|
||||
.setContentText(magiskManager.getString(R.string.manager_download_install))
|
||||
.setContentTitle(mm.getString(R.string.manager_update_title))
|
||||
.setContentText(mm.getString(R.string.manager_download_install))
|
||||
.setVibrate(new long[]{0, 100, 100, 100})
|
||||
.setAutoCancel(true);
|
||||
Intent intent = new Intent(magiskManager, ManagerUpdate.class);
|
||||
intent.putExtra(MagiskManager.INTENT_LINK, magiskManager.managerLink);
|
||||
intent.putExtra(MagiskManager.INTENT_VERSION, magiskManager.remoteManagerVersionString);
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(magiskManager,
|
||||
Intent intent = new Intent(mm, ManagerUpdate.class);
|
||||
intent.putExtra(MagiskManager.INTENT_LINK, mm.managerLink);
|
||||
intent.putExtra(MagiskManager.INTENT_VERSION, mm.remoteManagerVersionString);
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(mm,
|
||||
APK_UPDATE_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) magiskManager.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
(NotificationManager) mm.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(APK_UPDATE_NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,12 @@ public class WebService {
|
||||
InputStream in = request(GET, url, header);
|
||||
if (in == null) return "";
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
String line;
|
||||
int len;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
char buf[] = new char[4096];
|
||||
try {
|
||||
while ((line = br.readLine()) != null) {
|
||||
builder.append(line).append("\n");
|
||||
while ((len = br.read(buf)) != -1) {
|
||||
builder.append(buf, 0, len);
|
||||
}
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user