From: Angelo Mantellini (manangel) Date: Wed, 29 Mar 2017 16:00:06 +0000 (+0200) Subject: first commit X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=3137acdd5a45285dab9903f9d41560c63eca8523;p=cicn.git first commit Change-Id: I8412b8e7d966c2fbc508b537fd9a9bbcfc628ca8 Signed-off-by: Angelo Mantellini (manangel) --- diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..61a36eb2 --- /dev/null +++ b/Makefile @@ -0,0 +1,319 @@ + ############################################################################# + # Copyright (c) 2017 Cisco and/or its affiliates. + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at: + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + ############################################################################## + +DISTILLERY_VERSION=2.0 + +default.target: help + +all: init_depend install-all + +############################################################## +# Variables +# +# Set some variables +DISTILLERY_STAMP=.distillery.stamp +REBUILD_DEPENDS= + +############################################################## +# Load the configuration +# +# For more information please see config.default.mk +# +DISTILLERY_CONFIG_DIR ?= config + +##DISTILLERY_DEFAULT_CONFIG ?= ${DISTILLERY_CONFIG_DIR}/config.mk +##DISTILLERY_LOCAL_CONFIG ?= ${DISTILLERY_CONFIG_DIR}/local/config.mk +DISTILLERY_USER_CONFIG ?= ${DISTILLERY_CONFIG_DIR}/config.mk + +ifneq (,$(wildcard ${DISTILLERY_USER_CONFIG})) + include ${DISTILLERY_USER_CONFIG} + REBUILD_DEPENDS+=${DISTILLERY_USER_CONFIG} +else + DISTILLERY_USER_CONFIG+="[Not Found]" +endif + +ifneq (,$(wildcard ${DISTILLERY_LOCAL_CONFIG})) + include ${DISTILLERY_LOCAL_CONFIG} + REBUILD_DEPENDS+=${DISTILLERY_LOCAL_CONFIG} +endif + +include ${DISTILLERY_DEFAULT_CONFIG} + + +############################################################## +# Set the paths +# +# PATH: add our install dir, build dependencies and system dependencies +# LD_RUN_PATH: add our install dir + +export PATH := $(DISTILLERY_INSTALL_DIR)/bin:$(DISTILLERY_TOOLS_DIR)/bin:$(PATH) +#export LD_RUN_PATH := $(DISTILLERY_INSTALL_DIR)/lib +#export LD_LIBRARY_PATH := $(DISTILLERY_INSTALL_DIR)/lib +export CCNX_HOME +export FOUNDATION_HOME + + +############################################################## +# Modules +# +# Load the modules config. Please refer to that file for more information +DISTILLERY_MODULES_DIR=${DISTILLERY_CONFIG_DIR}/modules + +# The modules variable is a list of modules. It will be populated by the +# modules config files. +modules= +modules_dir= + include config/modules/000-distillery-update.mk + include config/modules/000-gitModule.mk + include config/modules/001-modules.mk + include config/modules/002-cmake-modules.mk + include config/modules/002-make-modules.mk + include config/modules/100-distillery.mk + include config/modules/110-longbow.mk + include config/modules/120-libparc.mk + include config/modules/210-libccnx-common.mk + include config/modules/220-libccnx-transport-rta.mk + include config/modules/230-libccnx-portal.mk + include config/modules/510-Metis.mk + include config/modules/610-libicnet.mk + include config/modules/610-libdash.mk + +# Load user defined modules +DISTILLERY_USER_MODULES_DIR=${DISTILLERY_USER_CONFIG_DIR}/modules +ifneq (,$(wildcard ${DISTILLERY_USER_MODULES_DIR})) + include ${DISTILLERY_USER_MODULES_DIR}/*.mk +else + DISTILLERY_USER_MODULES_DIR+="[Not Found]" +endif + +ifdef ${DISTILLERY_LOCAL_MODULES_DIR} + include ${DISTILLERY_LOCAL_MODULES_DIR}/*.mk +else + DISTILLERY_LOCAL_MODULES_DIR="[Undefined]" +endif + + +############################################################## +# Build variables and rules +# + +# We're going to create lists of targets as convenience +modules_clean=$(modules:=.clean) +modules_check=$(modules:=.check) +modules_step=$(modules:=.step) +modules_average-coverage=$(modules:=.average-coverage) + +# These are the basic build rules. They will call the module specific rules +install-all: install-directories pre-requisites ${modules} + +#distillery-sync: distillery-update ${DISTILLERY_ROOT_DIR}/tools/bin/syncOriginMasterWithCCNXUpstream +# @${DISTILLERY_ROOT_DIR}/tools/bin/syncOriginMasterWithCCNXUpstream + +init_depend: + ./scripts/init.sh ${ABI} ${DISTILLERY_INSTALL_DIR}; +android_metis: + ./scripts/compile_androidmetis.sh +android_metis_debug: + ./scripts/compile_androidmetis.sh DEBUG +android_iget: + ./scripts/compile_androidiget.sh +android_iget_debug: + ./scripts/compile_androidiget.sh DEBUG + +clobber: distclean + @rm -rf ${CONFIGURE_CACHE_FILE} + @rm -rf ${DISTILLERY_INSTALL_DIR}/bin + @rm -rf ${DISTILLERY_INSTALL_DIR}/lib + @rm -rf ${DISTILLERY_INSTALL_DIR}/include + @rm -rf ${DISTILLERY_INSTALL_DIR}/share + @rm -rf ${DISTILLERY_INSTALL_DIR}/etc + @rm -rf ${DISTILLERY_XCODE_DIR} + @rm -rf .*.stamp + +clean: ${modules_clean} + @rm -rf report.txt + +distclean: + @rm -rf ${DISTILLERY_BUILD_DIR} + @rm -rf report.txt + +#distillery-update: +# @echo "Fetching Distillery..." +# @git fetch --all +# @git pull + +distillery-upstream: + git remote add ${DISTILLERY_GITHUB_UPSTREAM_NAME} ${DISTILLERY_GITHUB_UPSTREAM_REPO} + +check: ${modules_check} + +step: ${modules_step} + +# From Distillery, 'make coverage' actually runs the summary version of coverage +# You can also run 'make .coverage' to get the output showing each file and its coverage. +coverage: ${modules_average-coverage} + +dependencies: + @${MAKE} -C dependencies + +dependencies.clean: + @${MAKE} -C dependencies clean + +dependencies.clobber: + @${MAKE} -C dependencies clobber + +pre-requisites: + +help: + @echo "Simple instructions: run \"make update step\"" + @echo + @echo "---- Basic build targets ----" + @echo "make help - This help message" + @echo "make info - Show basic information" + @echo "make status - Show status of modules" + @echo "make update - git clone and pull the different modules to the head of master" + @echo "make sync - fetch all remotes, merge upstream master, push to origin master" + @echo "make step - Module by module: configure, compile and install all software" + @echo " in the install directory (see make info) and run tests" + @echo "make all - Configure, compile and install all software in DISTILLERY_INSTALL_DIR" + @echo "make check - Run all the tests" + @echo "make clobber - Clean the build, remove the install software" + @echo + @echo "make sanity - Run simple sanity checks to test that the build is functional" + @echo + @echo "make coverage - Show the average coverage of each module." + @echo "make .coverage - Show the coverage of each file in the specified module." + @echo + @echo "---- Advanced targets ----" + @echo "make nuke-all-modules - DANGEROUS! Clean all the modules to git checkout (git clean -dfx)" + @echo " - You will lose all uncommitted changes" + @echo "make clean - Clean the build" + @echo "make distclean - Distclean the build" + @echo "make *-debug - make a target with DEBUG on (e.g. all-debug or check-debug)" + @echo "make *-release - make a target with RELEASE on (optimized)" + @echo "make *-nopants - make a target with NOPANTS on (no validation - use at your own risk)" + @echo + @echo "---- IDE support targets ----" + @echo "make xcode - Create xcode projects [only works on Mac]" + @echo "make MasterIDE.xcode - Makes an xcode uber-project (based on all-debug) that contains" + @echo " - the various sub-mdules" + @echo "make MasterIDE.xcodeopen - Makes MasterIDE.xcode and the starts xcode" + @echo "make MasterIDE.clionopen - Creates an uber CMakeLists.txt and starts CLion with the necessary" + @echo " - environment for development" + @echo + @echo "---- Basic module targets ----" + @echo "Module Directory = ${MODULES_DIRECTORY_DEFAULT}" + @echo "Modules Loaded = ${modules}" + @echo "GitModules Loaded = ${gitmodules}" + @echo "Per-module targets: \"Module\" \"Module.distclean\" \"Module.nuke\" \"Module-debug\"" + + +${DISTILLERY_STAMP}: ${REBUILD_DEPENDS} + touch $@ + +debug-%: export CMAKE_BUILD_TYPE_FLAG = -DCMAKE_BUILD_TYPE=DEBUG +debug-%: export DISTILLERY_BUILD_NAME = -debug +debug-%: + @${MAKE} $* + +%-debug: debug-% ; + +release-%: export CMAKE_BUILD_TYPE_FLAG = "-DCMAKE_BUILD_TYPE=RELEASE" +release-%: export DISTILLERY_BUILD_NAME = -release +release-%: + @${MAKE} $* + +%-release: release-% ; + +nopants-%: export CMAKE_BUILD_TYPE_FLAG = "-DCMAKE_BUILD_TYPE=NOPANTS" +nopants-%: export DISTILLERY_BUILD_NAME = -nopants +nopants-%: + @${MAKE} $* + +%-nopants: nopants-% ; + +releasedebug-%: export CMAKE_BUILD_TYPE_FLAG = "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO" +releasedebug-%: export DISTILLERY_BUILD_NAME = -releasedebug +releasedebug-%: + @${MAKE} $* + +%-releasedebug: releasedebug-% ; + +install-directories: + @mkdir -p ${DISTILLERY_INSTALL_DIR}/include + @mkdir -p ${DISTILLERY_INSTALL_DIR}/lib + @mkdir -p ${DISTILLERY_INSTALL_DIR}/bin + +Distillery.report: + @echo '###################################' + @echo 'Distillery report' + @echo "#" `date "+%Y-%m-%d %H:%M:%S"` + @echo "#" `uname -sr` "-" `uname -pm` + @echo "#" `uname -n` + @echo "#" PATH=${PATH} + + @git status + @git log -1 + @git diff -U1 + +report.txt: + $(MAKE) report > report.txt + @cat report.txt + +distillery.checkout.error: + @echo + @echo =========================================================== + @echo + @echo DISTILLERY ERROR: You have not checked out a repository! + @echo Please make sure to run \"make update\" at least once + @echo + @echo Otherwise there is a misconfigured module, + @echo please check the module config files at .distillery/modules + @echo + @echo =========================================================== + @echo + + +info: + @echo "############ Distillery Info ##################" + @${MAKE} env + + +# env produces shell interpretable output. It is read by some scripts. +# DO NOT ALTER THE FORMAT +env: + @echo DISTILLERY_ROOT_DIR=${DISTILLERY_ROOT_DIR} + @echo DISTILLERY_SOURCE_DIR=${DISTILLERY_SOURCE_DIR} + @echo DISTILLERY_BUILD_DIR=${DISTILLERY_BUILD_DIR} + @echo DISTILLERY_DEFAULT_CONFIG=${DISTILLERY_DEFAULT_CONFIG} + @echo DISTILLERY_LOCAL_CONFIG=${DISTILLERY_LOCAL_CONFIG} + @echo DISTILLERY_USER_CONFIG=${DISTILLERY_USER_CONFIG} + @echo DISTILLERY_MODULES_DIR=${DISTILLERY_MODULES_DIR} + @echo DISTILLERY_LOCAL_MODULES_DIR=${DISTILLERY_LOCAL_MODULES_DIR} + @echo DISTILLERY_USER_MODULES_DIR=${DISTILLERY_USER_MODULES_DIR} + @echo DISTILLERY_INSTALL_DIR=${DISTILLERY_INSTALL_DIR} + @echo DISTILLERY_DEPENDENCIES_DIR=${DISTILLERY_DEPENDENCIES_DIR} + @echo DISTILLERY_EXTERN_DIR=${DISTILLERY_EXTERN_DIR} + @echo DISTILLERY_TOOLS_DIR=${DISTILLERY_TOOLS_DIR} + @echo DISTILLERY_GITHUB_URL=${DISTILLERY_GITHUB_URL} + @echo DISTILLERY_GITHUB_URL_USER=${DISTILLERY_GITHUB_URL_USER} + @echo DISTILLERY_GITHUB_UPSTREAM_URL=${DISTILLERY_GITHUB_UPSTREAM_URL} + @echo CCNX_DEPENDENCIES=${CCNX_DEPENDENCIES} + @echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} + @echo LD_RUN_PATH=${LD_RUN_PATH} + @echo CCNX_HOME=${CCNX_HOME} + @echo PATH=${PATH} + +.PHONY: dependencies diff --git a/README.md b/README.md new file mode 100644 index 00000000..e0c87cf0 --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +############################################################################# +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################## + +Android SDK + +This is the CCNx Distillery software distribution for Android. It is in charge of pulling +together all the necessary modules to build a full CCNx software suite for Android. + + +## Quick Start ## + + +Clone this distro + +``` +git clone -b androidsdk/master https://gerrit.fd.io/r/cicn androidSdk +cd androidSdk +``` + +Export Android Sdk path + +``` +export SDK_PATH=/Users/angelomantellini/Library/Android/sdk +``` + +Export Android Ndk path + +``` +export SDK_PATH=/Users/angelomantellini/Library/Android/sdk/ndk-bundle +``` + +Export Android Android CMAKE path + +``` +export SDK_PATH=/Users/angelomantellini/Library/Android/sdk/cmake/3.6.3155560/bin +``` + +If the previous variables are not set, Sdk, Ndk and CMake for android will be downloaded + +Compile everything (dependencies and CCNx modules) + +``` +make all +``` + +The CCNx software will be installed in androidSdk/usr + + +To compile Metis for android app (ccnxandroidmetis) + +``` +make android_metis +``` + +To install the application run + +``` +adb install -r ccnxandroidmetis/app/build/outputs/apk/app-armeabi-v7a-release.apk +``` + +To compile IGet for android app (ccnxandroidmetis) + +``` +make android_iget +``` + +To install the application run + +``` +adb install -r iget_android/app/build/outputs/apk/app-armeabi-v7a-release.apk +``` + + +## Platforms ## + +- Android + + + +## Getting Started ## + +To get simple help run `make`. This will give you a list of possible targets to +execute. You will basically want to download all the sources and compile. + +Here's a short summary: + +- `make init_depend` - Compile the CCNx dependencies each module in sequence +- `make all` - Compile all the software +- `make distclean` - Delete build directory (but not built executables) +- `make clobber` - Delete build directory and install directories. WARNING - If you configure this to install on a system directory this may delete system files! +- `make android_metis` - Compile the Metis for Android +- `make android_metis_debug` - Compile the Metis for Android in debug mode +- `make android_iget` - Compile the Metis for Android +- `make android_iget_debug` - Compile the Metis for Android in debug mode + + +## Configuration ## + +Distillery can be configured in multiple ways. Please check the config directory (specifically `config/config.mk`) for more information. + diff --git a/ccnxandroidmetis/.gitignore b/ccnxandroidmetis/.gitignore new file mode 100644 index 00000000..b1acfd93 --- /dev/null +++ b/ccnxandroidmetis/.gitignore @@ -0,0 +1 @@ +local.properties \ No newline at end of file diff --git a/ccnxandroidmetis/MetisControl/build.gradle b/ccnxandroidmetis/MetisControl/build.gradle new file mode 100644 index 00000000..a1e8ed15 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/build.gradle @@ -0,0 +1,52 @@ + +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion '25.0.0' + + defaultConfig { + applicationId "com.parc.ccnx.ccnxsdk" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + dexOptions { + preDexLibraries true + javaMaxHeapSize "2g" // Use gig increments depending on needs + //incremental true + } + + signingConfigs { + release { + storeFile file("metis.keystore") + storePassword "icn_metis" + keyAlias "metis" + keyPassword "icn_metis" + } + } + + buildTypes { + release { + signingConfig signingConfigs.release + } + } +} + + +dependencies { + compile project(':ccnxsupportlibrary') + compile fileTree(include: ['*.jar'], dir: 'libs') + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:design:23.4.0' + compile 'com.android.support:support-v4:23.4.0' +} diff --git a/ccnxandroidmetis/MetisControl/metis.keystore b/ccnxandroidmetis/MetisControl/metis.keystore new file mode 100644 index 00000000..3435fccd Binary files /dev/null and b/ccnxandroidmetis/MetisControl/metis.keystore differ diff --git a/ccnxandroidmetis/MetisControl/proguard-rules.pro b/ccnxandroidmetis/MetisControl/proguard-rules.pro new file mode 100644 index 00000000..c51dd9b5 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/walendo/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/ccnxandroidmetis/MetisControl/src/main/AndroidManifest.xml b/ccnxandroidmetis/MetisControl/src/main/AndroidManifest.xml new file mode 100644 index 00000000..272d9270 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/AndroidManifest.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/ForwarderStatusActivity.java b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/ForwarderStatusActivity.java new file mode 100644 index 00000000..7bc6bdb3 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/ForwarderStatusActivity.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.metis.ccnx.ccnxsdk.metiscontrol; + +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +public class ForwarderStatusActivity extends AppCompatActivity implements + MetisStatusFragment.OnFragmentVisibleListener { + + private static final String TAG = "CCNX FSA"; + + private SectionsPagerAdapter mSectionsPagerAdapter; + + private ViewPager mViewPager; + private Fragment mVisibleFragment; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_forwarder_status); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); + mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager.setAdapter(mSectionsPagerAdapter); + + + final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + + assert fab != null; + fab.setVisibility(View.GONE); + + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (mVisibleFragment != null) { + if (mVisibleFragment instanceof IMetisAddNewItem) { + IMetisAddNewItem fragment = (IMetisAddNewItem) mVisibleFragment; + fragment.showAddNewItemDialog(); + } + } + } + }); + + } + + + @Override + + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_forwarder_status, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + int id = item.getItemId(); + + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + public static class PlaceholderFragment extends Fragment { + + private static final String ARG_SECTION_NUMBER = "section_number"; + + public PlaceholderFragment() { + } + + public static PlaceholderFragment newInstance(int sectionNumber) { + PlaceholderFragment fragment = new PlaceholderFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_SECTION_NUMBER, sectionNumber); + fragment.setArguments(args); + return fragment; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_forwarder_status, container, false); + TextView textView = (TextView) rootView.findViewById(R.id.section_label); + textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); + return rootView; + } + } + + public class SectionsPagerAdapter extends FragmentPagerAdapter { + + public SectionsPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + return MetisStatusFragment.newInstance(position + 1); + } + + @Override + public int getCount() { + return 1; + } + + @Override + public CharSequence getPageTitle(int position) { + return "SECTION 1"; + } + + + } + + public void onFragmentVisible(Fragment fragment) { + Log.d(TAG, "***** PAGE: " + fragment + " is now showing."); + mVisibleFragment = fragment; + + final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + + if (fragment instanceof IMetisAddNewItem) { + fab.setVisibility(View.VISIBLE); + } else { + fab.setVisibility(View.INVISIBLE); + } + + String appName = getResources().getString(R.string.app_name); + + if (fragment instanceof IMetisNamedFragment) { + appName += " // " + ((IMetisNamedFragment) fragment).getFragmentName(); + } + + setTitle(appName); + + } + + + +} diff --git a/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/IMetisAddNewItem.java b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/IMetisAddNewItem.java new file mode 100644 index 00000000..549f4a68 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/IMetisAddNewItem.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.metis.ccnx.ccnxsdk.metiscontrol; + +public interface IMetisAddNewItem { + + void showAddNewItemDialog(); + +} diff --git a/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/IMetisNamedFragment.java b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/IMetisNamedFragment.java new file mode 100644 index 00000000..bc4cddca --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/IMetisNamedFragment.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.metis.ccnx.ccnxsdk.metiscontrol; + +public interface IMetisNamedFragment { + public String getFragmentName(); +} diff --git a/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisConstants.java b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisConstants.java new file mode 100644 index 00000000..7b9046ae --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisConstants.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.metis.ccnx.ccnxsdk.metiscontrol; + +public class MetisConstants { + + public static final int MetisDefaultListenerPort = 9695; + + public static final String MetisModule_Control = "Control"; + public static final String MetisModule_FIB = "FIB"; + public static final String MetisModule_PIT = "PIT"; + public static final String MetisModule_ContentStore = "ContentStore"; + public static final String MetisModule_TransportLinkAdapter = "TransportLinkAdapter"; + + public static final String CCNxNameMetis_Forwarder = "ccnx:/local/forwarder"; + public static final String CCNxNameMetis_Control = CCNxNameMetis_Forwarder + "/" + MetisModule_Control; + public static final String CCNxNameMetis_FIB = CCNxNameMetis_Forwarder + "/" + MetisModule_FIB; + public static final String CCNxNameMetis_PIT = CCNxNameMetis_Forwarder + "/" + MetisModule_PIT; + public static final String CCNxNameMetis_ContentStore = CCNxNameMetis_Forwarder + "/" + MetisModule_ContentStore; + ; + public static final String CCNxNameMetis_Link = CCNxNameMetis_Forwarder + "/" + MetisModule_TransportLinkAdapter; + + // General Commands + public static final int MetisCommandSegment = 3; + public static final String MetisCommand_Lookup = "lookup"; + public static final String MetisCommand_Add = "add"; + public static final String MetisCommand_List = "list"; + public static final String MetisCommand_Remove = "remove"; + public static final String MetisCommand_Resize = "resize"; + public static final String MetisCommand_Set = "set"; + public static final String MetisCommand_Quit = "quit"; + public static final String MetisCommand_Run = "spawn"; + public static final String MetisCommand_Stats = "stats"; + + public static final String MetisCommand_LogLevel = "level"; + public static final String MetisCommand_LogDebug = "debug"; + public static final String MetisCommand_LogInfo = "info"; + public static final String MetisCommand_LogError = "error"; + public static final String MetisCommand_LogAll = "all"; + public static final String MetisCommand_LogOff = "off"; + public static final String MetisCommand_LogNotice = "notice"; + ; + + // Module Specific Commands + public static final String CCNxNameMetisCommand_LinkConnect = CCNxNameMetis_Link + "/" + MetisCommand_Add; // create a connection to interface specified in payload, returns name + public static final String CCNxNameMetisCommand_LinkDisconnect = CCNxNameMetis_Link + "/" + MetisCommand_Remove; // remove a connection to interface specified in payload, by name + public static final String CCNxNameMetisCommand_LinkList = CCNxNameMetis_Link + "/" + MetisCommand_List; // list interfaces + + public static final String CCNxNameMetisCommand_FIBLookup = CCNxNameMetis_FIB + "/" + MetisCommand_Lookup; // return current FIB contents for name in payload + public static final String CCNxNameMetisCommand_FIBList = CCNxNameMetis_FIB + "/" + MetisCommand_List; // list current FIB contents + public static final String CCNxNameMetisCommand_FIBAddRoute = CCNxNameMetis_FIB + "/" + MetisCommand_Add; // add route for arguments in payload + public static final String CCNxNameMetisCommand_FIBRemoveRoute = CCNxNameMetis_FIB + "/" + MetisCommand_Remove; // remove route for arguments in payload + + public static final String CCNxNameMetisCommand_PITLookup = CCNxNameMetis_PIT + "/" + MetisCommand_Lookup; // return current PIT contents for name in payload + public static final String CCNxNameMetisCommand_PITList = CCNxNameMetis_PIT + "/" + MetisCommand_List; // list current PIT contents + + public static final String CCNxNameMetisCommand_ContentStoreResize = CCNxNameMetis_ContentStore + "/" + MetisCommand_Resize; // resize current content store to size in MB in payload + + public static final String CCNxNameMetisCommand_Quit = CCNxNameMetis_Control + "/" + MetisCommand_Quit; // ask the forwarder to exit + public static final String CCNxNameMetisCommand_Run = CCNxNameMetis_Control + "/" + MetisCommand_Run; // start a new forwarder instance + public static final String CCNxNameMetisCommand_Set = CCNxNameMetis_Control + "/" + MetisCommand_Set; // set a forwarder variable + public static final String CCNxNameMetisCommand_Stats = CCNxNameMetis_Control + "/" + MetisCommand_Stats; // get forwarder stats +}; diff --git a/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisService.java b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisService.java new file mode 100644 index 00000000..ee5ef5be --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisService.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.metis.ccnx.ccnxsdk.metiscontrol; + +import android.app.Notification; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; +import android.util.Log; + +import com.metis.ccnx.ccnxsupportlibrary.Metis; +import android.widget.TextView; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.Socket; + +public class MetisService extends Service { + private final static String TAG = "CCNx.MetisService"; + + private static Thread sForwarderThread = null; + + public MetisService() { + } + + private String path; + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + + Metis metis = Metis.getInstance(); + if (!metis.isRunning()) { + Log.d(TAG, "Starting Metis"); + String path = null; + if (intent != null && intent.getExtras() != null && intent.getExtras().get("path") != null) { + + path = intent.getExtras().get("path").toString(); + startForwarder(intent, path); + } else { + //TextView mPathTextView = (TextView) view.findViewById(R.id.pathText); + startForwarder(intent, "/storage/emulated/0/MetisConf/metis.cfg".toString()); + } + } else { + Log.d(TAG, "Metis already running."); + } + // Tell Android we want it restarted if it dies or is killed by the OS. + return Service.START_STICKY; + } + + + @Override + public void onDestroy() { + //get Metis instance + Metis metis = Metis.getInstance(); + Log.d(TAG, "Destroying"); + if (metis.isRunning()) { + Log.d(TAG, "Trying to stop Metis: " + metis.toString()); + metis.stop(); + stopForeground(true); + } + super.onDestroy(); + } + + protected Runnable mForwarderRunner = new Runnable() { + + //private String path; + @Override + public void run() { + Metis metis = Metis.getInstance(); + + metis.start(path); + } + + + }; + + + private void startForwarder(Intent intent, String path) { + + int NOTIFICATION_ID = 12345; + + Metis metis = Metis.getInstance(); + if (!metis.isRunning()) { + this.path = path; + sForwarderThread = new Thread(mForwarderRunner, "CCNx.MetisRunner"); + sForwarderThread.start(); + metis.isRunning(); + Intent resultIntent = new Intent(this, ForwarderStatusActivity.class); + + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, resultIntent, 0); + + Notification notification = new Notification.Builder(getApplicationContext()) + .setContentTitle(getString(R.string.app_name)) + .setContentText("Metis is running") + // .setSmallIcon(R.drawable.ic_notification) + .setSmallIcon(R.mipmap.ic_notification) + .setWhen(System.currentTimeMillis()) + .setContentIntent(pendingIntent) + .build(); + + notification.flags |= Notification.FLAG_NO_CLEAR; + + startForeground(NOTIFICATION_ID, notification); + } + } + + +} diff --git a/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisStatusFragment.java b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisStatusFragment.java new file mode 100644 index 00000000..370a53b4 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/java/com/metis/ccnx/ccnxsdk/metiscontrol/MetisStatusFragment.java @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.metis.ccnx.ccnxsdk.metiscontrol; + +import android.content.Context; +import android.content.Intent; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Handler; +import android.support.design.widget.Snackbar; +import android.support.v4.app.Fragment; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.CompoundButton; +import android.widget.Spinner; +import android.widget.Switch; +import android.widget.TextView; + +import com.metis.ccnx.ccnxsupportlibrary.Metis; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.nio.charset.Charset; +import java.util.List; + + +public class MetisStatusFragment extends Fragment implements IMetisNamedFragment { + + private static final String ARG_PAGER_INDEX = "metisstatus_pager_number"; + private static final String TAG = "CCNXMetis SF"; + + // TODO: Rename and change types of parameters + private int mPagerIndex; + + private Switch mSwitchMetisOnOff = null; + private Spinner mSpinnerLogLevel = null; + private Switch mSwitchContentStoreOnOff = null; + private TextView mTVNumInterests = null; + private TextView mTVNumContentObjects = null; + private TextView mTVNumInterestReturns = null; + private TextView mTVNumControlMessages = null; + private TextView mTVNumPITEntries = null; + private TextView mPathTextView = null; + + // Stats counters, updated by background task. + private long mNumInterests = 0; + private long mNumCOs = 0; + private long mNumInterestReturns = 0; + private long mNumControl = 0; + private long mNumPITENtries = 0; + + private boolean mIsStatsQueryRunning = false; + + + //private PortalFactory mPortalFactory = null; + + private OnFragmentVisibleListener mListener; + + + /** + * Create a Handler and a Runnable to be called every few seconds to query + * Metis (when running) for stats. + */ + private Handler mStatusUpdaterHandler = new Handler(); + private Runnable mStatusUpdateRunnable = new Runnable() { + @Override + public void run() { + // This runs on the main thread, so start an AsyncTask + // Repeat this the same runnable code block again another few seconds + //new GetStatusTask(null).execute(mPortalFactory); + //if (mIsStatsQueryRunning) { + //mStatusUpdaterHandler.postDelayed(mStatusUpdateRunnable, 2 * 1000); + //} + } + }; + + + public MetisStatusFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @return A new instance of fragment MetisStatusFragment. + */ + // TODO: Rename and change types and number of parameters + public static MetisStatusFragment newInstance(int pagerIndex) { + MetisStatusFragment fragment = new MetisStatusFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_PAGER_INDEX, pagerIndex); + + fragment.setArguments(args); + + return fragment; + } + + @Override + public void onStart() { + Metis metis = Metis.getInstance(); + mSwitchMetisOnOff.setChecked(metis.isRunning()); + super.onStart(); + } + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mPagerIndex = getArguments().getInt(ARG_PAGER_INDEX); + } + + + Log.d(TAG, "Creating new PortalFactory"); + //Identity identity = CCNxUtils.createCCNxIdentity(getContext(), + // "password", "ccnxsdkdemo", 1024, 30); + //mPortalFactory = new PortalFactory(identity); + } + + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_metis_status, container, false); + + mSwitchMetisOnOff = (Switch) view.findViewById(R.id.switchMetisOnOff); + mSwitchContentStoreOnOff = (Switch) view.findViewById(R.id.switchMetisContentStoreOnOff); + mSpinnerLogLevel = (Spinner) view.findViewById(R.id.spinnerMetisLoggingLevel); + mPathTextView = (TextView) view.findViewById(R.id.pathText) ; + + mSpinnerLogLevel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + String loggingLevel = mSpinnerLogLevel.getSelectedItem().toString(); + updateMetisLoggingLevel(loggingLevel); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + mSwitchMetisOnOff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + startMetis(); + //mSpinnerLogLevel.setEnabled(true); + //Log.d(TAG, "################# Start periodic query for stats"); + //if (!mIsStatsQueryRunning) { + // mStatusUpdaterHandler.postDelayed(mStatusUpdateRunnable, 500); + // mIsStatsQueryRunning = true; + // String loggingLevel = mSpinnerLogLevel.getSelectedItem().toString(); + // if (!loggingLevel.equalsIgnoreCase("off")) { + // updateMetisLoggingLevel(loggingLevel); + // } + //} + } else { + Log.d(TAG, "################# Stop periodic query for stats"); + //mStatusUpdaterHandler.removeCallbacks(mStatusUpdateRunnable); + //mIsStatsQueryRunning = false; + stopMetis(); + //mSpinnerLogLevel.setEnabled(false); + //mSpinnerLogLevel.setSelection(0); + } + } + }); + + mTVNumInterests = (TextView) view.findViewById(R.id.tvStatsNumInterests); + mTVNumContentObjects = (TextView) view.findViewById(R.id.tvStatsNumContentObjects); + mTVNumInterestReturns = (TextView) view.findViewById(R.id.tvStatsNumInterestReturns); + mTVNumControlMessages = (TextView) view.findViewById(R.id.tvStatsNumControl); + mTVNumPITEntries = (TextView) view.findViewById(R.id.tvStatsPITSize); + + mTVNumInterests.setText(String.valueOf(mNumInterests)); + mTVNumContentObjects.setText(String.valueOf(mNumCOs)); + mTVNumControlMessages.setText(String.valueOf(mNumControl)); + mTVNumInterestReturns.setText(String.valueOf(mNumInterestReturns)); + mTVNumPITEntries.setText(""); + + return view; + } + + private void startMetis() { + mPathTextView.setEnabled(false); + Metis metis = Metis.getInstance(); + if (!metis.isRunning()) { + Intent intent = new Intent(getActivity(), MetisService.class); + intent.putExtra("path", mPathTextView.getText()); + getActivity().startService(intent); + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + createExternalListeners(); + } + }, 1000); + } + } + + private void stopMetis() { + mPathTextView.setEnabled(true); + Intent intent = new Intent(getActivity(), MetisService.class); + + getActivity().stopService(intent); + + } + + private void updateMetisLoggingLevel(String loggingLevel) { + /*Metis metis = Metis.getInstance(); + if (metis.isRunning()) { + // Send an Interest control message to Metis with the new logging level. + String commandURI = MetisConstants.CCNxNameMetisCommand_Set + "/" + MetisConstants.MetisCommand_LogLevel + "/" + loggingLevel; + Name name = new Name(commandURI); + SendInterestTask task = new SendInterestTask(name, null, new SendInterestTask.OnInterestSentListener() { + @Override + public void onInterestSent(Message message) { + if (message instanceof ContentObject) { + + String responseString = new String(((ContentObject) message).payload()); + Snackbar snackbar = Snackbar + .make(mSwitchMetisOnOff, responseString, Snackbar.LENGTH_SHORT); + + snackbar.show(); + } else { + Log.d(TAG, "Unexpected non-Content response from sent Interest"); + } + } + }); + + task.execute(mPortalFactory); + }*/ + } + + private void createExternalListeners() { + + /*Metis metis = Metis.getInstance(); + + if (metis.isRunning()) { + + List ipAddresses = CCNxUtils.getLocalIpAddress(); + + for (InetAddress addr : ipAddresses) { + + // For the moment, just listen on the IPV4 addresses. The V6 addresses should work, + // but it's not yet tested. + + if (addr instanceof Inet4Address) { + + String ipAddress = addr.getHostAddress(); + + Log.d(TAG, "Adding external listener on: " + ipAddress); + + String linkURI = "tcp://" + ipAddress + ":" + MetisConstants.MetisDefaultListenerPort + "/listener"; + + Name name = new Name(MetisConstants.CCNxNameMetisCommand_LinkConnect); + + SendInterestTask task = new SendInterestTask(name, linkURI.getBytes(), new SendInterestTask.OnInterestSentListener() { + @Override + public void onInterestSent(Message message) { + if (message instanceof ContentObject) { + + String responseString = new String(((ContentObject) message).payload()); + Snackbar snackbar = Snackbar + .make(mSwitchMetisOnOff, responseString, Snackbar.LENGTH_SHORT); + + snackbar.show(); + } else { + Log.d(TAG, "Unexpected non-Content response from sent Interest"); + } + } + }); + + task.execute(mPortalFactory); + } + } + }*/ + } + + + @Override + public void onAttach(Context context) { + super.onAttach(context); + if (context instanceof OnFragmentVisibleListener) { + mListener = (OnFragmentVisibleListener) context; + } else { + throw new RuntimeException(context.toString() + + " must implement OnFragmentInteractionListener"); + } + } + + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + Metis metis = Metis.getInstance(); + + if (isVisibleToUser) { + mListener.onFragmentVisible(this); + + if (metis.isRunning()) { + // Begin updating stats. + if (!mIsStatsQueryRunning) { + mStatusUpdaterHandler.postDelayed(mStatusUpdateRunnable, 100); + mIsStatsQueryRunning = true; + } + } + } else { + mStatusUpdaterHandler.removeCallbacks(mStatusUpdateRunnable); + mIsStatsQueryRunning = false; + } + } + + @Override + public void onDetach() { + mStatusUpdaterHandler.removeCallbacks(mStatusUpdateRunnable); + mIsStatsQueryRunning = false; + super.onDetach(); + mListener = null; + } + + @Override + public String getFragmentName() { + return "Status"; + } + + public interface OnFragmentVisibleListener { + // TODO: Update argument type and name + void onFragmentVisible(Fragment which); + } + + /*private class GetStatusTask extends AsyncTask { + + private boolean mSuccess = false; + private PortalFactory mPortalFactory = null; + + + public GetStatusTask(String unused) { + } + + @Override + protected Integer doInBackground(PortalFactory... args) { + Thread.currentThread().setName("GetStatusTask-Async"); + + mPortalFactory = args[0]; + try { + Name controlName = new Name(MetisConstants.CCNxNameMetisCommand_Stats); + + Interest interest = new Interest(controlName); + + try { + Portal portal = mPortalFactory.getPortal(); + + portal.send(interest, 0L); + + Message m = portal.receive(0L); + + if (m instanceof ContentObject) { + mSuccess = true; + ContentObject co = (ContentObject) m; + byte[] payload = co.payload(); + + if (payload != null) { + String jsonString = new String(payload, Charset.defaultCharset()); + //Log.d(TAG, "Received: XX " + jsonString + " XX"); + try { + JSONObject jo = new JSONObject(jsonString); + //Log.d(TAG, "JSON2: " + jo.toString(2)); + + mNumInterests = jo.getLong("numProcessedInterests"); + mNumCOs = jo.getLong("numProcessedContentObjects"); + mNumControl = jo.getLong("numProcessedControlMessages"); + mNumInterestReturns = jo.getLong("numProcessedInterestReturns"); + } catch (JSONException ex) { + Log.e(TAG, "Could not parse returned JSON: " + ex.getMessage()); + } + } + } + portal.close(); + } catch (Portal.CommunicationsError ex) { + Log.e(TAG, "Error sending AddLink command: " + ex.getMessage()); + } + } catch (Exception ex) { + Log.e(TAG, "Error adding link: " + ex.getMessage()); + } + + return 1; + } + + @Override + protected void onPostExecute(Integer ignored) { + + if (mSuccess) { + mTVNumInterests.setText(String.valueOf(mNumInterests)); + mTVNumContentObjects.setText(String.valueOf(mNumCOs)); + mTVNumControlMessages.setText(String.valueOf(mNumControl)); + mTVNumInterestReturns.setText(String.valueOf(mNumInterestReturns)); + mTVNumPITEntries.setText(""); + } + } + }*/ + +} diff --git a/ccnxandroidmetis/MetisControl/src/main/res/drawable/add_panel_border.xml b/ccnxandroidmetis/MetisControl/src/main/res/drawable/add_panel_border.xml new file mode 100644 index 00000000..abb8d9a8 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/drawable/add_panel_border.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_48.png b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_48.png new file mode 100644 index 00000000..660a9e50 Binary files /dev/null and b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_48.png differ diff --git a/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_96.png b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_96.png new file mode 100644 index 00000000..f73a233c Binary files /dev/null and b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_96.png differ diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/activity_forwarder_status.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/activity_forwarder_status.xml new file mode 100644 index 00000000..5e627c02 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/activity_forwarder_status.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_forwarder_status.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_forwarder_status.xml new file mode 100644 index 00000000..943d2ad2 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_forwarder_status.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_links.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_links.xml new file mode 100644 index 00000000..1041eeb4 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_links.xml @@ -0,0 +1,99 @@ + + + + + + + + + +