Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated hasEnoughSpaceOnSdCard() in RootToolsInternalMethods.java for android-18+ #45

Merged
merged 2 commits into from Aug 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1221,6 +1221,7 @@ else if (RootTools.checkUtil("toolbox"))
* space on SDCard. Will also return <code>false</code>, if the SDCard is not mounted as
* read/write
*/
@SuppressWarnings("deprecation")
public boolean hasEnoughSpaceOnSdCard(long updateSize)
{
RootTools.log("Checking SDcard size and that it is mounted as RW");
Expand All @@ -1231,8 +1232,15 @@ public boolean hasEnoughSpaceOnSdCard(long updateSize)
}
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
long blockSize = 0;
long availableBlocks = 0;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockSize = stat.getBlockSize();
availableBlocks = stat.getAvailableBlocks();
} else {
blockSize = stat.getBlockSizeLong();
availableBlocks = stat.getAvailableBlocksLong();
}
return (updateSize < availableBlocks * blockSize);
}

Expand Down