Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java b/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java |
| index b36cfb90293ec972d369f99e0e4a6dcd39e607b0..2deadb8225c6b0c7c50618098bf7be5200a3846d 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java |
| @@ -23,7 +23,8 @@ public class MinidumpUploadService extends IntentService { |
| private static final String TAG = "MinidmpUploadService"; |
| // Intent actions |
| - private static final String ACTION_FIND_LAST = |
| + @VisibleForTesting |
| + static final String ACTION_FIND_LAST = |
| "com.google.android.apps.chrome.crash.ACTION_FIND_LAST"; |
| @VisibleForTesting |
| static final String ACTION_FIND_ALL = |
| @@ -259,4 +260,32 @@ public class MinidumpUploadService extends IntentService { |
| Intent findAndUploadAllCrashesIntent = createFindAndUploadAllCrashesIntent(context); |
| context.startService(findAndUploadAllCrashesIntent); |
| } |
| + |
| + public static void tryUploadLastCrashDump(Context context) { |
| + Intent intent = createFindAndUploadLastCrashIntent(context); |
| + context.startService(intent); |
| + } |
| + |
| + /** |
| + * Checks whether it is the first time restrictions for cellular uploads should apply. Is used |
| + * to determine whether unsent crash uploads should be deleted which should happen only once. |
| + */ |
| + @VisibleForTesting |
| + protected boolean isMinidumpCleanNeeded() { |
|
Yaron
2015/12/04 21:29:30
Where is this used?
|
| + SharedPreferences sharedPreferences = |
| + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); |
| + |
| + // If cellular upload logic is enabled and the preference used for that is not initialized |
| + // then this is the first time that logic is enabled. |
| + boolean cleanNeeded = |
| + !sharedPreferences.contains(MinidumpUploadCallable.PREF_LAST_UPLOAD_DAY) |
| + && PrivacyPreferencesManager.getInstance(getApplicationContext()).isUploadLimited(); |
| + |
| + // Initialize the preference with default value to make sure the above check works only |
| + // once. |
| + if (cleanNeeded) { |
| + sharedPreferences.edit().putInt(MinidumpUploadCallable.PREF_LAST_UPLOAD_DAY, 0).apply(); |
| + } |
| + return cleanNeeded; |
| + } |
| } |