본문으로 건너뛰기
cccskills
무료GitHub에 공개

service-lifecycle

Reference for Android VPN/proxy service lifecycle: runtime coordinators, status/telemetry flow, where to make changes. Use when touching service start/stop, handover, or coordinator code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md5.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Service Lifecycle

Overview

The Android services are thin shells now. Real lifecycle behavior lives in runtime coordinators plus ServiceStatusReporter, not in a single global app-state singleton.

Service work in this repo usually touches one or more of:

  • start/stop orchestration
  • remembered-policy replay
  • handover-triggered restarts
  • active-policy signature tracking
  • ServiceStateStore status, events, and telemetry
  • hidden first-seen-network quick_v1 diagnostics probes after successful handovers

Architecture

ServiceController.start(mode)
  -> START_ACTION / STOP_ACTION intent
  -> RipDpiVpnService or RipDpiProxyService
  -> ProxyServiceRuntimeCoordinator / VpnServiceRuntimeCoordinator
  -> ConnectionPolicyResolver
  -> proxy / tunnel runtime start-stop-restart
  -> ServiceStatusReporter
  -> ServiceStateStore

Key Components

ComponentLocationRole
ServiceController / DefaultServiceControllercore/service/.../ServiceManager.ktApp entry point for start/stop
RipDpiVpnServicecore/service/.../RipDpiVpnService.ktAndroid VPN service shell
RipDpiProxyServicecore/service/.../RipDpiProxyService.ktAndroid foreground proxy service shell
BaseServiceRuntimeCoordinatorcore/service/.../ServiceRuntimeCoordinator.ktShared mutex, lifecycle state machine, stop/start/handover flow
ProxyServiceRuntimeCoordinatorcore/service/.../ProxyServiceRuntimeCoordinator.ktProxy-mode runtime orchestration
VpnServiceRuntimeCoordinatorcore/service/.../VpnServiceRuntimeCoordinator.ktVPN-mode proxy+tunnel orchestration, resolver refresh, DNS failover
ServiceStatusReportercore/service/.../ServiceStatusReporter.ktMaps runtime changes into UI-facing status/events/telemetry
ServiceStateStorecore/data/.../ServiceStateStore.ktShared StateFlow / SharedFlow store observed by the app
ConnectionPolicyResolvercore/service/.../ConnectionPolicyResolver.ktResolves live or remembered policy for the current network
NetworkHandoverMonitorcore/service/.../NetworkHandoverMonitor.ktDetects actionable network changes
ActiveConnectionPolicyStorecore/service/.../ActiveConnectionPolicyStore.ktPersists active policy metadata for diagnostics and telemetry

State Management

interface ServiceStateStore {
    val status: StateFlow<Pair<AppStatus, Mode>>
    val events: SharedFlow<ServiceEvent>
    val telemetry: StateFlow<ServiceTelemetrySnapshot>

    fun setStatus(status: AppStatus, mode: Mode)
    fun emitFailed(sender: Sender, reason: FailureReason)
    fun updateTelemetry(snapshot: ServiceTelemetrySnapshot)
}

Runtime code should usually write through ServiceStatusReporter. That keeps status, events, and telemetry consistent.

Lifecycle Pattern

Start/stop logic is serialized inside the coordinator mutex:

suspend fun start() {
    mutex.withLock {
        val resolution = resolveInitialConnectionPolicy()
        applyActiveConnectionPolicy(...)
        startResolvedRuntime(...)
        serviceRuntimeRegistry.register(session)
        updateStatus(ServiceStatus.Connected)
        startNetworkHandoverMonitoring()
        startModeTelemetryUpdates()
    }
}

The VPN coordinator adds:

  • VpnTunnelRuntime startup and shutdown
  • resolver refresh via VpnResolverRefreshPlanner
  • encrypted-DNS recovery via VpnEncryptedDnsFailoverController

The proxy coordinator adds:

  • ProxyRuntimeSupervisor startup and shutdown
  • proxy telemetry polling
  • proxy exit handling and failure classification

Where To Make Changes

  1. Change Android service classes only for Android-framework concerns such as intents, foreground-service behavior, or onRevoke().
  2. Change ProxyServiceRuntimeCoordinator or VpnServiceRuntimeCoordinator for runtime orchestration.
  3. Change ServiceStatusReporter for UI-visible status, failure, or telemetry projection.
  4. Change ConnectionPolicyResolver, NetworkHandoverMonitor, or resolver refresh logic when the behavior depends on network context.
  5. Treat ServiceTelemetrySnapshot and ServiceEvent as compatibility-sensitive contracts used by tests, diagnostics, and exports.

Common Mistakes

MistakeFix
Patching only the Android service shellMost lifecycle logic lives in the coordinator layer now
Writing directly to ServiceStateStore from arbitrary runtime codePrefer ServiceStatusReporter so fields stay coherent
Ignoring the coordinator mutex or lifecycle state machineStart/stop/handover paths must stay serialized
Forgetting remembered-policy or handover side effectsService restarts affect policy replay, telemetry, and hidden diagnostics probes
Treating telemetry fields as disposableServiceTelemetrySnapshot is part of the repo’s compatibility surface

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

RIPDPI's own Compose conventions: ViewModel pattern, Route/Screen split, DataStore->StateFlow, RipDpiThemeTokens. Use for how this app does Compose, not generic Compose API questions (see compose).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

po4yka/RIPDPI812026년 10월 20일 업데이트

ADB-based RIPDPI device/emulator debugging: build/install/launch, logcat filtering, fixture port-forwarding, instrumented tests, crash/ANR triage. Use when debugging on a real device or emulator.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

po4yka/RIPDPI812026년 10월 20일 업데이트

RIPDPI Appium launch-contract reference: start routes and permission/service/data presets. Use when a test launches to the wrong screen or a new automation route is added. General flakiness: appium-test-debug.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

po4yka/RIPDPI812026년 10월 20일 업데이트

RIPDPI Appium test authoring: page objects, resource-id locators, assertions, wait tiers. Use when writing a new Appium test or page object, or adding coverage for a new screen.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

po4yka/RIPDPI812026년 10월 20일 업데이트

RIPDPI Appium failure triage: flaky tests, locator/session/wait issues, screenshot and element-tree debugging. Use when an Appium test fails or is flaky.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

po4yka/RIPDPI812026년 10월 20일 업데이트

Add or modify a GitHub Actions job. Use when editing a file under .github/workflows/. Not for running a workflow locally (local-ci-act) or release signing (release-signing).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

po4yka/RIPDPI812026년 10월 20일 업데이트

po4yka의 스킬 모두 보기

이 스킬의 문제 신고