feat: household TV companion with scoped pairing and direct LAN camera strip
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
param([string]$ToolRoot='C:\Users\Administrator\Documents\ChatGPT\优创未来\services\toplc-vpn-android\.tools')
|
||||
$ErrorActionPreference='Stop'
|
||||
$source=Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$stage=Join-Path 'C:\CodexBuild' ('ZhaoDisplay-'+[guid]::NewGuid().ToString('N'))
|
||||
New-Item -ItemType Directory -Path $stage | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $source 'AndroidManifest.xml') -Destination $stage
|
||||
Copy-Item -LiteralPath (Join-Path $source 'res'),(Join-Path $source 'src') -Destination $stage -Recurse
|
||||
$jdk=Join-Path $ToolRoot 'jdk-staging\jdk-21.0.12.1+1'
|
||||
$sdk=Join-Path $ToolRoot 'android-sdk'
|
||||
$bt=Join-Path $sdk 'build-tools\36.0.0'
|
||||
$android=Join-Path $sdk 'platforms\android-37.0\android.jar'
|
||||
$env:JAVA_HOME=$jdk
|
||||
$env:Path="$jdk\bin;$env:Path"
|
||||
$build=Join-Path $stage 'build'
|
||||
New-Item -ItemType Directory -Path $build,"$build\classes","$build\dex","$build\generated" | Out-Null
|
||||
& "$bt\aapt2.exe" compile --dir "$stage\res" -o "$build\compiled.zip"
|
||||
if($LASTEXITCODE){throw 'Resource compilation failed'}
|
||||
& "$bt\aapt2.exe" link -o "$build\unsigned.apk" -I $android --manifest "$stage\AndroidManifest.xml" --java "$build\generated" "$build\compiled.zip"
|
||||
if($LASTEXITCODE){throw 'Resource linking failed'}
|
||||
$sources=@((Get-ChildItem "$stage\src","$build\generated" -Recurse -Filter '*.java').FullName)
|
||||
& "$jdk\bin\javac.exe" -encoding UTF-8 -source 8 -target 8 -cp $android -d "$build\classes" $sources
|
||||
if($LASTEXITCODE){throw 'Java compilation failed'}
|
||||
& "$jdk\bin\jar.exe" cf "$build\classes.jar" -C "$build\classes" .
|
||||
& "$bt\d8.bat" --lib $android --min-api 26 --output "$build\dex" "$build\classes.jar"
|
||||
if($LASTEXITCODE){throw 'Dex compilation failed'}
|
||||
Copy-Item "$build\unsigned.apk" "$build\with-dex.apk"
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
$zip=[IO.Compression.ZipFile]::Open("$build\with-dex.apk",[IO.Compression.ZipArchiveMode]::Update)
|
||||
try{[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,"$build\dex\classes.dex",'classes.dex',[IO.Compression.CompressionLevel]::Optimal) | Out-Null}finally{$zip.Dispose()}
|
||||
& "$bt\zipalign.exe" -f 4 "$build\with-dex.apk" "$build\aligned.apk"
|
||||
$keydir=Join-Path $env:LOCALAPPDATA 'ZhaoDisplay'
|
||||
New-Item -ItemType Directory -Force -Path $keydir | Out-Null
|
||||
$keystore=Join-Path $keydir 'display-signing.jks'
|
||||
if(!(Test-Path -LiteralPath $keystore)){
|
||||
& "$jdk\bin\keytool.exe" -genkeypair -keystore $keystore -storepass android -keypass android -alias zhaodisplay -keyalg RSA -keysize 2048 -validity 10000 -dname 'CN=Zhao Household Display,O=UCVL,C=CN'
|
||||
if($LASTEXITCODE){throw 'Signing key generation failed'}
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path "$source\build" | Out-Null
|
||||
& "$bt\apksigner.bat" sign --ks $keystore --ks-pass pass:android --key-pass pass:android --ks-key-alias zhaodisplay --out "$source\build\ZhaoDisplay.apk" "$build\aligned.apk"
|
||||
if($LASTEXITCODE){throw 'APK signing failed'}
|
||||
& "$bt\apksigner.bat" verify "$source\build\ZhaoDisplay.apk"
|
||||
if($LASTEXITCODE){throw 'APK verification failed'}
|
||||
Write-Output "$source\build\ZhaoDisplay.apk"
|
||||
Reference in New Issue
Block a user