ScreenSync MCP guide

Testing Android Local Network Protection with Claude Code

Test Android 17 Local Network Protection, ACCESS_LOCAL_NETWORK permissions, mDNS discovery, and LAN socket timeouts on real devices with Claude Code and ScreenSync MCP.

Minimalist 3D architectural render of an Android smartphone with floating concentric network shield rings linked by glowing purple fiber-optic lines to a developer laptop in deep navy lighting

Android 17 (API level 37) enforces Local Network Protection, ending more than a decade in which any Android application holding the install-time INTERNET permission could scan subnets, resolve .local mDNS hostnames, or open sockets to routers, printers, Cast receivers, and local developer hubs. For engineering teams building smart-home controllers, companion utilities, local-first sync engines, or LAN media tools, upgrading targetSdk to 37 immediately turns previously working local discovery flows into silent TCP connection timeouts and EPERM UDP socket failures unless the app implements ACCESS_LOCAL_NETWORK or adopts system-mediated pickers.

Pairing Claude Code with physical Android hardware through the Model Context Protocol (MCP) lets developers reproduce, diagnose, and validate these kernel-level local network restrictions without tedious manual permission toggling across multiple devices. Using ScreenSync MCP, an Android and browser MCP server created by EpsolDev, Claude Code toggles RESTRICT_LOCAL_NETWORK compatibility flags over ADB, grants and revokes android.permission.ACCESS_LOCAL_NETWORK, inspects live NEARBY_DEVICES system permission sheets with get_ui_hierarchy, correlates OkHttp timeouts against EPERM socket errors in get_logcat, and verifies recovery screens via get_latest_screenshot.

Key Takeaways

  • Android 17 Enforces ACCESS_LOCAL_NETWORK: Apps targeting API level 37 can no longer reach RFC 1918 subnets, link-local ranges, multicast/broadcast addresses, or .local mDNS hostnames using INTERNET alone; they require the runtime ACCESS_LOCAL_NETWORK permission (in the NEARBY_DEVICES group) or a system-mediated picker such as NsdManager FLAG_SHOW_PICKER.
  • Silent TCP Drops vs. EPERM UDP Errors: When blocked by Local Network Protection, outgoing TCP connections in OkHttp or Cronet typically surface as SocketTimeoutException timeouts, whereas raw UDP multicast and broadcast sockets fail immediately with EPERM (Operation not permitted).
  • Decoupled Capture vs. Control Architecture: ScreenSync MCP streams live device frames over your LAN via Android's native MediaProjection API (~94 ms median mirror latency) with no root and no ADB, while ADB handles am compat, pm grant/pm revoke, appops, and interactive control_tap / control_type steps.
  • 226-Tool Cross-Surface QA: The ScreenSync MCP desktop hub (Node.js 18+ on port 3000, MCP over stdio) exposes 29 phone and desktop tools (12 control_*, 3 os_*, 14 capture/hub tools including get_latest_screenshot, get_ui_hierarchy, get_logcat, and record_screen) plus *197 `web_` browser tools** for testing local web companion consoles.
  • Local-First Privacy Model: Screen frames stream directly from the Android app (com.screensync.mcp) to your local desktop hub over your LAN—never passing through EpsolDev servers—while screenshots explicitly requested by an AI agent are sent to that agent's model provider.

How Android 17 Local Network Protection Works Across IP Ranges and Sockets

Android 17 Local Network Protection decouples LAN access from the INTERNET permission by blocking unauthorized traffic to private IPv4 subnets, link-local addresses, multicast groups, and .local mDNS hostnames at the network stack. Apps targeting API level 37 must obtain ACCESS_LOCAL_NETWORK or use system-mediated pickers before communicating with local peripherals.

Historically, Android treated every IP packet leaving a Wi-Fi or Ethernet interface identically once an application declared android.permission.INTERNET in AndroidManifest.xml. Any SDK embedded inside an app could silently probe 192.168.1.1, scan SSDP or mDNS services, fingerprint router MAC-derived hostnames, and infer a user's home or corporate office location without triggering any runtime permission prompt.

