// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.xwalk.runtime.extension.api.device_capabilities;
+package org.xwalk.core.extension.api.device_capabilities;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.os.Build.VERSION;
+import android.os.Build.VERSION_CODES;
import android.os.Environment;
import android.os.StatFs;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import org.xwalk.runtime.extension.XWalkExtensionContext;
+import org.xwalk.core.extension.XWalkExtensionContext;
class DeviceCapabilitiesStorage {
private static final String TAG = "DeviceCapabilitiesStorage";
return file.canRead();
}
+ @SuppressWarnings("deprecation")
public void updateCapacity() {
if (!isValid()) {
return;
StatFs stat = new StatFs(mPath);
// FIXME(halton): After API level 18, use getTotalBytes() and
// getAvailableBytes() instead
- long blockSize = stat.getBlockSize();
- mCapacity = blockSize * stat.getBlockCount();
- mAvailCapacity = blockSize * stat.getAvailableBlocks();
+ long blockSize;
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
+ blockSize = stat.getBlockSizeLong();
+ mCapacity = blockSize * stat.getBlockCountLong();
+ mAvailCapacity = blockSize * stat.getAvailableBlocksLong();
+ } else {
+ blockSize = stat.getBlockSize();
+ mCapacity = blockSize * stat.getBlockCount();
+ mAvailCapacity = blockSize * stat.getAvailableBlocks();
+ }
}
public JSONObject convertToJSON() {