DBDigital / nookdevs

Automatically exported from code.google.com/p/nookdevs Please note I am not a developer. I only created this to prevent the code from being lost with the shutdown of GoogleCode. If you wish to work on this, contact me and I will add you. :)
0 stars 0 forks source link

Add start/stop adbd to Wifi Locker #44

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please add a start/stop adbd toggle button to the Wifi Locker. This will
allow us to turn off adbd while we're using an open Wifi connection.

Original issue reported on code.google.com by bgalbre...@gmail.com on 7 Mar 2010 at 6:51

GoogleCodeExporter commented 8 years ago
I don't know how to control adbd from an activity. Any idea?

Original comment by hari.swa...@gmail.com on 7 Mar 2010 at 8:26

GoogleCodeExporter commented 8 years ago
mabey turn off and on USB Debugging mode?

Original comment by SkavenAn...@gmail.com on 7 Mar 2010 at 9:00

GoogleCodeExporter commented 8 years ago
in the init.rc script, they run "start adbd" and "stop adbd".  Can you execute a
command from java?

Original comment by bgalbre...@gmail.com on 7 Mar 2010 at 9:47

GoogleCodeExporter commented 8 years ago
I tried that before. doesn't work. I can invoke other shell commands like ls, 
logcat 
etc but not the stop and start commands.
I'll try to debug this and include it in a build once I find a solution.

Original comment by hari.swa...@gmail.com on 7 Mar 2010 at 10:18

GoogleCodeExporter commented 8 years ago
Try:
import android.os.SystemProperties;
SystemProperties.set("persist.service.adb.enable", "1");
SystemProperties.set("persist.service.adb.enable", "0");
(This way is preferable because I think this setting will persist across 
reboots.  
You can use the corresponding .get method to get the current setting.)

Alternatively:
SystemService.start("adbd")
SystemService.stop("adbd")
(Should work but won't persist across reboots; so if user turns adbd off then 
reboots, it will come back on.)

Original comment by jmc...@gmail.com on 8 Mar 2010 at 6:34

GoogleCodeExporter commented 8 years ago
I tried SystemProperties.set("persist.service.adb.enable", "0") yesterday. For 
some 
reason, it doesn't change the value. If I do a get after this, it returns 1 and 
there is no change in the adb connection. 
I'll try the SystemService calls & see if that works. 

Original comment by hari.swa...@gmail.com on 8 Mar 2010 at 1:47

GoogleCodeExporter commented 8 years ago
Not sure if I need to assign any special permissions to access these classes. 
I can call the SystemProperties.get/set and SystemService.start/stop methods 
without 
any exceptions, but there is no effect on the service. I'll try to spend more 
time 
on this next weekend and see what's going on. 
If anyone has a fix/solution, please let me know. 

Thanks,

Original comment by hari.swa...@gmail.com on 8 Mar 2010 at 2:58

GoogleCodeExporter commented 8 years ago
Okay, I think there is a process "AdbSettingsObserver" that may not let you 
directly 
start/stop it.  I think they want you to go through the System Settings.  See
http://developer.android.com/reference/android/provider/Settings.System.html#ADB
_ENAB
LED
Settings.System.putInt(getContentResolver(), Settings.System.ADB_ENABLED, 1);

Unfortunately, that setting was deprecated and moved to a "secure" setting 
starting 
with Cupcake (i.e. Android 1.5--which is what the nook runs and is why your 
efforts 
above failed).  Unfortunately, only system software (signed with the platform 
certificate--not SDK applications) can change these "secure" settings.
See http://groups.google.com/group/android-
discuss/browse_thread/thread/595025c7cd6e6197?pli=1

There must be a way around that.  Could we not edit init.rc to tie the 
start/stop 
procedures to a custom (non-secure) property of our choosing, then set it using 
WifiLocker?

There is a suggestion here
http://www.mail-archive.com/android-beginners@googlegroups.com/msg14879.html
that assigning an app the "android.permission.WRITE_SECURE_SETTINGS" may work 
but 
only if the app is moved into and run from the "system" folder
http://www.mail-archive.com/android-beginners@googlegroups.com/msg17756.html

Original comment by jmc...@gmail.com on 9 Mar 2010 at 1:09

GoogleCodeExporter commented 8 years ago
A better link to the discussion I linked above:
http://groups.google.com/group/android-
beginners/browse_thread/thread/e0cd42df7a097b00

A little but more info with regard to enabling/disbling the GPS (another 
setting 
made "secure" in 1.5):
http://www.seangri-la.com/cgi-bin/moin.cgi/Enabling_GPS_
(and_other_location_providers)_when_user_has_disabled_them

If that still doesn't work, I think you may be able to take the user to the GUI 
settings page that controls whether to start adbd by using the 
ACTION_APPLICATION_DEVELOPMENT_SETTINGS activity.  I think it is the "USB 
Debugging" 
option.

Original comment by jmc...@gmail.com on 9 Mar 2010 at 1:25

GoogleCodeExporter commented 8 years ago
Thanks for the details. I'll go thro' it over the weekend. 
We already tried the ACTION_APPLICATION_DEVELOPMENT_SETTINGS activity approach 
for 
enabling non_market apps. This activity is not there in the system for nook.

Original comment by hari.swa...@gmail.com on 9 Mar 2010 at 2:52

GoogleCodeExporter commented 8 years ago
The "install_non_market_apps" setting was made a secure setting in 1.5 also.  
So, the same method used for 
changing it (i.e. running sqlite commands) should work for the adbd setting.  
Of course, the issue is how to do 
that programmatically.  You can't run a .sh script from an app can you?  I 
wonder if you could set up a new 
service in init.rc to do that...

Original comment by jmc...@gmail.com on 9 Mar 2010 at 4:01

GoogleCodeExporter commented 8 years ago
I tried Runtime.exec and ProcessManager class for executing the scripts. I can 
do 
stuff like "ls -l" but when I tried to call setprop/start/stop etc, it doesn't 
do 
anything. 
How to you call a service defined in init.rc? it will probably have the same 
restrictions. I'll check with stangri in IRC on this. He did the softroot 
changes 
and must be familiar with it.

Original comment by hari.swa...@gmail.com on 9 Mar 2010 at 4:12

GoogleCodeExporter commented 8 years ago
It works!. I just had to add android:sharedUserId="android.uid.system" in the 
manifest file and all the secure settings work. I can also call adb shell 
commands 
now.

Original comment by hari.swa...@gmail.com on 9 Mar 2010 at 1:41

GoogleCodeExporter commented 8 years ago
Excellent news!  Another  helpful addition along the same lines would be a 
button to 
start/stop the VNC server...

Original comment by jmc...@gmail.com on 10 Mar 2010 at 12:32

GoogleCodeExporter commented 8 years ago
Added this in version .3.

Original comment by hari.swa...@gmail.com on 14 Mar 2010 at 11:07