* Modernize CDP handshake so Chrome 147+ inspect link works
Phase 1 of the CDP-modernization fork. Goal: let `chrome://inspect` →
"inspect" (the modern frontend, not the appspot fallback) actually drive
Stetho's Network panel against current Chrome (138-150+).
Root cause: modern Chrome DevTools frontends call ~30 init-time methods
Stetho's MethodDispatcher answered with METHOD_NOT_FOUND. Several of
those (Target.setDiscoverTargets, Storage.getStorageKey, Browser.getVersion,
Page.getNavigationHistory, Runtime.enable, …) are blocking gates in the
frontend's init pipeline — the panel never advances past handshake when
they error out.
Server-side changes:
- MethodDispatcher: unknown methods now return empty success ({}) with
a verbose log instead of METHOD_NOT_FOUND. Modern frontends fan out
far more methods than any Stetho-era device implemented; acknowledging
them is forward-compatible and harmless for read-only panels.
- New Target domain (setDiscoverTargets/setAutoAttach/getTargets/...)
that emits a single Target.targetCreated describing the host process.
- New Browser domain (getVersion/getWindowForTarget) returning Stetho's
identity plus on-device Build info.
- New Storage domain (getStorageKey/getCookies/getUsageAndQuota/...) —
distinct from the legacy DOMStorage; modern Chrome probes
Storage.getStorageKey dozens of times during init.
- Page: add getNavigationHistory + addScriptToEvaluateOnNewDocument
stubs so the back/forward UI populates and document-init scripts are
acknowledged.
- Stetho.DefaultInspectorModulesBuilder: register the three new domains.
Build chain modernization (so the fork can be `includeBuild`'d into
modern AGP 8.x consumers):
- AGP 4.1.2 → 8.9.1, Gradle 6.5 → 8.14.3
- jcenter → mavenCentral
- settings.gradle slimmed to :stetho + :stetho-okhttp3 (drops the
sample app, Rhino, urlconnection, timber)
- Add namespace + Java 17 toolchain on both library modules
- minSdk 14 → 24, compileSdk 30 → 36
- Drop legacy Robolectric/PowerMock test stack and release.gradle
* Drop fallback frontend; impersonate Android WebView's discovery shape
Phase 2 of the modernization. With Phase 1 (handshake stub methods) in
place, Chrome 138+ would still load Stetho's `devtoolsFrontendUrl`
(appspot/cfede9db) under a stricter CSP that strips `unsafe-inline`,
breaking the bundled `Runtime.startApplication('inspector')` script. The
fix is to stop pointing at any external frontend at all — Chrome treats
the absence of `devtoolsFrontendUrl` as "use the bundled chrome-devtools://
inspector", which is what real WebView debugging does.
Discovery (`ChromeDiscoveryHandler`):
- `/json/list[].devtoolsFrontendUrl` removed entirely.
- `/json/list[].type` flipped from "app" to "page" so the bundled
frontend unlocks Network/Console/Sources rather than the limited
"app" target view.
- `/json/list[].webSocketDebuggerUrl` switched to a fully-qualified
form (`ws://localhost/devtools/page/1`) — Chrome rewrites the host
to whatever it forwarded the abstract socket to.
- `/json/version` adds `V8-Version` and a Mozilla-style `User-Agent`,
and reports `Browser` as `Chrome/<version>` (mirroring WebView).
These three fields gate panel feature availability in modern Chrome
frontends.
WebSocket path (`ChromeDevtoolsServer`):
- `PATH` migrates from legacy `/inspector` to `/devtools/page/1`,
matching `DevToolsManagerDelegate`. Bundled frontend hardcodes this
URL shape; the legacy path routes through Chrome's "remote frontend"
loader and triggers the same CSP issue described above.
Result: chrome://inspect → "inspect" link now opens chrome-devtools://
with the modern bundled frontend, no remote-frontend CSP, no inline-
script CSP. Network panel renders OkHttp traffic against the (still
CDP-1.3) Stetho server.
Phase 2c (Network domain field upgrades for Initiator/Timing/Cookie
parity with current CDP) is left for a follow-up.
Drive-by: bumped LogUtil level on the unimplemented-method ack from V
to D, since `adb logcat -d` filters V by default and the trace was
indistinguishable from "frontend stalled" during diagnosis.
* Add maven-publish so JitPack can build the fork
The previous build cleanup dropped the stale jcenter-era release.gradle
without replacing it. JitPack invokes `gradlew publishToMavenLocal` and
returned BUILD FAILED because no project declared that task.
Wires up `maven-publish` on both library modules and exposes the
`release` Android variant for publication. groupId / version are passed
in by JitPack via -Pgroup= / -Pversion=, so we only declare the
publication shape — no hardcoded coordinates.
Verified locally:
./gradlew clean publishToMavenLocal -Pgroup=com.github.lxp-git -Pversion=test-local
produces stetho.aar / stetho-okhttp3.aar plus pom files under
~/.m2/repository/com/github/lxp-git/, which is what JitPack uploads to
its CDN.
---------
Co-authored-by: Xuanping <xuanping@local>