Android 16 introduced opt-in test hooks so developers could audit LAN dependencies early. Android 17 (API level 37) turns Local Network Protection into mandatory default enforcement for apps targeting SDK 37 or higher. When an unauthorized app attempts to reach a broadcast-capable local interface (Wi-Fi or Ethernet), the OS network stack enforces two distinct failure modes depending on transport protocol:

  • TCP Connections (OkHttp, Cronet, java.net.Socket, WebView LAN requests): Outgoing SYN packets targeting restricted local addresses are silently dropped or prevented from completing the handshake before leaving the device. High-level HTTP clients rarely receive an explicit SecurityException; instead, they stall until their connect timeout expires and throw SocketTimeoutException or a generic ConnectException.
  • UDP, Multicast, and Broadcast Operations (DatagramSocket, MulticastSocket, SSDP): Sending or receiving multicast, broadcast, or local unicast datagrams without authorization fails synchronously at the POSIX socket layer with EPERM (Operation not permitted).
  • Service Discovery (NsdManager and .local DNS): Unmediated calls to NsdManager.discoverServices(), NsdManager.resolveService(), or InetAddress.getByName("printer.local") are blocked unless ACCESS_LOCAL_NETWORK is granted or the app uses a system-mediated picker.

Crucially, loopback traffic (127.0.0.1 and ::1) remains exempt because it stays inside the host network namespace and cannot probe external LAN hardware. Local DNS resolver traffic on port 53 is likewise handled separately by the platform resolver so standard internet domain lookups continue working normally.

Network Scope / Target Address Range or Protocol Android 16 (Default) Android 17 (targetSdk = 37, Denied) Primary Symptom in Code & Logcat
RFC 1918 Private IPv4 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 Permitted via INTERNET Blocked without ACCESS_LOCAL_NETWORK OkHttp / Cronet SocketTimeoutException on TCP connect
Link-Local & CGNAT 169.254.0.0/16, 100.64.0.0/10 Permitted via INTERNET Blocked without ACCESS_LOCAL_NETWORK Silent TCP drop or EPERM on local socket writes
IPv4 Multicast & Broadcast 224.0.0.0/4, 255.255.255.255 Permitted via INTERNET Blocked without ACCESS_LOCAL_NETWORK Immediate ErrnoException: sendto failed: EPERM
IPv6 Multicast & Link-Local ff00::/8, fe80::/10 Permitted via INTERNET Blocked without ACCESS_LOCAL_NETWORK EPERM on multicast socket bind or group join
mDNS & .local Resolution UDP 5353, NsdManager, .local queries Permitted via INTERNET Blocked unless picker or permission used Discovery callback stalls or fails resolution
Loopback Interface 127.0.0.1, ::1 Permitted Permitted (host namespace) Local embedded mock servers continue responding

Understanding how this kernel-level policy differs from general cellular/Wi-Fi connectivity loss is essential when triaging bugs; compare offline and captive-portal edge cases in our guide on testing Android network resilience with Claude Code and MCP alongside LAN-only permission drops.

Choosing Between ACCESS_LOCAL_NETWORK and System-Mediated Pickers

Developers upgrading to Android 17 can satisfy Local Network Protection either by requesting the broad ACCESS_LOCAL_NETWORK runtime permission or by delegating device discovery to a system-mediated picker such as NsdManager DiscoveryRequest.FLAG_SHOW_PICKER. System pickers avoid runtime permission friction and stricter Google Play Console policy reviews.

Before writing automated QA prompts for Claude Code, your team must verify which architectural path the application actually needs. Requesting ACCESS_LOCAL_NETWORK places your app under the NEARBY_DEVICES runtime permission group and triggers a Google Play Console policy declaration requirement: you must demonstrate that unmediated local network discovery or direct LAN communication is core to your app's primary purpose—such as controlling smart-home appliances, printing over Wi-Fi, syncing with a local NAS, or streaming to local hardware.

