Class: Headdesk::Checks::FirebaseMessagingEvent

Inherits:
Object
  • Object
show all
Includes:
Headdesk::Check::APK
Defined in:
lib/headdesk/checks/firebase_messaging_event.rb

Overview

An <activity-alias> is most commonly used to change the class of the MAIN activity, while preserving shortcuts.

com.google.firebase.MESSAGING_EVENT

Instance Method Summary collapse

Methods included from Headdesk::Check::APK

all, included

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/headdesk/checks/firebase_messaging_event.rb', line 16

def call
  intent_filters = apk.android_manifest.xpath("application/service/intent-filter/action[@android:name='com.google.firebase.MESSAGING_EVENT']")
  describe 'AndroidManifest.xml contains one or more <service> with <intent-filter> for \'com.google.firebase.MESSAGING_EVENT\''
  skip_check if: intent_filters.empty?

  filters = []
  intent_filters.each do |filter|
    filters << {
      name: filter.parent.parent.attributes['name'].to_s,
      priority: filter.parent.attributes['priority'].to_s.to_i
    }
  end
  export filters: filters

  max_priority = filters.max_by { |elem| elem[:priority].to_i }[:priority]
  describe 'AndroidManifest.xml contains only one <service> with highest \'android:priority\' <intent-filter>'
  fail_check if: filters.select { |elem| elem[:priority] == max_priority }.size > 1
end