From: Marius Gavrilescu Date: Thu, 14 Mar 2013 15:10:49 +0000 (+0200) Subject: Fix a bug in making FonBot a user/system app X-Git-Tag: 0.000_001~52 X-Git-Url: http://git.ieval.ro/?p=fonbot.git;a=commitdiff_plain;h=afce35a4788c248bb49caff285c3cb784a01bd3f Fix a bug in making FonBot a user/system app If FonBot was moved to /system and then updated, it will have apks in both /system/app and /data/app and ApplicationInfo.sourceDir will point to the second one. --- diff --git a/src/ro/ieval/fonbot/FonBotPreferenceActivity.java b/src/ro/ieval/fonbot/FonBotPreferenceActivity.java index 8754825..05a6c65 100644 --- a/src/ro/ieval/fonbot/FonBotPreferenceActivity.java +++ b/src/ro/ieval/fonbot/FonBotPreferenceActivity.java @@ -109,14 +109,15 @@ public final class FonBotPreferenceActivity extends PreferenceActivity { final String remountCommand="mount -o remount,rw /system"; final String copyToSystemCommand="cp "+info.sourceDir+" /system/app/FonBot.apk"; final String chmodSystemCommand="chmod 644 /system/app/FonBot.apk"; + final String rmSystemCommand="rm /system/app/FonBot.apk"; final String copyToUserCommand="cp "+info.sourceDir+" /data/app/FonBot.apk"; final String chmodUserCommand="chmod 644 /data/app/FonBot.apk"; - final String rmCommand="rm "+info.sourceDir; + final String rmUserCommand="rm "+info.sourceDir; if(isChecked){ Runtime.getRuntime().exec(new String[]{ "su", "-c", - remountCommand+';'+copyToSystemCommand+';'+chmodSystemCommand+';'+rmCommand + remountCommand+';'+copyToSystemCommand+';'+chmodSystemCommand+';'+rmUserCommand }).waitFor(); Toast.makeText(FonBotPreferenceActivity.this, @@ -124,9 +125,8 @@ public final class FonBotPreferenceActivity extends PreferenceActivity { } else { Runtime.getRuntime().exec(new String[]{ "su", "-c", - remountCommand+';'+copyToUserCommand+';'+chmodUserCommand+';'+rmCommand + remountCommand+';'+copyToUserCommand+';'+chmodUserCommand+';'+rmSystemCommand }).waitFor(); - Toast.makeText(FonBotPreferenceActivity.this, "Reboot to make FonBot a non-system application", Toast.LENGTH_LONG).show(); }