-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let's see what happens if we substitute Folger's crystals for real co…
…ffee! PiperOrigin-RevId: 676983588
- Loading branch information
1 parent
8e7b420
commit dbe1144
Showing
4 changed files
with
74 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
**New Features** | ||
|
||
* SPA FON | ||
|
||
**Breaking Changes** | ||
|
||
**API Changes** | ||
|
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
65 changes: 65 additions & 0 deletions
65
...ices/shellexecutor/java/androidx/test/services/shellexecutor/UiAutomationShellExecutor.kt
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,65 @@ | ||
package androidx.test.services.shellexecutor | ||
|
||
import android.app.UiAutomation | ||
import android.os.ParcelFileDescriptor | ||
import java.io.InputStream | ||
|
||
/** */ | ||
class UiAutomationShellExecutor(private val uiAutomation: UiAutomation) : ShellExecutor { | ||
override fun getBinderKey(): String { | ||
return BINDER_KEY | ||
} | ||
|
||
override fun executeShellCommandSync( | ||
command: String, | ||
parameters: List<String>, | ||
shellEnv: Map<String, String>, | ||
executeThroughShell: Boolean, | ||
timeoutMs: Long, | ||
): String { | ||
return executeShellCommand(command, parameters, shellEnv, executeThroughShell, timeoutMs) | ||
.readBytes() | ||
.toString(Charsets.UTF_8) | ||
} | ||
|
||
override fun executeShellCommandSync( | ||
command: String, | ||
parameters: List<String>, | ||
shellEnv: Map<String, String>, | ||
executeThroughShell: Boolean, | ||
): String { | ||
return executeShellCommandSync(command, parameters, shellEnv, executeThroughShell, 0) | ||
} | ||
|
||
override fun executeShellCommand( | ||
command: String, | ||
parameters: List<String>, | ||
shellEnv: Map<String, String>, | ||
executeThroughShell: Boolean, | ||
timeoutMs: Long, | ||
): InputStream { | ||
val commandLine = if (executeThroughShell) { | ||
listOf("sh", "-c", command) + parameters | ||
} else { | ||
listOf(command) + parameters | ||
}.joinToString(" ") | ||
// How to set the environment? The command is sent via an IUiAutomationConnection binder. | ||
// Ultimately it's calling java.lang.Runtime.exec(). Which *can* take an envp. That is, in turn, | ||
// using ProcessBuilder. | ||
val parcelFD = uiAutomation.executeShellCommand(commandLine) | ||
return ParcelFileDescriptor.AutoCloseInputStream(parcelFD) | ||
} | ||
|
||
override fun executeShellCommand( | ||
command: String, | ||
parameters: List<String>, | ||
shellEnv: Map<String, String>, | ||
executeThroughShell: Boolean, | ||
): InputStream { | ||
return executeShellCommand(command, parameters, shellEnv, executeThroughShell, 0) | ||
} | ||
|
||
public companion object { | ||
@JvmField val BINDER_KEY = "UiAutomationShellExecutor" | ||
} | ||
} |