mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
More defensive programming around odd Android exceptions
This commit is contained in:
parent
458923c3cd
commit
9fae90bc3c
|
@ -25,6 +25,8 @@ import android.os.AsyncTask;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finishes an activity after a period of inactivity if the device is on battery power.
|
* Finishes an activity after a period of inactivity if the device is on battery power.
|
||||||
*/
|
*/
|
||||||
|
@ -49,7 +51,11 @@ final class InactivityTimer {
|
||||||
synchronized void onActivity() {
|
synchronized void onActivity() {
|
||||||
cancel();
|
cancel();
|
||||||
inactivityTask = new InactivityAsyncTask();
|
inactivityTask = new InactivityAsyncTask();
|
||||||
|
try {
|
||||||
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
} catch (RejectedExecutionException ree) {
|
||||||
|
Log.w(TAG, "Couldn't schedule inactivity task; ignoring");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void onPause() {
|
synchronized void onPause() {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class ClipboardInterface {
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
try {
|
try {
|
||||||
getManager(context).setPrimaryClip(ClipData.newPlainText(null, text));
|
getManager(context).setPrimaryClip(ClipData.newPlainText(null, text));
|
||||||
} catch (NullPointerException | IllegalStateException e) {
|
} catch (NullPointerException | IllegalStateException | SecurityException e) {
|
||||||
// Have seen this in the wild, bizarrely
|
// Have seen this in the wild, bizarrely
|
||||||
Log.w(TAG, "Clipboard bug", e);
|
Log.w(TAG, "Clipboard bug", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.zxing.client.android.history;
|
package com.google.zxing.client.android.history;
|
||||||
|
|
||||||
|
import android.database.CursorIndexOutOfBoundsException;
|
||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
|
@ -112,6 +113,9 @@ public final class HistoryManager {
|
||||||
Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
|
Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
|
||||||
items.add(new HistoryItem(result, display, details));
|
items.add(new HistoryItem(result, display, details));
|
||||||
}
|
}
|
||||||
|
} catch (CursorIndexOutOfBoundsException cioobe) {
|
||||||
|
Log.w(TAG, cioobe);
|
||||||
|
// continue
|
||||||
} finally {
|
} finally {
|
||||||
close(cursor, db);
|
close(cursor, db);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue