Project

General

Profile

Actions

Task #2431

closed

Android service to start/stop NFD using jni shared library

Added by Alex Afanasyev almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
jni
Target version:
Start date:
01/27/2015
Due date:
% Done:

100%

Estimated time:

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

NFD_Service_Bootstrapping.png (242 KB) NFD_Service_Bootstrapping.png NFD Service Bootstrapping Ivan Yeo, 02/11/2015 12:25 AM
Actions #1

Updated by Alex Afanasyev almost 10 years ago

  • Project changed from ndn-embedded to NFD-android
  • Category changed from Android to jni
Actions #2

Updated by Ivan Yeo almost 10 years ago

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.

Actions #3

Updated by Alex Afanasyev almost 10 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)
Actions #4

Updated by Alex Afanasyev almost 10 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.

Actions #5

Updated by Ivan Yeo almost 10 years ago

Mmm ... I see what's going on. Good catch Alex! I'll head over and fix it right away.

Actions #6

Updated by Ivan Yeo almost 10 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.

Actions #7

Updated by Ivan Yeo almost 10 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/

Actions #8

Updated by Alex Afanasyev almost 10 years ago

  • Target version set to 0.1
Actions

Also available in: Atom PDF