微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > mute video存储空间不足

mute video存储空间不足

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
在图库中选择mute video时,会产生新的video,这个过程中若存储空间不足,则会发生图库异常的现象。
[SOLUTION]
在mute video前,添加存储空间是否充足的判断,具体code如下:
在alps\packages\apps\Gallery2\src\com\android\gallery3d\app\PhotoPage.java:
1. 添加:
import android.os.StatFs;
2. 修改onItEMSelected()方法中的:
case R.id.action_mute: {
/// M: disable mute when sdcard is full. @{
File srcFile = new File(current.getFilePath());
if (!isSpaceEnough(srcFile)) {
Toast.makeText(mActivity,
mActivity.getString(R.string.storage_not_enough),
Toast.LENGTH_SHORT)
.show();
return true;
}
/// @}
///M:fix google bug
// mute video is not done, when long press power key to power off,
// muteVideo runnable still there run after gallery activity destoryed.
mMuteVideo = new MuteVideo(current.getFilePath(),
manager.getContentUri(path), mActivity);
mMuteVideo.muteInBackground();
return true;
}
3. 添加如下方法:
/// M: disable mute when sdcard is full. @{
/**
* get available space which storage source video is in.
* @return the available sapce size, -1 means max storage size.
*/
private long getAvailableSpace(String path) {
try {
// Here just use one directory to stat fs.
StatFs stat = new StatFs(path);
return stat.getAvailableBlocks() * (long) stat.getBlockSize();
} catch (Exception e) {
mtkLog.v(TAG, "Fail to access external storage", e);
}
return -1;
}
/**
* calculate the space for video muted is enough or not
* lowStorageThreshold is reserve space. LCA projec is 9M, the others is 48M.
*/
private boolean isSpaceEnough(File srcFile) {
long spaceNeed;
long lowStorageThreshold;
if (FeatureOption.MTK_LCA_RAM_OPTIMIZE) {
lowStorageThreshold = 9 * 1024 * 1024;
} else {
lowStorageThreshold = 48 * 1024 * 1024;
}
spaceNeed = srcFile.length() + lowStorageThreshold;
if (getAvailableSpace(srcFile.getPath()) < spaceNeed) {
MtkLog.v(TAG, "space is not enough for save mute video");
return false;
} else {
return true;
}
}
/// @}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top