Skip to content

[android] improve the error logging when run from Android app sandbox without network permissions #152

@andrurogerz

Description

@andrurogerz

In order to debug an Android app, ds2 has to be run in the context of the app's sandbox. Since ds2 opens a TCP Socket, the app must have internet permissions declared in its manifest or ds2 cannot work.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

When the app does not have these permissions, ds2 fails to launch with a misleading error message:

emu64xa:/ $ run-as com.example.app ./ds2 platform --server --listen localhost:6543
[6898][std::unique_ptr<Socket> CreateTCPSocket(const std::string &, const std::string &, bool)] FATAL  : cannot listen on [localhost:6543]: Success
[6898][void ds2::Utils::PrintBacktrace()] ERROR  : 0x00005e71c7a40dd7 <unknown>+0x5e71c7a40dd7 (/data/user/0/com.example.jniplayground/ds2+0xa9dd7)
[6898][void ds2::Utils::PrintBacktrace()] ERROR  : 0x00005e71c7a41b78 <unknown>+0x5e71c7a41b78 (/data/user/0/com.example.jniplayground/ds2+0xaab78)
[6898][void ds2::Utils::PrintBacktrace()] ERROR  : 0x00005e71c79f8158 <unknown>+0x5e71c79f8158 (/data/user/0/com.example.jniplayground/ds2+0x61158)
[6898][void ds2::Utils::PrintBacktrace()] ERROR  : 0x00005e71c79f8801 <unknown>+0x5e71c79f8801 (/data/user/0/com.example.jniplayground/ds2+0x61801)
[6898][void ds2::Utils::PrintBacktrace()] ERROR  : 0x00005e71c79f6dc9 <unknown>+0x5e71c79f6dc9 (/data/user/0/com.example.jniplayground/ds2+0x5fdc9)
[6898][void ds2::Utils::PrintBacktrace()] ERROR  : 0x0000786c986e8c63 __libc_init+0x73 (/apex/com.android.runtime/lib64/bionic/libc.so+0x57c63)
Aborted

We should improve this error message to clearly indicate the problem may be due to missing network permissions if being run on Android.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions