Class: Pindo::Command::Android::Autoresign

Inherits:
Pindo::Command::Android show all
Includes:
Appselect
Defined in:
lib/pindo/command/android/autoresign.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Appselect

#all_deploy_bundle_name, #all_dev_bundle_name, #all_dev_bundleid, #all_itc_bundleid, #all_release_bundleid, #all_tool_bundleid, #deploy_build_setting_json, #dev_build_setting_json, #get_deploy_repo_with_modul_name, #get_deploy_setting_repo, #get_dev_setting_repo, #get_selected_deploy_bundle_name, #get_selected_deploy_bundleid, #get_selected_dev_bundle_name, #get_selected_dev_bundleid, #get_setting_bundleid_withdir, #load_setting, #select_main_app

Methods inherited from Pindo::Command

run, use_cache?, #validate!

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from Githelper

#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag

Methods included from Executable

capture_command, #executable, execute_command, which, which!

Constructor Details

#initialize(argv) ⇒ Autoresign



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/pindo/command/android/autoresign.rb', line 61

def initialize(argv)
    @args_apk_file = argv.shift_argument
    @args_set_apk_name = argv.option('apk')
    @args_release_flag = argv.flag?('release', false)
    @args_adhoc_flag = argv.flag?('adhoc', true)

    @args_upload_flag = argv.flag?('upload', false)
    @args_send_flag = argv.flag?('send', false)
    @args_proj_name = argv.option('proj')

    if @args_send_flag
        @args_upload_flag = true
    end

    super
    @additional_args = argv.remainder!
end

Class Method Details

.optionsObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/pindo/command/android/autoresign.rb', line 50

def self.options
    [
        ['--apk',      '指定要重签名的APK文件路径'],
        ['--release',  '使用release keystore签名'],
        ['--adhoc',    '使用adhoc keystore签名(默认)'],
        ['--proj',     '指定上传到测试平台的项目名称'],
        ['--upload',   '上传重签名后的APK到测试平台'],
        ['--send',     '上传成功后发送测试通知'],
    ].concat(super)
end

Instance Method Details

#runObject



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
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/pindo/command/android/autoresign.rb', line 79

def run
    # 查找APK文件
    apk_file_name = find_apk_file

    if apk_file_name.nil? || !File.exist?(apk_file_name)
        Funlog.instance.fancyinfo_error("未找到APK文件")
        return
    end

    puts
    puts "正在重签名的APK: #{apk_file_name}"
    puts "文件大小: #{(File.size(apk_file_name) / 1024.0 / 1024.0).round(2)} MB"
    puts "修改时间: #{File.mtime(apk_file_name)}"
    puts

    # 获取keystore配置
    keystore_info = get_keystore_info

    if keystore_info.nil?
        Funlog.instance.fancyinfo_error("无法获取keystore配置")
        return
    end

    # 执行重签名
    resigned_apk = resign_apk(apk_file_name, keystore_info)

    if resigned_apk.nil?
        Funlog.instance.fancyinfo_error("重签名失败")
        return
    end

    puts
    Funlog.instance.fancyinfo_success("重签名成功: #{resigned_apk}")
    puts

    # 上传到JPS
    if @args_upload_flag
        upload_to_jps(resigned_apk)
    end
end