Integration Approach Manifest Permission Required User Prompt UX Google Play Policy Burden Best Fit Use Case
ACCESS_LOCAL_NETWORK Runtime Permission <uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" /> Standard runtime dialog under NEARBY_DEVICES High — requires core-functionality declaration in Play Console Background companion apps, IoT hub controllers, custom UDP/SSDP discovery
NsdManager System-Mediated Picker None (when scoped strictly to picker-selected endpoint) Native OS device selection sheet Minimal — no broad LAN scan permission requested Connecting on demand to a specific printer, local server, or accessory
System Cast Output Switcher Media3 / Cast SDK integration System media routing sheet Minimal — OS mediates discovery and routing Audio/video casting to TVs and smart speakers

Manifest and Runtime Permission Implementation

When your app genuinely requires direct subnet access (for example, connecting via OkHttp to a user-configured 192.168.x.x REST bridge or running continuous mDNS discovery in the background), declare ACCESS_LOCAL_NETWORK in AndroidManifest.xml and handle the runtime permission launcher cleanly before initializing discovery:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Standard internet permission remains required alongside LAN access -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Required on Android 17 (API 37)+ for unmediated local network traffic -->
    <uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" />

    <application
        android:name=".LocalBridgeApp"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

In your Kotlin Activity or Compose host, check ContextCompat.checkSelfPermission for Manifest.permission.ACCESS_LOCAL_NETWORK (on API 37+) before triggering NsdManager or opening local OkHttp connections, and render an explicit recovery banner if the user denies access:

package com.example.localbridge.network

import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.net.nsd.NsdManager
import android.net.nsd.NsdServiceInfo
import android.os.Build
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat

class LocalDiscoveryController(
    private val activity: ComponentActivity,
    private val onEndpointReady: (String, Int) -> Unit,
    private val onPermissionDenied: () -> Unit
) {
    private val nsdManager =
        activity.getSystemService(Context.NSD_SERVICE) as NsdManager

    private var activeListener: NsdManager.DiscoveryListener? = null

    private val localNetworkLauncher = activity.registerForActivityResult(
        ActivityResultContracts.RequestPermission()
    ) { granted ->
        if (granted) {
            startMdnsDiscovery()
        } else {
            Log.w(TAG, "ACCESS_LOCAL_NETWORK denied; skipping LAN scan")
            onPermissionDenied()
        }
    }

    fun ensureLocalAccessAndDiscover() {
        if (Build.VERSION.SDK_INT < 37) {
            startMdnsDiscovery()
            return
        }
        val state = ContextCompat.checkSelfPermission(
            activity,
            Manifest.permission.ACCESS_LOCAL_NETWORK
        )
        if (state == PackageManager.PERMISSION_GRANTED) {
            startMdnsDiscovery()
        } else {
            localNetworkLauncher.launch(Manifest.permission.ACCESS_LOCAL_NETWORK)
        }
    }

    fun startMdnsDiscovery() {
        stopDiscovery()
        val listener = object : NsdManager.DiscoveryListener {
            override fun onDiscoveryStarted(regType: String) {
                Log.d(TAG, "mDNS discovery started for $regType")
            }

            override fun onServiceFound(serviceInfo: NsdServiceInfo) {
                Log.d(TAG, "Service candidate found: ${serviceInfo.serviceName}")
                nsdManager.resolveService(
                    serviceInfo,
                    object : NsdManager.ResolveListener {
                        override fun onResolveFailed(info: NsdServiceInfo, errorCode: Int) {
                            Log.e(TAG, "mDNS resolve failed: code=$errorCode")
                        }

                        override fun onServiceResolved(resolved: NsdServiceInfo) {
                            val hostAddress = resolved.host?.hostAddress ?: return
                            Log.i(TAG, "Resolved local endpoint $hostAddress:${resolved.port}")
                            onEndpointReady(hostAddress, resolved.port)
                        }
                    }
                )
            }

            override fun onServiceLost(serviceInfo: NsdServiceInfo) {
                Log.d(TAG, "Service lost: ${serviceInfo.serviceName}")
            }

            override fun onDiscoveryStopped(serviceType: String) {
                Log.d(TAG, "mDNS discovery stopped")
            }

            override fun onStartDiscoveryFailed(serviceType: String, errorCode: Int) {
                Log.e(TAG, "startDiscoveryFailed: $errorCode")
                nsdManager.stopServiceDiscovery(this)
            }

            override fun onStopDiscoveryFailed(serviceType: String, errorCode: Int) {
                Log.e(TAG, "stopDiscoveryFailed: $errorCode")
            }
        }
        activeListener = listener
        nsdManager.discoverServices("_http._tcp", NsdManager.PROTOCOL_DNS_SD, listener)
    }

    fun stopDiscovery() {
        activeListener?.let { listener ->
            runCatching { nsdManager.stopServiceDiscovery(listener) }
            activeListener = null
        }
    }

    companion object {
        private const val TAG = "LocalDiscoveryQA"
    }
}

