Fix fucking issue #193 by removing recycle in finalize

This commit is contained in:
hyb1996
2017-05-06 15:29:44 +08:00
parent 68845c9a21
commit ed2ebe1599
24 changed files with 373 additions and 65 deletions

View File

@@ -61,22 +61,22 @@ public class ProcessShell extends AbstractShell implements AutoCloseable {
@Override
public void exit() {
if(mProcess != null) {
if (mProcess != null) {
mProcess.destroy();
mProcess = null;
}
if(mSucceedReader != null){
try{
if (mSucceedReader != null) {
try {
mSucceedReader.close();
}catch (IOException ignored){
} catch (IOException ignored) {
}
mSucceedReader = null;
}
if(mErrorReader != null){
try{
if (mErrorReader != null) {
try {
mErrorReader.close();
}catch (IOException ignored){
} catch (IOException ignored) {
}
mErrorReader = null;
@@ -158,8 +158,8 @@ public class ProcessShell extends AbstractShell implements AutoCloseable {
}
public static Result exec(String[] commands, boolean isRoot) {
try(ProcessShell shell = new ProcessShell(isRoot)){
for(String command : commands){
try (ProcessShell shell = new ProcessShell(isRoot)) {
for (String command : commands) {
shell.exec(command);
}
shell.exec(COMMAND_EXIT);
@@ -173,4 +173,5 @@ public class ProcessShell extends AbstractShell implements AutoCloseable {
}
}
}

View File

@@ -65,7 +65,7 @@ public class UiSelector extends UiGlobalSelector {
public void execute(AccessibilityService service, AccessibilityEvent event) {
AccessibilityNodeInfo root = service.getRootInActiveWindow();
if (root != null) {
result = findOf(new UiObject(root, mAllocator));
result = findOf(UiObject.createRoot(root, mAllocator));
}
}
@@ -96,7 +96,7 @@ public class UiSelector extends UiGlobalSelector {
if (service != null) {
AccessibilityNodeInfo root = service.getRootInActiveWindow();
if (root != null) {
return findOf(new UiObject(root, mAllocator));
return findOf(UiObject.createRoot(root, mAllocator));
}
}
return null;

View File

@@ -200,7 +200,7 @@ public class SimpleActionAutomator {
if (root == null)
return false;
Log.v(TAG, "performAction: " + simpleAction + " root = " + root);
return simpleAction.perform(new UiObject(root));
return simpleAction.perform(UiObject.createRoot(root));
}
private boolean isRunningPackageSelf() {