diff options
author | Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr> | 2017-03-29 18:00:06 +0200 |
---|---|---|
committer | Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr> | 2017-03-30 18:58:33 +0200 |
commit | 3137acdd5a45285dab9903f9d41560c63eca8523 (patch) | |
tree | 38bd8525a9e214d848a73fc40e81ddb182cf91b6 /ccnxandroidmetis | |
parent | 9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff) |
first commit
Change-Id: I8412b8e7d966c2fbc508b537fd9a9bbcfc628ca8
Signed-off-by: Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr>
Diffstat (limited to 'ccnxandroidmetis')
52 files changed, 2435 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 00000000..3435fccd --- /dev/null +++ b/ccnxandroidmetis/MetisControl/metis.keystore 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 @@ +<?xml version="1.0" encoding="utf-8"?> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.metis.ccnx.ccnxsdk.metiscontrol"> + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@style/AppTheme"> + <activity + android:name=".ForwarderStatusActivity" + android:label="@string/app_name" + android:screenOrientation="portrait" + android:theme="@style/AppTheme.NoActionBar"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <service + android:name=".MetisService" + android:enabled="true" + android:exported="true"> + + </service> + + </application> + + + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission + android:name="android.permission.READ_EXTERNAL_STORAGE" + android:maxSdkVersion="21" /> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + + +</manifest> + + <!-- android:process=":metis_process" --> 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<InetAddress> 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<PortalFactory, String, Integer> { + + 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <stroke + android:width="3dp" + android:color="@color/colorPrimaryDark" /> + + <corners android:radius="10dip" /> +</shape> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_48.png b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_48.png Binary files differnew file mode 100644 index 00000000..660a9e50 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_48.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_96.png b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_96.png Binary files differnew file mode 100644 index 00000000..f73a233c --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/drawable/ic_plus_96.png 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.design.widget.CoordinatorLayout 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" + android:id="@+id/main_content" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:context=".ForwarderStatusActivity"> + + <android.support.design.widget.AppBarLayout + android:id="@+id/appbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="@dimen/appbar_padding_top" + android:theme="@style/AppTheme.AppBarOverlay"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + app:layout_scrollFlags="scroll|enterAlways" + app:popupTheme="@style/AppTheme.PopupOverlay"> + + </android.support.v7.widget.Toolbar> + + </android.support.design.widget.AppBarLayout> + + <android.support.v4.view.ViewPager + android:id="@+id/container" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + + + <android.support.design.widget.FloatingActionButton + android:id="@+id/fab" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end|bottom" + android:layout_margin="@dimen/fab_margin" + android:src="@android:drawable/ic_input_add" /> + +</android.support.design.widget.CoordinatorLayout> 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 @@ +<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:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + tools:context=".ForwarderStatusActivity$PlaceholderFragment"> + + <TextView + android:id="@+id/section_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + +</RelativeLayout> 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 @@ +<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:animateLayoutChanges="true" + + tools:context=".MetisLinksFragment"> + + <!-- TODO: Update blank fragment layout --> + + <RelativeLayout + android:id="@+id/rlLinkAddPanel" + android:visibility="visible" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginTop="10dp" + android:background="@drawable/add_panel_border" + android:gravity="top" + android:layout_marginBottom="10dp" + android:padding="10px" + + > + + <android.support.v7.widget.AppCompatSpinner + android:id="@+id/spinnerLinkTypeAdd" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginRight="8dp" + android:layout_centerVertical="true" + android:entries="@array/metis_link_type_array" /> + + + <Button + android:id="@+id/btnAddLink" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:text="Add Link" + android:layout_marginRight="10dp" + android:layout_alignParentEnd="true" /> + + <EditText + android:id="@+id/etLinkAddAddress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:hint="192.168.0.100:9695" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_toRightOf="@id/spinnerLinkTypeAdd" + android:layout_toLeftOf="@id/btnAddLink" /> + + <CheckBox + android:id="@+id/cbLinkListener" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="listener?" + android:layout_toRightOf="@id/spinnerLinkTypeAdd" + android:layout_below="@+id/etLinkAddAddress" /> + + + </RelativeLayout> + + <android.support.v7.widget.LinearLayoutCompat + android:id="@+id/llLinkButtons" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_marginBottom="20dp" + android:layout_marginTop="10dp" + android:layout_below="@id/rlLinkAddPanel" + android:orientation="horizontal"> + + <Button + android:id="@+id/btnRefresh" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/rlLinkAddPanel" + android:text="Refresh" /> + + </android.support.v7.widget.LinearLayoutCompat> + + <ListView + android:id="@+id/lvLinkList" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_below="@id/llLinkButtons" + android:layout_gravity="top|center_horizontal" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginBottom="80dp" + android:padding="10dp" + android:background="@drawable/add_panel_border" + android:divider="@android:color/transparent" + android:layout_alignParentBottom="true" + android:dividerHeight="10dp" /> + +</RelativeLayout> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_routes.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_routes.xml new file mode 100644 index 00000000..bd0857b5 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_routes.xml @@ -0,0 +1,80 @@ +<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:animateLayoutChanges="true" + + tools:context=".MetisRoutesFragment"> + + <!-- TODO: Update blank fragment layout --> + + <RelativeLayout + android:id="@+id/rlRouteAddPanel" + android:visibility="visible" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginTop="10dp" + android:background="@drawable/add_panel_border" + android:gravity="top" + android:layout_marginBottom="10dp" + android:padding="10px" + + > + + <Button + android:id="@+id/btnAddRoute" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:text="Add Route" + android:layout_marginRight="10dp" + android:layout_alignParentEnd="true" /> + + <EditText + android:id="@+id/etRouteAddAddress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:hint="192.168.0.100:9695" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_toLeftOf="@id/btnAddRoute" /> + + + </RelativeLayout> + + <android.support.v7.widget.LinearLayoutCompat + android:id="@+id/llRouteButtons" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_marginBottom="20dp" + android:layout_marginTop="10dp" + android:layout_below="@id/rlRouteAddPanel" + android:orientation="horizontal"> + + <Button + android:id="@+id/btnRefresh" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/rlRouteAddPanel" + android:text="Refresh" /> + + </android.support.v7.widget.LinearLayoutCompat> + + <ListView + android:id="@+id/lvRouteList" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_below="@id/llRouteButtons" + android:layout_gravity="top|center_horizontal" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginBottom="80dp" + android:background="@drawable/add_panel_border" + android:padding="10dp" + android:divider="@android:color/transparent" + android:layout_alignParentBottom="true" + android:dividerHeight="10dp" /> + +</RelativeLayout> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_script.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_script.xml new file mode 100644 index 00000000..c248203c --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_script.xml @@ -0,0 +1,54 @@ + +<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:animateLayoutChanges="true" + tools:context=".MetisStatusFragment"> + + <Button + android:id="@+id/btnRunScript" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal|top" + android:text="Run Script" + android:layout_alignParentTop="true" + android:layout_marginTop="20dp" + android:layout_centerHorizontal="true" /> + + <TextView + android:id="@+id/etScript" + style="@style/Base.TextAppearance.AppCompat.Small" + android:layout_below="@id/btnRunScript" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:enabled="true" + android:isScrollContainer="true" + android:maxLines="100" + android:minLines="6" + android:padding="24dp" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_marginTop="10dp" + android:layout_marginBottom="80dp" + android:focusable="true" + android:inputType="textMultiLine|textNoSuggestions" + android:textIsSelectable="true" + android:layout_centerVertical="true" + android:layout_alignParentStart="true" + android:background="@drawable/add_panel_border" + + /> + + <TextView + android:id="@+id/tvMetisScriptHelp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/metis_script_help" + android:gravity="center_horizontal" + android:layout_centerInParent="true" + android:paddingBottom="60dp" + android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" + /> + +</RelativeLayout> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_status.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_status.xml new file mode 100644 index 00000000..5678f0d4 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/fragment_metis_status.xml @@ -0,0 +1,208 @@ + +<FrameLayout 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" + tools:context=".MetisStatusFragment"> + + <!-- TODO: Update blank fragment layout --> + + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + + android:layout_gravity="top|center_horizontal" + android:layout_marginTop="80dp"> + + <EditText + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:inputType="textPersonName" + android:text="/storage/emulated/0/MetisConf/metis.cfg" + android:layout_marginBottom="30dp" + android:layout_gravity="top" + android:ems="10" + android:id="@+id/pathText" + android:typeface="normal" /> + + <Switch + android:id="@+id/switchMetisOnOff" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_below="@id/pathText" + android:layout_marginBottom="30dp" + android:checked="false" + android:text="Metis Enabled " + + android:textAppearance="?android:attr/textAppearanceLarge" /> + + <Switch + android:id="@+id/switchMetisContentStoreOnOff" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/switchMetisOnOff" + android:layout_gravity="center" + android:text="Content Store (cache) " + android:enabled="false" + android:layout_marginBottom="20dp" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/tvLoggingLevelLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:enabled="false" + android:text = "Logging level:" + android:layout_below="@id/switchMetisContentStoreOnOff" + android:textAppearance="?android:attr/textAppearanceMedium" + + /> + + <android.support.v7.widget.AppCompatSpinner + android:id="@+id/spinnerMetisLoggingLevel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/switchMetisContentStoreOnOff" + android:layout_toRightOf="@id/tvLoggingLevelLabel" + android:enabled="true" + android:textAppearance="?android:attr/textAppearanceMedium" + android:entries="@array/metis_log_levels" /> + + + </RelativeLayout> + + <TableLayout + android:visibility="invisible" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|center_horizontal" + android:background="@drawable/add_panel_border" + android:padding="20dp" + android:layout_marginBottom="80dp" + android:orientation="vertical"> + + <TableRow + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="4dp" + + android:layout_gravity="center_horizontal" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tvStatsNumInterestsLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="# Interests Processed: " + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/tvStatsNumInterests" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@+id/tvStatsNumInterestsLabel" + android:text="0" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + </TableRow> + + <TableRow + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="4dp" + + android:layout_gravity="center_horizontal" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tvStatsNumContentObjectsLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="# ContentObjects Processed: " + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/tvStatsNumContentObjects" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@+id/tvStatsNumInterestsLabel" + android:text="0" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + </TableRow> + + <TableRow + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginBottom="4dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tvStatsNumControlLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="# Control Messages Processed: " + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/tvStatsNumControl" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@+id/tvStatsNumInterestsLabel" + android:text="0" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + </TableRow> + + <TableRow + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginBottom="4dp" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tvStatsNumInterestReturnsLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="# InterestReturns Processed: " + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/tvStatsNumInterestReturns" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@+id/tvStatsNumInterestsLabel" + android:text="0" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + </TableRow> + + <TableRow + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tvStatsPITSizeLabel" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="# PIT entries: " + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/tvStatsPITSize" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@+id/tvStatsNumInterestsLabel" + android:text="0" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + </TableRow> + + </TableLayout> + +</FrameLayout> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/listitem_metis_links.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/listitem_metis_links.xml new file mode 100644 index 00000000..19bc5548 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/listitem_metis_links.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="10dp" + android:paddingTop="3dp" + > + + <TextView + android:id="@+id/tvLinkName" + android:text="foo bar bar" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textColor="@color/colorPrimaryDark" + /> + + + <TextView + android:id="@+id/tvLinkLocalOrRemote" + android:text="local" + android:layout_below="@id/tvLinkName" + + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="5dp" + /> + + <TextView + android:id="@+id/tvLinkListener" + android:text="listener" + android:layout_toRightOf="@id/tvLinkLocalOrRemote" + android:layout_below="@id/tvLinkName" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="5dp" + /> + + <TextView + android:id="@+id/tvLinkIPAddress" + android:layout_below="@id/tvLinkName" + android:text="" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="5dp" + android:layout_toRightOf="@id/tvLinkListener" + /> + +</RelativeLayout> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/layout/listitem_metis_routes.xml b/ccnxandroidmetis/MetisControl/src/main/res/layout/listitem_metis_routes.xml new file mode 100644 index 00000000..2372b352 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/layout/listitem_metis_routes.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="5dp" + android:paddingTop="3dp" + android:background="@color/list_bg_1" + > + + <TextView + android:id="@+id/tvRouteName" + android:text="ccnx:/foo/bar" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textColor="@color/colorPrimaryDark" + /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/tvRouteArrow" + android:text="==>" + android:layout_marginLeft="20dp" + android:layout_below="@id/tvRouteName" + android:textAppearance="@style/TextAppearance.AppCompat.Medium" + + /> + + <TextView + android:id="@+id/tvRouteLink" + android:text="dest" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/tvRouteName" + android:layout_marginLeft="15dp" + android:layout_toRightOf="@id/tvRouteArrow" + android:textAppearance="@style/TextAppearance.AppCompat.Medium" + + /> + +</RelativeLayout> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/menu/menu_forwarder_status.xml b/ccnxandroidmetis/MetisControl/src/main/res/menu/menu_forwarder_status.xml new file mode 100644 index 00000000..e94f118a --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/menu/menu_forwarder_status.xml @@ -0,0 +1,10 @@ +<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=".metiscontrol.ForwarderStatusActivity"> + <item + android:id="@+id/action_settings" + android:orderInCategory="100" + android:title="@string/action_settings" + app:showAsAction="never" /> +</menu> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/mipmap-hdpi/ic_launcher.png b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..96715136 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/mipmap-mdpi/ic_launcher.png b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..a74e9a0d --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/mipmap-mdpi/ic_notification.png b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-mdpi/ic_notification.png Binary files differnew file mode 100755 index 00000000..82552e85 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-mdpi/ic_notification.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xhdpi/ic_launcher.png b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..760fec0f --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xxhdpi/ic_launcher.png b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..d840ecb4 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 00000000..0844619e --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/ccnxandroidmetis/MetisControl/src/main/res/values-v21/styles.xml b/ccnxandroidmetis/MetisControl/src/main/res/values-v21/styles.xml new file mode 100644 index 00000000..de6d88e2 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/values-v21/styles.xml @@ -0,0 +1,10 @@ + +<resources> + + <style name="AppTheme.NoActionBar"> + <item name="windowActionBar">false</item> + <item name="windowNoTitle">true</item> + <item name="android:windowDrawsSystemBarBackgrounds">true</item> + <item name="android:statusBarColor">@android:color/transparent</item> + </style> +</resources> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/values-w820dp/dimens.xml b/ccnxandroidmetis/MetisControl/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 00000000..63fc8164 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/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/ccnxandroidmetis/MetisControl/src/main/res/values/colors.xml b/ccnxandroidmetis/MetisControl/src/main/res/values/colors.xml new file mode 100644 index 00000000..2c04684a --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="colorPrimary">#3F51B5</color> + <color name="colorPrimaryDark">#303F9F</color> + <color name="colorAccent">#FF4081</color> + + <color name="list_bg_1">#ffffff</color> + <color name="list_bg_2">#eafaea</color> + +</resources> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/values/dimens.xml b/ccnxandroidmetis/MetisControl/src/main/res/values/dimens.xml new file mode 100644 index 00000000..cef3abc4 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/values/dimens.xml @@ -0,0 +1,7 @@ +<resources> + <!-- Default screen margins, per the Android Design guidelines. --> + <dimen name="activity_horizontal_margin">16dp</dimen> + <dimen name="activity_vertical_margin">16dp</dimen> + <dimen name="fab_margin">16dp</dimen> + <dimen name="appbar_padding_top">8dp</dimen> +</resources> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/values/strings.xml b/ccnxandroidmetis/MetisControl/src/main/res/values/strings.xml new file mode 100644 index 00000000..e5a7f500 --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/values/strings.xml @@ -0,0 +1,37 @@ +<resources> + <string name="app_name">Metis Control</string> + <string name="action_settings">Settings</string> + <string name="section_format">Hello World from section: %1$d</string> + + <!-- TODO: Remove or change this placeholder text --> + <string name="asf_hello">Metis Status Fragment</string> + <string name="asf_big_text">METIS STATUS</string> + + <!-- TODO: Remove or change this placeholder text --> + <string name="hello_blank_fragment">Hello blank fragment</string> + + + <string-array name="metis_link_type_array"> + <item>TCP</item> + <item>UDP</item> + </string-array> + + <string-array name="metis_log_levels"> + <item>Off</item> + <item>Notice</item> + <item>Error</item> + <item>Info</item> + <item>Debug</item> + <item>All</item> + </string-array> + + <string name="cancel">Cancel</string> + <string name="add">Add</string> + + <string name="listener_remote">remote</string> + <string name="listener_local">local</string> + <string name="listener_listener">listener</string> + + <string name="metis_script_help">Place an Metis statefile in:\n /mnt/sdcard/ccnx/metis.statefile\nif you want to initialize Metis with\nmany commands.</string> + +</resources> diff --git a/ccnxandroidmetis/MetisControl/src/main/res/values/styles.xml b/ccnxandroidmetis/MetisControl/src/main/res/values/styles.xml new file mode 100644 index 00000000..545b9c6d --- /dev/null +++ b/ccnxandroidmetis/MetisControl/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + <item name="colorPrimary">@color/colorPrimary</item> + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> + <item name="colorAccent">@color/colorAccent</item> + </style> + + <style name="AppTheme.NoActionBar"> + <item name="windowActionBar">false</item> + <item name="windowNoTitle">true</item> + </style> + + <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> + + <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> + +</resources> diff --git a/ccnxandroidmetis/build.gradle b/ccnxandroidmetis/build.gradle new file mode 100644 index 00000000..2b9e8c54 --- /dev/null +++ b/ccnxandroidmetis/build.gradle @@ -0,0 +1,26 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} + +task build(dependsOn: ':ccnxsupportlibrary:build') + diff --git a/ccnxandroidmetis/ccnxsupportlibrary/build.gradle b/ccnxandroidmetis/ccnxsupportlibrary/build.gradle new file mode 100644 index 00000000..3ec07d19 --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/build.gradle @@ -0,0 +1,66 @@ + +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion '25.0.0' + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + debug { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + sourceSets { + main { + jni.srcDirs = [] + java.srcDirs = ['src/main/java'] + resources.srcDirs = ['src/main/res'] + res.srcDirs = ['src/main/res'] + jniLibs.srcDirs = ['src/main/libs'] + assets.srcDirs = ['src/main/assets'] + } + } + + task buildNative(type: Exec, description: 'Compile JNI source via NDK') { + def ndkDir = android.ndkDirectory + commandLine "$ndkDir/ndk-build", + '-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source + '-j', Runtime.runtime.availableProcessors(), + 'all', + 'NDK_DEBUG=1' + } + + task cleanNative(type: Exec, description: 'Clean JNI object files') { + def ndkDir = android.ndkDirectory + commandLine "$ndkDir/ndk-build", + '-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source + 'clean' + } + + tasks.withType(JavaCompile) { + compileTask -> compileTask.dependsOn(buildNative) + } + + clean.dependsOn 'cleanNative' +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.4.0' +} + +configurations.maybeCreate("default") +artifacts.add("default", file('build/outputs/aar/ccnxsupportlibrary-release.aar')) diff --git a/ccnxandroidmetis/ccnxsupportlibrary/proguard-rules.pro b/ccnxandroidmetis/ccnxsupportlibrary/proguard-rules.pro new file mode 100644 index 00000000..c51dd9b5 --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/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/ccnxsupportlibrary/src/main/AndroidManifest.xml b/ccnxandroidmetis/ccnxsupportlibrary/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8ac2d0c6 --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ +<!-- + ~ 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. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.metis.ccnx.ccnxsupportlibrary"> + + <application + android:allowBackup="true" + android:label="@string/app_name" + android:supportsRtl="true"> + + </application> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission + android:name="android.permission.READ_EXTERNAL_STORAGE" + android:maxSdkVersion="21" /> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + +</manifest> diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/java/com/metis/ccnx/ccnxsupportlibrary/Metis.java b/ccnxandroidmetis/ccnxsupportlibrary/src/main/java/com/metis/ccnx/ccnxsupportlibrary/Metis.java new file mode 100644 index 00000000..5be6af9a --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/java/com/metis/ccnx/ccnxsupportlibrary/Metis.java @@ -0,0 +1,40 @@ +/* + * 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.ccnxsupportlibrary; + +public class Metis { + + private static Metis sInstance = null; + + static { + System.loadLibrary("ccnxsupportlibrary"); + } + + public static Metis getInstance() { + if (sInstance == null) { + sInstance = new Metis(); + } + return sInstance; + } + + private Metis() { + + } + + public native boolean isRunning(); + public native void start(String path); + public native void stop(); +} diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/Android.mk b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/Android.mk new file mode 100644 index 00000000..6613742d --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/Android.mk @@ -0,0 +1,19 @@ +############################################################################## +# 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. +############################################################################## +LOCAL_PATH := $(call my-dir) + +subdirs := $(call all-subdir-makefiles) + +include $(subdirs) diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/Application.mk b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/Application.mk new file mode 100644 index 00000000..bd11e2d6 --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/Application.mk @@ -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. +############################################################################## + +APP_PLATFORM := android-23 + +APP_ABI := armeabi-v7a + +APP_MODULES += ccnxsupportlibrary diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Android.mk b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Android.mk new file mode 100644 index 00000000..2d2ab65c --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Android.mk @@ -0,0 +1,121 @@ +############################################################################## +# 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. +############################################################################## + +LOCAL_PATH := $(call my-dir) + +ARMDIST_ROOT := $(DISTILLERY_ROOT_DIR) + +ARMDIST := $(ARMDIST_ROOT)/usr +ARMDEPS := $(ARMDIST_ROOT)/usr +METIS_INC := $(ARMDIST_ROOT)/usr/include + +include $(CLEAR_VARS) +LOCAL_MODULE := liblongbow-ansiterm +LOCAL_SRC_FILES := $(ARMDIST)/lib/liblongbow-ansiterm.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := liblongbow-textplain +LOCAL_SRC_FILES := $(ARMDIST)/lib/liblongbow-textplain.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libparc +LOCAL_SRC_FILES := $(ARMDIST)/lib/libparc.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libmetis +LOCAL_SRC_FILES := $(ARMDIST)/lib/libmetis.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libccnx_api_control +LOCAL_SRC_FILES := $(ARMDIST)/lib/libccnx_api_control.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libccnx_api_notify +LOCAL_SRC_FILES := $(ARMDIST)/lib/libccnx_api_notify.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libccnx_api_portal +LOCAL_SRC_FILES := $(ARMDIST)/lib/libccnx_api_portal.a +include $(PREBUILT_STATIC_LIBRARY) +include $(CLEAR_VARS) + +include $(CLEAR_VARS) +LOCAL_MODULE := libccnx_transport_rta +LOCAL_SRC_FILES := $(ARMDIST)/lib/libccnx_transport_rta.a +include $(PREBUILT_STATIC_LIBRARY) +include $(CLEAR_VARS) + +include $(CLEAR_VARS) +LOCAL_MODULE := libccnx_common +LOCAL_SRC_FILES := $(ARMDIST)/lib/libccnx_common.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libevent +LOCAL_SRC_FILES := $(ARMDEPS)/lib/libevent.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libssl +LOCAL_SRC_FILES := $(ARMDEPS)/lib/libssl.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libcrypto +LOCAL_SRC_FILES := $(ARMDEPS)/lib/libcrypto.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := liblongbow +LOCAL_SRC_FILES := $(ARMDIST)/lib/liblongbow.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := ccnxsupportlibrary + + +LOCAL_SRC_FILES := \ + Metis_wrap.c + +LOCAL_CFLAGS := $(M_CFLAGS) $(OS_CFLAGS) -I$(ARMDIST)/include -I$(METIS_INC) + +LOCAL_CFLAGS += -I$(ARMDIST)/include -I$(METIS_INC) +LOCAL_CFLAGS += -std=c99 -g + + +LOCAL_LDLIBS := -ldl -llog $(OS_LDFLAGS) + +LOCAL_STATIC_LIBRARIES := \ + libmetis \ + libccnx_api_portal \ + libccnx_api_control \ + libccnx_api_notify \ + libccnx_transport_rta \ + libccnx_common \ + libparc \ + liblongbow \ + liblongbow-textplain \ + liblongbow-ansiterm \ + libssl \ + libevent \ + libcrypto + +include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Metis_wrap.c b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Metis_wrap.c new file mode 100644 index 00000000..2febb40f --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Metis_wrap.c @@ -0,0 +1,131 @@ +/* + * 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. + */ + +#include <string.h> +#include <stdio.h> +#include <getopt.h> +#include <sys/param.h> +#include <sys/utsname.h> +#include <pthread.h> +#include <dirent.h> +#include <android/log.h> +#include "Metis_wrap.h" +#include <ccnx/forwarder/metis/core/metis_Forwarder.h> +#include <ccnx/forwarder/metis/core/metis_System.h> +#include <ccnx/forwarder/metis/content_store/metis_ContentStoreInterface.h> +#include <ccnx/api/control/cpi_Listener.h> +#include <ccnx/api/control/cpi_InterfaceSet.h> + + +static bool _isRunning = false; + + +static MetisForwarder *metis; + +static void +_setLogLevelToLevel(int logLevelArray[MetisLoggerFacility_END], MetisLoggerFacility facility, const char *levelString) +{ + PARCLogLevel level = parcLogLevel_FromString(levelString); + + if (level < PARCLogLevel_All) { + // we have a good facility and level + logLevelArray[facility] = level; + } else { + printf("Invalid log level string %s\n", levelString); + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap", "Invalid log level stringa %s", levelString); + } +} + + +static void +_setLogLevel(int logLevelArray[MetisLoggerFacility_END], const char *string) +{ + char *tofree = parcMemory_StringDuplicate(string, strlen(string)); + char *p = tofree; + + char *facilityString = strsep(&p, "="); + if (facilityString) { + char *levelString = p; + + if (strcasecmp(facilityString, "all") == 0) { + for (MetisLoggerFacility facility = 0; facility < MetisLoggerFacility_END; facility++) { + _setLogLevelToLevel(logLevelArray, facility, levelString); + } + } else { + MetisLoggerFacility facility; + for (facility = 0; facility < MetisLoggerFacility_END; facility++) { + if (strcasecmp(facilityString, metisLogger_FacilityString(facility)) == 0) { + break; + } + } + + if (facility < MetisLoggerFacility_END) { + _setLogLevelToLevel(logLevelArray, facility, levelString); + } else { + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap", "Invalid facility string %s", facilityString); + } + } + } + parcMemory_Deallocate((void **) &tofree); +} + + + +JNIEXPORT void JNICALL Java_com_metis_ccnx_ccnxsupportlibrary_Metis_start + (JNIEnv *env, jobject obj, jstring path) +{ + if (!_isRunning) { + metis = metisForwarder_Create(NULL); + MetisConfiguration *configuration = metisForwarder_GetConfiguration(metis); + metisConfiguration_SetObjectStoreSize(configuration, 0); + metisConfiguration_StartCLI(configuration, 2001); + if (path != NULL) { + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap","qui"); + const char *configFileName = (*env)->GetStringUTFChars(env, path, 0); + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap", "configuration file %s", configFileName); + metisForwarder_SetupFromConfigFile(metis, configFileName); + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap","config from file"); + } else { + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap","qua"); + metisForwarder_SetupAllListeners(metis, PORT_NUMBER, NULL); + } + MetisDispatcher *dispatcher = metisForwarder_GetDispatcher(metis); + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap","dispatcher"); + _isRunning = true; + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap","true"); + metisDispatcher_Run(dispatcher); + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap","run"); + } + + } + +JNIEXPORT void JNICALL Java_com_metis_ccnx_ccnxsupportlibrary_Metis_stop + (JNIEnv *env, jobject obj) +{ + if(_isRunning) { + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap", "%s", "stopping metis..."); + metisForwarder_Destroy(&metis); + _isRunning = false; + } +} + + +JNIEXPORT jboolean JNICALL Java_com_metis_ccnx_ccnxsupportlibrary_Metis_isRunning + (JNIEnv *env, jobject obj) { + __android_log_print(ANDROID_LOG_DEBUG, "Metis Wrap", "%s %d", " metis is running", _isRunning); + return _isRunning; +} + + diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Metis_wrap.h b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Metis_wrap.h new file mode 100644 index 00000000..ad4bceb2 --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/jni/ccnxsupportlibrary/Metis_wrap.h @@ -0,0 +1,24 @@ +/* + * 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. + */ + +#include <jni.h> +#include <android/log.h> + +#define LOG_TAG "CCNxSDK" +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) + + diff --git a/ccnxandroidmetis/ccnxsupportlibrary/src/main/res/values/strings.xml b/ccnxandroidmetis/ccnxsupportlibrary/src/main/res/values/strings.xml new file mode 100644 index 00000000..843d2b5b --- /dev/null +++ b/ccnxandroidmetis/ccnxsupportlibrary/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">CCNxSupportLibrary</string> +</resources> diff --git a/ccnxandroidmetis/gradle.properties b/ccnxandroidmetis/gradle.properties new file mode 100644 index 00000000..a21cee45 --- /dev/null +++ b/ccnxandroidmetis/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +org.gradle.jvmargs=-Xmx3072M -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects + org.gradle.parallel=true diff --git a/ccnxandroidmetis/gradle/wrapper/gradle-wrapper.jar b/ccnxandroidmetis/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 00000000..13372aef --- /dev/null +++ b/ccnxandroidmetis/gradle/wrapper/gradle-wrapper.jar diff --git a/ccnxandroidmetis/gradle/wrapper/gradle-wrapper.properties b/ccnxandroidmetis/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..d72c5eb2 --- /dev/null +++ b/ccnxandroidmetis/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Mar 21 18:47:10 CET 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/ccnxandroidmetis/gradlew b/ccnxandroidmetis/gradlew new file mode 100755 index 00000000..9d82f789 --- /dev/null +++ b/ccnxandroidmetis/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/ccnxandroidmetis/gradlew.bat b/ccnxandroidmetis/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/ccnxandroidmetis/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ccnxandroidmetis/settings.gradle b/ccnxandroidmetis/settings.gradle new file mode 100644 index 00000000..68484424 --- /dev/null +++ b/ccnxandroidmetis/settings.gradle @@ -0,0 +1,3 @@ +include ':MetisControl', ':ccnxsupportlibrary' +//project(':ccnxsupportlibrary').projectDir = new File(settingsDir, "ccnxsupportlibrary") + |