For project requirements (no root permissions), I need my device to allow USB debugging only on a given computer.
Since I have no root permissions I can't write on data/misc/adb_keys
to delete all the keys that I don't know, so I thought I could dismiss the dialog with which a user allows USB debugging from a computer
I used android.intent.action.CLOSE_SYSTEM_DIALOGS
to close system dialogs and it works with all other dialogs but not for this one:
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
val closeDialog = Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
sendBroadcast(closeDialog)
}
}
Since the dialog is not closed and the above code works with other dialogs, it seems to not be a system dialog closable with ACTION_CLOSE_SYSTEM_DIALOGS
, what kind of dialog is the "Allow USB debugging?" one? How can I programmatically close it?