For broader runtime permission test patterns—including educational rationale cards and Android 14+ partial access dialogs—review our walkthrough on testing Android runtime permissions with Claude Code and MCP.

Setting Up ScreenSync MCP and Claude Code for Real-Device LAN Testing

Connecting Claude Code to a real Android phone for Local Network Protection testing requires installing the free ScreenSync MCP app on Android 7.0+ hardware, starting the Node.js 18+ desktop hub on port 3000, and enabling ADB over USB or wireless debugging. Capture streams via MediaProjection without root, while ADB drives permissions and UI taps.

Because Local Network Protection involves real Wi-Fi interfaces, mDNS multicast traffic, and OS-level NEARBY_DEVICES permission sheets, emulators frequently mask real-device timing and router multicast behavior. A physical phone on the same Wi-Fi subnet as your development workstation exposes genuine RFC 1918 routing, mDNS .local resolution, and OkHttp connect timeouts.

Verify these requirements before launching your automated test session:

  1. Android Device: Install the free ScreenSync MCP Android app on Google Play (com.screensync.mcp, version 2.5.7) on any physical phone running Android 7.0 or later (Android 16 or Android 17 hardware is ideal for testing RESTRICT_LOCAL_NETWORK and ACCESS_LOCAL_NETWORK).
  2. Desktop Hub: Download and extract the free ScreenSync MCP desktop hub (version 1.14.4) on Windows, macOS, or Linux with Node.js 18+ installed. Start the hub with start-hub.bat (Windows) or start-hub.sh (macOS/Linux); it listens on HTTP port 3000 and speaks MCP over stdio. Full setup steps are documented in the ScreenSync MCP setup guide.
  3. Pairing and Local Privacy: Pair the Android app with the hub by scanning the hub's QR code or via mDNS auto-discovery on your LAN (note that on Android 17 devices, ScreenSync MCP itself operates cleanly on your local Wi-Fi when paired, and every frame travels strictly from phone to your local hub—never to EpsolDev servers; Google Drive fallback is optional, and screenshots pulled by an agent go to that agent's model provider). Live mirror latency averages roughly 94 ms median on a LAN in our tests.
  4. Separate Capture from ADB Control: ScreenSync MCP uses Android's native MediaProjection API after your per-session consent to stream screen frames with no root and no ADB. By contrast, all interactive control tools (control_tap, control_type, control_swipe) and shell diagnostics (am compat, pm grant, appops get) execute through ADB over USB or wireless debugging.

Register ScreenSync MCP in Claude Code from your terminal:

claude mcp add screensync node "/path/to/hub/screensync-hub.js"

