Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f2174bd

Browse files
committedJun 8, 2014
roottools 3.4 replace 2.6 and caused refactoring because shell calls are
not synchronous anymore
1 parent 9750e22 commit f2174bd

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed
 

‎.classpath

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry exported="true" kind="lib" path="libs/RootTools-2.6.jar"/>
43
<classpathentry kind="lib" path="libs/jackson-all-1.9.11.jar"/>
54
<classpathentry kind="src" path="src"/>
65
<classpathentry kind="src" path="gen"/>

‎libs/RootTools-2.6.jar

-64.2 KB
Binary file not shown.

‎libs/RootTools-3.4.jar

80.4 KB
Binary file not shown.

‎src/com/asksven/android/common/NonRootShell.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9+
10+
911
//import com.asksven.andoid.common.contrib.Shell;
1012
import com.stericson.RootTools.RootTools;
1113
import com.stericson.RootTools.execution.Command;
14+
import com.stericson.RootTools.execution.CommandCapture;
1215
import com.stericson.RootTools.execution.Shell;
1316

1417
/**
@@ -51,7 +54,8 @@ public synchronized List<String> run(String command)
5154
// reopen if for whatever reason the shell got closed
5255
NonRootShell.getInstance();
5356
}
54-
Command shellCommand = new Command(0, command)
57+
58+
CommandCapture shellCommand = new CommandCapture(0, command)
5559
{
5660
@Override
5761
public void output(int id, String line)
@@ -61,7 +65,13 @@ public void output(int id, String line)
6165
};
6266
try
6367
{
64-
m_shell.add(shellCommand).waitForFinish();
68+
m_shell.add(shellCommand);
69+
70+
// we need to make this synchronous
71+
while (!shellCommand.isFinished())
72+
{
73+
Thread.sleep(100);
74+
}
6575
}
6676
catch (Exception e)
6777
{

‎src/com/asksven/android/common/RootShell.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9+
910
//import com.asksven.andoid.common.contrib.Shell;
1011
import com.stericson.RootTools.RootTools;
1112
import com.stericson.RootTools.execution.Command;
13+
import com.stericson.RootTools.execution.CommandCapture;
1214
import com.stericson.RootTools.execution.Shell;
1315

1416
/**
@@ -61,7 +63,8 @@ public synchronized List<String> run(String command)
6163
// reopen if for whatever reason the shell got closed
6264
RootShell.getInstance();
6365
}
64-
Command shellCommand = new Command(0, command)
66+
67+
CommandCapture shellCommand = new CommandCapture(0, command)
6568
{
6669
@Override
6770
public void output(int id, String line)
@@ -71,7 +74,13 @@ public void output(int id, String line)
7174
};
7275
try
7376
{
74-
RootTools.getShell(true).add(shellCommand).waitForFinish();
77+
RootTools.getShell(true).add(shellCommand);
78+
79+
// we need to make this synchronous
80+
while (!shellCommand.isFinished())
81+
{
82+
Thread.sleep(100);
83+
}
7584
}
7685
catch (Exception e)
7786
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2014 asksven
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.asksven.android.common;
17+
18+
import java.util.List;
19+
20+
import junit.framework.TestCase;
21+
22+
/**
23+
* @author sven
24+
*
25+
*/
26+
public class Shell extends TestCase
27+
{
28+
public void testShell()
29+
{
30+
List<String> res = NonRootShell.getInstance().run("ls -l /");
31+
assertTrue(res !=null);
32+
assertTrue(!res.isEmpty());
33+
}
34+
35+
}

0 commit comments

Comments
 (0)