Skip to content

Commit

Permalink
Fix uninstall system apps
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Jul 21, 2015
1 parent deef7b9 commit 2e57b3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void onClick(View view) {
@Override
public void onPositive(MaterialDialog dialog) {
MaterialDialog dialogUninstalling = UtilsDialog.showTitleContentWithProgress(context
, getResources().getString(R.string.dialog_uninstalling)
, String.format(getResources().getString(R.string.dialog_uninstalling),appInfo.getName())
, getResources().getString(R.string.dialog_uninstalling_description));
new UninstallInBackground(context, dialogUninstalling, appInfo).execute();
dialog.dismiss();
Expand Down Expand Up @@ -277,8 +277,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == UNINSTALL_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Log.i("App", "OK");
Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
finish();
startActivity(new Intent(context, MainActivity.class));
startActivity(intent);
} else if (resultCode == RESULT_CANCELED) {
Log.i("App", "CANCEL");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ protected void onPostExecute(Boolean status) {
super.onPostExecute(status);
dialog.dismiss();
if (status) {
Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
activity.finish();
context.startActivity(new Intent(context, MainActivity.class));
context.startActivity(intent);
} else {
UtilsDialog.showTitleContent(context, context.getResources().getString(R.string.dialog_root_required), context.getResources().getString(R.string.dialog_root_required_description));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,19 @@ public static boolean hideWithRootPermission(String apk, Boolean hidden) {
public static boolean uninstallWithRootPermission(String source) {
boolean status = false;
try {
String[] command = new String[]{"su", "-c", "rm -r " + source + "\n"};
String[] command_mount = new String[]{"su", "-c", "mount -o remount,rw /system /system\n"};
String[] command_delete = new String[]{"su", "-c", "rm -r " + "/" + source + "\n"};

Process process = Runtime.getRuntime().exec(command);
Process process = Runtime.getRuntime().exec(command_mount);
process.waitFor();
int i = process.exitValue();
if (i == 0) {
status = true;
process = Runtime.getRuntime().exec(command_delete);
process.waitFor();
i = process.exitValue();
if (i == 0) {
status = true;
}
}
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 2e57b3c

Please sign in to comment.