
格式化内置T卡和外置T卡
使用 根据 加载并初始化 提取并设置布局中的文本内容 定义确认操作的点击事件处理逻辑 在 根据不同的格式化需求启动相应的格式化工具(如 调用
发布日期:2021-05-16 17:47:32
浏览次数:13
分类:精选文章
本文共 2125 字,大约阅读时间需要 7 分钟。
T卡格式化处理
内置T卡格式化
内置T卡的格式化过程主要由com.android.settings.deviceinfo.PrivateVolumeFormat
类负责。该类通过StorageManager
获取存储管理服务,并结合VolumeInfo
中的VolumeId
参数初始化相关UI组件。具体实现步骤如下:
StorageManager
获取存储管理服务VolumeInfo.EXTRA_VOLUME_ID
参数获取具体的体积IDstorage_internal_format
布局文件代码片段:
final StorageManager storage = getActivity().getSystemService(StorageManager.class);final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);final View view = inflater.inflate(R.layout.storage_internal_format, container, false);final TextView body = (TextView) view.findViewById(R.id.body);final Button confirm = (Button) view.findViewById(R.id.confirm);mVolume = storage.findVolumeById(volumeId);if (mVolume == null) { getActivity().finish();} else { mDisk = storage.findDiskById(mVolume.getDiskId()); body.setText(TextUtils.expandTemplate(getText(R.string.storage_internal_format_details), mDisk.getDescription()));}confirm.setOnClickListener(mConfirmListener);
外部T卡格式化
外部T卡的格式化处理主要由Settings$StorageDashboardActivity
和StorageWizardFormatConfirm
类负责。具体流程如下:
Settings$StorageDashboardActivity
中根据用户选择的格式化类型(公用卷或私用卷)启动StorageWizardFormatConfirm
活动StorageWizardFormatConfirm
类通过传递DiskInfo.EXTRA_DISK_ID
和StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE
参数区分公用卷和私用卷格式化需求StorageWizardFormatPublic
或StorageWizardFormatPrivate
)storage.partitionPublic
或storage.partitionInternal
接口执行具体格式化操作代码片段:
} else if (pref == mFormatPublic) { // 外部T卡 final Intent intent = new Intent(context, StorageWizardFormatConfirm.class); intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId()); intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, false); startActivity(intent);} else if (pref == mFormatPrivate) { // 内部T卡 final Intent intent = new Intent(context, StorageWizardFormatConfirm.class); intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId()); intent.putExtra(StorageWizardFormatConfirm.EXTRA_FORMAT_PRIVATE, true); startActivity(intent);}
总结
内置T卡和外部T卡的格式化处理虽然目标不同,但都依赖于StorageManager
服务的核心功能来实现。通过合理的UI设计和逻辑分离,确保了用户能够根据实际需求选择适合的格式化方式,同时保证了系统的稳定性和用户体验。
发表评论
最新留言
关注你微信了!
[***.104.42.241]2025年05月01日 04时48分36秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
自动化测试——UI自动化测试的痛点
2019-03-15
如何将萌推商品主图、属性图、详情图批量保存到电脑的方法
2019-03-15
2021年N1叉车司机模拟考试及N1叉车司机考试软件
2019-03-15
【奇淫巧技】Java动态代理(JDK和cglib)
2019-03-15
【Stimulsoft Reports.Net教程】使用DesignerFx
2019-03-15
攻防世界 Pwn 新手
2019-03-15
mybtis-plus 出现 Wrong namespace
2019-03-15
升级java11后,maven命令打包报错
2019-03-16
springboot redis key乱码
2019-03-16
Win10禁用自带的笔记本键盘
2019-03-16
insmod模块的几种常见错误
2019-03-16
写时复制集合 —— CopyOnWriteArrayList
2019-03-16
什么是redis的缓存雪崩, 穿透, 击穿?
2019-03-16
【转载】DSP基础--定点小数运算
2019-03-16
idea thymeleaf页面变量报错解决
2019-03-16
云游戏,打响5G第一战
2019-03-16
Docker 拉取镜像速度太慢
2019-03-16
【毕设-STM32f103寄存器版本】智能防盗系统
2019-03-16