fix(android): use login consent instead of native privacy prompt
This commit is contained in:
@@ -107,37 +107,71 @@ try {
|
||||
throw "APK versionName mismatch: got $versionName, expected $($sourceManifest.versionName)"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($ExpectedTermsUrl)) {
|
||||
if ($BuildKind -eq 'custom-base') {
|
||||
# A DCloud custom base APK contains only the native debug runtime. HBuilderX
|
||||
# syncs the compiled www resources separately when it runs the app on a
|
||||
# device, so the legal links cannot truthfully be asserted from the APK.
|
||||
$compiledPrivacyPath = Join-Path $projectRoot 'dist\build\app\androidPrivacy.json'
|
||||
if (-not (Test-Path -LiteralPath $compiledPrivacyPath)) {
|
||||
throw 'Compiled App resources are missing androidPrivacy.json; run build:app first.'
|
||||
}
|
||||
$privacyJson = Get-Content -Raw -Encoding UTF8 -LiteralPath $compiledPrivacyPath
|
||||
if ($BuildKind -eq 'custom-base') {
|
||||
# A DCloud custom base APK contains only the native debug runtime. HBuilderX
|
||||
# syncs the compiled www resources separately when it runs the app on a
|
||||
# device, so both no-prompt and login-link checks use the compiled App files.
|
||||
$compiledPrivacyPath = Join-Path $projectRoot 'dist\build\app\androidPrivacy.json'
|
||||
if (-not (Test-Path -LiteralPath $compiledPrivacyPath)) {
|
||||
throw 'Compiled App resources are missing androidPrivacy.json; run build:app first.'
|
||||
}
|
||||
else {
|
||||
$bundledPrivacyFiles = @(
|
||||
Get-ChildItem -LiteralPath (Join-Path $decodePath 'assets\apps') `
|
||||
-Recurse -File -Filter 'androidPrivacy.json'
|
||||
)
|
||||
if ($bundledPrivacyFiles.Count -ne 1) {
|
||||
throw "Expected exactly one bundled androidPrivacy.json, found $($bundledPrivacyFiles.Count)."
|
||||
}
|
||||
$privacyJson = Get-Content -Raw -Encoding UTF8 -LiteralPath $bundledPrivacyFiles[0].FullName
|
||||
$privacyJson = Get-Content -Raw -Encoding UTF8 -LiteralPath $compiledPrivacyPath
|
||||
$legalAppServiceFiles = @(
|
||||
@(
|
||||
(Join-Path $projectRoot 'dist\build\app\app-service.js'),
|
||||
(Join-Path $projectRoot 'dist\build\app-plus\app-service.js')
|
||||
) |
|
||||
Where-Object { Test-Path -LiteralPath $_ } |
|
||||
Select-Object -First 1
|
||||
)
|
||||
}
|
||||
else {
|
||||
$bundledPrivacyFiles = @(
|
||||
Get-ChildItem -LiteralPath (Join-Path $decodePath 'assets\apps') `
|
||||
-Recurse -File -Filter 'androidPrivacy.json'
|
||||
)
|
||||
if ($bundledPrivacyFiles.Count -ne 1) {
|
||||
throw "Expected exactly one bundled androidPrivacy.json, found $($bundledPrivacyFiles.Count)."
|
||||
}
|
||||
$privacyJson = Get-Content -Raw -Encoding UTF8 -LiteralPath $bundledPrivacyFiles[0].FullName
|
||||
$legalAppServiceFiles = @(
|
||||
Get-ChildItem -LiteralPath (Join-Path $decodePath 'assets\apps') `
|
||||
-Recurse -File -Filter 'app-service.js'
|
||||
)
|
||||
}
|
||||
|
||||
if (-not $privacyJson.Contains($ExpectedTermsUrl)) {
|
||||
throw 'Packaged privacy configuration is missing the expected service agreement URL.'
|
||||
$privacyConfig = $privacyJson | ConvertFrom-Json
|
||||
if ($privacyConfig.prompt -ne 'none') {
|
||||
throw 'Packaged privacy configuration must disable the DCloud native prompt with prompt=none.'
|
||||
}
|
||||
foreach ($templateOnlyField in @(
|
||||
'title',
|
||||
'message',
|
||||
'buttonAccept',
|
||||
'buttonRefuse',
|
||||
'hrefLoader',
|
||||
'second',
|
||||
'disagreeMode',
|
||||
'styles'
|
||||
)) {
|
||||
if ($privacyConfig.PSObject.Properties.Name -contains $templateOnlyField) {
|
||||
throw "Packaged prompt=none privacy configuration must not contain $templateOnlyField."
|
||||
}
|
||||
if (-not $privacyJson.Contains($ExpectedPrivacyUrl)) {
|
||||
throw 'Packaged privacy configuration is missing the expected privacy policy URL.'
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($ExpectedTermsUrl)) {
|
||||
if ($legalAppServiceFiles.Count -ne 1) {
|
||||
throw "Expected exactly one App service for login legal-link verification, found $($legalAppServiceFiles.Count)."
|
||||
}
|
||||
$privacyConfig = $privacyJson | ConvertFrom-Json
|
||||
if ($privacyConfig.prompt -ne 'template') {
|
||||
throw 'Packaged privacy configuration must enable the DCloud native template prompt.'
|
||||
$legalAppService = Get-Content -Raw -Encoding UTF8 -LiteralPath $legalAppServiceFiles[0]
|
||||
if (-not $legalAppService.Contains($ExpectedTermsUrl)) {
|
||||
throw 'Packaged login flow is missing the expected service agreement URL.'
|
||||
}
|
||||
if (-not $legalAppService.Contains($ExpectedPrivacyUrl)) {
|
||||
throw 'Packaged login flow is missing the expected privacy policy URL.'
|
||||
}
|
||||
if (-not $legalAppService.Contains('请先阅读并勾选同意')) {
|
||||
throw 'Packaged login flow is missing the unchecked-consent failure message.'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user