本文开始参考在 android 上使用 adb client-CSDN博客,在shell中已经可以使用。但当我想在app中用

String command = "/data/local/tmp/adb -s 307ef90dc8128844 shell ls";

        StringBuilder output = new StringBuilder();

        try {
            Process process = Runtime.getRuntime().exec(command);
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

            String line;
            while ((line = reader.readLine()) != null) {
                output.append(line).append("\n");
            }

            reader.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

来调用已经编译好的adb时,服务由于没有权限操作usb,没办法对连接到usb上的adb device设备进行操作,发现不了该设备,必须要先用root权限先启动adb server后才能使用。

为了解决该问题,我决定把adb host的应用通过android源码编译,并加载到开机启动服务中。

在android源码中编译adb host,部分步骤可以参考android源码添加c/c++工程-CSDN博客

adb的源码使用在前面参考文章中的源码,由于使用名称adb与原有android中的工程冲突,改名为adbhost(大家可以随意改,看大家心情)。同时由于内置的libssl不知道抽什么风,老是报函数BIO_f_base64无法找到,干脆把openssl源码也直接编译进去。

Android.bp如下:

// Copyright 2013 The Android Open Source Project

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_binary {
    name: "adbhost",
    srcs: [
            "core/adb/adb.c",
            "core/adb/adb_client.c",
            "core/adb/adb_auth_host.c",
            "core/adb/commandline.c",
            "core/adb/console.c",
            "core/adb/file_sync_client.c",
            "core/adb/fdevent.c",
            "core/adb/get_my_path_linux.c",
            "core/adb/services.c",
            "core/adb/sockets.c",
            "core/adb/transport.c",
            "core/adb/transport_local.c",
            "core/adb/transport_usb.c",
            "core/adb/usb_linux.c",
            "core/adb/usb_vendors.c",
            "core/adb/utils.c",

            "core/libcutils/abort_socket.c",
            "core/libcutils/socket_inaddr_any_server.c",
            "core/libcutils/socket_local_client.c",
            "core/libcutils/socket_local_server.c",
            "core/libcutils/socket_loopback_client.c",
            "core/libcutils/socket_loopback_server.c",
            "core/libcutils/socket_network_client.c",
            "core/libcutils/list.c",
            "core/libcutils/load_file.c",

            "core/libzipfile/centraldir.c",
            "core/libzipfile/zipfile.c",

            "openssl-1.0.0e/ssl/d1_pkt.c",
            "openssl-1.0.0e/ssl/d1_both.c",
            "openssl-1.0.0e/ssl/s3_srvr.c",
            "openssl-1.0.0e/ssl/s2_meth.c",
            "openssl-1.0.0e/ssl/ssl_asn1.c",
            "openssl-1.0.0e/ssl/s23_pkt.c",
            "openssl-1.0.0e/ssl/s23_lib.c",
            "openssl-1.0.0e/ssl/s2_lib.c",
            "openssl-1.0.0e/ssl/ssl_err.c",
            "openssl-1.0.0e/ssl/s3_lib.c",
            "openssl-1.0.0e/ssl/t1_reneg.c",
            "openssl-1.0.0e/ssl/s3_meth.c",
            "openssl-1.0.0e/ssl/s3_clnt.c",
            "openssl-1.0.0e/ssl/d1_enc.c",
            "openssl-1.0.0e/ssl/s2_enc.c",
            "openssl-1.0.0e/ssl/t1_enc.c",
            "openssl-1.0.0e/ssl/ssl_sess.c",
            "openssl-1.0.0e/ssl/s23_meth.c",
            "openssl-1.0.0e/ssl/s2_clnt.c",
            "openssl-1.0.0e/ssl/kssl.c",
            "openssl-1.0.0e/ssl/t1_meth.c",
            "openssl-1.0.0e/ssl/t1_lib.c",
            "openssl-1.0.0e/ssl/d1_srvr.c",
            "openssl-1.0.0e/ssl/ssl_stat.c",
            "openssl-1.0.0e/ssl/ssl_rsa.c",
            "openssl-1.0.0e/ssl/ssl_err2.c",
            "openssl-1.0.0e/ssl/s3_enc.c",
            "openssl-1.0.0e/ssl/d1_lib.c",
            "openssl-1.0.0e/ssl/t1_clnt.c",
            "openssl-1.0.0e/ssl/t1_srvr.c",
            "openssl-1.0.0e/ssl/s3_both.c",
            "openssl-1.0.0e/ssl/s2_srvr.c",
            "openssl-1.0.0e/ssl/ssl_cert.c",
            "openssl-1.0.0e/ssl/s3_pkt.c",
            "openssl-1.0.0e/ssl/d1_meth.c",
            "openssl-1.0.0e/ssl/d1_clnt.c",
            "openssl-1.0.0e/ssl/ssl_algs.c",
            "openssl-1.0.0e/ssl/s23_srvr.c",
            "openssl-1.0.0e/ssl/s2_pkt.c",
            "openssl-1.0.0e/ssl/s23_clnt.c",
            "openssl-1.0.0e/ssl/bio_ssl.c",
            "openssl-1.0.0e/ssl/ssl_lib.c",
            "openssl-1.0.0e/ssl/ssl_txt.c",
            "openssl-1.0.0e/ssl/ssl_ciph.c",
            "openssl-1.0.0e/crypto/stack/stack.c",
            "openssl-1.0.0e/crypto/o_time.c",
            "openssl-1.0.0e/crypto/dsa/dsa_ossl.c",
            "openssl-1.0.0e/crypto/dsa/dsa_pmeth.c",
            "openssl-1.0.0e/crypto/dsa/dsa_key.c",
            "openssl-1.0.0e/crypto/dsa/dsa_ameth.c",
            "openssl-1.0.0e/crypto/dsa/dsa_gen.c",
            "openssl-1.0.0e/crypto/dsa/dsa_prn.c",
            "openssl-1.0.0e/crypto/dsa/dsa_vrf.c",
            "openssl-1.0.0e/crypto/dsa/dsa_asn1.c",
            "openssl-1.0.0e/crypto/dsa/dsa_lib.c",
            "openssl-1.0.0e/crypto/dsa/dsa_err.c",
            "openssl-1.0.0e/crypto/dsa/dsa_depr.c",
            "openssl-1.0.0e/crypto/dsa/dsa_sign.c",
            "openssl-1.0.0e/crypto/pkcs7/pk7_lib.c",
            "openssl-1.0.0e/crypto/pkcs7/pk7_mime.c",
            "openssl-1.0.0e/crypto/pkcs7/pk7_attr.c",
            "openssl-1.0.0e/crypto/pkcs7/bio_pk7.c",
            "openssl-1.0.0e/crypto/pkcs7/pk7_smime.c",
            "openssl-1.0.0e/crypto/pkcs7/pk7_asn1.c",
            "openssl-1.0.0e/crypto/pkcs7/pkcs7err.c",
            "openssl-1.0.0e/crypto/pkcs7/pk7_doit.c",
            "openssl-1.0.0e/crypto/ec/ec2_smpl.c",
            "openssl-1.0.0e/crypto/ec/ec_lib.c",
            "openssl-1.0.0e/crypto/ec/eck_prn.c",
            "openssl-1.0.0e/crypto/ec/ec_mult.c",
            "openssl-1.0.0e/crypto/ec/ecp_nist.c",
            "openssl-1.0.0e/crypto/ec/ec_key.c",
            "openssl-1.0.0e/crypto/ec/ec_check.c",
            "openssl-1.0.0e/crypto/ec/ec_curve.c",
            "openssl-1.0.0e/crypto/ec/ec_ameth.c",
            "openssl-1.0.0e/crypto/ec/ecp_smpl.c",
            "openssl-1.0.0e/crypto/ec/ec_pmeth.c",
            "openssl-1.0.0e/crypto/ec/ec_err.c",
            "openssl-1.0.0e/crypto/ec/ecp_mont.c",
            "openssl-1.0.0e/crypto/ec/ec_asn1.c",
            "openssl-1.0.0e/crypto/ec/ec_cvt.c",
            "openssl-1.0.0e/crypto/ec/ec_print.c",
            "openssl-1.0.0e/crypto/ec/ec2_mult.c",
            "openssl-1.0.0e/crypto/uid.c",
            "openssl-1.0.0e/crypto/bf/bf_ofb64.c",
            "openssl-1.0.0e/crypto/bf/bf_cfb64.c",
            "openssl-1.0.0e/crypto/bf/bf_enc.c",
            "openssl-1.0.0e/crypto/bf/bf_skey.c",
            "openssl-1.0.0e/crypto/bf/bf_ecb.c",
            "openssl-1.0.0e/crypto/des/des_old.c",
            "openssl-1.0.0e/crypto/des/cfb64enc.c",
            "openssl-1.0.0e/crypto/des/ofb64enc.c",
            "openssl-1.0.0e/crypto/des/cbc_enc.c",
            "openssl-1.0.0e/crypto/des/enc_writ.c",
            "openssl-1.0.0e/crypto/des/qud_cksm.c",
            "openssl-1.0.0e/crypto/des/set_key.c",
            "openssl-1.0.0e/crypto/des/ecb_enc.c",
            "openssl-1.0.0e/crypto/des/ofb64ede.c",
            "openssl-1.0.0e/crypto/des/pcbc_enc.c",
            "openssl-1.0.0e/crypto/des/cfb_enc.c",
            "openssl-1.0.0e/crypto/des/cbc_cksm.c",
            "openssl-1.0.0e/crypto/des/xcbc_enc.c",
            "openssl-1.0.0e/crypto/des/ecb3_enc.c",
            "openssl-1.0.0e/crypto/des/des_old2.c",
            "openssl-1.0.0e/crypto/des/rpc_enc.c",
            "openssl-1.0.0e/crypto/des/fcrypt_b.c",
            "openssl-1.0.0e/crypto/des/read2pwd.c",
            "openssl-1.0.0e/crypto/des/ede_cbcm_enc.c",
            "openssl-1.0.0e/crypto/des/enc_read.c",
            "openssl-1.0.0e/crypto/des/fcrypt.c",
            "openssl-1.0.0e/crypto/des/ofb_enc.c",
            "openssl-1.0.0e/crypto/des/des_enc.c",
            "openssl-1.0.0e/crypto/des/cfb64ede.c",
            "openssl-1.0.0e/crypto/des/str2key.c",
            "openssl-1.0.0e/crypto/des/rand_key.c",
            "openssl-1.0.0e/crypto/md5/md5_dgst.c",
            "openssl-1.0.0e/crypto/md5/md5_one.c",
            "openssl-1.0.0e/crypto/cpt_err.c",
            "openssl-1.0.0e/crypto/err/err.c",
            "openssl-1.0.0e/crypto/err/err_prn.c",
            "openssl-1.0.0e/crypto/err/err_all.c",
            "openssl-1.0.0e/crypto/rand/rand_os2.c",
            "openssl-1.0.0e/crypto/rand/rand_unix.c",
            "openssl-1.0.0e/crypto/rand/md_rand.c",
            "openssl-1.0.0e/crypto/rand/rand_win.c",
            "openssl-1.0.0e/crypto/rand/rand_lib.c",
            "openssl-1.0.0e/crypto/rand/rand_egd.c",
            "openssl-1.0.0e/crypto/rand/rand_err.c",
            "openssl-1.0.0e/crypto/rand/randfile.c",
            "openssl-1.0.0e/crypto/rand/rand_nw.c",
            "openssl-1.0.0e/crypto/o_dir.c",
            "openssl-1.0.0e/crypto/lhash/lh_stats.c",
            "openssl-1.0.0e/crypto/lhash/lhash.c",
            "openssl-1.0.0e/crypto/mem.c",
            "openssl-1.0.0e/crypto/x509v3/pcy_map.c",
            "openssl-1.0.0e/crypto/x509v3/v3_ia5.c",
            "openssl-1.0.0e/crypto/x509v3/v3_ocsp.c",
            "openssl-1.0.0e/crypto/x509v3/v3_conf.c",
            "openssl-1.0.0e/crypto/x509v3/v3_genn.c",
            "openssl-1.0.0e/crypto/x509v3/v3_purp.c",
            "openssl-1.0.0e/crypto/x509v3/pcy_lib.c",
            "openssl-1.0.0e/crypto/x509v3/v3_utl.c",
            "openssl-1.0.0e/crypto/x509v3/v3_akeya.c",
            "openssl-1.0.0e/crypto/x509v3/pcy_data.c",
            "openssl-1.0.0e/crypto/x509v3/v3_enum.c",
            "openssl-1.0.0e/crypto/x509v3/v3_pci.c",
            "openssl-1.0.0e/crypto/x509v3/pcy_tree.c",
            "openssl-1.0.0e/crypto/x509v3/v3_bitst.c",
            "openssl-1.0.0e/crypto/x509v3/v3_sxnet.c",
            "openssl-1.0.0e/crypto/x509v3/v3_alt.c",
            "openssl-1.0.0e/crypto/x509v3/v3_lib.c",
            "openssl-1.0.0e/crypto/x509v3/v3_skey.c",
            "openssl-1.0.0e/crypto/x509v3/pcy_node.c",
            "openssl-1.0.0e/crypto/x509v3/v3_addr.c",
            "openssl-1.0.0e/crypto/x509v3/v3_pcons.c",
            "openssl-1.0.0e/crypto/x509v3/v3_pmaps.c",
            "openssl-1.0.0e/crypto/x509v3/v3_asid.c",
            "openssl-1.0.0e/crypto/x509v3/v3_pku.c",
            "openssl-1.0.0e/crypto/x509v3/v3_prn.c",
            "openssl-1.0.0e/crypto/x509v3/v3_extku.c",
            "openssl-1.0.0e/crypto/x509v3/v3err.c",
            "openssl-1.0.0e/crypto/x509v3/v3_int.c",
            "openssl-1.0.0e/crypto/x509v3/v3_info.c",
            "openssl-1.0.0e/crypto/x509v3/v3_ncons.c",
            "openssl-1.0.0e/crypto/x509v3/v3_pcia.c",
            "openssl-1.0.0e/crypto/x509v3/v3_bcons.c",
            "openssl-1.0.0e/crypto/x509v3/v3_cpols.c",
            "openssl-1.0.0e/crypto/x509v3/pcy_cache.c",
            "openssl-1.0.0e/crypto/x509v3/v3_akey.c",
            "openssl-1.0.0e/crypto/x509v3/v3_crld.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_err.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_prn.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_vfy.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_lib.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_ht.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_srv.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_asn.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_ext.c",
            "openssl-1.0.0e/crypto/ocsp/ocsp_cl.c",
            "openssl-1.0.0e/crypto/cversion.c",
            "openssl-1.0.0e/crypto/whrlpool/wp_dgst.c",
            "openssl-1.0.0e/crypto/whrlpool/wp_block.c",
            "openssl-1.0.0e/crypto/cms/cms_env.c",
            "openssl-1.0.0e/crypto/cms/cms_att.c",
            "openssl-1.0.0e/crypto/cms/cms_ess.c",
            "openssl-1.0.0e/crypto/cms/cms_sd.c",
            "openssl-1.0.0e/crypto/cms/cms_smime.c",
            "openssl-1.0.0e/crypto/cms/cms_dd.c",
            "openssl-1.0.0e/crypto/cms/cms_asn1.c",
            "openssl-1.0.0e/crypto/cms/cms_lib.c",
            "openssl-1.0.0e/crypto/cms/cms_err.c",
            "openssl-1.0.0e/crypto/cms/cms_io.c",
            "openssl-1.0.0e/crypto/cms/cms_cd.c",
            "openssl-1.0.0e/crypto/cms/cms_enc.c",
            "openssl-1.0.0e/crypto/md4/md4_one.c",
            "openssl-1.0.0e/crypto/md4/md4_dgst.c",
            "openssl-1.0.0e/crypto/cryptlib.c",
            "openssl-1.0.0e/crypto/o_str.c",
            "openssl-1.0.0e/crypto/engine/eng_openssl.c",
            "openssl-1.0.0e/crypto/engine/eng_err.c",
            "openssl-1.0.0e/crypto/engine/eng_all.c",
            "openssl-1.0.0e/crypto/engine/eng_lib.c",
            "openssl-1.0.0e/crypto/engine/tb_pkmeth.c",
            "openssl-1.0.0e/crypto/engine/tb_rsa.c",
            "openssl-1.0.0e/crypto/engine/tb_cipher.c",
            "openssl-1.0.0e/crypto/engine/tb_dsa.c",
            "openssl-1.0.0e/crypto/engine/eng_fat.c",
            "openssl-1.0.0e/crypto/engine/tb_digest.c",
            "openssl-1.0.0e/crypto/engine/tb_ecdsa.c",
            "openssl-1.0.0e/crypto/engine/tb_store.c",
            "openssl-1.0.0e/crypto/engine/eng_table.c",
            "openssl-1.0.0e/crypto/engine/eng_cryptodev.c",
            "openssl-1.0.0e/crypto/engine/eng_dyn.c",
            "openssl-1.0.0e/crypto/engine/tb_rand.c",
            "openssl-1.0.0e/crypto/engine/eng_ctrl.c",
            "openssl-1.0.0e/crypto/engine/eng_cnf.c",
            "openssl-1.0.0e/crypto/engine/tb_asnmth.c",
            "openssl-1.0.0e/crypto/engine/eng_pkey.c",
            "openssl-1.0.0e/crypto/engine/eng_init.c",
            "openssl-1.0.0e/crypto/engine/tb_dh.c",
            "openssl-1.0.0e/crypto/engine/tb_ecdh.c",
            "openssl-1.0.0e/crypto/engine/eng_list.c",
            "openssl-1.0.0e/crypto/seed/seed_cfb.c",
            "openssl-1.0.0e/crypto/seed/seed_cbc.c",
            "openssl-1.0.0e/crypto/seed/seed_ecb.c",
            "openssl-1.0.0e/crypto/seed/seed.c",
            "openssl-1.0.0e/crypto/seed/seed_ofb.c",
            "openssl-1.0.0e/crypto/ecdsa/ecs_sign.c",
            "openssl-1.0.0e/crypto/ecdsa/ecs_lib.c",
            "openssl-1.0.0e/crypto/ecdsa/ecs_asn1.c",
            "openssl-1.0.0e/crypto/ecdsa/ecs_vrf.c",
            "openssl-1.0.0e/crypto/ecdsa/ecs_ossl.c",
            "openssl-1.0.0e/crypto/ecdsa/ecs_err.c",
            "openssl-1.0.0e/crypto/rsa/rsa_pk1.c",
            "openssl-1.0.0e/crypto/rsa/rsa_eay.c",
            "openssl-1.0.0e/crypto/rsa/rsa_lib.c",
            "openssl-1.0.0e/crypto/rsa/rsa_gen.c",
            "openssl-1.0.0e/crypto/rsa/rsa_ssl.c",
            "openssl-1.0.0e/crypto/rsa/rsa_asn1.c",
            "openssl-1.0.0e/crypto/rsa/rsa_prn.c",
            "openssl-1.0.0e/crypto/rsa/rsa_oaep.c",
            "openssl-1.0.0e/crypto/rsa/rsa_x931.c",
            "openssl-1.0.0e/crypto/rsa/rsa_ameth.c",
            "openssl-1.0.0e/crypto/rsa/rsa_pss.c",
            "openssl-1.0.0e/crypto/rsa/rsa_depr.c",
            "openssl-1.0.0e/crypto/rsa/rsa_err.c",
            "openssl-1.0.0e/crypto/rsa/rsa_sign.c",
            "openssl-1.0.0e/crypto/rsa/rsa_chk.c",
            "openssl-1.0.0e/crypto/rsa/rsa_null.c",
            "openssl-1.0.0e/crypto/rsa/rsa_saos.c",
            "openssl-1.0.0e/crypto/rsa/rsa_pmeth.c",
            "openssl-1.0.0e/crypto/rsa/rsa_none.c",
            "openssl-1.0.0e/crypto/ui/ui_err.c",
            "openssl-1.0.0e/crypto/ui/ui_lib.c",
            "openssl-1.0.0e/crypto/ui/ui_compat.c",
            "openssl-1.0.0e/crypto/ui/ui_util.c",
            "openssl-1.0.0e/crypto/ui/ui_openssl.c",
            "openssl-1.0.0e/crypto/rc4/rc4_enc.c",
            "openssl-1.0.0e/crypto/rc4/rc4_skey.c",
            "openssl-1.0.0e/crypto/objects/obj_lib.c",
            "openssl-1.0.0e/crypto/objects/obj_err.c",
            "openssl-1.0.0e/crypto/objects/o_names.c",
            "openssl-1.0.0e/crypto/objects/obj_dat.c",
            "openssl-1.0.0e/crypto/objects/obj_xref.c",
            "openssl-1.0.0e/crypto/ecdh/ech_lib.c",
            "openssl-1.0.0e/crypto/ecdh/ech_err.c",
            "openssl-1.0.0e/crypto/ecdh/ech_ossl.c",
            "openssl-1.0.0e/crypto/ecdh/ech_key.c",
            "openssl-1.0.0e/crypto/mdc2/mdc2dgst.c",
            "openssl-1.0.0e/crypto/mdc2/mdc2_one.c",
            "openssl-1.0.0e/crypto/aes/aes_ecb.c",
            "openssl-1.0.0e/crypto/aes/aes_cfb.c",
            "openssl-1.0.0e/crypto/aes/aes_wrap.c",
            "openssl-1.0.0e/crypto/aes/aes_ige.c",
            "openssl-1.0.0e/crypto/aes/aes_cbc.c",
            "openssl-1.0.0e/crypto/aes/aes_ofb.c",
            "openssl-1.0.0e/crypto/aes/aes_ctr.c",
            "openssl-1.0.0e/crypto/aes/aes_core.c",
            "openssl-1.0.0e/crypto/aes/aes_misc.c",
            "openssl-1.0.0e/crypto/krb5/krb5_asn.c",
            "openssl-1.0.0e/crypto/ripemd/rmd_dgst.c",
            "openssl-1.0.0e/crypto/ripemd/rmd_one.c",
            "openssl-1.0.0e/crypto/dso/dso_err.c",
            "openssl-1.0.0e/crypto/dso/dso_dlfcn.c",
            "openssl-1.0.0e/crypto/dso/dso_null.c",
            "openssl-1.0.0e/crypto/dso/dso_dl.c",
            "openssl-1.0.0e/crypto/dso/dso_openssl.c",
            "openssl-1.0.0e/crypto/dso/dso_vms.c",
            "openssl-1.0.0e/crypto/dso/dso_win32.c",
            "openssl-1.0.0e/crypto/dso/dso_beos.c",
            "openssl-1.0.0e/crypto/dso/dso_lib.c",
            "openssl-1.0.0e/crypto/dh/dh_depr.c",
            "openssl-1.0.0e/crypto/dh/dh_lib.c",
            "openssl-1.0.0e/crypto/dh/dh_prn.c",
            "openssl-1.0.0e/crypto/dh/dh_check.c",
            "openssl-1.0.0e/crypto/dh/dh_key.c",
            "openssl-1.0.0e/crypto/dh/dh_pmeth.c",
            "openssl-1.0.0e/crypto/dh/dh_err.c",
            "openssl-1.0.0e/crypto/dh/dh_ameth.c",
            "openssl-1.0.0e/crypto/dh/dh_asn1.c",
            "openssl-1.0.0e/crypto/dh/dh_gen.c",
            "openssl-1.0.0e/crypto/pem/pem_x509.c",
            "openssl-1.0.0e/crypto/pem/pem_pk8.c",
            "openssl-1.0.0e/crypto/pem/pem_pkey.c",
            "openssl-1.0.0e/crypto/pem/pem_all.c",
            "openssl-1.0.0e/crypto/pem/pem_sign.c",
            "openssl-1.0.0e/crypto/pem/pem_seal.c",
            "openssl-1.0.0e/crypto/pem/pem_oth.c",
            "openssl-1.0.0e/crypto/pem/pem_info.c",
            "openssl-1.0.0e/crypto/pem/pem_xaux.c",
            "openssl-1.0.0e/crypto/pem/pem_err.c",
            "openssl-1.0.0e/crypto/pem/pvkfmt.c",
            "openssl-1.0.0e/crypto/pem/pem_lib.c",
            "openssl-1.0.0e/crypto/cast/c_cfb64.c",
            "openssl-1.0.0e/crypto/cast/c_ofb64.c",
            "openssl-1.0.0e/crypto/cast/c_ecb.c",
            "openssl-1.0.0e/crypto/cast/c_enc.c",
            "openssl-1.0.0e/crypto/cast/c_skey.c",
            "openssl-1.0.0e/crypto/modes/ofb128.c",
            "openssl-1.0.0e/crypto/modes/cts128.c",
            "openssl-1.0.0e/crypto/modes/ctr128.c",
            "openssl-1.0.0e/crypto/modes/cfb128.c",
            "openssl-1.0.0e/crypto/modes/cbc128.c",
            "openssl-1.0.0e/crypto/mem_clr.c",
            "openssl-1.0.0e/crypto/evp/bio_md.c",
            "openssl-1.0.0e/crypto/evp/p_open.c",
            "openssl-1.0.0e/crypto/evp/encode.c",
            "openssl-1.0.0e/crypto/evp/evp_key.c",
            "openssl-1.0.0e/crypto/evp/bio_enc.c",
            "openssl-1.0.0e/crypto/evp/e_seed.c",
            "openssl-1.0.0e/crypto/evp/m_dss.c",
            "openssl-1.0.0e/crypto/evp/m_null.c",
            "openssl-1.0.0e/crypto/evp/e_aes.c",
            "openssl-1.0.0e/crypto/evp/m_ecdsa.c",
            "openssl-1.0.0e/crypto/evp/e_des.c",
            "openssl-1.0.0e/crypto/evp/m_md2.c",
            "openssl-1.0.0e/crypto/evp/p5_crpt.c",
            "openssl-1.0.0e/crypto/evp/p_enc.c",
            "openssl-1.0.0e/crypto/evp/e_null.c",
            "openssl-1.0.0e/crypto/evp/m_sha.c",
            "openssl-1.0.0e/crypto/evp/evp_err.c",
            "openssl-1.0.0e/crypto/evp/pmeth_fn.c",
            "openssl-1.0.0e/crypto/evp/evp_enc.c",
            "openssl-1.0.0e/crypto/evp/evp_acnf.c",
            "openssl-1.0.0e/crypto/evp/bio_ok.c",
            "openssl-1.0.0e/crypto/evp/e_xcbc_d.c",
            "openssl-1.0.0e/crypto/evp/e_des3.c",
            "openssl-1.0.0e/crypto/evp/evp_pbe.c",
            "openssl-1.0.0e/crypto/evp/m_dss1.c",
            "openssl-1.0.0e/crypto/evp/digest.c",
            "openssl-1.0.0e/crypto/evp/names.c",
            "openssl-1.0.0e/crypto/evp/pmeth_lib.c",
            "openssl-1.0.0e/crypto/evp/p_lib.c",
            "openssl-1.0.0e/crypto/evp/p5_crpt2.c",
            "openssl-1.0.0e/crypto/evp/m_md4.c",
            "openssl-1.0.0e/crypto/evp/m_wp.c",
            "openssl-1.0.0e/crypto/evp/m_mdc2.c",
            "openssl-1.0.0e/crypto/evp/m_md5.c",
            "openssl-1.0.0e/crypto/evp/p_verify.c",
            "openssl-1.0.0e/crypto/evp/m_sigver.c",
            "openssl-1.0.0e/crypto/evp/e_idea.c",
            "openssl-1.0.0e/crypto/evp/e_rc2.c",
            "openssl-1.0.0e/crypto/evp/evp_lib.c",
            "openssl-1.0.0e/crypto/evp/m_sha1.c",
            "openssl-1.0.0e/crypto/evp/e_camellia.c",
            "openssl-1.0.0e/crypto/evp/e_bf.c",
            "openssl-1.0.0e/crypto/evp/e_old.c",
            "openssl-1.0.0e/crypto/evp/e_rc4.c",
            "openssl-1.0.0e/crypto/evp/e_rc5.c",
            "openssl-1.0.0e/crypto/evp/p_seal.c",
            "openssl-1.0.0e/crypto/evp/p_sign.c",
            "openssl-1.0.0e/crypto/evp/m_ripemd.c",
            "openssl-1.0.0e/crypto/evp/c_allc.c",
            "openssl-1.0.0e/crypto/evp/c_all.c",
            "openssl-1.0.0e/crypto/evp/evp_pkey.c",
            "openssl-1.0.0e/crypto/evp/pmeth_gn.c",
            "openssl-1.0.0e/crypto/evp/e_cast.c",
            "openssl-1.0.0e/crypto/evp/c_alld.c",
            "openssl-1.0.0e/crypto/evp/p_dec.c",
            "openssl-1.0.0e/crypto/evp/bio_b64.c",
            "openssl-1.0.0e/crypto/rc2/rc2ofb64.c",
            "openssl-1.0.0e/crypto/rc2/rc2cfb64.c",
            "openssl-1.0.0e/crypto/rc2/rc2_cbc.c",
            "openssl-1.0.0e/crypto/rc2/rc2_skey.c",
            "openssl-1.0.0e/crypto/rc2/rc2_ecb.c",
            "openssl-1.0.0e/crypto/buffer/buf_err.c",
            "openssl-1.0.0e/crypto/buffer/buffer.c",
            "openssl-1.0.0e/crypto/comp/comp_err.c",
            "openssl-1.0.0e/crypto/comp/comp_lib.c",
            "openssl-1.0.0e/crypto/comp/c_zlib.c",
            "openssl-1.0.0e/crypto/comp/c_rle.c",
            "openssl-1.0.0e/crypto/mem_dbg.c",
            "openssl-1.0.0e/crypto/ex_data.c",
            "openssl-1.0.0e/crypto/sha/sha512.c",
            "openssl-1.0.0e/crypto/sha/sha256.c",
            "openssl-1.0.0e/crypto/sha/sha_one.c",
            "openssl-1.0.0e/crypto/sha/sha1dgst.c",
            "openssl-1.0.0e/crypto/sha/sha1_one.c",
            "openssl-1.0.0e/crypto/sha/sha_dgst.c",
            "openssl-1.0.0e/crypto/txt_db/txt_db.c",
            "openssl-1.0.0e/crypto/hmac/hm_pmeth.c",
            "openssl-1.0.0e/crypto/hmac/hmac.c",
            "openssl-1.0.0e/crypto/hmac/hm_ameth.c",
            "openssl-1.0.0e/crypto/bio/bss_conn.c",
            "openssl-1.0.0e/crypto/bio/bss_sock.c",
            "openssl-1.0.0e/crypto/bio/bss_acpt.c",
            "openssl-1.0.0e/crypto/bio/bss_null.c",
            "openssl-1.0.0e/crypto/bio/bss_dgram.c",
            "openssl-1.0.0e/crypto/bio/bss_mem.c",
            "openssl-1.0.0e/crypto/bio/b_dump.c",
            "openssl-1.0.0e/crypto/bio/bss_fd.c",
            "openssl-1.0.0e/crypto/bio/b_sock.c",
            "openssl-1.0.0e/crypto/bio/bf_buff.c",
            "openssl-1.0.0e/crypto/bio/bf_null.c",
            "openssl-1.0.0e/crypto/bio/bio_err.c",
            "openssl-1.0.0e/crypto/bio/b_print.c",
            "openssl-1.0.0e/crypto/bio/bf_nbio.c",
            "openssl-1.0.0e/crypto/bio/bio_lib.c",
            "openssl-1.0.0e/crypto/bio/bss_log.c",
            "openssl-1.0.0e/crypto/bio/bss_file.c",
            "openssl-1.0.0e/crypto/bio/bio_cb.c",
            "openssl-1.0.0e/crypto/bio/bss_bio.c",
            "openssl-1.0.0e/crypto/pqueue/pqueue.c",
            "openssl-1.0.0e/crypto/conf/conf_mall.c",
            "openssl-1.0.0e/crypto/conf/conf_sap.c",
            "openssl-1.0.0e/crypto/conf/conf_lib.c",
            "openssl-1.0.0e/crypto/conf/conf_err.c",
            "openssl-1.0.0e/crypto/conf/conf_api.c",
            "openssl-1.0.0e/crypto/conf/conf_mod.c",
            "openssl-1.0.0e/crypto/conf/conf_def.c",
            "openssl-1.0.0e/crypto/ebcdic.c",
            "openssl-1.0.0e/crypto/asn1/t_x509.c",
            "openssl-1.0.0e/crypto/asn1/x_x509.c",
            "openssl-1.0.0e/crypto/asn1/a_print.c",
            "openssl-1.0.0e/crypto/asn1/x_pubkey.c",
            "openssl-1.0.0e/crypto/asn1/p5_pbev2.c",
            "openssl-1.0.0e/crypto/asn1/p8_pkey.c",
            "openssl-1.0.0e/crypto/asn1/a_bool.c",
            "openssl-1.0.0e/crypto/asn1/a_type.c",
            "openssl-1.0.0e/crypto/asn1/i2d_pu.c",
            "openssl-1.0.0e/crypto/asn1/x_crl.c",
            "openssl-1.0.0e/crypto/asn1/x_sig.c",
            "openssl-1.0.0e/crypto/asn1/x_bignum.c",
            "openssl-1.0.0e/crypto/asn1/tasn_fre.c",
            "openssl-1.0.0e/crypto/asn1/t_bitst.c",
            "openssl-1.0.0e/crypto/asn1/a_time.c",
            "openssl-1.0.0e/crypto/asn1/x_nx509.c",
            "openssl-1.0.0e/crypto/asn1/ameth_lib.c",
            "openssl-1.0.0e/crypto/asn1/a_utctm.c",
            "openssl-1.0.0e/crypto/asn1/nsseq.c",
            "openssl-1.0.0e/crypto/asn1/x_exten.c",
            "openssl-1.0.0e/crypto/asn1/p5_pbe.c",
            "openssl-1.0.0e/crypto/asn1/a_object.c",
            "openssl-1.0.0e/crypto/asn1/x_long.c",
            "openssl-1.0.0e/crypto/asn1/bio_ndef.c",
            "openssl-1.0.0e/crypto/asn1/a_dup.c",
            "openssl-1.0.0e/crypto/asn1/t_pkey.c",
            "openssl-1.0.0e/crypto/asn1/asn1_err.c",
            "openssl-1.0.0e/crypto/asn1/a_set.c",
            "openssl-1.0.0e/crypto/asn1/t_crl.c",
            "openssl-1.0.0e/crypto/asn1/x_val.c",
            "openssl-1.0.0e/crypto/asn1/n_pkey.c",
            "openssl-1.0.0e/crypto/asn1/asn_pack.c",
            "openssl-1.0.0e/crypto/asn1/tasn_prn.c",
            "openssl-1.0.0e/crypto/asn1/a_utf8.c",
            "openssl-1.0.0e/crypto/asn1/bio_asn1.c",
            "openssl-1.0.0e/crypto/asn1/t_spki.c",
            "openssl-1.0.0e/crypto/asn1/a_digest.c",
            "openssl-1.0.0e/crypto/asn1/tasn_dec.c",
            "openssl-1.0.0e/crypto/asn1/asn1_par.c",
            "openssl-1.0.0e/crypto/asn1/tasn_enc.c",
            "openssl-1.0.0e/crypto/asn1/a_gentm.c",
            "openssl-1.0.0e/crypto/asn1/d2i_pu.c",
            "openssl-1.0.0e/crypto/asn1/a_verify.c",
            "openssl-1.0.0e/crypto/asn1/a_i2d_fp.c",
            "openssl-1.0.0e/crypto/asn1/asn_mime.c",
            "openssl-1.0.0e/crypto/asn1/i2d_pr.c",
            "openssl-1.0.0e/crypto/asn1/x_name.c",
            "openssl-1.0.0e/crypto/asn1/a_int.c",
            "openssl-1.0.0e/crypto/asn1/f_string.c",
            "openssl-1.0.0e/crypto/asn1/a_strnid.c",
            "openssl-1.0.0e/crypto/asn1/f_int.c",
            "openssl-1.0.0e/crypto/asn1/a_bytes.c",
            "openssl-1.0.0e/crypto/asn1/evp_asn1.c",
            "openssl-1.0.0e/crypto/asn1/x_info.c",
            "openssl-1.0.0e/crypto/asn1/asn1_lib.c",
            "openssl-1.0.0e/crypto/asn1/x_x509a.c",
            "openssl-1.0.0e/crypto/asn1/x_algor.c",
            "openssl-1.0.0e/crypto/asn1/tasn_typ.c",
            "openssl-1.0.0e/crypto/asn1/d2i_pr.c",
            "openssl-1.0.0e/crypto/asn1/a_sign.c",
            "openssl-1.0.0e/crypto/asn1/a_bitstr.c",
            "openssl-1.0.0e/crypto/asn1/t_x509a.c",
            "openssl-1.0.0e/crypto/asn1/tasn_new.c",
            "openssl-1.0.0e/crypto/asn1/tasn_utl.c",
            "openssl-1.0.0e/crypto/asn1/asn1_gen.c",
            "openssl-1.0.0e/crypto/asn1/a_octet.c",
            "openssl-1.0.0e/crypto/asn1/x_pkey.c",
            "openssl-1.0.0e/crypto/asn1/asn_moid.c",
            "openssl-1.0.0e/crypto/asn1/t_req.c",
            "openssl-1.0.0e/crypto/asn1/a_d2i_fp.c",
            "openssl-1.0.0e/crypto/asn1/x_attrib.c",
            "openssl-1.0.0e/crypto/asn1/a_enum.c",
            "openssl-1.0.0e/crypto/asn1/a_strex.c",
            "openssl-1.0.0e/crypto/asn1/a_mbstr.c",
            "openssl-1.0.0e/crypto/asn1/f_enum.c",
            "openssl-1.0.0e/crypto/asn1/x_spki.c",
            "openssl-1.0.0e/crypto/asn1/x_req.c",
            "openssl-1.0.0e/crypto/bn/bn_exp.c",
            "openssl-1.0.0e/crypto/bn/bn_recp.c",
            "openssl-1.0.0e/crypto/bn/bn_const.c",
            "openssl-1.0.0e/crypto/bn/bn_sqr.c",
            "openssl-1.0.0e/crypto/bn/bn_mul.c",
            "openssl-1.0.0e/crypto/bn/bn_word.c",
            "openssl-1.0.0e/crypto/bn/bn_div.c",
            "openssl-1.0.0e/crypto/bn/bn_lib.c",
            "openssl-1.0.0e/crypto/bn/bn_rand.c",
            "openssl-1.0.0e/crypto/bn/bn_sqrt.c",
            "openssl-1.0.0e/crypto/bn/bn_gcd.c",
            "openssl-1.0.0e/crypto/bn/bn_nist.c",
            "openssl-1.0.0e/crypto/bn/bn_add.c",
            "openssl-1.0.0e/crypto/bn/bn_prime.c",
            "openssl-1.0.0e/crypto/bn/bn_exp2.c",
            "openssl-1.0.0e/crypto/bn/bn_gf2m.c",
            "openssl-1.0.0e/crypto/bn/bn_depr.c",
            "openssl-1.0.0e/crypto/bn/bn_mpi.c",
            "openssl-1.0.0e/crypto/bn/bn_kron.c",
            "openssl-1.0.0e/crypto/bn/bn_mont.c",
            "openssl-1.0.0e/crypto/bn/bn_asm.c",
            "openssl-1.0.0e/crypto/bn/bn_print.c",
            "openssl-1.0.0e/crypto/bn/bn_blind.c",
            "openssl-1.0.0e/crypto/bn/bn_err.c",
            "openssl-1.0.0e/crypto/bn/bn_shift.c",
            "openssl-1.0.0e/crypto/bn/bn_ctx.c",
            "openssl-1.0.0e/crypto/bn/bn_mod.c",
            "openssl-1.0.0e/crypto/ts/ts_asn1.c",
            "openssl-1.0.0e/crypto/ts/ts_verify_ctx.c",
            "openssl-1.0.0e/crypto/ts/ts_req_utils.c",
            "openssl-1.0.0e/crypto/ts/ts_err.c",
            "openssl-1.0.0e/crypto/ts/ts_conf.c",
            "openssl-1.0.0e/crypto/ts/ts_rsp_print.c",
            "openssl-1.0.0e/crypto/ts/ts_lib.c",
            "openssl-1.0.0e/crypto/ts/ts_rsp_sign.c",
            "openssl-1.0.0e/crypto/ts/ts_rsp_verify.c",
            "openssl-1.0.0e/crypto/ts/ts_rsp_utils.c",
            "openssl-1.0.0e/crypto/ts/ts_req_print.c",
            "openssl-1.0.0e/crypto/camellia/cmll_ecb.c",
            "openssl-1.0.0e/crypto/camellia/cmll_misc.c",
            "openssl-1.0.0e/crypto/camellia/cmll_ofb.c",
            "openssl-1.0.0e/crypto/camellia/cmll_cfb.c",
            "openssl-1.0.0e/crypto/camellia/cmll_cbc.c",
            "openssl-1.0.0e/crypto/camellia/cmll_ctr.c",
            "openssl-1.0.0e/crypto/camellia/camellia.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_crt.c",
            "openssl-1.0.0e/crypto/pkcs12/pk12err.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_decr.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_utl.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_init.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_npas.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_asn.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_kiss.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_mutl.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_crpt.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_add.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_attr.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_p8d.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_p8e.c",
            "openssl-1.0.0e/crypto/pkcs12/p12_key.c",
            "openssl-1.0.0e/crypto/x509/x509_att.c",
            "openssl-1.0.0e/crypto/x509/by_file.c",
            "openssl-1.0.0e/crypto/x509/x509spki.c",
            "openssl-1.0.0e/crypto/x509/x509cset.c",
            "openssl-1.0.0e/crypto/x509/x509rset.c",
            "openssl-1.0.0e/crypto/x509/x_all.c",
            "openssl-1.0.0e/crypto/x509/x509_lu.c",
            "openssl-1.0.0e/crypto/x509/by_dir.c",
            "openssl-1.0.0e/crypto/x509/x509_req.c",
            "openssl-1.0.0e/crypto/x509/x509_r2x.c",
            "openssl-1.0.0e/crypto/x509/x509_trs.c",
            "openssl-1.0.0e/crypto/x509/x509_cmp.c",
            "openssl-1.0.0e/crypto/x509/x509_obj.c",
            "openssl-1.0.0e/crypto/x509/x509name.c",
            "openssl-1.0.0e/crypto/x509/x509_set.c",
            "openssl-1.0.0e/crypto/x509/x509_err.c",
            "openssl-1.0.0e/crypto/x509/x509_vfy.c",
            "openssl-1.0.0e/crypto/x509/x509_def.c",
            "openssl-1.0.0e/crypto/x509/x509type.c",
            "openssl-1.0.0e/crypto/x509/x509_vpm.c",
            "openssl-1.0.0e/crypto/x509/x509_txt.c",
            "openssl-1.0.0e/crypto/x509/x509_v3.c",
            "openssl-1.0.0e/crypto/x509/x509_d2.c",
            "openssl-1.0.0e/crypto/x509/x509_ext.c",
            "openssl-1.0.0e/crypto/idea/i_cbc.c",
            "openssl-1.0.0e/crypto/idea/i_ofb64.c",
            "openssl-1.0.0e/crypto/idea/i_skey.c",
            "openssl-1.0.0e/crypto/idea/i_ecb.c",
            "openssl-1.0.0e/crypto/idea/i_cfb64.c",
            "openssl-1.0.0e/engines/e_nuron.c",
            "openssl-1.0.0e/engines/e_4758cca.c",
            "openssl-1.0.0e/engines/e_atalla.c",
            "openssl-1.0.0e/engines/e_gmp.c",
            "openssl-1.0.0e/engines/e_sureware.c",
            "openssl-1.0.0e/engines/e_ubsec.c",
            "openssl-1.0.0e/engines/e_capi.c",
            "openssl-1.0.0e/engines/ccgost/gosthash.c",
            "openssl-1.0.0e/engines/ccgost/gost_ctl.c",
            "openssl-1.0.0e/engines/ccgost/gost_asn1.c",
            "openssl-1.0.0e/engines/ccgost/gost2001_keyx.c",
            "openssl-1.0.0e/engines/ccgost/gost_md.c",
            "openssl-1.0.0e/engines/ccgost/e_gost_err.c",
            "openssl-1.0.0e/engines/ccgost/gost_eng.c",
            "openssl-1.0.0e/engines/ccgost/gost_crypt.c",
            "openssl-1.0.0e/engines/ccgost/gost2001.c",
            "openssl-1.0.0e/engines/ccgost/gost_pmeth.c",
            "openssl-1.0.0e/engines/ccgost/gost89.c",
            "openssl-1.0.0e/engines/ccgost/gost_params.c",
            "openssl-1.0.0e/engines/ccgost/gost94_keyx.c",
            "openssl-1.0.0e/engines/ccgost/gost_sign.c",
            "openssl-1.0.0e/engines/ccgost/gost_keywrap.c",
            "openssl-1.0.0e/engines/ccgost/gost_ameth.c",
            "openssl-1.0.0e/engines/e_chil.c",
            "openssl-1.0.0e/engines/e_padlock.c",
            "openssl-1.0.0e/engines/e_aep.c",
            "openssl-1.0.0e/engines/e_cswift.c",

            ],
    local_include_dirs: [
            "core/include", 
            ".", "core/adb", 
            "openssl-1.0.0e/include", 
            "openssl-1.0.0e", 
            "openssl-1.0.0e/crypto", 
            "openssl-1.0.0e/crypto/evp", 
            "openssl-1.0.0e/crypto/asn1"
            ],
    shared_libs: ["libz"],
    cflags: ["-Wno-error",
            "-DADB_HOST=1",
            "-DHAVE_FORKEXEC=1",
            "-DHAVE_SYMLINKS",
            "-DHAVE_TERMIO_H",
            "-DOPENSSL_THREADS",
            "-DOPENSSL_NO_GMP",
            "-DOPENSSL_NO_JPAKE",
            "-DOPENSSL_NO_MD2",
            "-DOPENSSL_NO_RC5",
            "-DOPENSSL_NO_RFC3779",
            "-DOPENSSL_NO_STORE",
            "-DOPENSSL_NO_INLINE_ASM"
            ],
    recovery_available: true,
}

直接把adb源码中core目录和openssl目录放到android源码system/core/adbhost(添加的工程目录)目录下,编译时有少部分错误,直接修改源码改正,或能修改编译选项搞定都行,看大家心情。

接着在init.rc中添加服务,我最开始时使用的是android的aosp源码编译的qemu版本,直接修改system/core/rootdir/init.rc,至于其他平台的,按目标平台的来。

添加

service adbhost /system/bin/adbhost server nodaemon
    user root
    group root log readproc
    seclabel u:r:init:s0
    disabled

on property:sys.boot_completed=1

下添加

    start adbhost

至此修改完毕,make -j32

编译完成后就可以自行验证了。

注:由于android系统自身包涵adb device端server,已经占用默认的5037端口,可能影响host端server启动失败,可以把默认端口修改为4037(也可以改别的,看大家心情)。

11-11 17:32