mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-06 07:28:38 +00:00
add:下拉通知栏
This commit is contained in:
parent
33867d2668
commit
0da3fca247
13 changed files with 124 additions and 13 deletions
|
@ -13,6 +13,8 @@ public final class ControlEvent {
|
|||
public static final int TYPE_TOUCH = 5;
|
||||
|
||||
public static final int COMMAND_BACK_OR_SCREEN_ON = 0;
|
||||
public static final int COMMAND_EXPAND_NOTIFICATION_PANEL = 1;
|
||||
public static final int COMMAND_COLLAPSE_NOTIFICATION_PANEL = 2;
|
||||
|
||||
private int type;
|
||||
private String text;
|
||||
|
|
|
@ -172,6 +172,14 @@ public final class Device {
|
|||
this.rotationListener = rotationListener;
|
||||
}
|
||||
|
||||
public void expandNotificationPanel() {
|
||||
serviceManager.getStatusBarManager().expandNotificationsPanel();
|
||||
}
|
||||
|
||||
public void collapsePanels() {
|
||||
serviceManager.getStatusBarManager().collapsePanels();
|
||||
}
|
||||
|
||||
static Rect flipRect(Rect crop) {
|
||||
return new Rect(crop.top, crop.left, crop.bottom, crop.right);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.genymobile.scrcpy;
|
||||
|
||||
import com.genymobile.scrcpy.wrappers.InputManager;
|
||||
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.os.SystemClock;
|
||||
|
@ -301,6 +302,12 @@ public class EventController {
|
|||
switch (action) {
|
||||
case ControlEvent.COMMAND_BACK_OR_SCREEN_ON:
|
||||
return pressBackOrTurnScreenOn();
|
||||
case ControlEvent.COMMAND_EXPAND_NOTIFICATION_PANEL:
|
||||
device.expandNotificationPanel();
|
||||
return true;
|
||||
case ControlEvent.COMMAND_COLLAPSE_NOTIFICATION_PANEL:
|
||||
device.collapsePanels();
|
||||
return true;
|
||||
default:
|
||||
Ln.w("Unsupported command: " + action);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public final class ServiceManager {
|
|||
private DisplayManager displayManager;
|
||||
private InputManager inputManager;
|
||||
private PowerManager powerManager;
|
||||
private StatusBarManager statusBarManager;
|
||||
|
||||
public ServiceManager() {
|
||||
try {
|
||||
|
@ -60,4 +61,11 @@ public final class ServiceManager {
|
|||
}
|
||||
return powerManager;
|
||||
}
|
||||
|
||||
public StatusBarManager getStatusBarManager() {
|
||||
if (statusBarManager == null) {
|
||||
statusBarManager = new StatusBarManager(getService("statusbar", "com.android.internal.statusbar.IStatusBarService"));
|
||||
}
|
||||
return statusBarManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.genymobile.scrcpy.wrappers;
|
||||
|
||||
//import android.annotation.SuppressLint;
|
||||
import android.os.IInterface;
|
||||
//import android.view.InputEvent;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class StatusBarManager {
|
||||
|
||||
private final IInterface manager;
|
||||
private final Method expandNotificationsPanelMethod;
|
||||
private final Method collapsePanelsMethod;
|
||||
|
||||
public StatusBarManager(IInterface manager) {
|
||||
this.manager = manager;
|
||||
try {
|
||||
expandNotificationsPanelMethod = manager.getClass().getMethod("expandNotificationsPanel");
|
||||
collapsePanelsMethod = manager.getClass().getMethod("collapsePanels");
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void expandNotificationsPanel() {
|
||||
try {
|
||||
expandNotificationsPanelMethod.invoke(manager);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void collapsePanels() {
|
||||
try {
|
||||
collapsePanelsMethod.invoke(manager);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue