Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaUpdateInfobar.java

Issue 1309143004: Add UMA metrics to record the size of internal memory available on a user's device when the Update … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/record_histogram.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaUpdateInfobar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaUpdateInfobar.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaUpdateInfobar.java
index b92947ed4af1ef36ae3b3e9e991c2132c90dc19e..b557adfe8799ba4995a867ca592e0294426b2f30 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaUpdateInfobar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaUpdateInfobar.java
@@ -4,10 +4,15 @@
package org.chromium.chrome.browser.omaha;
+import android.annotation.TargetApi;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Environment;
+import android.os.StatFs;
import android.os.SystemClock;
import android.util.Log;
@@ -18,6 +23,7 @@ import org.chromium.chrome.browser.infobar.ConfirmInfoBar;
import org.chromium.chrome.browser.infobar.InfoBar;
import org.chromium.chrome.browser.infobar.InfoBarListeners;
+import java.io.File;
import java.util.concurrent.TimeUnit;
@@ -69,6 +75,7 @@ public class OmahaUpdateInfobar extends ConfirmInfoBar {
mActivityContext = activityContext;
mUrl = url;
mShownTime = SystemClock.uptimeMillis();
+ recordInternalStorageSize();
}
private void recordHistograms(int action) {
@@ -78,6 +85,37 @@ public class OmahaUpdateInfobar extends ConfirmInfoBar {
SystemClock.uptimeMillis() - mShownTime, TimeUnit.MILLISECONDS);
}
+ private void recordInternalStorageSize() {
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ File path = Environment.getDataDirectory();
+ StatFs statFs = new StatFs(path.getAbsolutePath());
+ int size;
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ size = getSize(statFs);
+ } else {
+ size = getSizeUpdatedApi(statFs);
+ }
+ RecordHistogram.recordLinearCountHistogram(
+ "GoogleUpdate.InfoBar.InternalStorageSizeAvailable", size, 1, 200, 100);
+ return null;
+ }
+ }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
+ private static int getSizeUpdatedApi(StatFs statFs) {
+ return (int) statFs.getAvailableBytes() / (1024 * 1024);
+ }
+
+ private static int getSize(StatFs statFs) {
+ int blockSize = statFs.getBlockSize();
+ int availableBlocks = statFs.getAvailableBlocks();
+ int size = (blockSize * availableBlocks) / (1024 * 1024);
+ return size;
+ }
+
@Override
public void onCloseButtonClicked() {
mActionTaken = true;
« no previous file with comments | « base/android/record_histogram.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698