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; |