• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Superuser


Commit MetaInfo

Revisão2a71bef0dfd91d8cf4adf52ff4aa617102531258 (tree)
Hora2010-08-28 15:31:06
Autortprochazka <tomas.prochazka@atom...>
Commitertprochazka

Mensagem de Log

- fixed problem with freeze on startup if original version of su is avalaible on device and "su -v" doesn't return any stream and application will block on readLine() method.
+ added nullpointer exception handling if downloading of manifest file failed from some reason
* if "su -v" doesn't return nothing version will be show as 'original'

Mudança Sumário

Diff

--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -17,6 +17,8 @@
1717 <string name="su_up_to_date">su is up to date</string>
1818 <string name="checking">Checking...</string>
1919 <string name="no_connection">No network connection. Could not check for updates</string>
20+ <string name="manifest_download_failed">Checking avalaible version failed</string>
21+ <string name="su_original">original</string>
2022
2123 <string name="tab_apps">Apps</string>
2224 <string name="tab_log">Log</string>
--- a/src/com/noshufou/android/su/Su.java
+++ b/src/com/noshufou/android/su/Su.java
@@ -2,8 +2,11 @@ package com.noshufou.android.su;
22
33 import java.io.BufferedReader;
44 import java.io.IOException;
5+import java.io.InputStream;
56 import java.io.InputStreamReader;
67
8+import org.w3c.dom.ProcessingInstruction;
9+
710 import android.app.TabActivity;
811 import android.content.Intent;
912 import android.content.SharedPreferences;
@@ -85,13 +88,25 @@ public class Su extends TabActivity {
8588 Process process = null;
8689 try {
8790 process = Runtime.getRuntime().exec("su -v");
88- BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
89- String suVersion = stdInput.readLine();
90- stdInput.close();
91- return suVersion;
91+ InputStream processInputStream = process.getInputStream();
92+ BufferedReader stdInput = new BufferedReader(new InputStreamReader(processInputStream));
93+ Thread.sleep(500);
94+ try {
95+ if (stdInput.ready()) {
96+ String suVersion = stdInput.readLine();
97+ return suVersion;
98+ } else {
99+ return " " + R.string.su_original;
100+ }
101+ } finally {
102+ stdInput.close();
103+ }
92104 } catch (IOException e) {
93105 Log.e(TAG, "Call to su failed. Perhaps the wrong version of su is present", e);
94- return null;
95- }
106+ return " " + R.string.su_original;
107+ } catch (InterruptedException e) {
108+ Log.e(TAG, "Call to su failed.", e);
109+ return " ...";
110+ }
96111 }
97112 }
--- a/src/com/noshufou/android/su/Updater.java
+++ b/src/com/noshufou/android/su/Updater.java
@@ -173,7 +173,9 @@ public class Updater {
173173
174174 @Override
175175 protected void onPostExecute(String result) {
176- if (result.equals("manifest.json")) {
176+ if (result == null) {
177+ Toast.makeText(mContext, R.string.manifest_download_failed, Toast.LENGTH_SHORT).show();
178+ } else if (result.equals("manifest.json")) {
177179 postManifest();
178180 } else if (result.equals("su")) {
179181 new AutoUpdateTask().execute();