Android SystemUI 通过StorageEventReceiver监听内卡和外卡参考

本文介绍了如何在Android中通过SystemUI的StorageEventReceiver监听内部和外部存储卡的插拔事件,避免使用ACTION_MEDIA_MOUNTED广播直接扫描storage路径的方法。详细解析了SystemUI StorageNotification.java的流程,以及StorageManagerService如何处理Volume状态变更,特别是针对USB设备的监听。通过注册监听器,能够在VolumeInfo状态变化时获取详细信息,区分内卡(TYPE_PRIVATE)和外卡(TYPE_PUBLIC),实现更精确的管理。
摘要由CSDN通过智能技术生成

 u盘插入

03-07 09:26:33.789  3141  3271 D UsbHostManager: USB device attached: vidpid 0951:1666 mfg/product/ver/serial Kingston/DataTraveler 3.0/0.01/60A44C425324F250899718BC hasAudio/HID/Storage: false/false/true
03-07 09:26:33.802  3141  3271 D UsbDeviceDescriptor:   1 configs
03-07 09:26:33.803  3141  3271 D UsbHostManager: Added device UsbDevice[mName=/dev/bus/usb/001/012,mVendorId=2385,mProductId=5734,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Kingston,mProductName=DataTraveler 3.0,mVersion=0.01,mSerialNumber=60A44C425324F250899718BC,mConfigurations=[
03-07 09:26:33.803  3141  3271 D UsbHostManager: UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=150,mInterfaces=[
03-07 09:26:33.803  3141  3271 D UsbHostManager: UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=8,mSubclass=6,mProtocol=80,mEndpoints=[
03-07 09:26:33.803  3141  3271 D UsbHostManager: UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=255]
03-07 09:26:33.803  3141  3271 D UsbHostManager: UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=512,mInterval=255]]]]
03-07 09:26:33.806  3347  3347 I UsbCameraReceiver: action: android.hardware.usb.action.USB_DEVICE_ATTACHED
03-07 09:26:33.815  3141  3162 D UsbDeviceManager: Clear notification
03-07 09:26:33.815  3141  3141 W TelecomManager: Telecom Service not found.
03-07 09:26:34.842    32    32 W kdevtmpfs: type=1400 audit(0.0:16476): avc: denied { create } for name="sda" scontext=u:r:kernel:s0 tcontext=u:object_r:device:s0 tclass=blk_file permissive=0
03-07 09:26:34.880  2866  2877 V vold    : /system/bin/sgdisk
03-07 09:26:34.880  2866  2877 V vold    :     --android-dump
03-07 09:26:34.880  2866  2877 V vold    :     /dev/block/vold/disk:8,0
03-07 09:26:34.858    32    32 W kdevtmpfs: type=1400 audit(0.0:16477): avc: denied { create } for name="sda1" scontext=u:r:kernel:s0 tcontext=u:object_r:device:s0 tclass=blk_file permissive=0
03-07 09:26:34.940  2866  2877 V vold    : DISK gpt 8E72B192-680D-414A-9004-17271C3F78E9
03-07 09:26:34.940  2866  2877 V vold    :
03-07 09:26:34.941  2866  2877 V vold    : PART 1 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 2896B8BB-257B-44EE-8258-DED0A48085D2 Basic data partition
03-07 09:26:34.941  2866  2877 V vold    :
03-07 09:26:34.943  2866  2935 V vold    : /system/bin/blkid
03-07 09:26:34.943  2866  2935 V vold    :     -c
03-07 09:26:34.943  2866  2935 V vold    :     /dev/null
03-07 09:26:34.943  2866  2935 V vold    :     -s
03-07 09:26:34.943  2866  2935 V vold    :     TYPE
03-07 09:26:34.943  2866  2935 V vold    :     -s
03-07 09:26:34.943  2866  2935 V vold    :     UUID
03-07 09:26:34.943  2866  2935 V vold    :     -s
03-07 09:26:34.943  2866  2935 V vold    :     LABEL
03-07 09:26:34.943  2866  2935 V vold    :     /dev/block/vold/public:8,1
03-07 09:26:34.945  3274  3274 D StorageNotification: Notifying about public volume: VolumeInfo{public:8,1}:
03-07 09:26:34.945  3274  3274 D StorageNotification:     type=PUBLIC diskId=disk:8,0 partGuid= mountFlags=VISIBLE mountUserId=0
03-07 09:26:34.945  3274  3274 D StorageNotification:     state=UNMOUNTED
03-07 09:26:34.945  3274  3274 D StorageNotification:     fsType=null fsUuid=null fsLabel=null
03-07 09:26:34.945  3274  3274 D StorageNotification:     path=null internalPath=null
03-07 09:26:34.947  3274  3274 D StorageNotification: Notifying about public volume: VolumeInfo{public:8,1}:
03-07 09:26:34.947  3274  3274 D StorageNotification:     type=PUBLIC diskId=disk:8,0 partGuid= mountFlags=VISIBLE mountUserId=0
03-07 09:26:34.947  3274  3274 D StorageNotification:     state=CHECKING
03-07 09:26:34.947  3274  3274 D StorageNotification:     fsType=null fsUuid=null fsLabel=null
03-07 09:26:34.947  3274  3274 D StorageNotification:     path=null internalPath=null
03-07 09:26:35.004  2866  2935 V vold    : HAVE_DLOPEN -->fat usb label = (null)
03-07 09:26:35.004  2866  2935 V vold    :
03-07 09:26:35.004  2866  2935 V vold    : /dev/block/vold/public:8,1: UUID="1CDF-6053" TYPE="vfat"
03-07 09:26:35.004  2866  2935 V vold    :
03-07 09:26:35.005  2866  2935 V vold    : /system/bin/fsck_msdos
03-07 09:26:35.005  2866  2935 V vold    :     -p
03-07 09:26:35.005  2866  2935 V vold    :     -f
03-07 09:26:35.005  2866  2935 V vold    :     /dev/block/vold/public:8,1
03-07 09:26:35.025  2866  2935 I fsck_msdos: ** /dev/block/vold/public:8,1
03-07 09:26:35.027  2866  2935 I fsck_msdos: ** Phase 1 - Read FAT (compare skipped)
03-07 09:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值