mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-17 21:04:50 +00:00
Do not log success on failure
If calling the private API does not work, an exception is printed. In that case, do not log that the action succeeded.
This commit is contained in:
parent
94e1696869
commit
bea1c11f8e
@ -163,8 +163,10 @@ public final class Device {
|
||||
}
|
||||
|
||||
public void setClipboardText(String text) {
|
||||
serviceManager.getClipboardManager().setText(text);
|
||||
Ln.i("Device clipboard set");
|
||||
boolean ok = serviceManager.getClipboardManager().setText(text);
|
||||
if (ok) {
|
||||
Ln.i("Device clipboard set");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,8 +178,10 @@ public final class Device {
|
||||
Ln.e("Could not get built-in display");
|
||||
return;
|
||||
}
|
||||
SurfaceControl.setDisplayPowerMode(d, mode);
|
||||
Ln.i("Device screen turned " + (mode == Device.POWER_MODE_OFF ? "off" : "on"));
|
||||
boolean ok = SurfaceControl.setDisplayPowerMode(d, mode);
|
||||
if (ok) {
|
||||
Ln.i("Device screen turned " + (mode == Device.POWER_MODE_OFF ? "off" : "on"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,13 +74,15 @@ public class ClipboardManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(CharSequence text) {
|
||||
public boolean setText(CharSequence text) {
|
||||
try {
|
||||
Method method = getSetPrimaryClipMethod();
|
||||
ClipData clipData = ClipData.newPlainText(null, text);
|
||||
setPrimaryClip(method, manager, clipData);
|
||||
return true;
|
||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||
Ln.e("Could not invoke method", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,12 +121,14 @@ public final class SurfaceControl {
|
||||
return setDisplayPowerModeMethod;
|
||||
}
|
||||
|
||||
public static void setDisplayPowerMode(IBinder displayToken, int mode) {
|
||||
public static boolean setDisplayPowerMode(IBinder displayToken, int mode) {
|
||||
try {
|
||||
Method method = getSetDisplayPowerModeMethod();
|
||||
method.invoke(null, displayToken, mode);
|
||||
return true;
|
||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||
Ln.e("Could not invoke method", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user