微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > T卡存满时,对视频静音,出现图库报停和闪退

T卡存满时,对视频静音,出现图库报停和闪退

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
操作步骤:
1. 手机插T卡,T卡空间为0,手机默认存储空间为T卡
2. 进图库打开一个保存在T卡中的视频文件
3. 选择静音功能
现象:
图库闪退,报JE,提示图库停止运行
[SOLUTION]
Solution:在mute之前检测sdcard的空间,如果空间不足就toast提示用户,退出mute
具体修改如下:
photopage.java
1.
import android.os.StatFs;
2. modify case mute:
protected boolean onItEMSelected(MenuItem item) {
....
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;
}
// M: mediatek added functions
case R.id.action_picture_quality: {
...
3. add functions:
/// 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