Reecc / roottools

Automatically exported from code.google.com/p/roottools
0 stars 0 forks source link

Root action does not works when phone is sleeping #54

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Do a root action on a service when phone is sleeping

What is the expected output? What do you see instead?
The action should be done imediatly, but with it is only done when the phone go 
out from sleep. It seems that it is wating something that will only work when 
phone is wake up.
If phone is on, the root action is done imediatly with no action from the user.

What version of the product are you using? On what operating system?
I am using the 2.6 lib and tried on the 3.3 lib too.
It's on a 4.3 rom with root granted, my program got root right with no question 
to do it.

Please provide any additional information below.
Here is the code i am using to do root action:
if (RootTools.isAccessGiven())
        {
            CommandCapture command = new CommandCapture(0, "settings put global airplane_mode_on "+enable, "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state "+state);
            try {
                RootTools.getShell(true).add(command);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (TimeoutException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (RootDeniedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

Maybe a do it wrong?

Thank's a lot.

Original issue reported on code.google.com by burn2....@gmail.com on 8 Nov 2013 at 9:45

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I fond a way to solve this problem!
I just force the wake lock with a pm manager:

PowerManager pm = 
(PowerManager)m_context.getSystemService(Context.POWER_SERVICE);
//PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | 
PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sleepytux");
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK| 
PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sleepytux");
wl.acquire();
if (RootTools.isAccessGiven())
        {
            CommandCapture command = new CommandCapture(0, "settings put global airplane_mode_on "+enable, "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state "+state);
            try {
                RootTools.getShell(true).add(command);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (TimeoutException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (RootDeniedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
wl.release();

It should work for all root command. ;)

Original comment by burn2....@gmail.com on 20 Nov 2013 at 5:20