Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7575cd90 authored by Idries Hamadi's avatar Idries Hamadi
Browse files

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
parent 662a3a6c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -265,6 +265,10 @@ cc_binary_host {
    // will violate ODR
    shared_libs: [],

    required: [
        "deploypatchgenerator",
    ],

    target: {
        darwin: {
            cflags: [
+3 −1
Original line number Diff line number Diff line
@@ -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 @@ int install_app(int argc, const char** argv) {
    }

    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) {
+12 −22
Original line number Diff line number Diff line
@@ -30,20 +30,13 @@ static constexpr long kRequiredAgentVersion = 0x00000001;

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 @@ int get_device_api_level() {
    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 @@ static bool get_agent_component_host_path(const char* local_path, const char* sd
        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 @@ static bool deploy_agent(bool checkTimeStamps) {
    }

    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 @@ static bool deploy_agent(bool checkTimeStamps) {
    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 @@ bool update_agent(FastDeploy_AgentUpdateStrategy agentUpdateStrategy) {
}

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 @@ int extract_metadata(const char* apkPath, FILE* outputFp) {
        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 @@ int extract_metadata(const char* apkPath, FILE* outputFp) {
}

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 @@ std::string get_patch_path(const char* apkPath) {
}

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 apply_patch_on_device(const char* apkPath, const char* patchPath, const char
}

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) {
+1 −4
Original line number Diff line number Diff line
@@ -24,10 +24,7 @@ enum FastDeploy_AgentUpdateStrategy {
    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);
+2 −9
Original line number Diff line number Diff line
@@ -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"],