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.util.Log;
|
||||
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
cancel();
|
||||
inactivityTask = new InactivityAsyncTask();
|
||||
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
try {
|
||||
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} catch (RejectedExecutionException ree) {
|
||||
Log.w(TAG, "Couldn't schedule inactivity task; ignoring");
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void onPause() {
|
||||
|
|
|
@ -41,7 +41,7 @@ public final class ClipboardInterface {
|
|||
if (text != null) {
|
||||
try {
|
||||
getManager(context).setPrimaryClip(ClipData.newPlainText(null, text));
|
||||
} catch (NullPointerException | IllegalStateException e) {
|
||||
} catch (NullPointerException | IllegalStateException | SecurityException e) {
|
||||
// Have seen this in the wild, bizarrely
|
||||
Log.w(TAG, "Clipboard bug", e);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.google.zxing.client.android.history;
|
||||
|
||||
import android.database.CursorIndexOutOfBoundsException;
|
||||
import android.database.SQLException;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
|
@ -112,6 +113,9 @@ public final class HistoryManager {
|
|||
Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
|
||||
items.add(new HistoryItem(result, display, details));
|
||||
}
|
||||
} catch (CursorIndexOutOfBoundsException cioobe) {
|
||||
Log.w(TAG, cioobe);
|
||||
// continue
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue