-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
190 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package me.duck.hooktest.bean; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
@Keep | ||
public class TestGson { | ||
|
||
private int testInt; | ||
private boolean testBoolean; | ||
private String testString; | ||
|
||
public TestGson(int testInt, boolean testBoolean, String testString) { | ||
|
||
this.testInt = testInt; | ||
this.testBoolean = testBoolean; | ||
this.testString = testString; | ||
} | ||
|
||
public String getTestString() { | ||
return testString; | ||
} | ||
|
||
public void setTestString(String testString) { | ||
this.testString = testString; | ||
} | ||
|
||
public boolean isTestBoolean() { | ||
return testBoolean; | ||
} | ||
|
||
public void setTestBoolean(boolean testBoolean) { | ||
this.testBoolean = testBoolean; | ||
} | ||
|
||
public int getTestInt() { | ||
return testInt; | ||
} | ||
|
||
public void setTestInt(int testInt) { | ||
this.testInt = testInt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package me.duck.hooktest.utils; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class ShellUtils { | ||
private static final String KEY_COMMAND_SHELL = "sh"; | ||
private static final String KEY_LINE_END_CHAR = "\n"; | ||
private static final String KEY_EXIT = "exit\n"; | ||
|
||
public static String execCmd(String command) { | ||
return execCmd(new String[]{command}).trim(); | ||
} | ||
|
||
public static String execCmd(String[] commands) { | ||
Process process = null; | ||
BufferedReader reader = null; | ||
InputStreamReader inputStream = null; | ||
DataOutputStream outputStream = null; | ||
try { | ||
process = Runtime.getRuntime().exec(KEY_COMMAND_SHELL); | ||
inputStream = new InputStreamReader(process.getInputStream()); | ||
reader = new BufferedReader(inputStream); | ||
outputStream = new DataOutputStream(process.getOutputStream()); | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
String line; | ||
for (String command : commands) { | ||
outputStream.writeBytes(command + KEY_LINE_END_CHAR); | ||
} | ||
outputStream.writeBytes(KEY_EXIT); | ||
outputStream.flush(); | ||
while ((line = reader.readLine()) != null) { | ||
stringBuilder.append(line).append(KEY_LINE_END_CHAR); | ||
} | ||
process.waitFor(); | ||
return stringBuilder.toString(); | ||
} catch (Exception ignored) { | ||
return "null"; | ||
} finally { | ||
try { | ||
if (outputStream != null) { | ||
outputStream.close(); | ||
} | ||
|
||
if (reader != null) { | ||
reader.close(); | ||
} | ||
|
||
if (inputStream != null) { | ||
inputStream.close(); | ||
} | ||
|
||
if (process != null) { | ||
process.destroy(); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...ck/hooktest/WindowPreferencesManager.java → ...ktest/utils/WindowPreferencesManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters