Modified fastdeploy dependencies to ensure that fast deploy is build as part of 'sdk' target
deploypatchgenerator is now a dependency of adb
deployagent is now a java_binary target and uses the built in 'wrapper' parameter to bundle deployagent.sh
fastdeploy.cpp code in adb modified to reference deployagent rather than deployagent.sh (required to work with built in wrapper functionality).
removed near-redundant fastdeploy_init and TFastDeployConfig singleton as per:
https://android-review.googlesource.com/c/platform/system/core/+/740521/12/adb/client/fastdeploy.cpp#36
relocated kFastDeployMinApi to more appropriate location
Test: rm -rf $ANDROID_ROOT/out
Test: make sdk -j40
Test: find out/ -iname deploypatchgenerator
Test: observe that deploypatchgenerator.jar has been built as a dependency of the sdk target
Test: mm
Test: adb install -r -f --force-agent --local-agent ~/example_apks/example.apk
Test: adb install -r -f --no-streaming --force-agent --local-agent ~/example_apks/example.apk
Change-Id: I4e52d32f87774b44845bf6b5be0bae331a0b2324
diff --git a/adb/Android.bp b/adb/Android.bp
index 7bea166..6cff0be 100644
--- a/adb/Android.bp
+++ b/adb/Android.bp
@@ -265,6 +265,10 @@
// will violate ODR
shared_libs: [],
+ required: [
+ "deploypatchgenerator",
+ ],
+
target: {
darwin: {
cflags: [
diff --git a/adb/client/adb_install.cpp b/adb/client/adb_install.cpp
index 8239dfa..c0d09fd 100644
--- a/adb/client/adb_install.cpp
+++ b/adb/client/adb_install.cpp
@@ -40,6 +40,8 @@
#include <android-base/strings.h>
#include <android-base/test_utils.h>
+static constexpr int kFastDeployMinApi = 24;
+
static bool _use_legacy_install() {
FeatureSet features;
std::string error;
@@ -380,7 +382,7 @@
}
if (use_fastdeploy == true) {
- fastdeploy_init(use_localagent);
+ fastdeploy_set_local_agent(use_localagent);
bool agent_up_to_date = update_agent(agent_update_strategy);
if (agent_up_to_date == false) {
diff --git a/adb/client/fastdeploy.cpp b/adb/client/fastdeploy.cpp
index c0d793c..2914836 100644
--- a/adb/client/fastdeploy.cpp
+++ b/adb/client/fastdeploy.cpp
@@ -30,20 +30,13 @@
static constexpr const char* kDeviceAgentPath = "/data/local/tmp/";
-struct TFastDeployConfig {
- bool use_localagent;
-};
-
-static TFastDeployConfig& get_fastdeploy_config() {
- TFastDeployConfig& instance = *new TFastDeployConfig;
- return instance;
-}
+static bool use_localagent = false;
long get_agent_version() {
std::vector<char> versionOutputBuffer;
std::vector<char> versionErrorBuffer;
- int statusCode = capture_shell_command("/data/local/tmp/deployagent.sh version",
+ int statusCode = capture_shell_command("/data/local/tmp/deployagent version",
&versionOutputBuffer, &versionErrorBuffer);
long version = -1;
@@ -68,8 +61,8 @@
return api_level;
}
-void fastdeploy_init(bool use_localagent) {
- get_fastdeploy_config().use_localagent = use_localagent;
+void fastdeploy_set_local_agent(bool set_use_localagent) {
+ use_localagent = set_use_localagent;
}
// local_path - must start with a '/' and be relative to $ANDROID_PRODUCT_OUT
@@ -80,7 +73,7 @@
return false;
}
- if (get_fastdeploy_config().use_localagent) {
+ if (use_localagent) {
const char* product_out = getenv("ANDROID_PRODUCT_OUT");
if (product_out == nullptr) {
return false;
@@ -105,8 +98,7 @@
}
std::string agent_sh_path;
- if (get_agent_component_host_path("/system/bin/deployagent.sh", "/deployagent.sh",
- &agent_sh_path)) {
+ if (get_agent_component_host_path("/system/bin/deployagent", "/deployagent", &agent_sh_path)) {
srcs.push_back(agent_sh_path.c_str());
} else {
return false;
@@ -115,7 +107,7 @@
if (do_sync_push(srcs, kDeviceAgentPath, checkTimeStamps)) {
// on windows the shell script might have lost execute permission
// so need to set this explicitly
- const char* kChmodCommandPattern = "chmod 777 %sdeployagent.sh";
+ const char* kChmodCommandPattern = "chmod 777 %sdeployagent";
std::string chmodCommand =
android::base::StringPrintf(kChmodCommandPattern, kDeviceAgentPath);
int ret = send_shell_command(chmodCommand);
@@ -158,7 +150,7 @@
}
static std::string get_aapt2_path() {
- if (get_fastdeploy_config().use_localagent) {
+ if (use_localagent) {
// This should never happen on a Windows machine
const char* host_out = getenv("ANDROID_HOST_OUT");
if (host_out == nullptr) {
@@ -214,7 +206,7 @@
return -1;
}
- const char* kAgentExtractCommandPattern = "/data/local/tmp/deployagent.sh extract %s";
+ const char* kAgentExtractCommandPattern = "/data/local/tmp/deployagent extract %s";
std::string extractCommand =
android::base::StringPrintf(kAgentExtractCommandPattern, packageName.c_str());
@@ -231,7 +223,7 @@
}
static std::string get_patch_generator_command() {
- if (get_fastdeploy_config().use_localagent) {
+ if (use_localagent) {
// This should never happen on a Windows machine
const char* host_out = getenv("ANDROID_HOST_OUT");
if (host_out == nullptr) {
@@ -269,8 +261,7 @@
}
int apply_patch_on_device(const char* apkPath, const char* patchPath, const char* outputPath) {
- const std::string kAgentApplyCommandPattern =
- "/data/local/tmp/deployagent.sh apply %s %s -o %s";
+ const std::string kAgentApplyCommandPattern = "/data/local/tmp/deployagent apply %s %s -o %s";
std::string packageName;
if (get_packagename_from_apk(apkPath, &packageName) == false) {
@@ -294,8 +285,7 @@
}
int install_patch(const char* apkPath, const char* patchPath, int argc, const char** argv) {
- const std::string kAgentApplyCommandPattern =
- "/data/local/tmp/deployagent.sh apply %s %s -pm %s";
+ const std::string kAgentApplyCommandPattern = "/data/local/tmp/deployagent apply %s %s -pm %s";
std::string packageName;
if (get_packagename_from_apk(apkPath, &packageName) == false) {
diff --git a/adb/client/fastdeploy.h b/adb/client/fastdeploy.h
index ec24f97..80f3875 100644
--- a/adb/client/fastdeploy.h
+++ b/adb/client/fastdeploy.h
@@ -24,10 +24,7 @@
FastDeploy_AgentUpdateDifferentVersion
};
-static constexpr int kFastDeployMinApi = 24;
-
-void fastdeploy_init(bool use_localagent);
-
+void fastdeploy_set_local_agent(bool use_localagent);
int get_device_api_level();
bool update_agent(FastDeploy_AgentUpdateStrategy agentUpdateStrategy);
int extract_metadata(const char* apkPath, FILE* outputFp);
diff --git a/adb/fastdeploy/Android.bp b/adb/fastdeploy/Android.bp
index 30f4730..400b12f 100644
--- a/adb/fastdeploy/Android.bp
+++ b/adb/fastdeploy/Android.bp
@@ -14,24 +14,17 @@
// limitations under the License.
//
-java_library {
+java_binary {
name: "deployagent",
sdk_version: "24",
srcs: ["deployagent/src/**/*.java", "deploylib/src/**/*.java", "proto/**/*.proto"],
static_libs: ["apkzlib_zip"],
+ wrapper: "deployagent/deployagent.sh",
proto: {
type: "lite",
}
}
-cc_prebuilt_binary {
- name: "deployagent.sh",
-
- srcs: ["deployagent/deployagent.sh"],
- required: ["deployagent"],
- device_supported: true,
-}
-
java_binary_host {
name: "deploypatchgenerator",
srcs: ["deploypatchgenerator/src/**/*.java", "deploylib/src/**/*.java", "proto/**/*.proto"],