service: Initial implementation of the NFD Android Service

Change-Id: Iee2c2f3588aa9af36bd170a22ce8333e4945ff67
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0310be5..85ba551 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,22 +2,44 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="net.named_data.nfd" >
 
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.READ_LOGS" />
+    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
+
     <application
         android:allowBackup="true"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
+
         <activity
-            android:name=".NfdSettingsActivity"
+            android:name=".NfdMainActivity"
             android:label="@string/app_name" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-    </application>
 
-    <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.READ_LOGS" />
+        <activity
+            android:name=".NfdSettingsActivity"
+            android:label="@string/app_name" >
+        </activity>
+
+        <service
+            android:name=".NfdService"
+            android:process="net.named_data.nfd.NfdService"
+            android:icon="@drawable/ic_launcher"
+            android:label="@string/service_name"
+            android:exported="true" >
+            <intent-filter>
+                <action android:name="net.named_data.nfd.NfdService" />
+            </intent-filter>
+        </service>
+
+    </application>
 
 </manifest>
diff --git a/app/src/main/java/net/named_data/nfd/G.java b/app/src/main/java/net/named_data/nfd/G.java
new file mode 100644
index 0000000..cacbecc
--- /dev/null
+++ b/app/src/main/java/net/named_data/nfd/G.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.named_data.nfd;
+
+import android.util.Log;
+
+/**
+ * Global convenience class used for NFD Service wide constants and logs.
+ *
+ * <br><br>
+ *
+ * If log messages need to be written to persistent storage, this is the
+ * place to implement it.
+ *
+ */
+public class G {
+
+  /** Flag that turns on/off debugging log output. */
+  private static final boolean DEBUG = true;
+
+  /** Tag used in log output to identify NFD Service. */
+  private static final String TAG = "NFDService";
+
+  /**
+   * Designated log message method that provides flexibility in message logging.
+   *
+   * @param tag Tag to identify log message.
+   * @param format Format qualifiers as used in String.format()
+   * @param args Output log message.
+   */
+  public static void Log(String tag, String format, Object ... args) {
+    if (DEBUG) {
+      Log.d(tag, String.format(format, args));
+    }
+  }
+
+  /**
+   * Convenience method to log a message with a specified tag.
+   *
+   * @param tag Tag to identify log message.
+   * @param message Output log message.
+   */
+  public static void Log(String tag, String message) {
+    Log(tag, "%s", message);
+  }
+
+  /**
+   * Convenience method to log messages with the default tag.
+   *
+   * @param message Output log message.
+   */
+  public static void Log(String message) {
+    Log(TAG, message);
+  }
+
+}
diff --git a/app/src/main/java/net/named_data/nfd/NfdMainActivity.java b/app/src/main/java/net/named_data/nfd/NfdMainActivity.java
new file mode 100644
index 0000000..b429e43
--- /dev/null
+++ b/app/src/main/java/net/named_data/nfd/NfdMainActivity.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.named_data.nfd;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+import net.named_data.nfd.service.NfdService;
+import net.named_data.nfd.wrappers.NfdWrapper;
+
+public class NfdMainActivity extends ActionBarActivity {
+
+  @Override
+  protected void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    setContentView(R.layout.activity_main);
+  }
+
+
+  @Override
+  public boolean onCreateOptionsMenu(Menu menu) {
+    // Inflate the menu; this adds items to the action bar if it is present.
+    getMenuInflater().inflate(R.menu.menu_main, menu);
+    return true;
+  }
+
+  @Override
+  public boolean onOptionsItemSelected(MenuItem item) {
+    // Handle action bar item clicks here. The action bar will
+    // automatically handle clicks on the Home/Up button, so long
+    // as you specify a parent activity in AndroidManifest.xml.
+    int id = item.getItemId();
+
+    //noinspection SimplifiableIfStatement
+    if (id == R.id.action_settings) {
+      return true;
+    }
+
+    return super.onOptionsItemSelected(item);
+  }
+
+  public void startNFD(View view) {
+    G.Log("Starting NFD ...");
+
+    Intent intent = new Intent(this, NfdService.class);
+    startService(intent);
+  }
+
+  public void stopNFD(View view) {
+    G.Log("Stopping NFD ...");
+
+    Intent intent = new Intent(this, NfdService.class);
+    stopService(intent);
+  }
+
+  public void startNFDexplicit(View view) {
+    G.Log("Starting NFD explicitly ...");
+
+    Intent intent = new Intent("net.named_data.nfd.NfdService");
+    startService(intent);
+  }
+
+  public void startNfd(View view) {
+    G.Log("Starting NFD through JNI ...");
+
+    NfdWrapper.startNfd();
+  }
+
+  public void stopNfd(View view) {
+    G.Log("Stopping NFD through JNI ...");
+
+    NfdWrapper.stopNfd();
+  }
+}
diff --git a/app/src/main/java/net/named_data/nfd/NfdSettingsActivity.java b/app/src/main/java/net/named_data/nfd/NfdSettingsActivity.java
index a161349..c288219 100644
--- a/app/src/main/java/net/named_data/nfd/NfdSettingsActivity.java
+++ b/app/src/main/java/net/named_data/nfd/NfdSettingsActivity.java
@@ -1,3 +1,21 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 package net.named_data.nfd;
 
 import android.annotation.TargetApi;
