Skip to content

Commit

Permalink
dynamic sensor detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpkarras committed Oct 3, 2023
1 parent 9638ecb commit 75c650a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/tpkarras/mirror2rearultra/Mirror.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 75c650a

Please sign in to comment.