lib/app_info/apk.rb in app-info-2.7.0 vs lib/app_info/apk.rb in app-info-2.8.0

- old
+ new

@@ -12,14 +12,15 @@ attr_reader :file # APK Devices module Device - PHONE = 'Phone' - TABLET = 'Tablet' - WATCH = 'Watch' - TV = 'Television' + PHONE = 'Phone' + TABLET = 'Tablet' + WATCH = 'Watch' + TV = 'Television' + AUTOMOTIVE = 'Automotive' end def initialize(file) @file = file end @@ -33,12 +34,13 @@ end alias file_type os def_delegators :apk, :manifest, :resource, :dex - def_delegators :manifest, :version_name, :package_name, - :use_permissions, :components + def_delegators :manifest, :version_name, :package_name, :target_sdk_version, + :components, :services, :use_permissions, :use_features, + :deep_links, :schemes alias release_version version_name alias identifier package_name alias bundle_id package_name @@ -54,42 +56,48 @@ def device_type if wear? Device::WATCH elsif tv? Device::TV + elsif automotive? + Device::AUTOMOTIVE else Device::PHONE end end - # TODO: find a way to detect + # TODO: find a way to detect, no way! # def tablet? - # resource # end def wear? use_features.include?('android.hardware.type.watch') end def tv? use_features.include?('android.software.leanback') end + def automotive? + use_features.include?('android.hardware.type.automotive') + end + def min_sdk_version manifest.min_sdk_ver end alias min_os_version min_sdk_version - def target_sdk_version - manifest.doc - .elements['/manifest/uses-sdk'] - .attributes['targetSdkVersion'] - .to_i - end + def sign_version + return 'v1' unless signs.empty? - def use_features - manifest_values('/manifest/uses-feature') + # when ? + # https://source.android.com/security/apksigning/v2?hl=zh-cn + # 'v2' + # when ? + # https://source.android.com/security/apksigning/v3?hl=zh-cn + # 'v3' + 'unknown' end def signs apk.signs.each_with_object([]) do |(path, sign), obj| obj << Sign.new(path, sign) @@ -104,14 +112,10 @@ def activities components.select { |c| c.type == 'activity' } end - def services - components.select { |c| c.type == 'service' } - end - def apk @apk ||= ::Android::Apk.new(@file) end def icons @@ -142,19 +146,9 @@ @info = nil end def contents @contents ||= File.join(Dir.mktmpdir, "AppInfo-android-#{SecureRandom.hex}") - end - - private - - def manifest_values(path, key = 'name') - values = [] - manifest.doc.each_element(path) do |elem| - values << elem.attributes[key] - end - values.uniq end # Android Certificate class Certificate attr_reader :path, :certificate