-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace shell2http -> httpshd in code and in backgrond cmd start broa…
…d cast
- Loading branch information
Showing
14 changed files
with
408 additions
and
223 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
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/puutaro/commandclick/proccess/ubuntu/ResAndProcess.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,59 @@ | ||
package com.puutaro.commandclick.proccess.ubuntu | ||
|
||
import android.content.Context | ||
import com.puutaro.commandclick.common.variable.broadcast.extra.UbuntuServerIntentExtra | ||
import com.puutaro.commandclick.common.variable.broadcast.scheme.BroadCastIntentSchemeUbuntu | ||
import com.puutaro.commandclick.proccess.broadcast.BroadcastSender | ||
import com.puutaro.commandclick.util.shell.LinuxCmd | ||
import kotlinx.coroutines.delay | ||
import java.io.File | ||
|
||
object ResAndProcess { | ||
suspend fun wait( | ||
context: Context?, | ||
resFilePath: String, | ||
procName: String, | ||
){ | ||
var beforeLength = 0L | ||
val resFilePathObj = File(resFilePath) | ||
val twoSec = 2000 | ||
val waitMilliSec = 200L | ||
val waitTimes = 200 | ||
for (i in 1..waitTimes) { | ||
delay(waitMilliSec) | ||
val soFarWaitTime = i * waitMilliSec | ||
if( | ||
soFarWaitTime > twoSec | ||
&& !LinuxCmd.isProcessCheck( | ||
context, | ||
procName | ||
) | ||
) break | ||
if ( | ||
!resFilePathObj.isFile | ||
) { | ||
continue | ||
} | ||
val resFileLen = resFilePathObj.length() | ||
if(beforeLength != resFileLen){ | ||
beforeLength = resFileLen | ||
continue | ||
} | ||
if( | ||
LinuxCmd.isProcessCheck( | ||
context, | ||
procName | ||
) | ||
) continue | ||
break | ||
} | ||
BroadcastSender.normalSend( | ||
context, | ||
BroadCastIntentSchemeUbuntu.CMD_KILL_BY_ADMIN.action, | ||
listOf( | ||
UbuntuServerIntentExtra.ubuntuCroutineJobTypeListForKill.schema to | ||
procName | ||
) | ||
) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/puutaro/commandclick/proccess/ubuntu/UbuntuCmdTool.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,25 @@ | ||
package com.puutaro.commandclick.proccess.ubuntu | ||
|
||
import com.puutaro.commandclick.util.str.QuoteTool | ||
|
||
object UbuntuCmdTool { | ||
fun makeRunBashScript( | ||
shellPath: String, | ||
tabSepaArgs: String | ||
): String { | ||
val args = | ||
tabSepaArgs.replace(Regex("[\t]+"), "\t") | ||
.split("\t") | ||
.map { | ||
QuoteTool.compBothQuote( | ||
it, | ||
"\"" | ||
) | ||
}.joinToString("\t") | ||
return listOf( | ||
"bash", | ||
"\"${shellPath}\"", | ||
args | ||
).joinToString(" ") | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/puutaro/commandclick/proccess/ubuntu/UbuntuProcessChecker.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,38 @@ | ||
package com.puutaro.commandclick.proccess.ubuntu | ||
|
||
import android.content.Context | ||
import com.blankj.utilcode.util.ToastUtils | ||
import com.puutaro.commandclick.common.variable.broadcast.scheme.BroadCastIntentSchemeUbuntu | ||
import com.puutaro.commandclick.proccess.broadcast.BroadcastSender | ||
import com.puutaro.commandclick.util.shell.LinuxCmd | ||
|
||
object UbuntuProcessChecker { | ||
fun isExist( | ||
context: Context?, | ||
ubuntuFilesSrc: UbuntuFiles? | ||
): Boolean { | ||
if( | ||
context == null | ||
) return false | ||
val ubuntuFiles = when(ubuntuFilesSrc == null){ | ||
true -> UbuntuFiles(context) | ||
false -> ubuntuFilesSrc | ||
} | ||
if ( | ||
!ubuntuFiles.ubuntuLaunchCompFile.isFile | ||
) { | ||
ToastUtils.showShort("Launch ubuntu") | ||
return false | ||
} | ||
if( | ||
!LinuxCmd.isBasicProcess(context) | ||
) { | ||
BroadcastSender.normalSend( | ||
context, | ||
BroadCastIntentSchemeUbuntu.STOP_UBUNTU_SERVICE.action | ||
) | ||
return false | ||
} | ||
return true | ||
} | ||
} |
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
Oops, something went wrong.