improvement test app's handling of irregular status file
if it reads an empty line, or have reached end of file, it
will default to the start from beginning scenario.
Change-Id: Ife2e49bf8adf70d6caba7a1d65094401990325a2
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java
index 547cb9f..98a0e9f 100644
--- a/tests/src/com/android/browser/PopularUrlsTest.java
+++ b/tests/src/com/android/browser/PopularUrlsTest.java
@@ -274,16 +274,26 @@
mFile = new File(file);
FileReader input = null;
BufferedReader reader = null;
+ isRecovery = false;
+ iteration = 0;
+ page = 0;
try {
input = new FileReader(mFile);
isRecovery = true;
reader = new BufferedReader(input);
- iteration = Integer.parseInt(reader.readLine());
- page = Integer.parseInt(reader.readLine());
+ String line = reader.readLine();
+ if (line == null)
+ return;
+ iteration = Integer.parseInt(line);
+ line = reader.readLine();
+ if (line == null)
+ return;
+ page = Integer.parseInt(line);
} catch (FileNotFoundException ex) {
- isRecovery = false;
- iteration = 0;
- page = 0;
+ return;
+ } catch (NumberFormatException nfe) {
+ Log.wtf(TAG, "unexpected data in status file, will start from begining");
+ return;
} finally {
try {
if (reader != null) {