@@ -108,8 +126,8 @@
    */
   private static boolean isXLargeTablet(Context context)
   {
-    return (context.getResources().getConfiguration().screenLayout
-      & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
+    return (context.getResources().getConfiguration().screenLayout &
+      Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
   }
 
   /**
@@ -121,9 +139,9 @@
    */
   private static boolean isSimplePreferences(Context context)
   {
-    return ALWAYS_SIMPLE_PREFS
-      || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
-      || !isXLargeTablet(context);
+    return ALWAYS_SIMPLE_PREFS ||
+      Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ||
+      !isXLargeTablet(context);
   }
 
   /**
@@ -157,9 +175,9 @@
 
         // Set the summary to reflect the new value.
         preference.setSummary(
-          index >= 0
-            ? listPreference.getEntries()[index]
-            : null);
+          index >= 0 ?
+            listPreference.getEntries()[index] :
+            null);
 
       } else if (preference instanceof RingtonePreference) {
         // For ringtone preferences, look up the correct display value
@@ -209,9 +227,9 @@
     // Trigger the listener immediately with the preference's
     // current value.
     sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
-                                                             PreferenceManager
-                                                               .getDefaultSharedPreferences(preference.getContext())
-                                                               .getString(preference.getKey(), ""));
+      PreferenceManager
+        .getDefaultSharedPreferences(preference.getContext())
+        .getString(preference.getKey(), ""));
   }
 
   /**
diff --git a/app/src/main/java/net/named_data/nfd/service/NfdService.java b/app/src/main/java/net/named_data/nfd/service/NfdService.java
new file mode 100644
index 0000000..1e2f7c6
--- /dev/null
+++ b/app/src/main/java/net/named_data/nfd/service/NfdService.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.named_data.nfd.service;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.Messenger;
+
+import net.named_data.nfd.G;
+
+public class NfdService extends Service {
+
+  private final Messenger mNfdServiceMessenger
+      = new Messenger(new NfdServiceMessageHandler(this));
+
+  @Override
+  public void onCreate() {
+    G.Log("onCreate()");
+    // TODO: Reload NFD and NRD in memory structures (if any)
+  }
+
+  @Override
+  public int onStartCommand(Intent intent, int flags, int startId) {
+    G.Log("onStartCommand()");
+    // If we need to handle per-client start invocations, they are to be
+    // handled here.
+
+    // Nothing else to do here for now.
+
+    // Service is restarted when killed.
+    // Pending intents delivered; null intent redelivered otherwise
+    return START_STICKY;
+  }
+
+  /**
+   * When clients bind to the NfdService, an IBinder interface to the
+   * NFD Service Messenger is returned for clients to send messages
+   * to the NFD Service.
+   *
+   * @param intent Intent as sent by the client.
+   * @return IBinder interface to send messages to the NFD Service.
+   */
+  @Override
+  public IBinder onBind(Intent intent) {
+    return mNfdServiceMessenger.getBinder();
+  }
+
+  @Override
+  public void onDestroy() {
+    G.Log("onDestroy()");
+    // TODO: Save NFD and NRD in memory data structures.
+  }
+}
diff --git a/app/src/main/java/net/named_data/nfd/service/NfdServiceMessageConstants.java b/app/src/main/java/net/named_data/nfd/service/NfdServiceMessageConstants.java
new file mode 100644
index 0000000..04239a5
--- /dev/null
+++ b/app/src/main/java/net/named_data/nfd/service/NfdServiceMessageConstants.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.named_data.nfd.service;
+
+/**
+ * Message constants that can be sent to the NFD Service for processing.
+ */
+public class NfdServiceMessageConstants {
+
+  /** Message to start NFD Service. */
+  public static final int MESSAGE_START_NFD_SERVICE = 1;
+
+}
diff --git a/app/src/main/java/net/named_data/nfd/service/NfdServiceMessageHandler.java b/app/src/main/java/net/named_data/nfd/service/NfdServiceMessageHandler.java
new file mode 100644
index 0000000..7efd6f9
--- /dev/null
+++ b/app/src/main/java/net/named_data/nfd/service/NfdServiceMessageHandler.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.named_data.nfd.service;
+
+import android.content.Intent;
+import android.os.Handler;
+import android.os.Message;
+
+/**
+ * Message handler for the the NFD Service.
+ */
+class NfdServiceMessageHandler extends Handler {
+
+  private NfdService mNfdService;
+
+  NfdServiceMessageHandler(NfdService nfdService) {
+    mNfdService = nfdService;
+  }
+
+  @Override
+  public void handleMessage(Message message) {
+    switch (message.what) {
+      case NfdServiceMessageConstants.MESSAGE_START_NFD_SERVICE:
+        break;
+      default:
+        super.handleMessage(message);
+        break;
+    }
+  }
+}
diff --git a/app/src/main/java/net/named_data/nfd/wrappers/NfdWrapper.java b/app/src/main/java/net/named_data/nfd/wrappers/NfdWrapper.java
new file mode 100644
index 0000000..ffad298
--- /dev/null
+++ b/app/src/main/java/net/named_data/nfd/wrappers/NfdWrapper.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.named_data.nfd.wrappers;
+
+public class NfdWrapper {
+    static {
+       System.loadLibrary("nfd-wrapper");
+    }
+
+    public native static void
+    startNfd();
+
+    public native static void
+    stopNfd();
+}
diff --git a/app/src/main/jni/Android.mk b/app/src/main/jni/Android.mk
index 925d790..7bae03f 100644
--- a/app/src/main/jni/Android.mk
+++ b/app/src/main/jni/Android.mk
@@ -3,8 +3,9 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := nfd-wrapper
-LOCAL_SRC_FILES := android-logger-streambuf.cpp wrappers-example.cpp
+LOCAL_SRC_FILES := android-logger-streambuf.cpp nfd-wrapper.cpp
 LOCAL_LDLIBS := -llog
+LOCAL_SHARED_LIBRARIES := nfd-daemon
 include $(BUILD_SHARED_LIBRARY)
 
 include $(LOCAL_PATH_SAVED)/ndn-cxx.mk
diff --git a/app/src/main/jni/ndn-cxx.mk b/app/src/main/jni/ndn-cxx.mk
index 4ecb9be..1e93bdb 100644
--- a/app/src/main/jni/ndn-cxx.mk
+++ b/app/src/main/jni/ndn-cxx.mk
@@ -3,9 +3,9 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := ndn-cxx
-NDN_CXX_BOOST_LIBS = system filesystem date_time iostreams regex program_options chrono random
+NDN_CXX_BOOST_LIBS = system filesystem date_time iostreams program_options chrono random
 LOCAL_SHARED_LIBRARIES := cryptopp $(addsuffix _shared,$(addprefix boost_,$(NDN_CXX_BOOST_LIBS)))
-LOCAL_STATIC_LIBRARIES := sqlite3
+LOCAL_STATIC_LIBRARIES := sqlite3 boost_regex_static
 NDN_CXX_SRC_FILES := name.cpp util/dns.cpp util/time-unit-test-clock.cpp util/segment-fetcher.cpp util/config-file.cpp util/in-memory-storage.cpp util/in-memory-storage-lfu.cpp util/in-memory-storage-fifo.cpp util/ethernet.cpp util/crypto.cpp util/regex/regex-top-matcher.cpp util/signal-scoped-connection.cpp util/dummy-client-face.cpp util/scheduler.cpp util/indented-stream.cpp util/signal-connection.cpp util/in-memory-storage-persistent.cpp util/digest.cpp util/in-memory-storage-lru.cpp util/in-memory-storage-entry.cpp util/time.cpp util/random.cpp util/face-uri.cpp interest-filter.cpp signature.cpp transport/tcp-transport.cpp transport/unix-transport.cpp management/nfd-face-event-notification.cpp management/nfd-control-command.cpp management/nfd-command-options.cpp management/nfd-face-status.cpp management/nfd-control-response.cpp management/nfd-rib-entry.cpp management/nfd-controller.cpp management/nfd-forwarder-status.cpp management/nfd-channel-status.cpp management/nfd-fib-entry.cpp management/nfd-strategy-choice.cpp management/nfd-face-query-filter.cpp management/nfd-control-parameters.cpp exclude.cpp name-component.cpp face.cpp key-locator.cpp data.cpp interest.cpp selectors.cpp meta-info.cpp signature-info.cpp encoding/nfd-constants.cpp encoding/oid.cpp encoding/cryptopp/asn_ext.cpp encoding/block.cpp encoding/buffer.cpp security/sec-public-info-sqlite3.cpp security/signature-sha256-with-rsa.cpp security/public-key.cpp security/certificate-cache-ttl.cpp security/sec-rule-specific.cpp security/sec-tpm-file.cpp security/digest-sha256.cpp security/sec-public-info.cpp security/certificate.cpp security/identity-certificate.cpp security/certificate-subject-description.cpp security/certificate-extension.cpp security/sec-tpm.cpp security/validator.cpp security/sec-rule-relative.cpp security/key-params.cpp security/secured-bag.cpp security/key-chain.cpp security/signature-sha256-with-ecdsa.cpp security/validator-config.cpp security/validator-regex.cpp
 LOCAL_SRC_FILES := $(addprefix ndn-cxx/src/,$(NDN_CXX_SRC_FILES))
 LOCAL_CPPFLAGS := -I$(LOCAL_PATH)/ndn-cxx/src -I$(LOCAL_PATH)/ndn-cxx-android
diff --git a/app/src/main/jni/nfd-wrapper.cpp b/app/src/main/jni/nfd-wrapper.cpp
new file mode 100644
index 0000000..6a6e3cd
--- /dev/null
+++ b/app/src/main/jni/nfd-wrapper.cpp
@@ -0,0 +1,40 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "nfd-wrapper.hpp"
+#include "android-logger-streambuf.hpp"
+
+extern "C" {
+int
+main(int argc, char** argv);
+}
+
+#include <iostream>
+
+JNIEXPORT void JNICALL
+Java_net_named_1data_nfd_wrappers_NfdWrapper_startNfd(JNIEnv *, jclass)
+{
+
+}
+
+JNIEXPORT void JNICALL
+Java_net_named_1data_nfd_wrappers_NfdWrapper_stopNfd(JNIEnv *, jclass)
+{
+
+}
diff --git a/app/src/main/jni/nfd-wrapper.hpp b/app/src/main/jni/nfd-wrapper.hpp
new file mode 100644
index 0000000..f709a21
--- /dev/null
+++ b/app/src/main/jni/nfd-wrapper.hpp
@@ -0,0 +1,48 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2015 Regents of the University of California
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
+ * See AUTHORS.md for complete list of NFD Android authors and contributors.
+ *
+ * NFD Android is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD Android is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class net_named_data_nfd_wrappers_NfdWrapper */
+
+#ifndef _Included_net_named_data_nfd_wrappers_NfdWrapper
+#define _Included_net_named_data_nfd_wrappers_NfdWrapper
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class:     net_named_data_nfd_wrappers_NfdWrapper
+ * Method:    startNfd
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_net_named_1data_nfd_wrappers_NfdWrapper_startNfd
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     net_named_data_nfd_wrappers_NfdWrapper
+ * Method:    stopNfd
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_net_named_1data_nfd_wrappers_NfdWrapper_stopNfd
+  (JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/app/src/main/jni/wrappers-example.cpp b/app/src/main/jni/wrappers-example.cpp
deleted file mode 100644
index 5553258..0000000
--- a/app/src/main/jni/wrappers-example.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2015,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "wrappers-example.hpp"
-#include "android-logger-streambuf.hpp"
-
-#include <iostream>
-
-JNIEXPORT void JNICALL
-Java_net_named_1data_nfd_wrappers_Example_main(JNIEnv*, jclass)
-{
-  nfd_android::AndroidLoggerStreambuf newBuffer;
-  std::streambuf *backupCout = std::cout.rdbuf(&newBuffer);
-  std::streambuf *backupCerr = std::cerr.rdbuf(&newBuffer);
-
-  std::cout << "Test message to cout" << std::endl;
-  std::cerr << "Test message to cerr" << std::endl;
-
-  std::cerr.rdbuf(backupCerr);
-  std::cout.rdbuf(backupCout);
-}
diff --git a/app/src/main/jni/wrappers-example.hpp b/app/src/main/jni/wrappers-example.hpp
deleted file mode 100644
index 9bf11e3..0000000
--- a/app/src/main/jni/wrappers-example.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2015,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class net_named_data_nfd_wrappers_Example */
-
-#ifndef _Included_net_named_data_nfd_wrappers_Example
-#define _Included_net_named_data_nfd_wrappers_Example
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     net_named_data_nfd_wrappers_Example
- * Method:    main
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_net_named_1data_nfd_wrappers_Example_main
-  (JNIEnv *, jclass);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..289db7d
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
+
+    <Button
+        android:id="@+id/start_nfd_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="startNFD"
+        android:text="Start NFD" />
+
+    <Button
+        android:id="@+id/stop_nfd_button"
+        android:layout_below="@id/start_nfd_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="stopNFD"
+        android:text="Stop NFD" />
+
+    <Button
+        android:id="@+id/start_nfd_explicit_button"
+        android:layout_below="@id/stop_nfd_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="startNFDexplicit"
+        android:text="Start NFD explicit!" />
+
+    <Button
+        android:id="@+id/start_nfd_jni"
+        android:layout_below="@id/start_nfd_explicit_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="startNfd"
+        android:text="Start NFD through JNI" />
+
+    <Button
+        android:id="@+id/stop_nfd_jni"
+        android:layout_below="@id/start_nfd_jni"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:onClick="stopNfd"
+        android:text="Stop NFD through JNI" />
+</RelativeLayout>
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..b1cb908
--- /dev/null
+++ b/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,6 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"
+        android:orderInCategory="100" app:showAsAction="never" />
+</menu>
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 63746a1..e39585d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,5 @@
 <resources>
     <string name="app_name">NFD</string>
+    <string name="service_name">NFD Service</string>
+    <string name="action_settings">Settings</string>
 </resources>