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