├── .gitignore ├── CHANGELOG.rst ├── CMakeLists.txt ├── Makefile ├── README.md ├── build.gradle ├── common_tools ├── build.gradle ├── graveyard │ └── common_tools │ │ ├── AppLauncher.java │ │ ├── AppsManager.java │ │ ├── ConcertChecker.java │ │ ├── ListenerNode.java │ │ └── NfcManager.java └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── rosjava │ │ └── android_remocons │ │ └── common_tools │ │ ├── apps │ │ ├── AppParameters.java │ │ ├── AppRemappings.java │ │ ├── MasterNameResolver.java │ │ └── RosAppActivity.java │ │ ├── dashboards │ │ ├── Dashboard.java │ │ └── DefaultDashboard.java │ │ ├── layouts │ │ └── CheckableLinearLayout.java │ │ ├── master │ │ ├── ConcertChecker.java │ │ ├── MasterDescription.java │ │ ├── MasterId.java │ │ └── RoconDescription.java │ │ ├── nfc │ │ ├── NfcManager.java │ │ └── NfcReaderActivity.java │ │ ├── rocon │ │ ├── AppLauncher.java │ │ ├── AppsManager.java │ │ ├── Constants.java │ │ └── InteractionsManager.java │ │ ├── system │ │ ├── Util.java │ │ └── WifiChecker.java │ │ └── zeroconf │ │ ├── DiscoveryAdapter.java │ │ ├── DiscoveryHandler.java │ │ ├── DiscoverySetup.java │ │ ├── Logger.java │ │ └── MasterSearcher.java │ └── res │ ├── drawable │ └── ros_master.png │ ├── layout │ ├── default_dashboard.xml │ ├── main.xml │ ├── nfc_tag_scan.xml │ ├── zeroconf_master_item.xml │ └── zeroconf_master_list.xml │ └── values │ └── strings.xml ├── external_libraries ├── Readme.rst └── snakeyaml-1.10-android.jar ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── headless_launcher ├── README.md ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── rosjava │ │ └── android_remocons │ │ └── headless_launcher │ │ ├── AlertDialogActivity.java │ │ └── NfcLauncherActivity.java │ └── res │ ├── drawable │ ├── playstore_icon.png │ └── playstore_icon_small.png │ ├── layout │ ├── activity_alert_dialog.xml │ └── main.xml │ ├── menu │ └── menu_alert_dialog.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ └── strings.xml ├── listener ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── rosjava │ │ └── android_remocons │ │ └── listener │ │ └── Listener.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── main.xml │ └── values │ └── strings.xml ├── package.xml ├── rocon_nfc_writer ├── README.md ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── rosjava │ │ └── android_remocons │ │ └── rocon_nfc_writer │ │ └── RoconNfcWriter.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ ├── menu │ └── main.xml │ └── values │ └── strings.xml ├── rocon_remocon ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── rosjava │ │ └── android_remocons │ │ └── rocon_remocon │ │ ├── AppAdapter.java │ │ ├── Database.java │ │ ├── MasterAdapter.java │ │ ├── MasterChooser.java │ │ ├── MasterItem.java │ │ ├── NfcLauncherActivity.java │ │ ├── PairSubscriber.java │ │ ├── Remocon.java │ │ ├── StatusPublisher.java │ │ └── dialogs │ │ ├── AlertDialogWrapper.java │ │ ├── LaunchInteractionDialog.java │ │ └── ProgressDialogWrapper.java │ └── res │ ├── drawable-hdpi │ ├── nfc_tag.png │ ├── pr2.jpg │ ├── qrcode.png │ ├── question_mark.jpg │ ├── rocon_icon.png │ ├── rocon_main.png │ ├── turtlebot.png │ └── wifi_question_mark.jpg │ ├── drawable-ldpi │ ├── nfc_tag.png │ ├── pr2.jpg │ ├── qrcode.png │ ├── question_mark.jpg │ ├── rocon_icon.png │ ├── turtlebot.png │ └── wifi_question_mark.jpg │ ├── drawable-mdpi │ ├── coffee_icon.png │ ├── failure.png │ ├── failure_small.png │ ├── nfc_tag.png │ ├── playstore_icon.png │ ├── playstore_icon_small.png │ ├── pr2.jpg │ ├── qrcode.png │ ├── question_mark.jpg │ ├── rocon_icon.png │ ├── turtlebot.png │ └── wifi_question_mark.jpg │ ├── drawable │ ├── checkable.xml │ ├── conductor.png │ ├── error_triangle.png │ ├── highlight.png │ └── turtle.png │ ├── layout-land │ └── add_uri_dialog.xml │ ├── layout │ ├── add_uri_dialog.xml │ ├── app_item.xml │ ├── master_chooser.xml │ ├── master_item.xml │ └── rocon_remocon.xml │ ├── menu │ └── master_chooser_option_menu.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── icon.png │ ├── mipmap-ldpi │ ├── ic_launcher.png │ └── icon.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── icon.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── icon.png │ └── rocon_icon.png │ └── values │ ├── colors.xml │ └── strings.xml ├── settings.gradle └── talker ├── build.gradle └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── github │ └── rosjava │ └── android_remocons │ └── talker │ └── Talker.java └── res ├── drawable-hdpi └── ic_launcher.png ├── drawable-ldpi └── ic_launcher.png ├── drawable-mdpi └── ic_launcher.png ├── layout └── main.xml └── values └── strings.xml /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | gen 3 | libs 4 | build 5 | build.xml 6 | local.properties 7 | proguard-project.txt 8 | .gradle 9 | 10 | # These are Android Studio files, might be worth including these later. 11 | .idea 12 | *.iml 13 | *.log 14 | build-log.xml 15 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | 0.3.0 (2018-04-10) 5 | ------------------ 6 | * First build on Kinetic with refactored android_core for Android P. 7 | 8 | 0.2.0 (2015-02-22) 9 | ------------------ 10 | * First build on indigo 11 | 12 | 0.1.2 [2013-10-31] 13 | ------------------ 14 | * use ROS_MAVEN_REPOSITORY 15 | 16 | 0.1.1 [2013-10-26] 17 | ------------------ 18 | * gradle and android tool upgrades 19 | * nfc card reader 20 | * various crash bugfixes 21 | 22 | 0.1.0 [2013-06-26] 23 | ------------------ 24 | 25 | * First public release for hydro. 26 | * First upgraded (from app chooser) robot remocon for pairing. 27 | 28 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(android_remocons) 3 | 4 | find_package(catkin REQUIRED rosjava_build_tools) 5 | 6 | catkin_android_setup(assembleRelease uploadArchives) 7 | 8 | catkin_package() 9 | 10 | install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_MAVEN_DESTINATION}/com/github/rosjava/android_remocons/ 11 | DESTINATION ${CATKIN_GLOBAL_MAVEN_DESTINATION}/com/github/rosjava/android_remocons/) 12 | 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | @for i in *; do \ 3 | if [ -d "$${i}/build" ]; then \ 4 | echo "++ $${i}"; \ 5 | rm -rf $${i}/build; \ 6 | else \ 7 | echo "-- $${i}"; \ 8 | fi; \ 9 | done 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Documentation 2 | 3 | See [rosjava_core](https://github.com/rosjava/rosjava_core) readme. 4 | 5 | ### Master Branch 6 | 7 | The master branch is currently dependant on stable hydro branches of the other rosjava and android 8 | core repositories (too much movement there to depend on master). Also dependant on the master branch of 9 | android_apps. 10 | 11 | ### Rosinstaller 12 | 13 | 14 | * Master: https://raw.github.com/rosjava/rosjava/master/android_apps.rosinstall 15 | * Hydro: https://raw.github.com/rosjava/rosjava/hydro/android_apps.rosinstall 16 | ======= 17 | Android Remocons 18 | ================ 19 | 20 | Remocons for pairing and concert modes as well as some simple apps for testing. 21 | 22 | Installation 23 | ============ 24 | 25 | This is primarily to get the rosjava build tools. If you are using precise, you don't need this step (it will get it from debs). 26 | 27 | ``` 28 | > yujin_init_workspace -j5 ~/rosjava rosjava 29 | > cd ~/rosjava 30 | > yujin_init_build . 31 | > yujin_make --install-rosdeps 32 | > yujin_make 33 | ``` 34 | 35 | This will use the maven repos for the core rosjava and android repos. 36 | 37 | ``` 38 | > yujin_init_workspace -j5 ~/rocon_rosjava rocon-rosjava 39 | > cd ~/rocon_rosjava 40 | > yujin_init_build --underlays=~/rosjava/devel . 41 | > yujin_make --install-rosdeps 42 | > yujin_make 43 | ``` 44 | 45 | Android core (only necessary on indigo): 46 | 47 | ``` 48 | > yujin_init_workspace -j5 ~/android_core android-core 49 | > cd ~/android_core 50 | > yujin_init_build --underlays=~/rosjava/devel . 51 | > yujin_make 52 | ``` 53 | 54 | The android interactions:: 55 | 56 | ``` 57 | > yujin_init_workspace -j5 ~/android_interactions 58 | > cd ~/android_interactions 59 | > yujin_init_build --underlays="~/android_core/devel;~/rocon_rosjava/devel;~/rosjava/devel" . 60 | > cd ~/android_interactions/src 61 | # to compile the rocon android apps as well 62 | > wstool set rocon_android_apps --git https://github.com/robotics-in-concert/rocon_android_apps.git --version=headless_launcher_update 63 | > wstool update -j5 64 | > yujin_make 65 | > . .bashrc 66 | ``` 67 | 68 | Launch the android studio, compile the ```rocon_nfc_writer``` and ```headless_launcher``` 69 | 70 | Other README's 71 | ============== 72 | 73 | * rocon_nfc_writer/README.md 74 | * headless_launcher/README.md 75 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Daniel Stonier 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | task wrapper(type: Wrapper) { 18 | gradleVersion = '4.10.2' 19 | } 20 | 21 | buildscript { 22 | apply from: "https://github.com/rosjava/android_core/raw/kinetic/buildscript.gradle" 23 | } 24 | 25 | apply plugin: 'catkin' 26 | 27 | allprojects { 28 | group 'com.github.rosjava.android_remocons' 29 | version = project.catkin.pkg.version 30 | } 31 | 32 | subprojects { 33 | /* 34 | * The android plugin configures a few things: 35 | * 36 | * - local deployment repository : where it dumps the jars and packaged artifacts) 37 | * - local maven repositories : where it finds your locally installed/built artifacts) 38 | * - external maven repositories : where it goes looking if it can't find dependencies locally 39 | * - android build tools version : which version we use across the board 40 | * 41 | * To modify, or add repos to the default external maven repositories list, pull request against this code: 42 | * 43 | * https://github.com/rosjava/rosjava_bootstrap/blob/indigo/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/RosPlugin.groovy#L31 44 | * 45 | * To modify the build tools version, pull request against this code: 46 | * 47 | * https://github.com/rosjava/rosjava_bootstrap/blob/indigo/gradle_plugins/src/main/groovy/org/ros/gradle_plugins/RosAndroid.groovy#L14 48 | */ 49 | apply plugin: 'ros-android' 50 | 51 | afterEvaluate { project -> 52 | android { 53 | // Exclude a few files that are duplicated across our dependencies and 54 | // prevent packaging Android applications. 55 | packagingOptions { 56 | exclude "META-INF/LICENSE.txt" 57 | exclude "META-INF/NOTICE.txt" 58 | } 59 | flavorDimensions 'default' 60 | } 61 | 62 | } 63 | } 64 | 65 | defaultTasks 'assembleRelease', 'uploadArchives' 66 | -------------------------------------------------------------------------------- /common_tools/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Jorge Santos. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | //noinspection GroovyAssignabilityCheck 18 | dependencies { 19 | compile 'org.ros.android_core:android_core_components:[0.4,0.5)' 20 | compile 'org.ros.rosjava_core:rosjava:[0.3,0.4)' 21 | compile 'org.ros.rosjava_bootstrap:message_generation:[0.3,0.4)' 22 | compile 'org.ros.rosjava_messages:diagnostic_msgs:[1.12, 1.13)' 23 | compile 'org.ros.rosjava_messages:rocon_interaction_msgs:[0.7,0.8)' 24 | compile 'org.ros.rosjava_messages:rocon_std_msgs:[0.7,0.8)' 25 | compile 'org.ros.rosjava_messages:rocon_app_manager_msgs:[0.7,0.8)' 26 | compile 'com.github.rosjava.android_extras:gingerbread:[0.3,0.4)' 27 | compile 'com.github.rosjava.android_extras:zxing:[0.3,0.4)' 28 | compile 'com.github.rosjava.zeroconf_jmdns_suite:jmdns:[0.3,0.4)' 29 | compile 'com.github.robotics_in_concert.rocon_rosjava_core:rosjava_utils:[0.2,0.3)' 30 | compile 'com.github.robotics_in_concert.rocon_rosjava_core:master_info:[0.2,0.3)' 31 | compile 'com.github.robotics_in_concert.rocon_rosjava_core:rocon_interactions:[0.2,0.3)' 32 | compile fileTree(dir: '../external_libraries', include:'snakeyaml*.jar') 33 | } 34 | 35 | apply plugin: 'com.android.library' 36 | 37 | android { 38 | compileSdkVersion 28 39 | 40 | defaultConfig { 41 | minSdkVersion 16 42 | targetSdkVersion 28 43 | versionCode 1 44 | versionName "1.0.1" 45 | } 46 | lintOptions { 47 | abortOnError = false 48 | } 49 | } 50 | 51 | defaultTasks 'assembleRelease' 52 | -------------------------------------------------------------------------------- /common_tools/graveyard/common_tools/ListenerNode.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.common_tools; 2 | 3 | import org.ros.android.MessageCallable; 4 | import org.ros.exception.RosException; 5 | import org.ros.exception.RosRuntimeException; 6 | import org.ros.message.MessageListener; 7 | import org.ros.namespace.GraphName; 8 | import org.ros.node.AbstractNodeMain; 9 | import org.ros.node.ConnectedNode; 10 | import org.ros.node.topic.Subscriber; 11 | 12 | 13 | /** 14 | * Created by jorge on 10/30/13. 15 | */ 16 | public class ListenerNode extends AbstractNodeMain 17 | { 18 | private String topicName; 19 | private String messageType; 20 | private T lastMessage; 21 | private MessageCallable callable; 22 | 23 | public ListenerNode(String topic, String type) 24 | { 25 | topicName = topic; 26 | messageType = type; 27 | } 28 | 29 | public T getLastMessage() 30 | { 31 | return lastMessage; 32 | } 33 | 34 | public void setTopicName(String topicName) 35 | { 36 | this.topicName = topicName; 37 | } 38 | 39 | public void setMessageType(String messageType) 40 | { 41 | this.messageType = messageType; 42 | } 43 | 44 | public void setMessageToStringCallable(MessageCallable callable) 45 | { 46 | this.callable = callable; 47 | } 48 | 49 | @Override 50 | public GraphName getDefaultNodeName() { 51 | return GraphName.of("get_" + topicName + "_node"); 52 | } 53 | 54 | @Override 55 | public void onStart(ConnectedNode connectedNode) { 56 | Subscriber subscriber = connectedNode.newSubscriber(topicName, messageType); 57 | subscriber.addMessageListener(new MessageListener() { 58 | @Override 59 | public void onNewMessage(final T message) { 60 | lastMessage = message; 61 | if (callable != null) { 62 | callable.call(message); 63 | } 64 | } 65 | }); 66 | } 67 | 68 | /** 69 | * Utility function to block until subscriber receives the first message. 70 | * 71 | * @throws org.ros.exception.RosException : when it times out waiting for the service. 72 | */ 73 | public void waitForResponse() throws RosException { 74 | int count = 0; 75 | while ( lastMessage == null ) { 76 | try { 77 | Thread.sleep(200); 78 | } catch (Exception e) { 79 | throw new RosRuntimeException(e); 80 | } 81 | if ( count == 20 ) { // timeout. 82 | throw new RosException("timed out waiting for topic messages"); 83 | } 84 | count = count + 1; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /common_tools/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/apps/AppParameters.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.common_tools.apps; 2 | 3 | import java.util.LinkedHashMap; 4 | 5 | /** 6 | * Just to provide a get method with default value to LinkedHashMap 7 | * Created by jorge on 11/26/13. 8 | */ 9 | public class AppParameters extends LinkedHashMap { 10 | public AppParameters() { super(); } // Required by snake yaml 11 | 12 | public Object get(String key, Object def) { 13 | return super.containsKey(key) ? super.get(key) : def; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/apps/AppRemappings.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.common_tools.apps; 2 | 3 | import java.util.LinkedHashMap; 4 | 5 | /** 6 | * Just to provide a get method with default value to LinkedHashMap 7 | * Created by jorge on 11/26/13. 8 | */ 9 | public class AppRemappings extends LinkedHashMap { 10 | public String get(String from) { 11 | return super.containsKey(from) ? super.get(from) : from; 12 | } 13 | 14 | public String get(String from, String to) { 15 | return super.containsKey(from) ? super.get(from) : to; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/apps/MasterNameResolver.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.common_tools.apps; 2 | 3 | import android.util.Log; 4 | 5 | import com.github.rosjava.android_remocons.common_tools.master.MasterDescription; 6 | 7 | import org.ros.master.client.MasterStateClient; 8 | import org.ros.master.client.SystemState; 9 | import org.ros.master.client.TopicSystemState; 10 | import org.ros.namespace.GraphName; 11 | import org.ros.namespace.NameResolver; 12 | import org.ros.node.AbstractNodeMain; 13 | import org.ros.node.ConnectedNode; 14 | 15 | public class MasterNameResolver extends AbstractNodeMain { 16 | 17 | private MasterDescription currentMaster; 18 | private NameResolver masterNameResolver; 19 | private GraphName masterName; 20 | private ConnectedNode connectedNode; 21 | private boolean resolved = false; 22 | 23 | public MasterNameResolver() { 24 | } 25 | 26 | public void setMaster(MasterDescription currentMaster) { 27 | this.currentMaster = currentMaster; 28 | } 29 | 30 | @Override 31 | public GraphName getDefaultNodeName() { 32 | return null; 33 | } 34 | 35 | public void setMasterName(String name) { 36 | this.masterName = GraphName.of(name); 37 | } 38 | 39 | /** 40 | * Return the master name as is that will be resolved when actually 41 | * connected to a node. 42 | * 43 | * @return the name, e.g. 'turtlebot'. 44 | */ 45 | public String getMasterName() { 46 | return this.masterName.toString(); 47 | } 48 | 49 | public void resetMasterName(String name) { 50 | masterNameResolver = connectedNode.getResolver().newChild(name); 51 | } 52 | 53 | /** 54 | * The resolved master namespace (after connecting to a master). 55 | * 56 | * Warning: Do not call this before actually starting the resolver, 57 | * or else it will return a null object. 58 | * 59 | * todo : get this to throw an exception if null 60 | * 61 | * @return the master name resolver 62 | */ 63 | public NameResolver getMasterNameSpace() { 64 | return masterNameResolver; 65 | } 66 | 67 | /** 68 | * Call this to block until the resolver finishes its job. 69 | * i.e. after an execute is called to run the onStart method 70 | * below. 71 | * 72 | * Note - BLOCKING call! 73 | */ 74 | public void waitForResolver() { 75 | while (!resolved) { 76 | try { 77 | Thread.sleep(100); 78 | } catch (Exception e) { 79 | Log.w("MasterRemocon", "Master name waitForResolver caught an arbitrary exception"); 80 | } 81 | } 82 | } 83 | 84 | @Override 85 | /** 86 | * Resolves the namespace under which master apps can be started 87 | * and stopped. Sometimes this will already have been provided 88 | * via setMaster() by managed applications (e.g. remocons) which 89 | * use the MasterChecker. 90 | * 91 | * In other cases, such as standalone application we do a simple 92 | * parameter lookup, falling back to a default if provided. 93 | */ 94 | public void onStart(final ConnectedNode connectedNode) { 95 | this.connectedNode = connectedNode; 96 | if (currentMaster != null) { 97 | masterName = GraphName.of(currentMaster.getAppsNameSpace()); 98 | } else { 99 | // This is duplicated in PlatformInfoServiceClient and could be better stored somewhere, but it's not much. 100 | MasterStateClient masterClient = new MasterStateClient(this.connectedNode, this.connectedNode.getMasterUri()); 101 | SystemState systemState = masterClient.getSystemState(); 102 | for (TopicSystemState topic : systemState.getTopics()) { 103 | String topicName = topic.getTopicName(); 104 | GraphName graph_name = GraphName.of(topicName); 105 | if ( graph_name.getBasename().toString().equals("app_list") ) { 106 | masterName = graph_name.getParent().toRelative(); 107 | Log.i("ApplicationManagement", "Configuring master namespace resolver [" + masterName + "]"); 108 | break; 109 | } 110 | } 111 | } 112 | masterNameResolver = connectedNode.getResolver().newChild(masterName); 113 | resolved = true; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/dashboards/Dashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2011, Willow Garage, Inc. 5 | * All rights reserved. 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following 14 | * disclaimer in the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of Willow Garage, Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | package com.github.rosjava.android_remocons.common_tools.dashboards; 35 | 36 | import android.app.Activity; 37 | import android.content.Context; 38 | import android.util.Log; 39 | import android.view.View; 40 | import android.view.ViewGroup; 41 | 42 | import org.ros.namespace.GraphName; 43 | import org.ros.node.ConnectedNode; 44 | import org.ros.node.Node; 45 | import org.ros.node.NodeMain; 46 | 47 | public class Dashboard implements NodeMain { 48 | public interface DashboardInterface { 49 | /** 50 | * Set the ROS Node to use to get status data and connect it up. 51 | * Disconnects the previous node if there was one. 52 | */ 53 | public void onStart(ConnectedNode connectedNode); 54 | 55 | public void onShutdown(Node node); 56 | } 57 | 58 | private static final String defaultDashboardPath = "com.github.rosjava.android_remocons.common_tools.dashboards.DefaultDashboard"; 59 | private static final String turtlebotDashboardPath = "com.github.turtlebot.turtlebot_android.turtlebot_core.dashboards.TurtlebotDashboard"; 60 | private static final String pr2DashboardPath = "com.ros.pr2.apps.core_components.Pr2Dashboard"; 61 | 62 | private DashboardInterface dashboard; 63 | private Activity activity; 64 | private ViewGroup view; 65 | private ViewGroup.LayoutParams lparams; 66 | private static String robotName; 67 | private static String customDashboardPath; 68 | 69 | public Dashboard(Activity activity) { 70 | dashboard = null; 71 | this.activity = activity; 72 | this.view = null; 73 | this.lparams = null; 74 | } 75 | 76 | public void setView(ViewGroup view, ViewGroup.LayoutParams lparams) { 77 | if (view == null) { 78 | Log.e("Dashboard", "Null view for dashboard"); 79 | } 80 | this.view = view; 81 | this.lparams = lparams; 82 | } 83 | 84 | public void setRobotName(String name) { 85 | robotName = name; 86 | } 87 | 88 | public void setCustomDashboardPath(String path) { 89 | this.customDashboardPath = path; 90 | } 91 | 92 | private static DashboardInterface createDashboard(Class dashClass, 93 | Context context) { 94 | ClassLoader classLoader = Dashboard.class.getClassLoader(); 95 | Object[] args = new Object[1]; 96 | DashboardInterface result = null; 97 | args[0] = context; 98 | try { 99 | Class contextClass = Class.forName("android.content.Context"); 100 | result = (DashboardInterface) dashClass.getConstructor(contextClass).newInstance(args); 101 | } catch (Exception ex) { 102 | Log.e("Dashboard", "Error during dashboard instantiation:", ex); 103 | result = null; 104 | } 105 | return result; 106 | } 107 | 108 | private static DashboardInterface createDashboard(String className, 109 | Context context) { 110 | Class dashClass = null; 111 | try { 112 | dashClass = Class.forName(className); 113 | } catch (Exception ex) { 114 | Log.e("Dashboard", "Error during dashboard class loading:", ex); 115 | return null; 116 | } 117 | return createDashboard(dashClass, context); 118 | 119 | } 120 | 121 | /** 122 | * Dynamically locate and create a dashboard. 123 | */ 124 | // TODO: deal with the custom robot dashboard 125 | private static DashboardInterface createDashboard(Context context) { 126 | if (customDashboardPath != null) { 127 | return createDashboard(customDashboardPath, context); 128 | // } else if (robotName.equals("turtlebot")) { 129 | // return createDashboard(turtlebotDashboardPath, context); 130 | // } else if (robotName.equals("pr2")) { 131 | // return createDashboard(pr2DashboardPath, context); 132 | } else { 133 | return createDashboard(defaultDashboardPath, context); 134 | } 135 | } 136 | 137 | @Override 138 | public void onError(Node arg0, Throwable arg1) { 139 | // TODO Auto-generated method stub 140 | 141 | } 142 | 143 | @Override 144 | public void onShutdown(final Node node) { 145 | activity.runOnUiThread(new Runnable() { 146 | @Override 147 | public void run() { 148 | DashboardInterface dash = dashboard; 149 | if (dash != null) { 150 | dash.onShutdown(node); 151 | view.removeView((View) dash); 152 | } 153 | dashboard = null; 154 | } 155 | }); 156 | } 157 | 158 | @Override 159 | public void onShutdownComplete(Node node) { 160 | // TODO Auto-generated method stub 161 | 162 | } 163 | 164 | @Override 165 | public void onStart(ConnectedNode connectedNode) { 166 | if (dashboard != null) { 167 | // FIXME: should we re-start the dashboard? I think this is really 168 | // an error. 169 | return; 170 | } 171 | dashboard = Dashboard.createDashboard(activity); 172 | if (dashboard != null) { 173 | activity.runOnUiThread(new Runnable() { 174 | @Override 175 | public void run() { 176 | 177 | DashboardInterface dash = dashboard; 178 | ViewGroup localView = view; 179 | if (dash != null && localView != null) { 180 | localView.addView((View) dash, lparams); 181 | } else if (dash == null) { 182 | Log.e("Dashboard", 183 | "Dashboard could not start: no dashboard"); 184 | } else if (view == null) { 185 | Log.e("Dashboard", "Dashboard could not start: no view"); 186 | } else { 187 | Log.e("Dashboard", 188 | "Dashboard could not start: no view or dashboard"); 189 | } 190 | } 191 | }); 192 | dashboard.onStart(connectedNode); 193 | } 194 | } 195 | 196 | @Override 197 | public GraphName getDefaultNodeName() { 198 | // TODO Auto-generated method stub 199 | return null; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/dashboards/DefaultDashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2011, Willow Garage, Inc. 5 | * All rights reserved. 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following 14 | * disclaimer in the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of Willow Garage, Inc. nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | * POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | package com.github.rosjava.android_remocons.common_tools.dashboards; 35 | 36 | import android.content.Context; 37 | import android.util.AttributeSet; 38 | import android.view.LayoutInflater; 39 | import android.widget.LinearLayout; 40 | 41 | import com.github.rosjava.android_extras.gingerbread.view.BatteryLevelView; 42 | import com.github.rosjava.android_remocons.common_tools.R; 43 | 44 | import org.ros.exception.RosException; 45 | import org.ros.message.MessageListener; 46 | import org.ros.namespace.GraphName; 47 | import org.ros.namespace.NameResolver; 48 | import org.ros.node.ConnectedNode; 49 | import org.ros.node.Node; 50 | import org.ros.node.topic.Subscriber; 51 | 52 | import java.util.HashMap; 53 | import java.util.List; 54 | 55 | import diagnostic_msgs.DiagnosticArray; 56 | import diagnostic_msgs.DiagnosticStatus; 57 | import diagnostic_msgs.KeyValue; 58 | 59 | public class DefaultDashboard extends LinearLayout implements Dashboard.DashboardInterface { 60 | private BatteryLevelView robotBattery; 61 | private BatteryLevelView laptopBattery; 62 | private ConnectedNode connectedNode; 63 | private Subscriber diagnosticSubscriber; 64 | private boolean powerOn = false; 65 | 66 | public DefaultDashboard(Context context) { 67 | super(context); 68 | inflateSelf(context); 69 | } 70 | public DefaultDashboard(Context context, AttributeSet attrs) { 71 | super(context, attrs); 72 | inflateSelf(context); 73 | } 74 | private void inflateSelf(Context context) { 75 | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 76 | inflater.inflate(R.layout.default_dashboard, this); 77 | robotBattery = (BatteryLevelView) findViewById(R.id.robot_battery); 78 | laptopBattery = (BatteryLevelView) findViewById(R.id.laptop_battery); 79 | } 80 | /** 81 | * Set the ROS Node to use to get status data and connect it up. Disconnects 82 | * the previous node if there was one. 83 | * 84 | * @throws org.ros.exception.RosException 85 | */ 86 | /** 87 | * Populate view with new diagnostic data. This must be called in the UI 88 | * thread. 89 | */ 90 | private void handleDiagnosticArray(DiagnosticArray msg) { 91 | for(DiagnosticStatus status : msg.getStatus()) { 92 | if(status.getName().equals("/Power System/Battery")) { 93 | populateBatteryFromStatus(robotBattery, status); 94 | } 95 | if(status.getName().equals("/Power System/Laptop Battery")) { 96 | populateBatteryFromStatus(laptopBattery, status); 97 | } 98 | } 99 | } 100 | 101 | 102 | private void populateBatteryFromStatus(BatteryLevelView view, DiagnosticStatus status) { 103 | HashMap values = keyValueArrayToMap(status.getValues()); 104 | try { 105 | float percent = 100 * Float.parseFloat(values.get("Charge (Ah)")) / Float.parseFloat(values.get("Capacity (Ah)")); 106 | view.setBatteryPercent((int) percent); 107 | // TODO: set color red/yellow/green based on level (maybe with 108 | // level-set 109 | // in XML) 110 | } catch(NumberFormatException ex) { 111 | // TODO: make battery level gray 112 | } catch(ArithmeticException ex) { 113 | // TODO: make battery level gray 114 | } catch(NullPointerException ex) { 115 | // Do nothing: data wasn't there. 116 | } 117 | try { 118 | view.setPluggedIn(Float.parseFloat(values.get("Current (A)")) > 0); 119 | } catch(NumberFormatException ex) { 120 | } catch(ArithmeticException ex) { 121 | } catch(NullPointerException ex) { 122 | } 123 | } 124 | private HashMap keyValueArrayToMap(List list) { 125 | HashMap map = new HashMap(); 126 | for(KeyValue kv : list) { 127 | map.put(kv.getKey(), kv.getValue()); 128 | } 129 | return map; 130 | } 131 | 132 | @Override 133 | public void onShutdown(Node node) { 134 | if(diagnosticSubscriber != null) { 135 | diagnosticSubscriber.shutdown(); 136 | } 137 | diagnosticSubscriber = null; 138 | connectedNode = null; 139 | 140 | } 141 | 142 | @Override 143 | public void onStart(ConnectedNode connectedNode) { 144 | 145 | this.connectedNode = connectedNode; 146 | try { 147 | if(diagnosticSubscriber == null){ 148 | 149 | } 150 | diagnosticSubscriber = connectedNode.newSubscriber("diagnostics_agg", "diagnostic_msgs/DiagnosticArray"); 151 | diagnosticSubscriber.addMessageListener(new MessageListener() { 152 | @Override 153 | public void onNewMessage(final DiagnosticArray message) { 154 | DefaultDashboard.this.post(new Runnable() { 155 | @Override 156 | public void run() { 157 | DefaultDashboard.this.handleDiagnosticArray(message); 158 | } 159 | }); 160 | } 161 | }); 162 | NameResolver resolver = connectedNode.getResolver().newChild(GraphName.of("/turtlebot_node")); 163 | } catch(Exception ex) { 164 | this.connectedNode = null; 165 | try { 166 | throw (new RosException(ex)); 167 | } catch (RosException e) { 168 | // TODO Auto-generated catch block 169 | e.printStackTrace(); 170 | } 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/layouts/CheckableLinearLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Willow Garage, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Willow Garage, Inc. nor the names of its 14 | * contributors may be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.github.rosjava.android_remocons.common_tools.layouts; 31 | 32 | import android.content.Context; 33 | import android.util.AttributeSet; 34 | import android.widget.Checkable; 35 | import android.widget.LinearLayout; 36 | /** 37 | * Simple extension of LinearLayout which trivially implements 38 | * Checkable interface and adds state_checked to drawable states when 39 | * appropriate. 40 | */ 41 | public class CheckableLinearLayout extends LinearLayout implements Checkable { 42 | private boolean checked = false; 43 | private static final int[] CHECKED_STATE_SET = { 44 | android.R.attr.state_checked 45 | }; 46 | public CheckableLinearLayout(Context ctx) { 47 | super(ctx); 48 | } 49 | public CheckableLinearLayout(Context context, AttributeSet attrs) { 50 | super(context, attrs); 51 | } 52 | @Override 53 | public boolean isChecked() { 54 | return checked; 55 | } 56 | @Override 57 | public void setChecked( boolean checked ) { 58 | if( this.checked != checked ) { 59 | this.checked = checked; 60 | refreshDrawableState(); 61 | } 62 | } 63 | 64 | @Override 65 | public void toggle() { 66 | setChecked( !checked ); 67 | } 68 | @Override 69 | protected int[] onCreateDrawableState(int extraSpace) { 70 | final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); 71 | if( isChecked() ) { 72 | mergeDrawableStates(drawableState, CHECKED_STATE_SET); 73 | } 74 | return drawableState; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/master/MasterId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2013, Yujin Robot. 5 | * 6 | * All rights reserved. 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of Willow Garage, Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | package com.github.rosjava.android_remocons.common_tools.master; 36 | 37 | import java.util.Map; 38 | 39 | /** 40 | * Mostly a clone of RobotId but generic enough to work also for concert apps. 41 | * 42 | * @author jorge@yujinrobot.com (Jorge Santos Simon) 43 | */ 44 | public class MasterId implements java.io.Serializable { 45 | private static final long serialVersionUID = -1185642483404745956L; 46 | 47 | private String masterUri; 48 | private String wifi; 49 | private String wifiEncryption; 50 | private String wifiPassword; 51 | 52 | public MasterId() { 53 | } 54 | 55 | public MasterId(String masterUri, String wifi, String wifiEncryption, String wifiPassword) { 56 | this.masterUri = masterUri; 57 | this.wifi = wifi; 58 | this.wifiEncryption = wifiEncryption; 59 | this.wifiPassword = wifiPassword; 60 | } 61 | 62 | public MasterId(Map map) { 63 | if (map.containsKey("URL")) { 64 | this.masterUri = map.get("URL").toString(); 65 | } 66 | if (map.containsKey("WIFI")) { 67 | this.wifi = map.get("WIFI").toString(); 68 | } 69 | if (map.containsKey("WIFIENC")) { 70 | this.wifiEncryption = map.get("WIFIENC").toString(); 71 | } 72 | if (map.containsKey("WIFIPW")) { 73 | this.wifiPassword = map.get("WIFIPW").toString(); 74 | } 75 | } 76 | 77 | public MasterId(String masterUri) { 78 | this.masterUri = masterUri; 79 | } 80 | 81 | public String getMasterUri() { 82 | return masterUri; 83 | } 84 | 85 | public String getWifi() { 86 | return wifi; 87 | } 88 | 89 | public String getWifiEncryption() { 90 | return wifiEncryption; 91 | } 92 | 93 | public String getWifiPassword() { 94 | return wifiPassword; 95 | } 96 | 97 | @Override 98 | public String toString() { 99 | String str = getMasterUri() == null ? "" : getMasterUri(); 100 | if (getWifi() != null) { 101 | str = str + " On Wifi: " + getWifi(); 102 | } 103 | return str; 104 | } 105 | 106 | //TODO: not needed? 107 | private boolean nullSafeEquals(Object a, Object b) { 108 | if (a == b) { //Handles case where both are null. 109 | return true; 110 | } 111 | if (a == null || b == null) { 112 | return false; 113 | } 114 | //Non-are null 115 | return a.equals(b); 116 | } 117 | 118 | @Override 119 | public boolean equals(Object o) { 120 | 121 | // Return true if the objects are identical. 122 | // (This is just an optimization, not required for correctness.) 123 | if (this == o) { 124 | return true; 125 | } 126 | // Return false if the other object has the wrong type. 127 | // This type may be an interface depending on the interface's specification. 128 | if (!(o instanceof MasterId)) { 129 | return false; 130 | } 131 | // Cast to the appropriate type. 132 | // This will succeed because of the instanceof, and lets us access private fields. 133 | MasterId lhs = (MasterId) o; 134 | return nullSafeEquals(this.masterUri, lhs.masterUri) 135 | && nullSafeEquals(this.wifi, lhs.wifi) 136 | && nullSafeEquals(this.wifiEncryption, lhs.wifiEncryption) 137 | && nullSafeEquals(this.wifiPassword, lhs.wifiPassword); 138 | } 139 | 140 | @Override 141 | public int hashCode() { 142 | // Start with a non-zero constant. 143 | int result = 17; 144 | // Include a hash for each field checked by equals(). 145 | result = 31 * result + (masterUri == null ? 0 : masterUri.hashCode()); 146 | result = 31 * result + (wifi == null ? 0 : wifi.hashCode()); 147 | result = 31 * result + (wifiEncryption == null ? 0 : wifiEncryption.hashCode()); 148 | result = 31 * result + (wifiPassword == null ? 0 : wifiPassword.hashCode()); 149 | return result; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/master/RoconDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2013, Yujin Robot. 5 | * 6 | * All rights reserved. 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of Willow Garage, Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | package com.github.rosjava.android_remocons.common_tools.master; 36 | 37 | import java.util.Date; 38 | import java.util.List; 39 | 40 | /** 41 | * Extends MasterDescription with concert specific attributes. 42 | * On concerts, apps namespace must be empty. 43 | * 44 | * @author jorge@yujinrobot.com (Jorge Santos Simon) 45 | */ 46 | public class RoconDescription extends MasterDescription implements java.io.Serializable { 47 | private static final long serialVersionUID = -4705526306056241179L; 48 | 49 | private String description; 50 | private String[] userRoles; 51 | private int currentRole = -1; 52 | private String interactionsNamespace; 53 | 54 | public static RoconDescription create(MasterDescription master) { 55 | RoconDescription cd = new RoconDescription(master.getMasterId(), master.getMasterName(), 56 | null, null, null, new Date()); 57 | cd.setMasterIconFormat(master.getMasterIconFormat()); 58 | cd.setMasterIconData(master.getMasterIconData()); 59 | return cd; 60 | } 61 | 62 | public static RoconDescription createUnknown(MasterId masterId) { 63 | return new RoconDescription(masterId, NAME_UNKNOWN, null, null, null, new Date()); 64 | } 65 | 66 | /** 67 | * Empty constructor required by snake yaml parsing 68 | */ 69 | public RoconDescription() { 70 | } 71 | 72 | public RoconDescription(MasterId masterId, String concertName, String description, 73 | rocon_std_msgs.Icon concertIcon, String interactionsNamespace, 74 | Date timeLastSeen) { 75 | super(masterId, concertName, "Rocon concert", concertIcon, "", timeLastSeen); 76 | 77 | this.description = description; 78 | this.interactionsNamespace = interactionsNamespace; 79 | } 80 | 81 | public void copyFrom(RoconDescription other) { 82 | super.copyFrom(other); 83 | 84 | this.userRoles = other.userRoles.clone(); 85 | this.description = other.description; 86 | this.interactionsNamespace = other.interactionsNamespace; 87 | } 88 | 89 | public String getInteractionsNamespace() { return this.interactionsNamespace; } 90 | 91 | public String[] getUserRoles() { 92 | return userRoles; 93 | } 94 | 95 | public String getCurrentRole() { 96 | if (userRoles != null && currentRole >= 0 && currentRole < userRoles.length) 97 | return userRoles[currentRole]; 98 | else 99 | return null; 100 | } 101 | 102 | public void setInteractionsNamespace(String namespace) { 103 | this.interactionsNamespace = namespace; 104 | } 105 | 106 | public void setUserRoles(List roles) 107 | { 108 | userRoles = new String[roles.size()]; 109 | roles.toArray(userRoles); 110 | } 111 | public void setCurrentRole(int role) { 112 | currentRole = role; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/nfc/NfcReaderActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2013, Yujin Robot. 5 | * 6 | * All rights reserved. 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of Willow Garage, Inc. nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | package com.github.rosjava.android_remocons.common_tools.nfc; 36 | 37 | import android.app.Activity; 38 | import android.content.Intent; 39 | import android.os.Bundle; 40 | import android.util.Log; 41 | import android.widget.TextView; 42 | 43 | import com.github.robotics_in_concert.rocon_rosjava_core.rosjava_utils.ByteArrays; 44 | import com.github.rosjava.android_remocons.common_tools.R; 45 | 46 | import java.util.HashMap; 47 | 48 | import static com.github.rosjava.android_remocons.common_tools.rocon.Constants.NFC_MASTER_HOST_FIELD_LENGTH; 49 | import static com.github.rosjava.android_remocons.common_tools.rocon.Constants.NFC_PASSWORD_FIELD_LENGTH; 50 | import static com.github.rosjava.android_remocons.common_tools.rocon.Constants.NFC_PAYLOAD_LENGTH; 51 | import static com.github.rosjava.android_remocons.common_tools.rocon.Constants.NFC_SSID_FIELD_LENGTH; 52 | 53 | /** 54 | * Read NfcF tags and return the resulting hash map to the invoker action. 55 | */ 56 | public class NfcReaderActivity extends Activity { 57 | public static boolean enabled = true; 58 | 59 | private NfcManager nfcManager; 60 | private TextView textView; 61 | 62 | private HashMap data; 63 | 64 | @Override 65 | public void onCreate(Bundle savedState) { 66 | super.onCreate(savedState); 67 | 68 | try{ 69 | setContentView(R.layout.nfc_tag_scan); 70 | textView = (TextView) findViewById(R.id.text); 71 | textView.setText("Scan a NFC tag"); 72 | nfcManager = new NfcManager(this); 73 | } 74 | catch (Exception e) { 75 | Log.e("NfcReader", e.getMessage()); 76 | finish(); 77 | } 78 | } 79 | 80 | @Override 81 | public void onResume() { 82 | super.onResume(); 83 | if (nfcManager != null) 84 | nfcManager.enableForegroundDispatch(); 85 | } 86 | 87 | @Override 88 | protected void onNewIntent(Intent intent) { 89 | super.onNewIntent(intent); 90 | 91 | if ((nfcManager != null) && (nfcManager.onNewIntent(intent))) { 92 | Log.i("NfcReader", "NFC tag read"); 93 | byte[] payload = nfcManager.getPayload(); 94 | if (payload.length != NFC_PAYLOAD_LENGTH + 3) // 1 byte for status and 2 lang bytes 95 | { 96 | Log.e("NfcReader", "Payload doesn't match expected length: " + payload.length +" != " + NFC_PAYLOAD_LENGTH); 97 | return; 98 | } 99 | 100 | data = new HashMap(); 101 | 102 | int offset = 3; // skip 1 byte for status and 2 lang bytes 103 | data.put("WIFI", ByteArrays.toString(payload, offset, NFC_SSID_FIELD_LENGTH).trim()); 104 | offset += NFC_SSID_FIELD_LENGTH; 105 | data.put("WIFIPW", ByteArrays.toString(payload, offset, NFC_PASSWORD_FIELD_LENGTH).trim()); 106 | data.put("WIFIENC", "WPA2"); 107 | offset += NFC_PASSWORD_FIELD_LENGTH; 108 | String host = ByteArrays.toString(payload, offset, NFC_MASTER_HOST_FIELD_LENGTH).trim(); 109 | offset += NFC_MASTER_HOST_FIELD_LENGTH; 110 | short port = ByteArrays.toShort(payload, offset); 111 | data.put("URL", "http://" + host + ":" + port); 112 | 113 | finish(); 114 | } 115 | } 116 | 117 | @Override 118 | public void onPause() { 119 | super.onPause(); 120 | if (nfcManager != null) 121 | nfcManager.disableForegroundDispatch(); 122 | } 123 | 124 | @Override 125 | public void finish() { 126 | // Prepare data in tent 127 | Intent returnIntent = new Intent(); 128 | if (data != null) { 129 | // Activity finished ok, return the data 130 | returnIntent.putExtra("tag_data", data); 131 | setResult(RESULT_OK, returnIntent); 132 | } 133 | else { 134 | setResult(RESULT_CANCELED, returnIntent); 135 | } 136 | 137 | super.finish(); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/rocon/Constants.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.common_tools.rocon; 2 | 3 | import org.ros.internal.message.DefaultMessageFactory; 4 | import org.ros.internal.message.definition.MessageDefinitionReflectionProvider; 5 | 6 | import rocon_std_msgs.PlatformInfo; 7 | import rocon_std_msgs.Strings; 8 | 9 | /** 10 | * General rocon android app constants and topic/parameter/service names 11 | * 12 | * @author jorge@yujinrobot.com (Jorge Santos Simon) 13 | */ 14 | public class Constants { 15 | public static final int NFC_SSID_FIELD_LENGTH = 16; 16 | public static final int NFC_PASSWORD_FIELD_LENGTH = 16; 17 | public static final int NFC_MASTER_HOST_FIELD_LENGTH = 16; 18 | public static final int NFC_MASTER_PORT_FIELD_LENGTH = 2; 19 | public static final int NFC_APP_HASH_FIELD_LENGTH = 4; 20 | public static final int NFC_EXTRA_DATA_FIELD_LENGTH = 2; 21 | public static final int NFC_APP_RECORD_FIELD_LENGTH = 56; 22 | public static final int NFC_PAYLOAD_LENGTH = 56; // 16 + 16 + 16 + 2 + 4 + 2 23 | public static final int NFC_ULTRALIGHT_C_MAX_LENGTH = 137; 24 | 25 | // unique identifier to key string variables between activities. 26 | static public final String ACTIVITY_SWITCHER_ID = "com.github.rosjava.android_remocons.common_tools.rocon.Constants"; 27 | static public final String ACTIVITY_ROCON_REMOCON = "com.github.rosjava.android_remocons.rocon_remocon.Remocon"; 28 | 29 | public static final rocon_std_msgs.PlatformInfo ANDROID_PLATFORM_INFO = makePlatformInfo(); 30 | 31 | /** 32 | * Generate platform information, most specifically, the rocon uri string that is needed. 33 | * 34 | * @todo : this doesn't introspect the android phone... 35 | * 36 | * @return rocon_std_msgs.PlatformInfo : filled out platform information 37 | */ 38 | private static PlatformInfo makePlatformInfo() { 39 | MessageDefinitionReflectionProvider messageDefinitionProvider = new MessageDefinitionReflectionProvider(); 40 | DefaultMessageFactory messageFactory = new DefaultMessageFactory(messageDefinitionProvider); 41 | PlatformInfo platformInfo = messageFactory.newFromType(PlatformInfo._TYPE); 42 | // rocon:/hw/name/app_framework/os" 43 | platformInfo.setUri("rocon:/" 44 | + Strings.URI_WILDCARD + "/" + Strings.URI_WILDCARD + "/" 45 | + Strings.APPLICATION_FRAMEWORK_INDIGO + "/" 46 | + Strings.OS_ICE_CREAM_SANDWICH + "|" + Strings.OS_JELLYBEAN + "|" 47 | + Strings.OS_CHROME 48 | ); 49 | platformInfo.setVersion(Strings.ROCON_VERSION); 50 | /* Not yet implemented */ 51 | /* platformInfo.setIcon() */ 52 | 53 | return platformInfo; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/system/Util.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.common_tools.system; 2 | 3 | import java.security.InvalidParameterException; 4 | 5 | public class Util { 6 | 7 | // Hex help 8 | private static final byte[] HEX_CHAR_TABLE = { (byte) '0', (byte) '1', 9 | (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', 10 | (byte) '7', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B', 11 | (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F' }; 12 | 13 | public Util() { 14 | // TODO Auto-generated constructor stub 15 | } 16 | 17 | public static String getHexString(byte[] raw, int len) { 18 | byte[] hex = new byte[3 * len]; 19 | int index = 0; 20 | int pos = 0; 21 | 22 | for (byte b : raw) { 23 | if (pos >= len) 24 | break; 25 | 26 | pos++; 27 | int v = b & 0xFF; 28 | hex[index++] = HEX_CHAR_TABLE[v >>> 4]; 29 | hex[index++] = HEX_CHAR_TABLE[v & 0xF]; 30 | hex[index++] = ' '; 31 | } 32 | 33 | return new String(hex); 34 | } 35 | 36 | public static byte[] concat(byte[]... arrays) { 37 | int length = 0; 38 | for (byte[] array : arrays) { 39 | length += array.length; 40 | } 41 | 42 | byte[] result = new byte[length]; 43 | int pos = 0; 44 | for (byte[] array : arrays) { 45 | System.arraycopy(array, 0, result, pos, array.length); 46 | pos += array.length; 47 | } 48 | 49 | return result; 50 | } 51 | 52 | public static String toString(byte[] input, int offset, int count) { 53 | if ((offset + count) > input.length) 54 | throw new ArrayIndexOutOfBoundsException("Requested chunk exceeds byte array limits"); 55 | 56 | byte[] result = new byte[count]; 57 | for (int i = 0; i < count; i++) 58 | result[i] = input[offset + i]; 59 | 60 | return new String(result); 61 | } 62 | 63 | public static short toShort(byte[] input, int offset) { 64 | if ((offset + 2) > input.length) 65 | throw new ArrayIndexOutOfBoundsException("Requested chunk exceeds byte array limits"); 66 | 67 | return (short) (input[offset + 1] & 0xFF | 68 | (input[offset + 0] & 0xFF) << 8); 69 | } 70 | 71 | 72 | public static int toInteger(byte[] input, int offset) { 73 | if ((offset + 4) > input.length) 74 | throw new ArrayIndexOutOfBoundsException("Requested chunk exceeds byte array limits"); 75 | 76 | return input[offset + 3] & 0xFF | 77 | (input[offset + 2] & 0xFF) << 8 | 78 | (input[offset + 1] & 0xFF) << 16 | 79 | (input[offset + 0] & 0xFF) << 24; 80 | } 81 | 82 | public static byte[] toFixSizeBytes(String input, int length, byte padding) { 83 | if (input.length() > length) 84 | throw new InvalidParameterException(length + "exceeds limit in " 85 | + (input.length() - length) + " chars"); 86 | 87 | byte[] result = new byte[length]; 88 | byte[] source = input.getBytes(); 89 | for (int i = 0; i < length; i++) 90 | result[i] = i < source.length ? source[i] : padding; 91 | 92 | return result; 93 | } 94 | 95 | public static byte[] toBytes(int input) 96 | { 97 | byte[] result = new byte[4]; 98 | result[0] = (byte) (input >> 24); 99 | result[1] = (byte) (input >> 16); 100 | result[2] = (byte) (input >> 8); 101 | result[3] = (byte) (input); 102 | 103 | return result; 104 | } 105 | 106 | public static byte[] toBytes(short input) 107 | { 108 | byte[] result = new byte[2]; 109 | result[0] = (byte) (input >> 8); 110 | result[1] = (byte) (input); 111 | 112 | return result; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/zeroconf/DiscoveryAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Yujin Robot. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package com.github.rosjava.android_remocons.common_tools.zeroconf; 18 | 19 | import android.content.Context; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.ArrayAdapter; 24 | import android.widget.Checkable; 25 | import android.widget.CheckedTextView; 26 | import android.widget.ImageView; 27 | import android.widget.LinearLayout; 28 | import android.widget.TextView; 29 | 30 | import com.github.rosjava.android_remocons.common_tools.R; 31 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.DiscoveredService; 32 | 33 | import java.util.ArrayList; 34 | 35 | 36 | public class DiscoveryAdapter extends ArrayAdapter { 37 | 38 | /** 39 | * This class is necessary to work a checkbox well 40 | */ 41 | 42 | public class CustomCheckBox extends LinearLayout implements Checkable { 43 | private CheckedTextView checkbox; 44 | 45 | public CustomCheckBox(Context context) { 46 | super(context); 47 | 48 | View view = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) 49 | .inflate(R.layout.zeroconf_master_item, this, false); 50 | checkbox = (CheckedTextView) view.findViewById(R.id.service_detail); 51 | addView(view); 52 | } 53 | 54 | 55 | @Override 56 | public void setChecked(boolean checked) { 57 | checkbox.setChecked(checked); 58 | 59 | } 60 | 61 | @Override 62 | public boolean isChecked() { 63 | return checkbox.isChecked(); 64 | } 65 | 66 | @Override 67 | public void toggle() { 68 | setChecked(!isChecked()); 69 | 70 | } 71 | } 72 | 73 | 74 | private final Context context; 75 | private ArrayList discoveredServices; 76 | private String targetServiceName; 77 | private int targetServiceDrawable; 78 | private int otherServicesDrawable; 79 | 80 | public DiscoveryAdapter(Context context, ArrayList discoveredServices, 81 | String targetServiceName, int targetServiceDrawable, int otherServicesDrawable) { 82 | super(context, R.layout.zeroconf_master_item, discoveredServices); // pass the list to the super 83 | this.context = context; 84 | this.discoveredServices = discoveredServices; // keep a pointer locally so we can play with it 85 | this.targetServiceName = targetServiceName; 86 | this.targetServiceDrawable = targetServiceDrawable; 87 | this.otherServicesDrawable = otherServicesDrawable; 88 | } 89 | 90 | @Override 91 | public View getView(int position, View convertView, ViewGroup parent) { 92 | View v = convertView; 93 | if (v == null) { 94 | v = new CustomCheckBox(getContext()); 95 | } 96 | 97 | DiscoveredService discovered_service = discoveredServices.get(position); 98 | if (discovered_service != null) { 99 | TextView tt = (TextView) v.findViewById(R.id.service_name); 100 | TextView bt = (TextView) v.findViewById(R.id.service_detail); 101 | if (tt != null) { 102 | tt.setText(discovered_service.name); 103 | } 104 | if (bt != null) { 105 | String result = ""; 106 | for (String ipv4_address : discovered_service.ipv4_addresses) { 107 | if (result.equals("")) { 108 | result += ipv4_address + ":" + discovered_service.port; 109 | } else { 110 | result += "\n" + ipv4_address + ":" + discovered_service.port; 111 | } 112 | } 113 | for (String ipv6_address : discovered_service.ipv6_addresses) { 114 | if (result.equals("")) { 115 | result += ipv6_address + ":" + discovered_service.port; 116 | } else { 117 | result += "\n" + ipv6_address + ":" + discovered_service.port; 118 | } 119 | } 120 | bt.setText(result); 121 | } 122 | ImageView im = (ImageView) v.findViewById(R.id.icon); 123 | if (im != null) { 124 | if (discovered_service.type.indexOf("_" + targetServiceName + "._tcp") != -1 || 125 | discovered_service.type.indexOf("_" + targetServiceName + "._udp") != -1) { 126 | im.setImageDrawable(context.getResources().getDrawable(targetServiceDrawable)); 127 | } else { 128 | im.setImageDrawable(context.getResources().getDrawable(otherServicesDrawable)); 129 | } 130 | } 131 | } 132 | return v; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/zeroconf/DiscoveryHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Yujin Robot. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package com.github.rosjava.android_remocons.common_tools.zeroconf; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.os.AsyncTask; 21 | 22 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.DiscoveredService; 23 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.ZeroconfDiscoveryHandler; 24 | 25 | import java.util.ArrayList; 26 | 27 | /** 28 | * This class is the callback handler for services being listened for 29 | * by the jmdns zeroconf class. 30 | *

