title: Looking to enable and disable (toggle) ADB or USB debugging using command line or in app
body: <p>I'm trying to enable ADB (USB debugging) only when my application is running and disabling it when my application is not. I have full access to the phone and it is rooted, <code>su</code> available, etc., but I cannot find a way to do the toggling.</p>
  
  <p>What I've tried so far:</p>
  
  <pre><code>Process proc = Runtime.getRuntime().exec(new String [] { "su", "-c", "setprop", "persist.service.adb.enable", "0"});
  proc.waitFor();
  Process proc2 = Runtime.getRuntime().exec(new String [] { "su", "-c", "stop", "adbd"});
  proc2.waitFor();
  </code></pre>
  
  <p>This however causes the phone to enter a reboot loop instantaneously.</p>