# frozen_string_literal: true module Headdesk module Checks # # An is most commonly used to change the class of the MAIN # activity, while preserving shortcuts. # # must include both: # # # # and must point to an that has been defined # class ActivityAlias include Check::APK check_name 'activity_alias' describe ' is used to preserve app shortcuts' def call describe 'AndroidManifest.xml contains one or more ' skip_check if: apk.android_manifest.xpath('application/activity-alias').empty? aliases = [] apk.android_manifest.xpath('application/activity-alias').each do |activity_alias| old_activity = activity_alias.attributes['name'] new_activity = activity_alias.attributes['targetActivity'] describe "AndroidManifest.xml contains '#{new_activity}'" fail_check if: apk.android_manifest.xpath("application/activity[@android:name='#{new_activity}']").empty? describe " '#{old_activity}' -> '#{new_activity}' has ''" fail_check if: activity_alias.xpath('intent-filter').empty? describe " contains ''" fail_check if: activity_alias.xpath("intent-filter/action[@android:name='android.intent.action.MAIN']").empty? describe " contains ''" fail_check if: activity_alias.xpath("intent-filter/category[@android:name='android.intent.category.LAUNCHER']").empty? aliases << { name: old_activity, targetActivity: new_activity } end export aliases: aliases end end end end