Class: Acouchi::ApkModifier

Inherits:
Object
  • Object
show all
Defined in:
lib/acouchi/apk_modifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(apk) ⇒ ApkModifier

Returns a new instance of ApkModifier.



6
7
8
9
# File 'lib/acouchi/apk_modifier.rb', line 6

def initialize apk
  @apk = apk
  @output_path = "#{Dir.tmpdir}/#{SecureRandom.uuid}/"
end

Instance Method Details

#modify_manifestObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/acouchi/apk_modifier.rb', line 11

def modify_manifest
  if block_given?
    decompile_apk
    manifest_path = File.join(@output_path, "AndroidManifest.xml")
    new_manifest = yield(File.read(manifest_path))
    File.open(manifest_path, "w") {|f| f.write(new_manifest)}
    compile_apk
    sign_apk_in_debug_mode
    overwrite_original_apk
  else
    throw "modify_manifest takes a block"
  end
end