Sha256: f24855451290504f5fbdf20fa17def7123bc5981a8c591a9386b3d6191aa9fe4

Contents?: true

Size: 895 Bytes

Versions: 22

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

module Headdesk
  module Checks
    #
    # Make sure all <reciever> blocks in AndroidManifest.xml point to a Java class
    # that exists in the APK.
    #
    class Receiver
      include Check::APK

      check_name 'receiver'
      describe 'All <receiver> blocks in AndroidManifest.xml point to valid Java classes'
      def call
        receivers = []
        apk.android_manifest.xpath('//receiver').each do |receiver|
          receiver_name = receiver.attributes['name'].to_s
          fail_check unless: -> { apk.class?(receiver_name) }
          klass = apk.find_class(receiver_name)

          describe "#{receiver_name} has onReceive method"
          fail_check unless: -> { klass.method?('onReceive') }

          receivers << {
            name: receiver_name
          }
        end
        export receivers: receivers
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
headdesk-0.5.0 lib/headdesk/checks/receiver.rb
headdesk-0.4.0 lib/headdesk/checks/receiver.rb