From 75c650ad1b0d168d5414a74dd3f85d760a3f5a4f Mon Sep 17 00:00:00 2001 From: taylorkarras Date: Mon, 2 Oct 2023 19:40:13 -0700 Subject: [PATCH] dynamic sensor detection. --- app/build.gradle | 2 +- .../java/com/tpkarras/mirror2rearultra/Mirror.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0ccfd86..fef1f08 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { minSdk 30 targetSdk 31 versionCode 1 - versionName "1.0.4.2-3" + versionName "1.0.4.2-4" signingConfig signingConfigs.debug testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/tpkarras/mirror2rearultra/Mirror.java b/app/src/main/java/com/tpkarras/mirror2rearultra/Mirror.java index 1f0d886..c4150a0 100644 --- a/app/src/main/java/com/tpkarras/mirror2rearultra/Mirror.java +++ b/app/src/main/java/com/tpkarras/mirror2rearultra/Mirror.java @@ -40,7 +40,6 @@ public class Mirror extends Activity { private TextureView textureView; private VirtualDisplay virtualDisplay; private static int subscreenSwitch; - private static Binder sBinder; private static Method serviceMethod; private IBinder windowBinder; @@ -52,7 +51,6 @@ public static void rearScreenSwitch(boolean z){ if(z) { code = 16777210; Binder binder = new Binder(); - sBinder = binder; parcel.writeStrongBinder(binder); parcel.writeLong(SystemClock.uptimeMillis()); parcel.writeInt(1); @@ -122,7 +120,13 @@ public void run() { } super.onCreate(savedInstanceState); SensorManager sensorManager = (SensorManager) getApplicationContext().getSystemService(Context.SENSOR_SERVICE); - Sensor screenDown = sensorManager.getDefaultSensor(33171037); + Sensor screenDown = null; + for (Sensor sensor: sensorManager.getSensorList(Sensor.TYPE_ALL)){ + if(sensor.getName().matches("screen_down.*") && sensor.isWakeUpSensor() == false) { + screenDown = sensor; + break; + } + } SensorEventListener sensorEventListener = new SensorEventListener() { @Override public void onSensorChanged(SensorEvent sensorEvent) {