adb sync指代的两种软件

第一种是指

sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendor]
sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
-n: dry run: push files to device without storing to the filesystem
-l: list files that would be copied, but don't copy them
-z: enable compression with a specified algorithm (any/none/brotli/lz4/zstd)
-Z: disable compression

 

这个adb sync 似乎只用于把在电脑上源码构建的Android系统push到手机上

$ANDROID_PRODUCT_OUT 是一个环境变量,用于指示 Android 编译系统生成的构建输出目录的路径。在 Android 开发环境中,该变量通常设置为构建输出目录的完整路径。

Android 编译系统会根据所选的目标设备和其他配置参数,将编译结果生成到 $ANDROID_PRODUCT_OUT 目录中。该目录中包含了构建所需的各种文件和目录,例如系统镜像文件、应用程序等。

如果电脑上没有设置这个ANDROID_PRODUCT_OUT,会输出 adb.exe: product directory not specified; set $ANDROID_PRODUCT_OUT

 

https://medium.com/@yigitpirildak/syncing-aosp-build-changes-using-adb-sync-885ce12e5cc7

https://xdaforums.com/t/adb-sync-question.552372/

 


 

https://android.googlesource.com/platform/packages/modules/adb/+/refs/heads/master

看源码

        std::vector<std::string> partitions{"data",   "odm",        "oem",   "product",
                                            "system", "system_ext", "vendor"};
        bool found = false;
        for (const auto& partition : partitions) {
            if (src == "all" || src == partition) {
                std::string src_dir{product_file(partition)};
                if (!directory_exists(src_dir)) continue;
                found = true;
                if (!do_sync_sync(src_dir, "/" + partition, list_only, compression, dry_run)) {
                    return 1;
                }
            }
        }

从源码来看,

"data",   "odm",        "oem",   "product","system", "system_ext", "vendor" 这些构建出来应该都是一个个目录
bool directory_exists(const std::string& path) {
  struct stat sb;
  return stat(path.c_str(), &sb) != -1 && S_ISDIR(sb.st_mode);
}
struct stat S_ISDIR这些都是linux的库,看起来是用了mingw
 
            // If the destination path existed originally, the source directory
            // should be copied as a child of the destination.
 
调用
do_sync_sync
调用
copy_local_dir_remote
调用
                if (!sync_send(sc, ci.lpath, ci.rpath, ci.time, ci.mode, false, compression,
                               dry_run)) 发送文件到手机
 

 

第二种是指

https://github.com/google/adb-sync

python写的

adb-sync 是一个使用 ADB(Android 调试桥)在 PC 和 Android 设备之间同步文件的工具。

posted @ 2024-02-09 12:34  hrdom  阅读(103)  评论(0编辑  收藏  举报