mirror of
https://github.com/Genymobile/scrcpy.git
synced 2024-09-19 05:31:21 +02:00
Remove rotation listener
The display listener notifies whenever the display changes, including when the device is rotated.
This commit is contained in:
parent
391f2de3fa
commit
a0e2160437
4 changed files with 1 additions and 74 deletions
|
@ -1,25 +0,0 @@
|
|||
/* //device/java/android/android/hardware/ISensorListener.aidl
|
||||
**
|
||||
** Copyright 2008, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
interface IRotationWatcher {
|
||||
oneway void onRotationChanged(int rotation);
|
||||
}
|
|
@ -16,7 +16,6 @@ import android.os.HandlerThread;
|
|||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.view.IDisplayFoldListener;
|
||||
import android.view.IRotationWatcher;
|
||||
import android.view.InputDevice;
|
||||
import android.view.InputEvent;
|
||||
import android.view.KeyCharacterMap;
|
||||
|
@ -40,10 +39,6 @@ public final class Device {
|
|||
void onDisplayChanged();
|
||||
}
|
||||
|
||||
public interface RotationListener {
|
||||
void onRotationChanged(int rotation);
|
||||
}
|
||||
|
||||
public interface FoldListener {
|
||||
void onFoldChanged(int displayId, boolean folded);
|
||||
}
|
||||
|
@ -59,7 +54,6 @@ public final class Device {
|
|||
private Size deviceSize;
|
||||
private ScreenInfo screenInfo;
|
||||
private DisplayChangeListener displayChangeListener;
|
||||
private RotationListener rotationListener;
|
||||
private FoldListener foldListener;
|
||||
private ClipboardListener clipboardListener;
|
||||
private final AtomicBoolean isSettingClipboard = new AtomicBoolean();
|
||||
|
@ -115,20 +109,6 @@ public final class Device {
|
|||
}
|
||||
}, displayListenerHandler);
|
||||
|
||||
ServiceManager.getWindowManager().registerRotationWatcher(new IRotationWatcher.Stub() {
|
||||
@Override
|
||||
public void onRotationChanged(int rotation) {
|
||||
synchronized (Device.this) {
|
||||
screenInfo = screenInfo.withDeviceRotation(rotation);
|
||||
|
||||
// notify
|
||||
if (rotationListener != null) {
|
||||
rotationListener.onRotationChanged(rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, displayId);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
ServiceManager.getWindowManager().registerDisplayFoldListener(new IDisplayFoldListener.Stub() {
|
||||
@Override
|
||||
|
@ -286,10 +266,6 @@ public final class Device {
|
|||
this.displayChangeListener = displayChangeListener;
|
||||
}
|
||||
|
||||
public synchronized void setRotationListener(RotationListener rotationListener) {
|
||||
this.rotationListener = rotationListener;
|
||||
}
|
||||
|
||||
public synchronized void setFoldListener(FoldListener foldlistener) {
|
||||
this.foldListener = foldlistener;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.os.Build;
|
|||
import android.os.IBinder;
|
||||
import android.view.Surface;
|
||||
|
||||
public class ScreenCapture extends SurfaceCapture implements Device.DisplayChangeListener, Device.RotationListener, Device.FoldListener {
|
||||
public class ScreenCapture extends SurfaceCapture implements Device.DisplayChangeListener, Device.FoldListener {
|
||||
|
||||
private final Device device;
|
||||
private IBinder display;
|
||||
|
@ -19,7 +19,6 @@ public class ScreenCapture extends SurfaceCapture implements Device.DisplayChang
|
|||
@Override
|
||||
public void init() {
|
||||
device.setDisplayChangeListener(this);
|
||||
device.setRotationListener(this);
|
||||
device.setFoldListener(this);
|
||||
}
|
||||
|
||||
|
@ -43,7 +42,6 @@ public class ScreenCapture extends SurfaceCapture implements Device.DisplayChang
|
|||
@Override
|
||||
public void release() {
|
||||
device.setDisplayChangeListener(null);
|
||||
device.setRotationListener(null);
|
||||
device.setFoldListener(null);
|
||||
if (display != null) {
|
||||
SurfaceControl.destroyDisplay(display);
|
||||
|
@ -66,11 +64,6 @@ public class ScreenCapture extends SurfaceCapture implements Device.DisplayChang
|
|||
requestReset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRotationChanged(int rotation) {
|
||||
requestReset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayChanged() {
|
||||
requestReset();
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.genymobile.scrcpy.Ln;
|
|||
import android.annotation.TargetApi;
|
||||
import android.os.IInterface;
|
||||
import android.view.IDisplayFoldListener;
|
||||
import android.view.IRotationWatcher;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -95,22 +94,6 @@ public final class WindowManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void registerRotationWatcher(IRotationWatcher rotationWatcher, int displayId) {
|
||||
try {
|
||||
Class<?> cls = manager.getClass();
|
||||
try {
|
||||
// display parameter added since this commit:
|
||||
// https://android.googlesource.com/platform/frameworks/base/+/35fa3c26adcb5f6577849fd0df5228b1f67cf2c6%5E%21/#F1
|
||||
cls.getMethod("watchRotation", IRotationWatcher.class, int.class).invoke(manager, rotationWatcher, displayId);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// old version
|
||||
cls.getMethod("watchRotation", IRotationWatcher.class).invoke(manager, rotationWatcher);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Ln.e("Could not register rotation watcher", e);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(29)
|
||||
public void registerDisplayFoldListener(IDisplayFoldListener foldListener) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue