Grant MANAGE_USB permission, so we can get USB serial numbers
This is needed to reliably identify USB mass storage devices. If someone has several identical thumb drives, this prevents a backup from being performed when non-backup drives get attached.
This commit is contained in:
parent
007dd7759d
commit
2c4d44c5b9
4 changed files with 8 additions and 2 deletions
|
@ -14,6 +14,11 @@
|
|||
android:name="android.permission.MANAGE_DOCUMENTS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<!-- This is needed to access the serial number of USB mass storage devices -->
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_USB"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<application
|
||||
android:name=".Backup"
|
||||
android:allowBackup="false"
|
||||
|
|
|
@ -77,7 +77,7 @@ private fun UsbInterface.isMassStorage(): Boolean {
|
|||
|
||||
private fun UsbDevice.log() {
|
||||
Log.d(TAG, " name: $manufacturerName $productName")
|
||||
// Log.d(TAG, " serialNumber: $serialNumber") // requires a permission since API 29
|
||||
Log.d(TAG, " serialNumber: $serialNumber")
|
||||
Log.d(TAG, " productId: $productId")
|
||||
Log.d(TAG, " vendorId: $vendorId")
|
||||
Log.d(TAG, " isMassStorage: ${isMassStorage()}")
|
||||
|
|
|
@ -131,7 +131,7 @@ data class FlashDrive(
|
|||
companion object {
|
||||
fun from(device: UsbDevice) = FlashDrive(
|
||||
name = "${device.manufacturerName} ${device.productName}",
|
||||
serialNumber = "", // device.serialNumber requires a permission since API 29
|
||||
serialNumber = device.serialNumber,
|
||||
vendorId = device.vendorId,
|
||||
productId = device.productId
|
||||
)
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<permissions>
|
||||
<privapp-permissions package="com.stevesoltys.backup">
|
||||
<permission name="android.permission.BACKUP"/>
|
||||
<permission name="android.permission.MANAGE_USB"/>
|
||||
</privapp-permissions>
|
||||
</permissions>
|
Loading…
Reference in a new issue