mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-13 03:29:16 +00:00
feat: now can run hello world
This commit is contained in:
parent
1ee343de04
commit
8cdcf4138b
4 changed files with 45 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '2.0.21'
|
ext.kotlin_version = '2.1.21'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
|
5
justfile
Normal file
5
justfile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
|
||||||
|
|
||||||
|
push-server:
|
||||||
|
./gradlew assembleRelease
|
||||||
|
adb push ./server/build/outputs/apk/release/server-release-unsigned.apk /data/local/tmp/souls
|
|
@ -6,7 +6,7 @@ android {
|
||||||
compileSdk 35
|
compileSdk 35
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.genymobile.scrcpy"
|
applicationId "com.genymobile.scrcpy"
|
||||||
minSdkVersion 21
|
minSdkVersion 26
|
||||||
targetSdkVersion 35
|
targetSdkVersion 35
|
||||||
versionCode 30301
|
versionCode 30301
|
||||||
versionName "3.3.1"
|
versionName "3.3.1"
|
||||||
|
@ -22,11 +22,26 @@ android {
|
||||||
buildConfig true
|
buildConfig true
|
||||||
aidl true
|
aidl true
|
||||||
}
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
packaging {
|
||||||
|
resources {
|
||||||
|
excludes += ['META-INF/INDEX.LIST', 'META-INF/io.netty.versions.properties']
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//noinspection GradleDependency
|
//noinspection GradleDependencyleVersion
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.0.21"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.1.21"
|
||||||
|
implementation("io.ktor:ktor-server-netty:3.2.0")
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ import com.genymobile.scrcpy.video.ScreenCapture
|
||||||
import com.genymobile.scrcpy.video.SurfaceCapture
|
import com.genymobile.scrcpy.video.SurfaceCapture
|
||||||
import com.genymobile.scrcpy.video.SurfaceEncoder
|
import com.genymobile.scrcpy.video.SurfaceEncoder
|
||||||
import com.genymobile.scrcpy.video.VideoSource
|
import com.genymobile.scrcpy.video.VideoSource
|
||||||
|
import io.ktor.http.ContentType
|
||||||
|
import io.ktor.server.engine.embeddedServer
|
||||||
|
import io.ktor.server.netty.Netty
|
||||||
|
import io.ktor.server.response.respondText
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import io.ktor.server.routing.routing
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -39,6 +45,19 @@ object Server {
|
||||||
SERVER_PATH = classPaths[0]
|
SERVER_PATH = classPaths[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开启http server
|
||||||
|
*/
|
||||||
|
private fun startHttpServer() {
|
||||||
|
embeddedServer(Netty, 8080) {
|
||||||
|
routing {
|
||||||
|
get("/") {
|
||||||
|
call.respondText("Hello, world!", ContentType.Text.Html)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start(wait = true)
|
||||||
|
}
|
||||||
|
|
||||||
@Throws(IOException::class, ConfigurationException::class)
|
@Throws(IOException::class, ConfigurationException::class)
|
||||||
private fun scrcpy(options: Options) {
|
private fun scrcpy(options: Options) {
|
||||||
if (Build.VERSION.SDK_INT < AndroidVersions.API_31_ANDROID_12 && options.getVideoSource() == VideoSource.CAMERA) {
|
if (Build.VERSION.SDK_INT < AndroidVersions.API_31_ANDROID_12 && options.getVideoSource() == VideoSource.CAMERA) {
|
||||||
|
@ -247,7 +266,8 @@ object Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scrcpy(options)
|
startHttpServer()
|
||||||
|
// scrcpy(options)
|
||||||
} catch (e: ConfigurationException) {
|
} catch (e: ConfigurationException) {
|
||||||
// Do not print stack trace, a user-friendly error-message has already been logged
|
// Do not print stack trace, a user-friendly error-message has already been logged
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue