Skip to content

Commit edb201c

Browse files
committed
- fixed bug which show number instead of original in preferences action if user have original version of su binary
+ added refresh displayed version of su binary in preferences action after update (before stay old version here) * more effective way to detect su version (don't sleep too long with already updates su binary) * move not translatable strings at the end of strings.xml to better compare translation for translators
1 parent 369e12f commit edb201c

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

res/values/strings.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
<string name="app_name">Superuser</string>
44
<string name="app_name_request">Superuser Request</string>
55

6-
<!-- Do not translate -->
7-
<string name="update_filename">su-2.3.1-bin-signed.zip</string>
8-
96
<string name="permlab_respond">respond to superuser requests</string>
107
<string name="permdesc_respond">Allows the application to respond to requests for superuser access.</string>
118

@@ -30,10 +27,6 @@
3027
<string name="yes">Yes</string>
3128
<string name="no">No</string>
3229

33-
<!-- Do not translate -->
34-
<string name="report_subject">Possibly malicious app found</string>
35-
<string name="report_body">The following package was found to be requesting to respond to Superuser requests.\n\n - %s\n\nPlease investigate.</string>
36-
3730
<string name="tab_apps">Apps</string>
3831
<string name="tab_log">Log</string>
3932
<string name="tab_settings">Settings</string>
@@ -95,4 +88,9 @@
9588
<string name="pref_bin_version_summary">Tap to check for updates</string>
9689

9790
<string name="notification_text">%s has been granted Superuser permissions</string>
91+
92+
<!-- Do not translate -->
93+
<string name="report_subject">Possibly malicious app found</string>
94+
<string name="report_body">The following package was found to be requesting to respond to Superuser requests.\n\n - %s\n\nPlease investigate.</string>
95+
<string name="update_filename">su-2.3.1-bin-signed.zip</string>
9896
</resources>

src/com/noshufou/android/su/Su.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Su extends TabActivity {
2929
private static final int PACKAGE_UNINSTALL = 1;
3030
private static final int SEND_REPORT = 2;
3131

32-
private Context mContext;
32+
private static Context mContext;
3333
private String mMaliciousAppPackage = "";
3434

3535
@Override
@@ -162,20 +162,23 @@ public static String getSuVersion()
162162
process = Runtime.getRuntime().exec("su -v");
163163
InputStream processInputStream = process.getInputStream();
164164
BufferedReader stdInput = new BufferedReader(new InputStreamReader(processInputStream));
165-
Thread.sleep(500);
166165
try {
167-
if (stdInput.ready()) {
168-
String suVersion = stdInput.readLine();
169-
return suVersion;
170-
} else {
171-
return " " + R.string.su_original;
166+
int counter = 0;
167+
while(counter < 20) {
168+
Thread.sleep(50);
169+
if (stdInput.ready()) {
170+
String suVersion = stdInput.readLine();
171+
return suVersion;
172+
}
173+
counter++;
172174
}
175+
return " " + mContext.getString(R.string.su_original);
173176
} finally {
174177
stdInput.close();
175178
}
176179
} catch (IOException e) {
177180
Log.e(TAG, "Call to su failed. Perhaps the wrong version of su is present", e);
178-
return " " + R.string.su_original;
181+
return " " + mContext.getString(R.string.su_original);
179182
} catch (InterruptedException e) {
180183
Log.e(TAG, "Call to su failed.", e);
181184
return " ...";

src/com/noshufou/android/su/SuPreferences.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
2828
db.close();
2929

3030
Preference binVersionPreference = getPreferenceScreen().findPreference("pref_bin_version");
31-
new ShowBinVersion().execute();
31+
updateSuVersionInformation();
3232
binVersionPreference.setOnPreferenceClickListener(this);
3333

3434
Preference clearLogPreference = getPreferenceScreen().findPreference("pref_clear_log");
@@ -72,6 +72,10 @@ public boolean onPreferenceClick(Preference preference) {
7272
return false;
7373
}
7474
}
75+
76+
public void updateSuVersionInformation() {
77+
new ShowBinVersion().execute();
78+
}
7579

7680
private String getSuperuserVersion()
7781
{

src/com/noshufou/android/su/Updater.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ protected Boolean doInBackground(String... params) {
240240
@Override
241241
protected void onPostExecute(Boolean result) {
242242
if (result) {
243+
if (mContext instanceof SuPreferences) {
244+
// update version number after binary update
245+
((SuPreferences)mContext).updateSuVersionInformation();
246+
}
243247
Toast.makeText(mContext, R.string.su_updated, Toast.LENGTH_SHORT).show();
244248
} else {
245249
copyUpdateZip(true);

0 commit comments

Comments
 (0)