7

I have tried developer mode and USB debugging is enabled or not,

using the below code changes. it's working fine.

private fun check_My_Android_Mobile_Developer_Mode_Status() {

// solution 1

val adb: Int = Settings.Secure.getInt(this.contentResolver,
            Settings.Global.ADB_ENABLED, 0)

        Toast.makeText(this,"USB Debugging Detect: adb mode:"+adb, Toast.LENGTH_LONG).show()

// solution 2

    if(Settings.Secure.getInt(this.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) {
        // Developer Mode enabled
        Toast.makeText(this,"Developer Mode enabled: Show Alert", Toast.LENGTH_LONG).show()
    } else {
        //Developer Mode does not enabled
        Toast.makeText(this,"Developer does not enabled: Running Safe Mode", Toast.LENGTH_LONG).show()
    }
}

But, I want to check wireless debug mode is enabled or not alone(from developer mode On status). I unable to find any solution.

can anyone help on this. Thanks Advance. Referred links below:

how-to-check-usb-debugging-enabled

wireless-adb-android-11

android-detect-when-adb-active-over-usb

harikrishnan
  • 1,985
  • 4
  • 32
  • 63

1 Answers1

3

Android source code reveals the wifi debugging setting: https://cs.android.com/android/platform/superproject/+/master:packages/apps/Settings/src/com/android/settings/development/WirelessDebuggingEnabler.java;l=73?q=wireless%20debugging

Settings.Global.ADB_WIFI_ENABLED = "adb_wifi_enabled"

fun isWifiAdbEnabled(): Boolean {
    // "this" is your activity or context
    return Settings.Global.getInt(this.contentResolver, "adb_wifi_enabled", 0) != 0
}

Usage:

Toast.makeText(this, "adb mode: ${isWifiAdbEnabled()}", Toast.LENGTH_LONG).show()
Troy
  • 690
  • 1
  • 7
  • 25