Class: AppInfo::Android

Inherits:
File
  • Object
show all
Extended by:
Forwardable
Includes:
Helper::HumanFileSize
Defined in:
lib/app_info/android.rb,
lib/app_info/android/signature.rb,
lib/app_info/android/signatures/v1.rb,
lib/app_info/android/signatures/v2.rb,
lib/app_info/android/signatures/v3.rb,
lib/app_info/android/signatures/v4.rb,
lib/app_info/android/signatures/base.rb,
lib/app_info/android/signatures/info.rb

Overview

Android base parser for apk and aab file

Direct Known Subclasses

AAB, APK

Defined Under Namespace

Modules: Signature

Constant Summary

Constants included from Helper::HumanFileSize

Helper::HumanFileSize::FILE_SIZE_UNITS

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods included from Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Methods inherited from File

#format, #initialize, #not_implemented_error!

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#activitiesObject

This method is abstract.

Subclass and override #use_permissions to implement.



94
95
96
# File 'lib/app_info/android.rb', line 94

def activities
  not_implemented_error!(__method__)
end

#automotive?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/app_info/android.rb', line 79

def automotive?
  !!use_features&.include?('android.hardware.type.automotive')
end

#certificatesArray<OpenSSL::PKCS7, nil>

Deprecated.

Legacy v1 scheme certificates, it will remove soon.

Returns:

  • (Array<OpenSSL::PKCS7, nil>)

    certificates



125
126
127
# File 'lib/app_info/android.rb', line 125

def certificates
  @certificates ||= v1sign&.certificates || []
end

#clear!Object

This method is abstract.

Subclass and override #clear! to implement.



145
146
147
# File 'lib/app_info/android.rb', line 145

def clear!
  not_implemented_error!(__method__)
end

#componentsObject

This method is abstract.

Subclass and override #use_permissions to implement.



104
105
106
# File 'lib/app_info/android.rb', line 104

def components
  not_implemented_error!(__method__)
end

#contentsString

Returns contents path of contents.

Returns:

  • (String)

    contents path of contents



150
151
152
# File 'lib/app_info/android.rb', line 150

def contents
  @contents ||= ::File.join(Dir.mktmpdir, "AppInfo-android-#{SecureRandom.hex}")
end

#deviceSymbol

Returns Device.

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/app_info/android.rb', line 37

def device
  if watch?
    Device::Google::WATCH
  elsif television?
    Device::Google::TELEVISION
  elsif automotive?
    Device::Google::AUTOMOTIVE
  elsif tablet?
    Device::Google::TABLET
  else
    Device::Google::PHONE
  end
end

#manifestObject

This method is abstract.

Subclass and override #manifest to implement.



130
131
132
# File 'lib/app_info/android.rb', line 130

def manifest
  not_implemented_error!(__method__)
end

#manufacturerSymbol

Returns Manufacturer.

Returns:



27
28
29
# File 'lib/app_info/android.rb', line 27

def manufacturer
  Manufacturer::GOOGLE
end

#nameObject

This method is abstract.

Subclass and override #name to implement.



52
53
54
# File 'lib/app_info/android.rb', line 52

def name
  not_implemented_error!(__method__)
end

#platformSymbol

Returns Platform.

Returns:



32
33
34
# File 'lib/app_info/android.rb', line 32

def platform
  Platform::ANDROID
end

#resourceObject

This method is abstract.

Subclass and override #resource to implement.



135
136
137
# File 'lib/app_info/android.rb', line 135

def resource
  not_implemented_error!(__method__)
end

#servicesObject

This method is abstract.

Subclass and override #use_permissions to implement.



99
100
101
# File 'lib/app_info/android.rb', line 99

def services
  not_implemented_error!(__method__)
end

#signaturesArray<Hash>

Return multi version certifiates of signatures

Returns:

  • (Array<Hash>)

    signatures

See Also:



111
112
113
# File 'lib/app_info/android.rb', line 111

def signatures
  @signatures ||= Android::Signature.verify(self)
end

#signsArray<OpenSSL::PKCS7, nil>

Deprecated.

Legacy v1 scheme signatures, it will remove soon.

Returns:

  • (Array<OpenSSL::PKCS7, nil>)

    signatures



118
119
120
# File 'lib/app_info/android.rb', line 118

def signs
  @signs ||= v1sign&.signatures || []
end

#size(human_size: false) ⇒ Integer, String

return file size

Examples:

Read file size in integer

aab.size                    # => 3618865

Read file size in human readabale

aab.size(human_size: true)  # => '3.45 MB'

Parameters:

  • human_size (Boolean) (defaults to: false)

    Convert integer value to human readable.

Returns:

  • (Integer, String)


22
23
24
# File 'lib/app_info/android.rb', line 22

def size(human_size: false)
  file_to_human_size(@file, human_size: human_size)
end

#tablet?Boolean

TODO:

find a way to detect, no way!

Returns false always false.



59
60
61
62
63
64
65
66
# File 'lib/app_info/android.rb', line 59

def tablet?
  # Not works!
  # resource.first_package
  #         .entries('bool')
  #         .select{|e| e.name == 'isTablet' }
  #         .size >= 1
  false
end

#television?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/app_info/android.rb', line 74

def television?
  !!use_features&.include?('android.software.leanback')
end

#use_featuresObject

This method is abstract.

Subclass and override #use_features to implement.



84
85
86
# File 'lib/app_info/android.rb', line 84

def use_features
  not_implemented_error!(__method__)
end

#use_permissionsObject

This method is abstract.

Subclass and override #use_permissions to implement.



89
90
91
# File 'lib/app_info/android.rb', line 89

def use_permissions
  not_implemented_error!(__method__)
end

#watch?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/app_info/android.rb', line 69

def watch?
  !!use_features&.include?('android.hardware.type.watch')
end

#zipObject

This method is abstract.

Subclass and override #zip to implement.



140
141
142
# File 'lib/app_info/android.rb', line 140

def zip
  not_implemented_error!(__method__)
end