Skip to content

Commit eda0a64

Browse files
committed
feat: add stable and beta updates with runtime reliability improvements
1 parent b761ce3 commit eda0a64

69 files changed

Lines changed: 3486 additions & 290 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build-apk.yml‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@ name: Verify and Build APKs
22

33
"on":
44
workflow_dispatch:
5+
inputs:
6+
version_name:
7+
description: Version name (for example 1.8.0-beta.1)
8+
required: true
9+
type: string
10+
default: 1.7.6
11+
version_code:
12+
description: Globally increasing Android version code
13+
required: true
14+
type: string
15+
default: '1790000013'
16+
release_channel:
17+
description: stable or beta/canary/rc pre-release metadata
18+
required: true
19+
type: choice
20+
options: [stable, beta]
21+
default: beta
522
push:
623
branches: [main]
724

@@ -14,6 +31,10 @@ env:
1431
jobs:
1532
verify:
1633
runs-on: ubuntu-latest
34+
env:
35+
APP_VERSION_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.version_name || '1.7.6' }}
36+
APP_VERSION_CODE: ${{ github.event_name == 'workflow_dispatch' && inputs.version_code || '1790000013' }}
37+
RELEASE_CHANNEL: ${{ github.event_name == 'workflow_dispatch' && inputs.release_channel || 'beta' }}
1738
steps:
1839
- uses: actions/checkout@v4
1940
with:
@@ -55,14 +76,14 @@ jobs:
5576
# Run separately to avoid a reproduced Kotlin FIR analysis failure during combined builds.
5677
run: ./gradlew lint --max-workers=1 --build-cache --stacktrace
5778
- name: Release APKs
58-
run: ./gradlew :app:assembleRelease :app:exportReleaseApks -PBUILD_REVISION="$GITHUB_SHA" --build-cache --stacktrace
79+
run: ./gradlew :app:assembleRelease :app:exportReleaseApks -PAPP_VERSION_NAME="$APP_VERSION_NAME" -PAPP_VERSION_CODE="$APP_VERSION_CODE" -PBUILD_REVISION="$GITHUB_SHA" --build-cache --stacktrace
5980
env:
6081
KEYSTORE_PASSWORD: ${{ secrets.SIGN_KEYSTORE_PASSWORD }}
6182
KEY_ALIAS: ${{ secrets.SIGN_ALIAS }}
6283
KEY_PASSWORD: ${{ secrets.SIGN_KEY_PASSWORD }}
6384
AMAP_ANDROID_KEY: ${{ secrets.AMAP_ANDROID_KEY }}
6485
- name: Verify signed APKs and upgrade certificate
65-
run: python3 scripts/verify_release_apks.py --version 1.7.5 --version-code 1790000012
86+
run: python3 scripts/verify_release_apks.py --version "$APP_VERSION_NAME" --version-code "$APP_VERSION_CODE" --channel "$RELEASE_CHANNEL"
6687
- name: Upload APKs
6788
uses: actions/upload-artifact@v4
6889
with:

‎app/build.gradle.kts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ plugins {
66
alias(libs.plugins.jetbrains.kotlin.serialization)
77
}
88

9-
val releaseVersionName = providers.gradleProperty("APP_VERSION_NAME").orElse("1.7.5")
10-
val releaseVersionCode = providers.gradleProperty("APP_VERSION_CODE").orElse("1790000012").map(String::toInt)
9+
val releaseVersionName = providers.gradleProperty("APP_VERSION_NAME").orElse("1.7.6")
10+
val releaseVersionCode = providers.gradleProperty("APP_VERSION_CODE").orElse("1790000013").map(String::toInt)
1111
val revision = providers.gradleProperty("BUILD_REVISION").orElse("unknown")
12-
require(releaseVersionName.get().matches(Regex("[0-9]+\\.[0-9]+\\.[0-9]+"))) { "APP_VERSION_NAME must be major.minor.patch" }
12+
require(releaseVersionName.get().matches(Regex("[0-9]+\\.[0-9]+\\.[0-9]+(?:-(?:beta|canary|rc)\\.[0-9]+)?"))) { "APP_VERSION_NAME must be major.minor.patch with optional -beta.N, -canary.N, or -rc.N" }
1313
require(releaseVersionCode.get() in 1..2_100_000_000) { "Invalid APP_VERSION_CODE" }
1414
require(revision.get().matches(Regex("[A-Za-z0-9._-]{1,64}"))) { "Invalid BUILD_REVISION" }
1515

@@ -27,7 +27,7 @@ android {
2727
versionName = releaseVersionName.get()
2828
buildConfigField("String", "GIT_REVISION", "\"${revision.get()}\"")
2929

30-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
30+
testInstrumentationRunner = "com.system.location.service.PortalTestRunner"
3131

3232
// val googleServicesFile = project.file("google-services.json")
3333
// if (!googleServicesFile.exists()) {

‎app/src/androidTest/java/com/system/location/service/MapUiTest.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import java.io.File
2626

2727
@RunWith(AndroidJUnit4::class)
2828
class MapUiTest {
29+
@org.junit.Before fun acceptMapConsentForThisFixture() {
30+
com.system.location.service.privacy.SdkPrivacy.acceptMaps()
31+
}
2932
private val instrumentation = InstrumentationRegistry.getInstrumentation()
3033
@Before fun permissions() {
3134
listOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,

‎app/src/androidTest/java/com/system/location/service/MockProviderDeviceTest.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import kotlinx.coroutines.runBlocking
2828

2929
@RunWith(AndroidJUnit4::class)
3030
class MockProviderDeviceTest {
31+
@org.junit.Before fun acceptMapConsentForThisFixture() {
32+
com.system.location.service.privacy.SdkPrivacy.acceptMaps()
33+
}
3134
private val instrumentation = InstrumentationRegistry.getInstrumentation()
3235
private val context = instrumentation.targetContext
3336
private val manager = context.getSystemService(LocationManager::class.java)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.system.location.service
2+
3+
import androidx.test.runner.AndroidJUnitRunner
4+
import android.app.Application
5+
6+
/** No implicit agreement: each map test fixture explicitly accepts maps. */
7+
class PortalTestRunner : AndroidJUnitRunner() {
8+
override fun callApplicationOnCreate(app: Application) {
9+
// Clear BEFORE Application restores choices or initializes third-party SDKs.
10+
if (androidx.test.platform.app.InstrumentationRegistry.getArguments().getString("freshPrivacy") == "true") {
11+
check(app.getSharedPreferences("sdk_privacy", 0).edit().clear().commit())
12+
}
13+
super.callApplicationOnCreate(app)
14+
}
15+
}

‎app/src/androidTest/java/com/system/location/service/RockerOverlayTest.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import org.hamcrest.Matchers.containsString
2828
/** Integration test for overlay ownership and the user's persisted visibility choice. */
2929
@RunWith(AndroidJUnit4::class)
3030
class RockerOverlayTest {
31+
@org.junit.Before fun acceptMapConsentForThisFixture() {
32+
com.system.location.service.privacy.SdkPrivacy.acceptMaps()
33+
}
3134
@Test fun overlaySurvivesNavigationRecreationAndStopUntilHomeDisablesIt() {
3235
val instrumentation = InstrumentationRegistry.getInstrumentation()
3336
val context = instrumentation.targetContext
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.system.location.service
2+
3+
import androidx.test.core.app.ActivityScenario
4+
import androidx.test.espresso.Espresso.onView
5+
import androidx.test.espresso.action.ViewActions.click
6+
import androidx.test.espresso.assertion.ViewAssertions.matches
7+
import androidx.test.espresso.matcher.ViewMatchers.*
8+
import androidx.test.ext.junit.runners.AndroidJUnit4
9+
import androidx.test.platform.app.InstrumentationRegistry
10+
import com.system.location.service.privacy.SdkPrivacy
11+
import org.junit.Assume.assumeTrue
12+
import org.junit.Assert.*
13+
import org.junit.Before
14+
import org.junit.Test
15+
import org.junit.runner.RunWith
16+
17+
@RunWith(AndroidJUnit4::class)
18+
class SdkPrivacyUiTest {
19+
@Before fun requireFreshPrivacyProcess() {
20+
assumeTrue("Run alone with -e freshPrivacy true", InstrumentationRegistry.getArguments().getString("freshPrivacy") == "true")
21+
assertFalse(SdkPrivacy.mapsAccepted)
22+
assertFalse("Runner must not initialize map SDK", SdkPrivacy.mapsReady)
23+
assertFalse(SdkPrivacy.crashReportingEnabled)
24+
}
25+
26+
@Test fun freshPromptSurvivesRotationDeclineAndLaterExplicitAcceptance() {
27+
ActivityScenario.launch(MainActivity::class.java).use { scenario ->
28+
onView(withText(R.string.map_privacy_title)).check(matches(isDisplayed()))
29+
scenario.onActivity { assertTrue(it.supportFragmentManager.fragments.isEmpty()) }
30+
scenario.recreate()
31+
onView(withText(R.string.map_privacy_title)).check(matches(isDisplayed()))
32+
scenario.onActivity { assertTrue(it.supportFragmentManager.fragments.isEmpty()) }
33+
assertFalse(SdkPrivacy.mapsAccepted)
34+
assertFalse(SdkPrivacy.mapsReady)
35+
onView(withText(R.string.map_privacy_decline)).perform(click())
36+
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
37+
assertEquals(androidx.lifecycle.Lifecycle.State.DESTROYED, scenario.state)
38+
assertFalse(SdkPrivacy.mapsAccepted)
39+
assertFalse(SdkPrivacy.crashReportingEnabled)
40+
}
41+
val instrumentation = InstrumentationRegistry.getInstrumentation()
42+
listOf(android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION,
43+
android.Manifest.permission.POST_NOTIFICATIONS).forEach {
44+
instrumentation.uiAutomation.grantRuntimePermission(instrumentation.targetContext.packageName, it)
45+
}
46+
ActivityScenario.launch(MainActivity::class.java).use { scenario ->
47+
onView(withText(R.string.map_privacy_accept)).perform(click())
48+
assertTrue(SdkPrivacy.mapsAccepted)
49+
assertTrue(SdkPrivacy.mapsReady)
50+
assertFalse(SdkPrivacy.crashReportingEnabled)
51+
assertFalse(SdkPrivacy.crashReportingRequested)
52+
scenario.recreate()
53+
assertTrue(SdkPrivacy.mapsAccepted)
54+
assertFalse(SdkPrivacy.crashReportingEnabled)
55+
}
56+
}
57+
}

‎app/src/androidTest/java/com/system/location/service/SimulationFeaturesTest.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import org.junit.runner.RunWith
2121

2222
@RunWith(AndroidJUnit4::class)
2323
class SimulationFeaturesTest {
24+
@org.junit.Before fun acceptMapConsentForThisFixture() {
25+
com.system.location.service.privacy.SdkPrivacy.acceptMaps()
26+
}
2427
@Test fun androidSaxPreservesSeparatedTracksAndRejectsExternalEntities() {
2528
val route = Route("r", "测试 & 路线", listOf(Wgs84(1.0, 2.0), Wgs84(1.1, 2.1)))
2629
val xml = GpxCodec.encode(listOf(route, route.copy(id = "b", name = "第二段")))

‎app/src/androidTest/java/com/system/location/service/UiDesignTest.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import android.widget.TextView
3232

3333
@RunWith(AndroidJUnit4::class)
3434
class UiDesignTest {
35+
@org.junit.Before fun acceptMapConsentForThisFixture() {
36+
com.system.location.service.privacy.SdkPrivacy.acceptMaps()
37+
}
3538
@Test fun homeHasNoToolbarGapAfterReturningFromEveryOtherPage() {
3639
permissions()
3740
ActivityScenario.launch(MainActivity::class.java).use { scenario ->

‎app/src/main/java/com/system/location/service/LocationServiceApp.kt‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ package com.system.location.service
22

33
import android.app.Application
44
import android.content.Context
5-
import com.amap.api.location.AMapLocationClient
6-
import com.amap.api.maps.MapsInitializer
7-
import com.tencent.bugly.crashreport.CrashReport
8-
import com.system.location.service.android.Bugly
5+
import com.system.location.service.privacy.SdkPrivacy
96

107
class LocationServiceApp: Application() {
118

@@ -15,22 +12,11 @@ class LocationServiceApp: Application() {
1512
// The receiver must not initialize playback or clean the main process's providers.
1613
if (getProcessName() == "$packageName:location_probe") return
1714

18-
// 高德 SDK 隐私合规(必须最先调用,否则 SDK 无法启动)
19-
MapsInitializer.updatePrivacyShow(this, true, true)
20-
MapsInitializer.updatePrivacyAgree(this, true)
21-
AMapLocationClient.updatePrivacyShow(this, true, true)
22-
AMapLocationClient.updatePrivacyAgree(this, true)
23-
24-
CrashReport.initCrashReport(applicationContext)
25-
26-
CrashReport.setUserId(applicationContext, Bugly.getUniqueDeviceId(applicationContext))
27-
CrashReport.setDeviceId(applicationContext, Bugly.getUniqueDeviceId(applicationContext))
28-
CrashReport.setDeviceModel(applicationContext, Bugly.getDeviceModel())
29-
CrashReport.setCollectPrivacyInfo(applicationContext, true)
15+
SdkPrivacy.initialize(this)
3016

3117
com.system.location.service.runtime.ScenarioRuntime.initialize()
3218

33-
//CrashReport.setAllThreadStackEnable(applicationContext, true, true)
19+
// Optional SDK restore failures are isolated by SdkPrivacy; runtime remains usable.
3420
}
3521

3622
companion object {

0 commit comments

Comments
 (0)