Sha256: 60f077ec5a111ea66a643cdb2e6dacab8efb8f812ac81ce385339eb5f47b3087

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Headdesk
  module Checks
    #
    # An <activity-alias> is most commonly used to change the class of the MAIN
    # activity, while preserving shortcuts.
    #
    # com.google.firebase.MESSAGING_EVENT
    #
    class FirebaseMessagingEvent
      include Check::APK

      check_name 'firebase_messaging_event'
      describe '<intent-filter> for \'com.google.firebase.MESSAGING_EVENT\''
      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
headdesk-0.17.0 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.16.2 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.16.1 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.16.0 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.15.1 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.15.0 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.14.0 lib/headdesk/checks/firebase_messaging_event.rb
headdesk-0.13.0 lib/headdesk/checks/firebase_messaging_event.rb