# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/ohos.gni")
import("//foundation/aafwk/standard/aafwk.gni")

config("appmgr_config") {
  include_dirs = [
    "include",
    "${ability_base_innerapi_path}/configuration/include",
    "${services_path}/common/include",
    "//base/startup/appspawn_standard/interfaces/innerkits/include",
    "${aafwk_path}/tools/aa/include",
  ]
}

group("appms_target") {
  deps = [ ":libappms" ]
}

ohos_shared_library("libappms") {
  sources = [
    "src/ability_running_record.cpp",
    "src/ams_mgr_scheduler.cpp",
    "src/app_death_recipient.cpp",
    "src/app_lifecycle_deal.cpp",
    "src/app_mgr_service.cpp",
    "src/app_mgr_service_event_handler.cpp",
    "src/app_mgr_service_inner.cpp",
    "src/app_process_manager.cpp",
    "src/app_running_manager.cpp",
    "src/app_running_record.cpp",
    "src/app_spawn_client.cpp",
    "src/app_spawn_msg_wrapper.cpp",
    "src/app_spawn_socket.cpp",
    "src/app_state_observer_manager.cpp",
    "src/module_running_record.cpp",
    "src/remote_client_manager.cpp",
    "src/system_environment_information.cpp",
  ]

  defines = [
    "AMS_LOG_TAG = \"AppMgrService\"",
    "AMS_LOG_DOMAIN = 0xD001110",
  ]

  defines += [ "ABILITY_COMMAND_FOR_TEST" ]

  configs = [ ":appmgr_config" ]
  cflags = []
  if (target_cpu == "arm") {
    cflags += [ "-DBINDER_IPC_32BIT" ]
  }
  deps = [
    "${innerkits_path}/uri_permission:uri_permission_mgr",
    "${services_path}/common:perm_verification",
  ]

  external_deps = [
    "ability_base:base",
    "ability_base:configuration",
    "ability_base:want",
    "ability_runtime:app_manager",
    "access_token:libaccesstoken_sdk",
    "appspawn:appspawn_socket_client",
    "bundle_framework:appexecfwk_base",
    "bundle_framework:appexecfwk_core",
    "common_event_service:cesfwk_core",
    "common_event_service:cesfwk_innerkits",
    "eventhandler:libeventhandler",
    "hicollie_native:libhicollie",
    "hisysevent_native:libhisysevent",
    "hitrace_native:hitrace_meter",
    "hiviewdfx_hilog_native:libhilog",
    "ipc:ipc_core",
    "safwk:system_ability_fwk",
    "samgr_standard:samgr_proxy",
    "utils_base:utils",
  ]

  if (os_account_part_enabled) {
    defines += [ "OS_ACCOUNT_PART_ENABLED" ]
    external_deps += [ "os_account:os_account_innerkits" ]
  }

  if (ability_runtime_graphics) {
    defines += [ "SUPPORT_GRAPHICS" ]
    deps += []
    external_deps += [ "i18n:intl_util" ]
  }

  subsystem_name = "aafwk"
  part_name = "ability_runtime"
}
