aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangping Dong <wgtdkp@google.com>2024-01-31 05:42:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-01-31 05:42:37 +0000
commit658bbdeecb993d618bdcb1e2e72d224de8dee60b (patch)
tree9704f19325e7ed41407d31b6958e9ba36a1538ac
parent9708b536f94dfd929123c33b383461cdd7ef6654 (diff)
parent1fa9c6fdf7dc18e4b7e44327876a4d699aec8b8a (diff)
downloadot-br-posix-658bbdeecb993d618bdcb1e2e72d224de8dee60b.tar.gz
Merge changes Iebab49ea,I61af2704 into main
* changes: [android] exit ot-daemon when factoryreset (#2173) [Thread] suppress unused-unfction
-rw-r--r--Android.bp1
-rw-r--r--src/agent/main.cpp13
2 files changed, 12 insertions, 2 deletions
diff --git a/Android.bp b/Android.bp
index 0a76d7b2..2b818cbd 100644
--- a/Android.bp
+++ b/Android.bp
@@ -122,6 +122,7 @@ cc_defaults {
cflags: [
"-Wall",
"-Wextra",
+ "-Wno-unused-function",
// The HAL client implementation requires features which are
// available on only 31+, but it's guaranteed that ot-daemon
diff --git a/src/agent/main.cpp b/src/agent/main.cpp
index 5409671d..4ed5e277 100644
--- a/src/agent/main.cpp
+++ b/src/agent/main.cpp
@@ -78,7 +78,9 @@ enum
OTBR_OPT_REST_LISTEN_PORT,
};
-static jmp_buf sResetJump;
+#ifndef __ANDROID__
+static jmp_buf sResetJump;
+#endif
static otbr::Application *gApp = nullptr;
void __gcov_flush();
@@ -317,12 +319,19 @@ void otPlatReset(otInstance *aInstance)
gApp->Deinit();
gApp = nullptr;
+#ifndef __ANDROID__
longjmp(sResetJump, 1);
assert(false);
+#else
+ // Exits immediately on Android. The Android system_server will receive the
+ // signal and decide whether (and how) to restart the ot-daemon
+ exit(0);
+#endif
}
int main(int argc, char *argv[])
{
+#ifndef __ANDROID__
if (setjmp(sResetJump))
{
std::vector<char *> args = AppendAutoAttachDisableArg(argc, argv);
@@ -334,6 +343,6 @@ int main(int argc, char *argv[])
execvp(args[0], args.data());
}
-
+#endif
return realmain(argc, argv);
}