Example #1
0
static bool deploy_agent(bool checkTimeStamps) {
    std::vector<const char*> srcs;
    std::string jar_path =
            get_agent_component_host_path("/system/framework/deployagent.jar", "/deployagent.jar");
    std::string script_path =
            get_agent_component_host_path("/system/bin/deployagent", "/deployagent");
    srcs.push_back(jar_path.c_str());
    srcs.push_back(script_path.c_str());

    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";
        std::string chmodCommand =
                android::base::StringPrintf(kChmodCommandPattern, kDeviceAgentPath);
        int ret = send_shell_command(chmodCommand);
        if (ret != 0) {
            error_exit("Error executing %s returncode: %d", chmodCommand.c_str(), ret);
        }
    } else {
        error_exit("Error pushing agent files to device");
    }

    return true;
}
Example #2
0
void extract_metadata(const char* apkPath, FILE* outputFp) {
    std::string packageName = get_packagename_from_apk(apkPath);
    const char* kAgentExtractCommandPattern = "/data/local/tmp/deployagent extract %s";
    std::string extractCommand =
            android::base::StringPrintf(kAgentExtractCommandPattern, packageName.c_str());

    std::vector<char> extractErrorBuffer;
    DeployAgentFileCallback cb(outputFp, &extractErrorBuffer);
    int returnCode = send_shell_command(extractCommand, false, &cb);
    if (returnCode != 0) {
        fprintf(stderr, "Executing %s returned %d\n", extractCommand.c_str(), returnCode);
        fprintf(stderr, "%*s\n", int(extractErrorBuffer.size()), extractErrorBuffer.data());
        error_exit("Aborting");
    }
}
int Bugreport::SendShellCommand(TransportType transport_type, const char* serial,
                                const std::string& command, bool disable_shell_protocol,
                                StandardStreamsCallbackInterface* callback) {
    return send_shell_command(transport_type, serial, command, disable_shell_protocol, callback);
}