Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Can you suggest me a widget for toggling usb debugging mode for Android? Or could you code it and upload to market, please?

(I need it because of HTC Desire and HD's init process consuming 100% cpu bug. When toggled, it resets to 0)

share|improve this question
1  
I've had usb debugging mode enabled since this fix was first mentioned and other than the annoying missing driver popup from Windows when I plug it in, I've not noticed amy adverse effects. Why do you need to toggle it on and off? –  Matt H Jan 16 '11 at 14:45
    
As I said before, If I do not keep USB debugging mode ON, init process starts to consume 100% cpu in htc desire phones. –  Ahmet Alp Balkan Jan 20 '11 at 10:59

2 Answers 2

up vote 7 down vote accepted

Here installer for easy installation or widget only for manual installation


INSTALLATION INSTRUCTION


Prerequisites:

  1. You must be rooted
  2. You must be able to write to /system/app/ folder. USB Debugging is a "Secure" setting, so this widget must be installed as a system apps. It will not work if you install to the standard install location even in rooted device.


Easy Instruction (Recommended)

  1. Nico have written an easy-to-use installer to automate installation to /system/app/; download it here and run the installer app.
  2. Add the widget to your home screen like regular widget.


Manual installation

If the easy instruction doesn't work, try the manual installation:

  1. Download ADBWidget.apk and save it to your computer
  2. Copy ADBWidget.apk to /system/app

    • Method 1 -- Using Android Debug Bridge (ADB)

      1. Remount /system/app to read-write (see Additional Instructions section below)
      2. adb push ADBWidget-x.x.apk /system/app/ADBWidget.apk (replace x.x with the appropriate version number)
      3. Remount /system/app to read-only
    • Method 2 -- Using Recovery's update.zip (have not been tested yet)

    • Method 3 -- Using Root Explorer (have not been tested yet)
  3. Add ADBWidget to your home screen


Upgrade Instruction

If you're upgrading from a previous version, you do not need to do all of the above again. You can simply install an update on regular application directory by using regular installation methods (e.g. opening the apk from a file explorer). As long as there is a previous version of the widget in the /system/app directory with the same signing key (i.e. my key, if you used the apk download above), Android will give the updated version in /data/app the same permission.


USAGE INSTRUCTION

Click on the widget to toggle USB debugging. Blue USB icon means that USB debugging is inactive, red USB icon means that USB debugging is enabled.


UNINSTALL INSTRUCTION

Since the widget is installed to /system/app, you cannot remove it using standard application uninstaller. So, simply delete the .apk from /system/app.

su
remount /system as read write
rm /system/app/ADBWidget.apk
remount /system as read only


ADDITIONAL INSTRUCTION


Remounting /system/ as read-write

  1. Open "Terminal Emulator" or "adb shell"
  2. Get root permission, type su
  3. Get the device name, type mount | grep /system
  4. You should see something similar to:

    /dev/<device-name> on /system type rfs (ro,codepage=utf8,vfat,fcache(blks)=128,xattr,check=no)

  5. Take note of the <device-name>, and type: mount -o remount,rw /dev/<device-name> /system


Remounting /system/ as read-only

  1. Step 1, 2, 3, 4 same as above
  2. type: mount -o remount,ro /dev/<device-name> /system


TROUBLESHOOTING

  • Sometimes the widget froze and do not responds to clicks. If this happens, removing and re-adding the Widget usually will fix the problem.


NOTE

  • Don't complain about the ugly default icon and widget button, but if you can send me a better icon/widget image, I'd be happy to add it. Now we have an icon, thanks to @Jay.
  • Do not trust strangers that asks you to install an application to /system/app
  • Tested on Samsung Spica i5700 SpicagenMod Froyo.
share|improve this answer
    
Awesome, thanks! You are very fast! But why do we require root access? AFAIK manually enabling it does not require root access. Thanks anyway. –  Ahmet Alp Balkan Jan 20 '11 at 11:00
    
@Ahmet Alp Balkan: the Settings application (the manual way) is a system application, i.e. it is installed in /system/app. In unrooted Android phones, this partition is read-only to maintain the system's integrity and security, and applications which are not installed in /system/app cannot obtain "write secure settings" permission. This widget requires root access only so you can install to /system/app so the widget can obtain the "write secure settings" permission, I don't think you need root for actually using the permission, though I haven't tested on derooted phone yet. –  Lie Ryan Jan 20 '11 at 14:49
    
In short, USB Debugging is a "Secure" setting, only system apps can obtain "write Secure setting" permission, system apps need to be installed in /system/app, only rooted phones can write to /system/app, therefore this app requires root. The Settings app does not require root since it is preinstalled in /system/app. Alternatively, I can easily launch Setting app so you can disable the USB Debugging yourself, but that takes 3 clicks (1 on the widget/icon, 1 on USB debugging, 1 on confirmation) instead of 1 click on widget, just doing that won't require root but is still a hassle. –  Lie Ryan Jan 20 '11 at 17:14
    
Works great, but man that icon is ugly! :-p In the next version, any way to make it indicate that the toggle was successful or indicate whether or not USB debugging is enabled or disabled? (i.e. perhaps the icon is one color for enabled, another for disabled.) Just a thought, but thanks! –  user3042 Feb 21 '11 at 15:40
    
Hi, I look your source code and try to add this option to my application (Widgetsoid) but it's not work for me. I have 02-22 11:26:07.260: WARN/Settings(3652): Setting adb_enabled has moved from android.provider.Settings.System to android.provider.Settings.Secure, returning read-only value. 02-22 11:26:07.260: WARN/Settings(3652): Setting adb_enabled has moved from android.provider.Settings.System to android.provider.Settings.Secure, value is unchanged. What I have doing wrong ? Thanks for helping me. Regards Jim –  user3064 Feb 22 '11 at 14:33

If you have 2.1 or above you can use the drop down notification area to quickly disable debug mode. Sadly that is all I got, turning it on will have to be done manually. I searched and was unable to find a widget.

share|improve this answer

protected by Al E. Sep 15 '11 at 12:36

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.