module Appium::Core::Base::Device::AppManagement

def activate_app(app_id)

def activate_app(app_id)
  # required: [['appId'], ['bundleId']]
  execute :activate_app, {}, bundleId: app_id
end

def app_installed?(app_id)

def app_installed?(app_id)
  # required: [['appId'], ['bundleId']]
  execute :app_installed?, {}, bundleId: app_id
end

def app_strings(language = nil)

def app_strings(language = nil)
  opts = language ? { language: language } : {}
  execute_script 'mobile:getAppStrings', opts
end

def background_app(duration = 0)

def background_app(duration = 0)
  # Should override in each driver
  raise NotImplementedError
end

def install_app(path, options = {})

def install_app(path, options = {})
  args = { appPath: path }
  args[:options] = options unless options&.empty?
  execute :install_app, {}, args
end

def options?(*args)

def options?(*args)
  args.compact.any?
end

def remove_app(id, keep_data: nil, timeout: nil)

def remove_app(id, keep_data: nil, timeout: nil)
  # required: [['appId'], ['bundleId']]
  args = { appId: id }
  args[:options] = {} unless keep_data.nil? && timeout.nil?
  args[:options][:keepData] = keep_data unless keep_data.nil?
  args[:options][:timeout] = timeout unless timeout.nil?
  execute :remove_app, {}, args
end

def terminate_app(app_id, timeout: nil)

def terminate_app(app_id, timeout: nil)
  # required: [['appId'], ['bundleId']]
  #
  args = { appId: app_id }
  args[:options] = {} unless timeout.nil?
  args[:options][:timeout] = timeout unless timeout.nil?
  execute :terminate_app, {}, args
end