Task #2431
closedAndroid service to start/stop NFD using jni shared library
Description
NFD android service needs to be started and be re-started when NDN-enabled applications wants to express interests or publish data.
This task is to create such service and define framework how applications (or application library) should request service to be started.
Files
Updated by Alex Afanasyev over 9 years ago
- Project changed from ndn-embedded to NFD-android
- Category changed from Android to jni
Updated by Ivan Yeo over 9 years ago
- File NFD_Service_Bootstrapping.png NFD_Service_Bootstrapping.png added
- % Done changed from 0 to 100
The current design can be seen from the attached image file.
The starting of the NFD Service can be done through one of the following ways:
1) NFD Control Application
2) Any NDN Enable application
In both cases, the application starts the NFD Service by sending a start Intent through the Android's startService(). The request to start the NFD Service is idempotent in that: if the NFD Service is already started, then the start Intent that is sent to the NFD Service is ignored.
Updated by Alex Afanasyev over 9 years ago
- Subject changed from Android service to run nfd/nrd processes (or shared library wrappers) in the background to Android service to start/stop NFD using jni shared library
- Description updated (diff)
Updated by Alex Afanasyev over 9 years ago
With the patset 7 of http://gerrit.named-data.net/#/c/1749/, I'm getting the following error whenever I exit activity (with back button on emulator)
02-17 14:02:22.750: E/ActivityThread(2261): Activity net.named_data.nfd.NfdMainActivity has leaked ServiceConnection net.named_data.nfd.NfdMainActivity$1@3e96a2c2 that was originally bound here
02-17 14:02:22.750: E/ActivityThread(2261): android.app.ServiceConnectionLeaked: Activity net.named_data.nfd.NfdMainActivity has leaked ServiceConnection net.named_data.nfd.NfdMainActivity$1@3e96a2c2 that was originally bound here
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1072)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:966)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1768)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ContextImpl.bindService(ContextImpl.java:1751)
02-17 14:02:22.750: E/ActivityThread(2261): at android.content.ContextWrapper.bindService(ContextWrapper.java:538)
02-17 14:02:22.750: E/ActivityThread(2261): at net.named_data.nfd.NfdMainActivity.bindNfdService(NfdMainActivity.java:147)
02-17 14:02:22.750: E/ActivityThread(2261): at net.named_data.nfd.NfdMainActivity.onCreate(NfdMainActivity.java:58)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.Activity.performCreate(Activity.java:5933)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ActivityThread.access$800(ActivityThread.java:144)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
02-17 14:02:22.750: E/ActivityThread(2261): at android.os.Handler.dispatchMessage(Handler.java:102)
02-17 14:02:22.750: E/ActivityThread(2261): at android.os.Looper.loop(Looper.java:135)
02-17 14:02:22.750: E/ActivityThread(2261): at android.app.ActivityThread.main(ActivityThread.java:5221)
02-17 14:02:22.750: E/ActivityThread(2261): at java.lang.reflect.Method.invoke(Native Method)
02-17 14:02:22.750: E/ActivityThread(2261): at java.lang.reflect.Method.invoke(Method.java:372)
02-17 14:02:22.750: E/ActivityThread(2261): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
02-17 14:02:22.750: E/ActivityThread(2261): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
I think something is going on wrong. I haven't seen this issue previously.
Updated by Ivan Yeo over 9 years ago
Mmm ... I see what's going on. Good catch Alex! I'll head over and fix it right away.
Updated by Ivan Yeo over 9 years ago
- Status changed from New to Code review
Cross post from comments in: http://gerrit.named-data.net/#/c/1749/9
This is the most robust implementation of the Android NFD Service that I can think of right now.
The Android NFD Service can tolerate and recover from the following scenarios:
1) System forcefully killing the app
- Service restarts if it was previously started; app doesn't 2) User or system forcefully killing the app and service
- Service restarts if it was previously started; app doesn't 3) System forcefully killing the service
- App reconnects to the service through the service connection
The following use cases are also taken care of:
1) User starts app, but doesn't start NFD, leaves app
- NFD not started; app and service terminates 2) User starts app, starts NFD, stays in app
- Service starts; NFD starts; button is updated to allow the user to stop NFD 3) User starts app, starts NFD, leaves app and maybe returns to app
- Service starts; NFD starts; button is updated to allow the user to stop NFD
- Service and NFD continues running
- If the user returns to the app, the button to control NFD will update accordingly
The Android NFD Service is designed and built to be thread safe, such that there can only be one invocation of the native startNfd/stopNfd.
Updated by Ivan Yeo over 9 years ago
- Status changed from Code review to Closed
Code has been fully merged and published to Github: https://github.com/named-data/NFD-android
Code review at: http://gerrit.named-data.net/#/c/1749/