Class: DeviceAPI::Android::AAPT

Inherits:
Execution
  • Object
show all
Defined in:
lib/device_api/android/aapt.rb

Overview

Namespace for all methods encapsulating aapt calls

Class Method Summary collapse

Class Method Details

.aapt_available?Boolean

Check to ensure that aapt has been setup correctly and is available

Returns:

  • (Boolean)

    true if aapt is available, false otherwise



15
16
17
18
# File 'lib/device_api/android/aapt.rb', line 15

def self.aapt_available?
  result = execute('which aapt')
  result.exit == 0
end

.get_app_props(apk) ⇒ Hash

Gets properties from the apk and returns them in a hash

Parameters:

  • apk

    path to the apk

Returns:

  • (Hash)

    list of properties from the apk

Raises:

  • (StandardError)


23
24
25
26
27
28
29
30
# File 'lib/device_api/android/aapt.rb', line 23

def self.get_app_props(apk)
  raise StandardError.new('aapt not found - please create a symlink in $ANDROID_HOME/tools') unless aapt_available?
  result = execute("aapt dump badging #{apk}")

  fail result.stderr if result.exit != 0

  result.stdout.scan(/(.*): (.*)/).map { |a,b| { a => Hash[b.split(' ').map { |c| c.tr('\'','').split('=') }] } }
end