summaryrefslogtreecommitdiff
path: root/devel/android-tools-adb/files/patch-adb_client_adb__install.cpp
blob: 5cd17d5211284c682259a9d0f5fe589a763a56a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
--- adb/client/adb_install.cpp.orig	2019-10-18 00:22:21 UTC
+++ adb/client/adb_install.cpp
@@ -35,9 +35,11 @@
 #include "adb_utils.h"
 #include "client/file_sync_client.h"
 #include "commandline.h"
+#if defined(ENABLE_FASTDEPLOY)
 #include "fastdeploy.h"
 
 static constexpr int kFastDeployMinApi = 24;
+#endif
 
 namespace {
 
@@ -167,6 +169,7 @@ static int install_app_streamed(int argc, const char**
     }
 
     if (use_fastdeploy) {
+#if defined(ENABLE_FASTDEPLOY)
         auto metadata = extract_metadata(file);
         if (metadata.has_value()) {
             // pass all but 1st (command) and last (apk path) parameters through to pm for
@@ -175,6 +178,9 @@ static int install_app_streamed(int argc, const char**
             auto patchFd = install_patch(pm_args.size(), pm_args.data());
             return stream_patch(file, std::move(metadata.value()), std::move(patchFd));
         }
+#else
+        error_exit("fastdeploy is disabled");
+#endif
     }
 
     struct stat sb;
@@ -189,7 +195,7 @@ static int install_app_streamed(int argc, const char**
         return 1;
     }
 
-#ifdef __linux__
+#if !defined(__APPLE__) && !defined(_WIN32)
     posix_fadvise(local_fd.get(), 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE);
 #endif
 
@@ -263,6 +269,7 @@ static int install_app_legacy(int argc, const char** a
     argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */
 
     if (use_fastdeploy) {
+#if defined(ENABLE_FASTDEPLOY)
         auto metadata = extract_metadata(apk_file[0]);
         if (metadata.has_value()) {
             auto patchFd = apply_patch_on_device(apk_dest.c_str());
@@ -273,6 +280,9 @@ static int install_app_legacy(int argc, const char** a
 
             return status;
         }
+#else
+        error_exit("fastdeploy is disabled");
+#endif
     }
 
     if (do_sync_push(apk_file, apk_dest.c_str(), false)) {
@@ -288,7 +298,9 @@ int install_app(int argc, const char** argv) {
     InstallMode installMode = INSTALL_DEFAULT;
     bool use_fastdeploy = false;
     bool is_reinstall = false;
+#if defined(ENABLE_FASTDEPLOY)
     FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
+#endif
 
     for (int i = 1; i < argc; i++) {
         if (!strcmp(argv[i], "--streaming")) {
@@ -309,13 +321,19 @@ int install_app(int argc, const char** argv) {
             use_fastdeploy = false;
         } else if (!strcmp(argv[i], "--force-agent")) {
             processedArgIndicies.push_back(i);
+#if defined(ENABLE_FASTDEPLOY)
             agent_update_strategy = FastDeploy_AgentUpdateAlways;
+#endif
         } else if (!strcmp(argv[i], "--date-check-agent")) {
             processedArgIndicies.push_back(i);
+#if defined(ENABLE_FASTDEPLOY)
             agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp;
+#endif
         } else if (!strcmp(argv[i], "--version-check-agent")) {
             processedArgIndicies.push_back(i);
+#if defined(ENABLE_FASTDEPLOY)
             agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
+#endif
         }
     }
 
@@ -327,6 +345,7 @@ int install_app(int argc, const char** argv) {
         error_exit("Attempting to use streaming install on unsupported device");
     }
 
+#if defined(ENABLE_FASTDEPLOY)
     if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) {
         printf("Fast Deploy is only compatible with devices of API version %d or higher, "
                "ignoring.\n",
@@ -334,6 +353,7 @@ int install_app(int argc, const char** argv) {
         use_fastdeploy = false;
     }
     fastdeploy_set_agent_update_strategy(agent_update_strategy);
+#endif
 
     std::vector<const char*> passthrough_argv;
     for (int i = 0; i < argc; i++) {