mirror of
https://gitee.com/openharmony/advertising_oaid
synced 2024-11-23 07:49:59 +00:00
Description: oaid按需启停改造
Feature or Bugfix: Feature Binary Source:No Signed-off-by:dzq<dongziqian2@huawei.com>
This commit is contained in:
parent
f6a4bc5f3d
commit
4e456ae384
@ -35,7 +35,8 @@
|
||||
"napi",
|
||||
"safwk",
|
||||
"samgr",
|
||||
"hiappevent"
|
||||
"hiappevent",
|
||||
"eventhandler"
|
||||
],
|
||||
"third_party": [
|
||||
"libuv",
|
||||
|
@ -6,7 +6,8 @@
|
||||
"libpath":"liboaid_service.z.so",
|
||||
"run-on-create":true,
|
||||
"distributed":false,
|
||||
"dump-level":1
|
||||
"dump-level":1,
|
||||
"recycle-strategy": "low-memory"
|
||||
}
|
||||
]
|
||||
}
|
@ -62,6 +62,7 @@ ohos_shared_library("oaid_service") {
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
"eventhandler:libeventhandler",
|
||||
]
|
||||
part_name = "oaid"
|
||||
subsystem_name = "advertising"
|
||||
|
@ -51,6 +51,10 @@ static const std::string OAID_TRUSTLIST_EXTENSION_CONFIG_PATH = "/etc/advertisin
|
||||
|
||||
/* oaid check define */
|
||||
const std::string OAID_UPDATE = "/data/service/el1/public/database/oaid_service_manager/update_check.json";
|
||||
|
||||
/* oaid service 按需停空闲等待时间。单位(ms) */
|
||||
static constexpr int32_t DELAY_TIME = 290000;
|
||||
static const std::string TASK_ID = "unload";
|
||||
} // namespace Cloud
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_CLOUD_OAID_SERVICE_DEFINE_H
|
@ -25,6 +25,8 @@
|
||||
#include "oaid_service_interface.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Cloud {
|
||||
@ -51,7 +53,11 @@ private:
|
||||
|
||||
bool CheckPermission(const std::string &permissionName);
|
||||
bool CheckSystemApp();
|
||||
|
||||
void PostDelayUnloadTask();
|
||||
|
||||
std::map<uint32_t, OAIDServiceFunc> memberFuncMap_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_;
|
||||
};
|
||||
} // namespace Cloud
|
||||
} // namespace OHOS
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "oaid_service.h"
|
||||
#include "oaid_service_ipc_interface_code.h"
|
||||
#include "config_policy_utils.h"
|
||||
|
||||
#include "iservice_registry.h"
|
||||
|
||||
using namespace OHOS::Security::AccessToken;
|
||||
|
||||
@ -142,6 +142,12 @@ bool LoadAndCheckOaidTrustList(const std::string &bundleName)
|
||||
int32_t OAIDServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
if (unloadHandler_ == nullptr) {
|
||||
const char *runnerName = "unlock";
|
||||
auto runner = AppExecFwk::EventRunner::Create(runnerName);
|
||||
unloadHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
PostDelayUnloadTask();
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Start, code is %{public}u.", code);
|
||||
std::string bundleName;
|
||||
pid_t uid = IPCSkeleton::GetCallingUid();
|
||||
@ -222,5 +228,25 @@ int32_t OAIDServiceStub::OnResetOAID(MessageParcel &data, MessageParcel &reply)
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Reset OAID End.");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void OAIDServiceStub::PostDelayUnloadTask()
|
||||
{
|
||||
auto task = [this]() {
|
||||
auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgrProxy == nullptr) {
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Get samgr failed.");
|
||||
return;
|
||||
}
|
||||
int32_t ret = samgrProxy->UnloadSystemAbility(OAID_SYSTME_ID);
|
||||
if (ret != ERR_OK) {
|
||||
OAID_HILOGI(OAID_MODULE_SERVICE, "Unload system ability %{public}d failed, result: %{public}d.",
|
||||
OAID_SYSTME_ID, ret);
|
||||
return;
|
||||
}
|
||||
};
|
||||
unloadHandler_->RemoveTask(TASK_ID);
|
||||
unloadHandler_->PostTask(task, TASK_ID, DELAY_TIME);
|
||||
}
|
||||
|
||||
} // namespace Cloud
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user