Rather than System.exec(), how about using something like (warning:
untested code!):

FileWriter fw = new
FileWriter("/sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-mbc/force_usb_limit_dangerous");
try {
  fw.write("500");
  fw.flush();
} finally {
  fw.close();
}

As long as other has write permission to
/sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-mbc/force_usb_limit_dangerous,
you should be all set. So in init.rc, you'd need something like:

chmod 666 
/sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-mbc/force_usb_limit_dangerous

Jim

On Tue, Jan 27, 2009 at 3:01 AM, Cédric Berger
<cedric.berge...@gmail.com> wrote:
> Hi,
> I tried to write a little android application to be able to monitor the
> charge from usb for my Freerunner (to use a car charger...)
> I do not think that in current version there is a way via android API (?)
> -> I tried to directly issue :
> echo 500 >
> /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-mbc/force_usb_limit_dangerous
> This works via adb shell, when connected to my PC (and charging icon in
> android goes away when switching to 100mA, comes back when 500mA)
> In my application, I used Runtime.getRuntime().exec() to try to do the same.
> This way, reading current values works, so I can successfully exec :
> cat /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-mbc/usb_curlim
> cat /sys/class/power_supply/battery/current_now
> But trying to change usb charge via  exec(sh -c "echo 500 >
> /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-mbc/force_usb_limit_dangerous") 
> fails
> :
> "permission denied" (this is the error I get in the shell process)
> Is there a way to get this to work ? Can my application request permissions
> that will allow it do do this ?
> Or maybe via another method, like JNI ? (but this should not grant more
> rights ?)
> _______________________________________________
> android-freerunner mailing list
> android-freerunner@android.koolu.org
> http://android.koolu.org/listinfo.cgi/android-freerunner-koolu.org
>
>
_______________________________________________
android-freerunner mailing list
android-freerunner@android.koolu.org
http://android.koolu.org/listinfo.cgi/android-freerunner-koolu.org

Reply via email to