lib/headdesk/checks/activity_alias.rb in headdesk-0.12.0 vs lib/headdesk/checks/activity_alias.rb in headdesk-0.13.0
- old
+ new
@@ -14,31 +14,34 @@
#
class ActivityAlias
include Check::APK
check_name 'activity_alias'
- describe "<activity-alias> is used to preserve app shortcuts"
+ describe '<activity-alias> is used to preserve app shortcuts'
def call
describe 'AndroidManifest.xml contains one or more <activity-alias>'
skip_check if: apk.android_manifest.xpath('application/activity-alias').empty?
aliases = []
apk.android_manifest.xpath('application/activity-alias').each do |activity_alias|
- describe "AndroidManifest.xml contains <activity> '#{activity_alias.attributes['targetActivity']}'"
- fail_check if: apk.android_manifest.xpath("application/activity[@android:name='#{activity_alias.attributes['targetActivity']}']").empty?
+ old_activity = activity_alias.attributes['name']
+ new_activity = activity_alias.attributes['targetActivity']
- describe "<activity-alias> '#{activity_alias.attributes['name']}' -> '#{activity_alias.attributes['targetActivity']}' has '<intent-filter>'"
- fail_check if: activity_alias.xpath("intent-filter").empty?
+ describe "AndroidManifest.xml contains <activity> '#{new_activity}'"
+ fail_check if: apk.android_manifest.xpath("application/activity[@android:name='#{new_activity}']").empty?
+ describe "<activity-alias> '#{old_activity}' -> '#{new_activity}' has '<intent-filter>'"
+ fail_check if: activity_alias.xpath('intent-filter').empty?
+
describe "<intent-filter> contains '<action android:name=\"android.intent.action.MAIN\" />'"
fail_check if: activity_alias.xpath("intent-filter/action[@android:name='android.intent.action.MAIN']").empty?
describe "<intent-filter> contains '<category android:name=\"android.intent.category.LAUNCHER\" />'"
fail_check if: activity_alias.xpath("intent-filter/category[@android:name='android.intent.category.LAUNCHER']").empty?
aliases << {
- name: activity_alias.attributes['name'],
- targetActivity: activity_alias.attributes['targetActivity']
+ name: old_activity,
+ targetActivity: new_activity
}
end
export aliases: aliases
end
end