If you run Claude Desktop, Cursor, or VS Code agent mode, add the local stdio entry inside claude_desktop_config.json (or your client's MCP configuration file) with the bearer token printed by your hub:

{
  "mcpServers": {
    "screensync": {
      "command": "node",
      "args": ["/path/to/hub/screensync-hub.js"],
      "env": {
        "SCREEN_SYNC_TOKEN": "your-local-hub-token"
      }
    }
  }
}

Note that ChatGPT's web app requires remote HTTPS MCP endpoints and is not supported; use local stdio-capable clients. To compare how decoupling MediaProjection capture from ADB control avoids frame stalls compared with legacy ADB-only bridges, see our architectural breakdown of Android MCP servers and our deep dive into mDNS and ephemeral token pairing.

Simulating Android 17 Local Network Restrictions via ADB (RESTRICT_LOCAL_NETWORK, pm, and appops)

Developers can force and toggle Android 17 Local Network Protection deterministically over ADB using am compat enable RESTRICT_LOCAL_NETWORK, pm grant and pm revoke for ACCESS_LOCAL_NETWORK, and appops get verification. Claude Code executes these ADB commands in sequence to test both granted and denied LAN code paths without reinstalling builds.

Waiting for every QA engineer to carry an Android 17 preview device slows down regression testing. On Android 16 (API 36) hardware, Android's App Compatibility framework allows you to opt any installed package into local network enforcement on demand, while Android 17 devices enforce the restriction natively for targetSdk = 37 and expose direct pm and appops state inspection.

# 1. Force Local Network Protection enforcement on Android 16 (API 36) test builds
adb shell am compat enable RESTRICT_LOCAL_NETWORK com.example.localbridge

# 2. Verify whether the compatibility change is active for the package
adb shell dumpsys platform_compat | grep -A 3 "RESTRICT_LOCAL_NETWORK"

# 3. Revoke ACCESS_LOCAL_NETWORK to reproduce denied/fresh-install state
adb shell pm revoke com.example.localbridge android.permission.ACCESS_LOCAL_NETWORK

# 4. Inspect AppOps state for local network access
adb shell appops get com.example.localbridge | grep -i local

# 5. Grant ACCESS_LOCAL_NETWORK to test recovery without manual UI tapping
adb shell pm grant com.example.localbridge android.permission.ACCESS_LOCAL_NETWORK

# 6. Clear app state and disable compat override after the test run
adb shell pm clear com.example.localbridge
adb shell am compat disable RESTRICT_LOCAL_NETWORK com.example.localbridge

When Claude Code orchestrates a full test matrix against com.example.localbridge, it separates cold-deny verification (what happens if the user rejects the NEARBY_DEVICES prompt) from live-grant recovery (tapping "Allow" inside the system dialog or invoking pm grant and verifying immediate mDNS resolution).

Verification Step ADB Command / ScreenSync MCP Tool Target Layer Expected Result Under Test
Force API 37 LAN Policy adb shell am compat enable RESTRICT_LOCAL_NETWORK <pkg> Platform Compatibility Local IP & multicast traffic blocked until permitted
Revoke Runtime Permission adb shell pm revoke <pkg> android.permission.ACCESS_LOCAL_NETWORK Package Manager App transitions to ungranted state for fresh-prompt QA
Verify AppOps Policy adb shell appops get <pkg> AppOps Service Confirms ignore / deny vs allow state accurately
Inspect System Prompt get_ui_hierarchy Accessibility / UI Tree Locates system dialog resource IDs (permission_allow_button)
Approve or Deny Dialog control_tap ADB Input Drives real user tap on "Allow" or "Don't allow"
Verify Fallback UI get_latest_screenshot MediaProjection (no root, no ADB) Confirms rationale banner renders cleanly after denial
Diagnose Socket Failures get_logcat ADB Logcat Captures SocketTimeoutException vs ErrnoException: EPERM
Record Flaky Transitions record_screen MediaProjection / Hub Captures multi-step discovery spinner and picker transitions

Catching Silent OkHttp Timeouts and EPERM Multicast Errors with get_logcat and get_ui_hierarchy

Catching Local Network Protection failures reliably requires pairing get_logcat socket error signatures with get_ui_hierarchy UI tree verification so an AI agent distinguishes a blocked local IP from a dead server. Because OkHttp reports blocked LAN requests as SocketTimeoutException while UDP throws EPERM, Logcat correlation prevents misdiagnosis.

When an app runs without ACCESS_LOCAL_NETWORK, developers often misdiagnose the bug as a slow Wi-Fi router or an unresponsive IoT bridge. Why? Because OkHttp does not throw SecurityException: Missing ACCESS_LOCAL_NETWORK. Instead, the TCP SYN never completes, and OkHttp aborts after its connectTimeout window (often 10 seconds), surfacing a misleading timeout exception in UI error banners.

Differentiating TCP Drops from UDP EPERM in Your App

Wrap local HTTP and UDP probes with explicit diagnostic logging and short connect timeouts for LAN endpoints so both your engineers and Claude Code can pinpoint Local Network Protection blocks in under three seconds:

package com.example.localbridge.network

import android.util.Log
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.IOException
import java.net.DatagramPacket
import java.net.DatagramSocket
import java.net.InetAddress
import java.net.SocketTimeoutException
import java.util.concurrent.TimeUnit

class LocalProbeClient {
    private val httpClient = OkHttpClient.Builder()
        .connectTimeout(3, TimeUnit.SECONDS)
        .readTimeout(3, TimeUnit.SECONDS)
        .build()

    suspend fun pingLocalBridge(hostIp: String, port: Int): Result<String> =
        withContext(Dispatchers.IO) {
            val request = Request.Builder()
                .url("http://$hostIp:$port/health")
                .build()
            try {
                httpClient.newCall(request).execute().use { response ->
                    if (!response.isSuccessful) {
                        return@withContext Result.failure(
                            IOException("HTTP ${response.code} from $hostIp:$port")
                        )
                    }
                    Result.success(response.body?.string().orEmpty())
                }
            } catch (timeout: SocketTimeoutException) {
                Log.e(
                    TAG,
                    "LAN TCP timeout to $hostIp:$port — verify ACCESS_LOCAL_NETWORK grant",
                    timeout
                )
                Result.failure(timeout)
            } catch (io: IOException) {
                Log.e(TAG, "LAN TCP error to $hostIp:$port: ${io.message}", io)
                Result.failure(io)
            }
        }

    suspend fun sendSsdpProbe(): Result<Unit> = withContext(Dispatchers.IO) {
        val payload = (
            "M-SEARCH * HTTP/1.1
" +
                "HOST: 239.255.255.250:1900
" +
                "MAN: "ssdp:discover"
" +
                "MX: 1
" +
                "ST: ssdp:all

"
            ).toByteArray()

        try {
            DatagramSocket().use { socket ->
                socket.soTimeout = 2000
                val group = InetAddress.getByName("239.255.255.250")
                val packet = DatagramPacket(payload, payload.size, group, 1900)
                socket.send(packet)
            }
            Result.success(Unit)
        } catch (io: IOException) {
            // Android 17 Local Network Protection throws ErrnoException (EPERM) here
            Log.e(TAG, "Multicast probe failed (${io.message})", io)
            Result.failure(io)
        }
    }

    companion object {
        private const val TAG = "LocalProbeQA"
    }
}

Automating the Dual Structural + Logcat Loop in Claude Code

Once ScreenSync MCP is paired, issue a single structured prompt to Claude Code from your repository root:

"Verify Android 17 Local Network Protection on com.example.localbridge. First revoke android.permission.ACCESS_LOCAL_NETWORK via ADB and enable RESTRICT_LOCAL_NETWORK compat mode, launch .MainActivity, call get_ui_hierarchy and control_tap to deny the permission dialog, trigger the local bridge scan, inspect get_logcat for EPERM or SocketTimeoutException, and take get_latest_screenshot to confirm the rationale UI renders. Then tap 'Retry Permission', tap 'Allow' on the system sheet using get_ui_hierarchy bounds, and verify the local endpoint resolves in get_logcat."

Inside that session, Claude Code executes a deterministic closed loop:

  1. Pre-Condition Enforcement: Runs adb shell am compat enable RESTRICT_LOCAL_NETWORK com.example.localbridge and adb shell pm revoke com.example.localbridge android.permission.ACCESS_LOCAL_NETWORK, then clears Logcat buffers.
  2. System Dialog Inspection (get_ui_hierarchy): When the app launches and invokes localNetworkLauncher.launch(...), Android's com.google.android.permissioncontroller displays the runtime permission dialog. Because system dialogs sit outside your app's own Compose/Espresso test process, Espresso alone cannot tap them—whereas ScreenSync MCP's get_ui_hierarchy reads the live system window tree directly, returning exact clickable bounds for "Allow" and "Don't allow". Relying on Android UI hierarchy trees for AI agents prevents brittle coordinate drift across Pixel, Samsung One UI, and Xiaomi permission sheets.
  3. Denial & Timeout Triage (control_tap + get_logcat): Claude Code taps "Don't allow" via control_tap, triggers the scan button, and streams get_logcat. It confirms that LocalProbeQA logs EPERM on the SSDP UDP socket and SocketTimeoutException on the 192.168.x.x probe—without crashing the app with an unhandled SecurityException—and captures get_latest_screenshot to verify the explanatory banner is readable and unclipped.
  4. Grant Recovery & Evidence Capture (record_screen): Claude Code taps the app's retry CTA, taps "Allow" in the re-opened permission sheet, captures a short clip via record_screen if validating an animated discovery list, and reads get_logcat to confirm Resolved local endpoint 192.168.x.x and HTTP 200 OK from /health.

Testing Hybrid Mobile + Local Web Companion Flows Across 226 MCP Tools

Testing hybrid Android and local web companion workflows ensures that mobile apps pairing with local routers, smart-home admin dashboards, or developer hubs authenticate and exchange state seamlessly across both screens. ScreenSync MCP combines 29 phone and desktop tools with 197 web_* browser tools inside one Claude Code session.

Many real-world LAN apps do not stop at a native Android screen. Consider a local NAS setup wizard, a Wi-Fi router onboarding flow, or a local developer dashboard where the Android app discovers a 192.168.x.x or .local gateway, hands an auth code to the user's desktop browser, or lets the user confirm device pairing on a local web portal running on localhost or a LAN IP.

Through the ScreenSync MCP Chrome and Edge extension (Manifest V3, version 1.14.4), Claude Code can drive your real desktop browser tab right alongside your physical Android phone:

  • 29 Phone and Desktop Tools: 12 control_* actions, 3 os_* tools, and 14 capture/hub tools (get_latest_screenshot, get_ui_hierarchy, get_logcat, record_screen, and hub state tools).
  • *197 `web_Browser Tools:** Inspect DOM elements on a local router admin page (http://192.168.1.1) or local hub console (http://localhost:3000`), trigger pairing actions, and verify websocket or REST status updates—complete with a built-in human approval prompt before risky browser actions run.
  • 17 Prompts and 3 Resources: Pre-wired workflows inside the ScreenSync MCP server that help clients like Claude Code, Cursor, and VS Code agent mode execute multi-step mobile-to-browser checks without custom glue scripts.