31 | * Usually we should do a bit of checking to make sure that any 32 | * service isn't getting repeated on another interface, but for 33 | * now we can assume your android has only the one interface so that 34 | * we handle each added/resolved/removed as a unique entry. 35 | */ 36 | public class DiscoveryHandler implements ZeroconfDiscoveryHandler { 37 | 38 | /** 39 | * ****************** 40 | * Tasks 41 | * ****************** 42 | */ 43 | @SuppressLint("NewApi") 44 | private class ServiceAddedTask extends AsyncTask { 45 | 46 | @SuppressLint("NewApi") 47 | protected Void doInBackground(DiscoveredService... services) { 48 | if (services.length == 1) { 49 | DiscoveredService service = services[0]; 50 | String result = "[+] Service added: " + service.name + "." + service.type + "." + service.domain + "."; 51 | publishProgress(result); 52 | } else { 53 | publishProgress("Error - ServiceAddedTask::doInBackground received #services != 1"); 54 | } 55 | return null; 56 | } 57 | 58 | } 59 | 60 | @SuppressLint("NewApi") 61 | private class ServiceResolvedTask extends AsyncTask { 62 | 63 | @SuppressLint("NewApi") 64 | protected DiscoveredService doInBackground(DiscoveredService... services) { 65 | if (services.length == 1) { 66 | DiscoveredService discovered_service = services[0]; 67 | String result = "[=] Service resolved: " + discovered_service.name + "." + discovered_service.type + "." + discovered_service.domain + ".\n"; 68 | result += " Port: " + discovered_service.port; 69 | for (String address : discovered_service.ipv4_addresses) { 70 | result += "\n Address: " + address; 71 | } 72 | for (String address : discovered_service.ipv6_addresses) { 73 | result += "\n Address: " + address; 74 | } 75 | publishProgress(result); 76 | return discovered_service; 77 | } else { 78 | publishProgress("Error - ServiceAddedTask::doInBackground received #services != 1"); 79 | } 80 | return null; 81 | } 82 | 83 | @SuppressLint("NewApi") 84 | protected void onPostExecute(DiscoveredService discovered_service) { 85 | // add to the content and notify the list view if its a new service 86 | if (discovered_service != null) { 87 | int index = 0; 88 | for (DiscoveredService s : discovered_services) { 89 | if (s.name.equals(discovered_service.name)) { 90 | break; 91 | } else { 92 | ++index; 93 | } 94 | } 95 | if (index == discovered_services.size()) { 96 | discovered_services.add(discovered_service); 97 | discovery_adapter.notifyDataSetChanged(); 98 | } else { 99 | android.util.Log.i("zeroconf", "Tried to add an existing service (fix this)"); 100 | } 101 | } 102 | } 103 | } 104 | 105 | @SuppressLint("NewApi") 106 | private class ServiceRemovedTask extends AsyncTask { 107 | 108 | @SuppressLint("NewApi") 109 | protected DiscoveredService doInBackground(DiscoveredService... services) { 110 | if (services.length == 1) { 111 | DiscoveredService discovered_service = services[0]; 112 | String result = "[-] Service removed: " + discovered_service.name + "." + discovered_service.type + "." + discovered_service.domain + ".\n"; 113 | result += " Port: " + discovered_service.port; 114 | publishProgress(result); 115 | return discovered_service; 116 | } else { 117 | publishProgress("Error - ServiceAddedTask::doInBackground received #services != 1"); 118 | } 119 | return null; 120 | } 121 | 122 | 123 | protected void onPostExecute(DiscoveredService discovered_service) { 124 | // remove service from storage and notify list view 125 | if (discovered_service != null) { 126 | int index = 0; 127 | for (DiscoveredService s : discovered_services) { 128 | if (s.name.equals(discovered_service.name)) { 129 | break; 130 | } else { 131 | ++index; 132 | } 133 | } 134 | if (index != discovered_services.size()) { 135 | discovered_services.remove(index); 136 | discovery_adapter.notifyDataSetChanged(); 137 | } else { 138 | android.util.Log.i("zeroconf", "Tried to remove a non-existant service"); 139 | } 140 | } 141 | } 142 | } 143 | 144 | /** 145 | * ****************** 146 | * Variables 147 | * ****************** 148 | */ 149 | private ArrayList discovered_services; 150 | private DiscoveryAdapter discovery_adapter; 151 | 152 | /** 153 | * ****************** 154 | * Constructors 155 | * ****************** 156 | */ 157 | public DiscoveryHandler(DiscoveryAdapter discovery_adapter, ArrayList discovered_services) { 158 | this.discovery_adapter = discovery_adapter; 159 | this.discovered_services = discovered_services; 160 | } 161 | 162 | /** 163 | * ****************** 164 | * Callbacks 165 | * ****************** 166 | */ 167 | public void serviceAdded(DiscoveredService service) { 168 | new ServiceAddedTask().execute(service); 169 | } 170 | 171 | public void serviceRemoved(DiscoveredService service) { 172 | new ServiceRemovedTask().execute(service); 173 | } 174 | 175 | public void serviceResolved(DiscoveredService service) { 176 | new ServiceResolvedTask().execute(service); 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/zeroconf/DiscoverySetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Yujin Robot. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package com.github.rosjava.android_remocons.common_tools.zeroconf; 18 | 19 | import android.app.ProgressDialog; 20 | import android.content.Context; 21 | import android.os.AsyncTask; 22 | 23 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf; 24 | 25 | 26 | /** 27 | * Configures the zeroconf class for discovery of services. 28 | */ 29 | 30 | public class DiscoverySetup extends AsyncTask { 31 | 32 | private ProgressDialog commencing_dialog; 33 | private final Context context; 34 | 35 | public DiscoverySetup(Context context) { 36 | this.context = context; 37 | } 38 | 39 | protected Void doInBackground(Zeroconf... zeroconfs) { 40 | if (zeroconfs.length == 1) { 41 | Zeroconf zconf = zeroconfs[0]; 42 | android.util.Log.i("zeroconf", "*********** Discovery Commencing **************"); 43 | 44 | zconf.addListener("_ros-master._tcp", "local"); 45 | zconf.addListener("_ros-master._udp", "local"); 46 | zconf.addListener("_concert-master._tcp", "local"); 47 | zconf.addListener("_concert-master._udp", "local"); 48 | 49 | } else { 50 | android.util.Log.i("zeroconf", "Error - DiscoveryTask::doInBackground received #zeroconfs != 1"); 51 | } 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/zeroconf/Logger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Yujin Robot. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package com.github.rosjava.android_remocons.common_tools.zeroconf; 18 | 19 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.ZeroconfLogger; 20 | 21 | public class Logger implements ZeroconfLogger { 22 | 23 | public void println(String msg) { 24 | android.util.Log.i("zeroconf", msg); 25 | } 26 | } -------------------------------------------------------------------------------- /common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/zeroconf/MasterSearcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Yujin Robot. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package com.github.rosjava.android_remocons.common_tools.zeroconf; 18 | 19 | import android.content.Context; 20 | import android.widget.ListView; 21 | 22 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.DiscoveredService; 23 | import com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf; 24 | 25 | import java.io.IOException; 26 | import java.util.ArrayList; 27 | 28 | 29 | public class MasterSearcher { 30 | 31 | private Zeroconf zeroconf; 32 | private ArrayList discoveredMasters; 33 | private DiscoveryAdapter discoveryAdapter; 34 | private DiscoveryHandler discoveryHandler; 35 | private Logger logger; 36 | 37 | public MasterSearcher(Context context, final ListView listView, 38 | String targetServiceName, int targetServiceDrawable, int otherServicesDrawable) { 39 | 40 | discoveredMasters = new ArrayList(); 41 | 42 | discoveryAdapter = new DiscoveryAdapter(context, discoveredMasters, 43 | targetServiceName, targetServiceDrawable, otherServicesDrawable); 44 | listView.setAdapter(discoveryAdapter); 45 | listView.setItemsCanFocus(false); 46 | listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); 47 | 48 | logger = new Logger(); 49 | zeroconf = new Zeroconf(logger); 50 | discoveryHandler = new DiscoveryHandler(discoveryAdapter, discoveredMasters); 51 | zeroconf.setDefaultDiscoveryCallback(discoveryHandler); 52 | 53 | new DiscoverySetup(context).execute(zeroconf); 54 | } 55 | 56 | public void shutdown() { 57 | try { 58 | zeroconf.shutdown(); 59 | } catch (IOException e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /common_tools/src/main/res/drawable/ros_master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rosjava/android_remocons/cfd4e9103ce788999b685f7550795f66f7094c4f/common_tools/src/main/res/drawable/ros_master.png -------------------------------------------------------------------------------- /common_tools/src/main/res/layout/default_dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 14 | 17 | 18 | 19 | 23 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /common_tools/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /common_tools/src/main/res/layout/nfc_tag_scan.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /common_tools/src/main/res/layout/zeroconf_master_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 18 | 19 | 27 | 28 | 42 | -------------------------------------------------------------------------------- /common_tools/src/main/res/layout/zeroconf_master_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /common_tools/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /external_libraries/Readme.rst: -------------------------------------------------------------------------------- 1 | External Jars 2 | ============= 3 | 4 | What libraries we have here are usually patched libraries for android. You can't find them 5 | in maven central (e.g. vanilla snake_yaml is on maven central, doesn't run on android because 6 | it uses introspection methods that the dalvik virtual machine does not support). 7 | 8 | It would be great to get these out to a maven repository of our own. 9 | 10 | 11 | -------------------------------------------------------------------------------- /external_libraries/snakeyaml-1.10-android.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rosjava/android_remocons/cfd4e9103ce788999b685f7550795f66f7094c4f/external_libraries/snakeyaml-1.10-android.jar -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=true 2 | # Disabling the SNI extension fixes "handshake alert: unrecognized_name" error 3 | # in Java 7. 4 | org.gradle.jvmargs=-XX:MaxPermSize=512m -Djsse.enableSNIExtension=false 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rosjava/android_remocons/cfd4e9103ce788999b685f7550795f66f7094c4f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /headless_launcher/README.md: -------------------------------------------------------------------------------- 1 | Headless Launcher 2 | ================= 3 | 4 | ### Connect network 5 | 1. Write the wireless network name you want to connect in NFC 6 | 2. Connect another wireless network 7 | 3. Tagging the nfc 8 | 4. Check the current wireless network whether or not 9 | 10 | ### Launching the App 11 | 1. Install the app you want to launch 12 | 2. Check the app hash using ```rocon_interaction``` in command line 13 | 3. Write the app hash in NFC 14 | 4. Tagging the nfc 15 | 5. Check the app launcing whether or not 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /headless_launcher/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Jorge Santos. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | //noinspection GroovyAssignabilityCheck 18 | dependencies { 19 | compile project(':common_tools') 20 | } 21 | 22 | apply plugin: 'com.android.application' 23 | 24 | android { 25 | compileSdkVersion 28 26 | 27 | defaultConfig { 28 | minSdkVersion 16 29 | targetSdkVersion 28 30 | versionCode 6 31 | versionName "1.4.1" 32 | } 33 | productFlavors { 34 | kinetic { 35 | applicationId "com.github.rosjava.android_remocons.headless_launcher.kinetic" 36 | } 37 | } 38 | lintOptions { 39 | abortOnError = false 40 | } 41 | } 42 | 43 | defaultTasks 'assembleRelease' 44 | -------------------------------------------------------------------------------- /headless_launcher/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /headless_launcher/src/main/java/com/github/rosjava/android_remocons/headless_launcher/AlertDialogActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.rosjava.android_remocons.headless_launcher; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | public class AlertDialogActivity extends Activity implements View.OnClickListener { 11 | private String installPackage = ""; 12 | private String mainContext = ""; 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_alert_dialog); 17 | findViewById(R.id.yes).setOnClickListener(this); 18 | findViewById(R.id.no).setOnClickListener(this); 19 | 20 | installPackage = getIntent().getExtras().getString("InstallPackageName"); 21 | mainContext = getIntent().getExtras().getString("MainContext"); 22 | 23 | TextView text_view; 24 | text_view = (TextView)this.findViewById(R.id.main_context); 25 | text_view.setText(mainContext); 26 | } 27 | 28 | @Override 29 | public void onClick(View v) { 30 | switch(v.getId()){ 31 | case R.id.yes: 32 | Uri uri = Uri.parse("market://details?id=" + installPackage); 33 | Intent intent = new Intent(Intent.ACTION_VIEW, uri); 34 | AlertDialogActivity.this.startActivity(intent); 35 | finish(); 36 | break; 37 | case R.id.no: 38 | finish(); 39 | break; 40 | default: 41 | break; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /headless_launcher/src/main/res/drawable/playstore_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rosjava/android_remocons/cfd4e9103ce788999b685f7550795f66f7094c4f/headless_launcher/src/main/res/drawable/playstore_icon.png -------------------------------------------------------------------------------- /headless_launcher/src/main/res/drawable/playstore_icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rosjava/android_remocons/cfd4e9103ce788999b685f7550795f66f7094c4f/headless_launcher/src/main/res/drawable/playstore_icon_small.png -------------------------------------------------------------------------------- /headless_launcher/src/main/res/layout/activity_alert_dialog.xml: -------------------------------------------------------------------------------- 1 | 13 | 14 |