OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 package org.chromium.chrome.browser.crash; | 4 package org.chromium.chrome.browser.crash; |
5 | 5 |
6 import android.annotation.TargetApi; | 6 import android.annotation.TargetApi; |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.net.ConnectivityManager; | 8 import android.net.ConnectivityManager; |
9 import android.net.NetworkInfo; | 9 import android.net.NetworkInfo; |
10 import android.os.Build; | 10 import android.os.Build; |
11 import android.os.PersistableBundle; | 11 import android.os.PersistableBundle; |
12 | 12 |
13 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager
; | 13 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager
; |
14 import org.chromium.components.minidump_uploader.MinidumpUploaderDelegate; | 14 import org.chromium.components.minidump_uploader.MinidumpUploaderDelegate; |
15 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa
nager; | 15 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa
nager; |
16 | 16 |
17 import java.io.File; | 17 import java.io.File; |
18 | 18 |
19 /** | 19 /** |
20 * Chrome-specific implementations for minidump uploading logic. | 20 * Chrome-specific implementations for minidump uploading logic. |
21 */ | 21 */ |
22 @TargetApi(Build.VERSION_CODES.M) | 22 @TargetApi(Build.VERSION_CODES.M) |
23 public class ChromeMinidumpUploaderDelegate implements MinidumpUploaderDelegate
{ | 23 public class ChromeMinidumpUploaderDelegate implements MinidumpUploaderDelegate
{ |
24 // PersistableBundle keys: | 24 // PersistableBundle keys: |
25 static final String IS_CLIENT_IN_METRICS_SAMPLE = "isClientInMetricsSample"; | 25 static final String IS_CLIENT_IN_METRICS_SAMPLE = "isClientInMetricsSample"; |
26 static final String IS_CRASH_UPLOAD_DISABLED_BY_COMMAND_LINE = | |
27 "isCrashUploadDisabledByCommandLine"; | |
28 static final String IS_UPLOAD_ENABLED_FOR_TESTS = "isUploadEnabledForTests"; | 26 static final String IS_UPLOAD_ENABLED_FOR_TESTS = "isUploadEnabledForTests"; |
29 | 27 |
30 /** | 28 /** |
31 * The application context in which minidump uploads are running. | 29 * The application context in which minidump uploads are running. |
32 */ | 30 */ |
33 private final Context mContext; | 31 private final Context mContext; |
34 | 32 |
35 /** | 33 /** |
36 * The cached crash reporting permissions. These are cached because the uplo
ad job might run | 34 * The cached crash reporting permissions. These are cached because the uplo
ad job might run |
37 * outside of a context in which the original permissions are easily accessi
ble. | 35 * outside of a context in which the original permissions are easily accessi
ble. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // testing the type of the connection. Implement this change in
M59 -- for M58, it's | 73 // testing the type of the connection. Implement this change in
M59 -- for M58, it's |
76 // more important to maintain consistency with the previous impl
ementation. When | 74 // more important to maintain consistency with the previous impl
ementation. When |
77 // changing this, note that forced uploads do *not* require unme
tered connections. | 75 // changing this, note that forced uploads do *not* require unme
tered connections. |
78 NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkI
nfo(); | 76 NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkI
nfo(); |
79 if (networkInfo == null || !networkInfo.isConnected()) return fa
lse; | 77 if (networkInfo == null || !networkInfo.isConnected()) return fa
lse; |
80 return networkInfo.getType() == ConnectivityManager.TYPE_WIFI | 78 return networkInfo.getType() == ConnectivityManager.TYPE_WIFI |
81 || networkInfo.getType() == ConnectivityManager.TYPE_ETH
ERNET; | 79 || networkInfo.getType() == ConnectivityManager.TYPE_ETH
ERNET; |
82 } | 80 } |
83 | 81 |
84 @Override | 82 @Override |
85 public boolean isCrashUploadDisabledByCommandLine() { | |
86 return mPermissions.getBoolean(IS_CRASH_UPLOAD_DISABLED_BY_COMMA
ND_LINE, false); | |
87 } | |
88 | |
89 @Override | |
90 public boolean isMetricsUploadPermitted() { | 83 public boolean isMetricsUploadPermitted() { |
91 // This method is already represented by isClientInMetricsSample
() and | 84 // This method is already represented by isClientInMetricsSample
() and |
92 // isNetworkAvailableForCrashUploads(), so it's fine to return a
dummy value. | 85 // isNetworkAvailableForCrashUploads(), so it's fine to return a
dummy value. |
93 return true; | 86 return true; |
94 } | 87 } |
95 | 88 |
96 @Override | 89 @Override |
97 public boolean isUsageAndCrashReportingPermittedByUser() { | 90 public boolean isUsageAndCrashReportingPermittedByUser() { |
98 return PrivacyPreferencesManager.getInstance() | 91 return PrivacyPreferencesManager.getInstance() |
99 .isUsageAndCrashReportingPermittedByUser(); | 92 .isUsageAndCrashReportingPermittedByUser(); |
(...skipping 14 matching lines...) Expand all Loading... |
114 @Override | 107 @Override |
115 public void recordUploadSuccess(File minidump) { | 108 public void recordUploadSuccess(File minidump) { |
116 MinidumpUploadService.incrementCrashSuccessUploadCount(minidump.getAbsol
utePath()); | 109 MinidumpUploadService.incrementCrashSuccessUploadCount(minidump.getAbsol
utePath()); |
117 } | 110 } |
118 | 111 |
119 @Override | 112 @Override |
120 public void recordUploadFailure(File minidump) { | 113 public void recordUploadFailure(File minidump) { |
121 MinidumpUploadService.incrementCrashFailureUploadCount(minidump.getAbsol
utePath()); | 114 MinidumpUploadService.incrementCrashFailureUploadCount(minidump.getAbsol
utePath()); |
122 } | 115 } |
123 } | 116 } |
OLD | NEW |