Class: Headdesk::Checks::ActivityAlias
- Inherits:
-
Object
- Object
- Headdesk::Checks::ActivityAlias
- Includes:
- Headdesk::Check::APK
- Defined in:
- lib/headdesk/checks/activity_alias.rb
Overview
An <activity-alias> is most commonly used to change the class of the MAIN activity, while preserving shortcuts.
<intent-filter> must include both:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
and must point to an <activity> that has been defined
Instance Method Summary collapse
Methods included from Headdesk::Check::APK
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/headdesk/checks/activity_alias.rb', line 20 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| old_activity = activity_alias.attributes['name'] new_activity = activity_alias.attributes['targetActivity'] 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: old_activity, targetActivity: new_activity } end export aliases: aliases end |