Compare commits
2 Commits
broadcast
...
sdcard_dow
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b6e511322 | ||
|
|
af228706f1 |
@@ -709,15 +709,15 @@ There is no visual feedback, a log is printed to the console.
|
||||
|
||||
#### Push file to device
|
||||
|
||||
To push a file to `/sdcard/` on the device, drag & drop a (non-APK) file to the
|
||||
_scrcpy_ window.
|
||||
To push a file to `/sdcard/Download/` on the device, drag & drop a (non-APK)
|
||||
file to the _scrcpy_ window.
|
||||
|
||||
There is no visual feedback, a log is printed to the console.
|
||||
|
||||
The target directory can be changed on start:
|
||||
|
||||
```bash
|
||||
scrcpy --push-target=/sdcard/Download/
|
||||
scrcpy --push-target=/sdcard/Movies/
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ but breaks the expected behavior of alpha keys in games (typically WASD).
|
||||
.BI "\-\-push\-target " path
|
||||
Set the target directory for pushing files to the device by drag & drop. It is passed as\-is to "adb push".
|
||||
|
||||
Default is "/sdcard/".
|
||||
Default is "/sdcard/Download/".
|
||||
|
||||
.TP
|
||||
.BI "\-r, \-\-record " file
|
||||
|
||||
@@ -129,7 +129,7 @@ scrcpy_print_usage(const char *arg0) {
|
||||
" --push-target path\n"
|
||||
" Set the target directory for pushing files to the device by\n"
|
||||
" drag & drop. It is passed as-is to \"adb push\".\n"
|
||||
" Default is \"/sdcard/\".\n"
|
||||
" Default is \"/sdcard/Download/\".\n"
|
||||
"\n"
|
||||
" -r, --record file.mp4\n"
|
||||
" Record screen to file.\n"
|
||||
|
||||
@@ -22,6 +22,18 @@
|
||||
# define SCRCPY_LAVF_REQUIRES_REGISTER_ALL
|
||||
#endif
|
||||
|
||||
|
||||
// In ffmpeg/doc/APIchanges:
|
||||
// 2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
|
||||
// Deprecate AVFormatContext filename field which had limited length, use the
|
||||
// new dynamically allocated url field instead.
|
||||
//
|
||||
// 2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
|
||||
// Add url field to AVFormatContext and add ff_format_set_url helper function.
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 100)
|
||||
# define SCRCPY_LAVF_HAS_AVFORMATCONTEXT_URL
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
// <https://wiki.libsdl.org/SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH>
|
||||
# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH
|
||||
|
||||
@@ -80,13 +80,6 @@ control_msg_serialize(const struct control_msg *msg, unsigned char *buf) {
|
||||
case CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE:
|
||||
buf[1] = msg->set_screen_power_mode.mode;
|
||||
return 2;
|
||||
case CONTROL_MSG_TYPE_SCAN_MEDIA:
|
||||
{
|
||||
size_t len = write_string(msg->scan_media.path,
|
||||
CONTROL_MSG_SCAN_MEDIA_PATH_MAX_LENGTH,
|
||||
&buf[1]);
|
||||
return 1 + len;
|
||||
}
|
||||
case CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL:
|
||||
case CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL:
|
||||
case CONTROL_MSG_TYPE_COLLAPSE_PANELS:
|
||||
@@ -109,9 +102,6 @@ control_msg_destroy(struct control_msg *msg) {
|
||||
case CONTROL_MSG_TYPE_SET_CLIPBOARD:
|
||||
free(msg->set_clipboard.text);
|
||||
break;
|
||||
case CONTROL_MSG_TYPE_SCAN_MEDIA:
|
||||
free(msg->scan_media.path);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
||||
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
||||
|
||||
#define CONTROL_MSG_SCAN_MEDIA_PATH_MAX_LENGTH 256
|
||||
|
||||
#define POINTER_ID_MOUSE UINT64_C(-1);
|
||||
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2);
|
||||
|
||||
@@ -35,7 +33,6 @@ enum control_msg_type {
|
||||
CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
||||
CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
|
||||
CONTROL_MSG_TYPE_ROTATE_DEVICE,
|
||||
CONTROL_MSG_TYPE_SCAN_MEDIA,
|
||||
};
|
||||
|
||||
enum screen_power_mode {
|
||||
@@ -79,9 +76,6 @@ struct control_msg {
|
||||
struct {
|
||||
enum screen_power_mode mode;
|
||||
} set_screen_power_mode;
|
||||
struct {
|
||||
char *path; // owned, to be freed by free()
|
||||
} scan_media;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "adb.h"
|
||||
#include "util/log.h"
|
||||
|
||||
#define DEFAULT_PUSH_TARGET "/sdcard/"
|
||||
#define DEFAULT_PUSH_TARGET "/sdcard/Download/"
|
||||
|
||||
static void
|
||||
file_handler_request_destroy(struct file_handler_request *req) {
|
||||
|
||||
@@ -180,12 +180,17 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
||||
// still expects a pointer-to-non-const (it has not be updated accordingly)
|
||||
// <https://github.com/FFmpeg/FFmpeg/commit/0694d8702421e7aff1340038559c438b61bb30dd>
|
||||
vs->format_ctx->oformat = (AVOutputFormat *) format;
|
||||
#ifdef SCRCPY_LAVF_HAS_AVFORMATCONTEXT_URL
|
||||
vs->format_ctx->url = strdup(vs->device_name);
|
||||
if (!vs->format_ctx->url) {
|
||||
LOGE("Could not strdup v4l2 device name");
|
||||
goto error_avformat_free_context;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
strncpy(vs->format_ctx->filename, vs->device_name,
|
||||
sizeof(vs->format_ctx->filename));
|
||||
#endif
|
||||
|
||||
AVStream *ostream = avformat_new_stream(vs->format_ctx, encoder);
|
||||
if (!ostream) {
|
||||
|
||||
@@ -278,28 +278,6 @@ static void test_serialize_rotate_device(void) {
|
||||
assert(!memcmp(buf, expected, sizeof(expected)));
|
||||
}
|
||||
|
||||
static void test_serialize_scan_media(void) {
|
||||
struct control_msg msg = {
|
||||
.type = CONTROL_MSG_TYPE_SCAN_MEDIA,
|
||||
.scan_media = {
|
||||
.path = "/sdcard/Download/",
|
||||
},
|
||||
};
|
||||
|
||||
unsigned char buf[CONTROL_MSG_MAX_SIZE];
|
||||
size_t size = control_msg_serialize(&msg, buf);
|
||||
assert(size == 22);
|
||||
|
||||
const unsigned char expected[] = {
|
||||
CONTROL_MSG_TYPE_SCAN_MEDIA,
|
||||
0x00, 0x00, 0x00, 0x11, // path length
|
||||
'/', 's', 'd', 'c', 'a', 'r', 'd', '/',
|
||||
'D', 'o', 'w', 'n', 'l', 'o', 'a', 'd',
|
||||
'/' // path
|
||||
};
|
||||
assert(!memcmp(buf, expected, sizeof(expected)));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
@@ -317,6 +295,5 @@ int main(int argc, char *argv[]) {
|
||||
test_serialize_set_clipboard();
|
||||
test_serialize_set_screen_power_mode();
|
||||
test_serialize_rotate_device();
|
||||
test_serialize_scan_media();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ public final class ControlMessage {
|
||||
public static final int TYPE_SET_CLIPBOARD = 9;
|
||||
public static final int TYPE_SET_SCREEN_POWER_MODE = 10;
|
||||
public static final int TYPE_ROTATE_DEVICE = 11;
|
||||
public static final int TYPE_SCAN_MEDIA = 12;
|
||||
|
||||
private int type;
|
||||
private String text;
|
||||
@@ -98,13 +97,6 @@ public final class ControlMessage {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static ControlMessage createScanMedia(String path) {
|
||||
ControlMessage msg = new ControlMessage();
|
||||
msg.type = TYPE_SCAN_MEDIA;
|
||||
msg.text = path;
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static ControlMessage createEmpty(int type) {
|
||||
ControlMessage msg = new ControlMessage();
|
||||
msg.type = type;
|
||||
|
||||
@@ -76,9 +76,6 @@ public class ControlMessageReader {
|
||||
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
|
||||
msg = parseSetScreenPowerMode();
|
||||
break;
|
||||
case ControlMessage.TYPE_SCAN_MEDIA:
|
||||
msg = parseScanMedia();
|
||||
break;
|
||||
case ControlMessage.TYPE_EXPAND_NOTIFICATION_PANEL:
|
||||
case ControlMessage.TYPE_EXPAND_SETTINGS_PANEL:
|
||||
case ControlMessage.TYPE_COLLAPSE_PANELS:
|
||||
@@ -185,14 +182,6 @@ public class ControlMessageReader {
|
||||
return ControlMessage.createSetScreenPowerMode(mode);
|
||||
}
|
||||
|
||||
private ControlMessage parseScanMedia() {
|
||||
String path = parseString();
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return ControlMessage.createScanMedia(path);
|
||||
}
|
||||
|
||||
private static Position readPosition(ByteBuffer buffer) {
|
||||
int x = buffer.getInt();
|
||||
int y = buffer.getInt();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.view.InputDevice;
|
||||
@@ -9,7 +7,6 @@ import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -138,12 +135,6 @@ public class Controller {
|
||||
case ControlMessage.TYPE_ROTATE_DEVICE:
|
||||
Device.rotateDevice();
|
||||
break;
|
||||
case ControlMessage.TYPE_SCAN_MEDIA:
|
||||
String path = msg.getText();
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(Uri.fromFile(new File(path)));
|
||||
Device.sendBroadcast(intent);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
||||
import com.genymobile.scrcpy.wrappers.WindowManager;
|
||||
|
||||
import android.content.IOnPrimaryClipChangedListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
@@ -300,8 +299,4 @@ public final class Device {
|
||||
public static ContentProvider createSettingsProvider() {
|
||||
return SERVICE_MANAGER.getActivityManager().createSettingsProvider();
|
||||
}
|
||||
|
||||
public static void sendBroadcast(Intent intent) {
|
||||
SERVICE_MANAGER.getActivityManager().sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.genymobile.scrcpy.wrappers;
|
||||
|
||||
import com.genymobile.scrcpy.Ln;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
|
||||
@@ -18,7 +16,6 @@ public class ActivityManager {
|
||||
private Method getContentProviderExternalMethod;
|
||||
private boolean getContentProviderExternalMethodNewVersion = true;
|
||||
private Method removeContentProviderExternalMethod;
|
||||
private Method broadcastIntentMethod;
|
||||
|
||||
public ActivityManager(IInterface manager) {
|
||||
this.manager = manager;
|
||||
@@ -45,22 +42,6 @@ public class ActivityManager {
|
||||
return removeContentProviderExternalMethod;
|
||||
}
|
||||
|
||||
private Method getBroadcastIntentMethod() throws NoSuchMethodException {
|
||||
if (broadcastIntentMethod == null) {
|
||||
try {
|
||||
Class<?> iApplicationThreadClass = Class.forName("android.app.IApplicationThread");
|
||||
Class<?> iIntentReceiverClass = Class.forName("android.content.IIntentReceiver");
|
||||
broadcastIntentMethod = manager.getClass()
|
||||
.getMethod("broadcastIntent", iApplicationThreadClass, Intent.class, String.class, iIntentReceiverClass, int.class,
|
||||
String.class, Bundle.class, String[].class, int.class, Bundle.class, boolean.class, boolean.class, int.class);
|
||||
return broadcastIntentMethod;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
return broadcastIntentMethod;
|
||||
}
|
||||
|
||||
private ContentProvider getContentProviderExternal(String name, IBinder token) {
|
||||
try {
|
||||
Method method = getGetContentProviderExternalMethod();
|
||||
@@ -103,13 +84,4 @@ public class ActivityManager {
|
||||
public ContentProvider createSettingsProvider() {
|
||||
return getContentProviderExternal("settings", new Binder());
|
||||
}
|
||||
|
||||
public void sendBroadcast(Intent intent) {
|
||||
try {
|
||||
Method method = getBroadcastIntentMethod();
|
||||
method.invoke(manager, null, intent, null, null, 0, null, null, null, -1, null, true, false, ServiceManager.USER_ID);
|
||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||
Ln.e("Could not invoke method", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,26 +314,6 @@ public class ControlMessageReaderTest {
|
||||
Assert.assertEquals(ControlMessage.TYPE_ROTATE_DEVICE, event.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScanMedia() throws IOException {
|
||||
ControlMessageReader reader = new ControlMessageReader();
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
dos.writeByte(ControlMessage.TYPE_SCAN_MEDIA);
|
||||
byte[] text = "/sdcard/Download/".getBytes(StandardCharsets.UTF_8);
|
||||
dos.writeInt(text.length);
|
||||
dos.write(text);
|
||||
|
||||
byte[] packet = bos.toByteArray();
|
||||
|
||||
reader.readFrom(new ByteArrayInputStream(packet));
|
||||
ControlMessage event = reader.next();
|
||||
|
||||
Assert.assertEquals(ControlMessage.TYPE_SCAN_MEDIA, event.getType());
|
||||
Assert.assertEquals("/sdcard/Download/", event.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiEvents() throws IOException {
|
||||
ControlMessageReader reader = new ControlMessageReader();
|
||||
|
||||
Reference in New Issue
Block a user