If your team wants a complete end-to-end blueprint for running Claude Code against real Android phones in daily CI or pre-release sweeps, read our guide on whether Claude Code can test Android apps on real mobile devices.

Production QA Checklist for Android 17 Local Network Protection

A production Android 17 Local Network Protection audit confirms manifest declarations, runtime permission denial recovery, NsdManager picker fallbacks, short LAN socket timeouts, and Google Play policy readiness on real hardware. Running this seven-step checklist with Claude Code and ScreenSync MCP eliminates silent LAN timeouts before rollout.

  1. Audit Every LAN Dependency: Grep your codebase and third-party SDKs for RFC 1918 IP literals, MulticastSocket, DatagramSocket, NsdManager, .local DNS lookups, and OkHttp/Cronet local bridge calls.
  2. Prefer System Pickers Where Possible: Replace blanket background LAN scanning with NsdManager FLAG_SHOW_PICKER or system Cast output switchers whenever the user only needs to pick a single target device.
  3. Declare ACCESS_LOCAL_NETWORK Only When Core: Add <uses-permission android:name="android.permission.ACCESS_LOCAL_NETWORK" /> only if direct subnet access is essential, and prepare your Google Play Console core-functionality justification.
  4. Enforce Compat Flags in Automated QA: Run adb shell am compat enable RESTRICT_LOCAL_NETWORK <package> on Android 16 devices and test natively on Android 17 hardware with targetSdk = 37.
  5. Verify Denial and Revocation Flows via get_ui_hierarchy: Use Claude Code and ScreenSync MCP to tap "Don't allow" on the NEARBY_DEVICES dialog, verify graceful fallback UI with get_latest_screenshot, and test mid-session revocation via adb shell pm revoke.
  6. Confirm Short LAN Timeouts and Clean Logcat Signals: Keep local TCP connectTimeout values tight (2–3 seconds) and log clear diagnostics for SocketTimeoutException and EPERM so get_logcat catches blocked LAN calls immediately.
  7. Keep Staging Data Local: Stream frames strictly over your firewalled development LAN via ScreenSync MCP, and avoid exposing production credentials on screens captured via get_latest_screenshot for model inspection.

Ready to automate Android 17 Local Network Protection and ACCESS_LOCAL_NETWORK testing on physical hardware? Visit ScreenSync MCP to install the free Android app, launch the desktop hub, and connect Claude Code to your real test devices in minutes.

Next steps

FAQ

Questions, answered

What does Android 17 Local Network Protection restrict for apps?

Android 17 Local Network Protection restricts apps targeting API level 37 from reaching private RFC 1918 IPv4 subnets, link-local addresses, CGNAT ranges, IPv4/IPv6 multicast and broadcast traffic, and .local mDNS hostnames using only INTERNET. Apps must hold ACCESS_LOCAL_NETWORK or use system-mediated pickers.

Why does OkHttp throw SocketTimeoutException instead of SecurityException when blocked?

Android 17 enforces Local Network Protection deep in the networking stack by silently dropping unauthorized local TCP handshake packets before they reach the LAN interface. Because no explicit rejection frame returns, OkHttp and Cronet wait until connectTimeout expires and report SocketTimeoutException rather than SecurityException.

How can I test Android 17 Local Network Protection on an Android 16 phone?

On Android 16 (API level 36) devices, enable the platform compatibility flag via ADB by running adb shell am compat enable RESTRICT_LOCAL_NETWORK followed by your package name. Restart the app, verify the flag in dumpsys platform_compat, and disable it later with am compat disable.

Does ScreenSync MCP require root or ADB to capture Android screens?

ScreenSync MCP uses Android's native MediaProjection API after per-session user consent to capture and mirror screens over your LAN with no root and no ADB required. Interactive control tools such as control_tap, control_type, control_swipe, and shell permission commands run separately over ADB.

When should I use NsdManager system pickers instead of ACCESS_LOCAL_NETWORK?

Use NsdManager system-mediated pickers or system output switchers whenever users only need to select a specific local printer, speaker, or bridge on demand. Requesting the broad ACCESS_LOCAL_NETWORK runtime permission triggers stricter Google Play Console policy reviews requiring proof of core LAN functionality.

How does Claude Code tap Android system permission dialogs during automated QA?

Because Android runtime permission dialogs belong to the system permission controller rather than your app process, Claude Code calls ScreenSync MCP's get_ui_hierarchy to read exact node bounding boxes on the active screen and uses control_tap over ADB to press Allow or Don't allow reliably.

How many tools does ScreenSync MCP provide for mobile and web companion testing?

ScreenSync MCP exposes 226 MCP tools in total, comprising 29 phone and desktop tools—12 control_* actions, 3 os_* tools, and 14 capture and hub tools such as get_latest_screenshot, get_ui_hierarchy, get_logcat, and record_screen—plus 197 web_* browser automation tools via Chrome or Edge.

Where do captured screenshots go when testing local networks with ScreenSync MCP?

Live screen mirror frames stream directly from the ScreenSync MCP Android app to your local Node.js desktop hub on your LAN, never passing through EpsolDev servers (Drive fallback is optional). Any screenshot an AI agent explicitly fetches via get_latest_screenshot is sent to that agent's model provider.

Written by

ScreenSync MCP team

The ScreenSync MCP team at EpsolDev builds the Android app, the desktop MCP hub and the browser extension that let AI agents see and control a real phone. These guides come out of that work.