From 161858696d02c9584be42089cea8f2694c944544 Mon Sep 17 00:00:00 2001
From: rschoene <rene.schoene@tu-dresden.de>
Date: Tue, 22 May 2018 14:38:02 +0200
Subject: [PATCH] Reduce minSdkVersion to run on Moto 360.

---
 .idea/misc.xml                                |  2 +-
 common/build.gradle                           |  2 +-
 wear/build.gradle                             |  8 +++----
 .../inf/st/sensorsharing/MainActivity.java    | 22 +++++++++++++++++++
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/.idea/misc.xml b/.idea/misc.xml
index 75dac50..3963879 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -24,7 +24,7 @@
       </value>
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
diff --git a/common/build.gradle b/common/build.gradle
index 8e95a6b..0b1a1f1 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -6,7 +6,7 @@ android {
 
 
     defaultConfig {
-        minSdkVersion 24
+        minSdkVersion 23
         targetSdkVersion 26
         versionCode 1
         versionName "1.0"
diff --git a/wear/build.gradle b/wear/build.gradle
index 5f5d0fd..2687019 100644
--- a/wear/build.gradle
+++ b/wear/build.gradle
@@ -4,7 +4,7 @@ android {
     compileSdkVersion 26
     defaultConfig {
         applicationId "de.tudresden.inf.st.sensorsharing"
-        minSdkVersion 25
+        minSdkVersion 23
         targetSdkVersion 26
         versionCode 1
         versionName "1.0"
@@ -22,11 +22,11 @@ dependencies {
 
     implementation project(':common')
 
-    implementation 'com.google.android.support:wearable:2.2.0'
-    implementation 'com.google.android.gms:play-services-wearable:11.8.0'
+    implementation 'com.google.android.support:wearable:2.3.0'
+    implementation 'com.google.android.gms:play-services-wearable:15.0.1'
     implementation 'com.android.support:percent:26.1.0'
     implementation 'com.android.support:support-v4:26.1.0'
     implementation 'com.android.support:recyclerview-v7:26.1.0'
     implementation 'com.android.support:wear:26.1.0'
-    compileOnly 'com.google.android.wearable:wearable:2.2.0'
+    compileOnly 'com.google.android.wearable:wearable:2.3.0'
 }
diff --git a/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java b/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
index c6e71f4..ec74faf 100644
--- a/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
+++ b/wear/src/main/java/de/tudresden/inf/st/sensorsharing/MainActivity.java
@@ -62,7 +62,27 @@ public class MainActivity extends WearableActivity implements SensorEventListene
         // initialize sensors
         mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
         mLinearAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
+        if (mLinearAcceleration == null) {
+            mLinearAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+            if (mRotationVector == null) {
+                Log.e(TAG, "Couldn't find acceleration sensor!");
+                TextView textView = findViewById(R.id.acceleration_value);
+                textView.setText("ERROR");
+            } else {
+                Log.w(TAG, "Using alternative accelerometer sensor!");
+            }
+        }
         mRotationVector = mSensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
+        if (mRotationVector == null) {
+            mRotationVector = mSensorManager.getDefaultSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR);
+            if (mRotationVector == null) {
+                TextView textView = findViewById(R.id.rotation_value);
+                textView.setText("ERROR");
+                Log.e(TAG, "Couldn't find rotation sensor!");
+            } else {
+                Log.w(TAG, "Using alternative rotation sensor!");
+            }
+        }
 
         // initialize sensor values
         mLinearAccelerationValues = new float[3];
@@ -84,11 +104,13 @@ public class MainActivity extends WearableActivity implements SensorEventListene
                 sendCurrentValueToAllConnectedNodes();
                 break;
             case Sensor.TYPE_LINEAR_ACCELERATION:
+            case Sensor.TYPE_ACCELEROMETER:
                 mLinearAccelerationValues = sensorEvent.values;
                 textView = findViewById(R.id.acceleration_value);
                 textView.setText(formatArray3(mLinearAccelerationValues));
                 break;
             case Sensor.TYPE_GAME_ROTATION_VECTOR:
+            case Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR:
                 mRotationVectorValues = sensorEvent.values;
                 textView = findViewById(R.id.rotation_value);
                 textView.setText(formatArray3(mRotationVectorValues));
-- 
GitLab