mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Merge branch 'master' of https://gitee.com/openharmony/ability_ability_runtime into runtime_graphic
This commit is contained in:
commit
b2e79b6643
@ -126,6 +126,11 @@ declare_args() {
|
||||
resource_schedule_service_enable = false
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.powermgr_power_manager)) {
|
||||
ability_runtime_power = false
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.resourceschedule_efficiency_manager)) {
|
||||
efficiency_manager = false
|
||||
|
@ -80,11 +80,13 @@
|
||||
"netmanager_base",
|
||||
"node",
|
||||
"os_account",
|
||||
"power_manager",
|
||||
"relational_store",
|
||||
"resource_management",
|
||||
"resource_schedule_service",
|
||||
"safwk",
|
||||
"samgr",
|
||||
"screenlock_mgr",
|
||||
"storage_service",
|
||||
"toolchain",
|
||||
"webview",
|
||||
|
@ -46,7 +46,7 @@ void JsAbilityAutoStartupCallBack::OnAutoStartupOff(const AutoStartupInfo &info)
|
||||
void JsAbilityAutoStartupCallBack::Register(napi_value value)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called.");
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
for (const auto &callback : callbacks_) {
|
||||
if (IsJsCallbackEquals(callback, value)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The current callback already exists.");
|
||||
@ -64,7 +64,7 @@ void JsAbilityAutoStartupCallBack::UnRegister(napi_value value)
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called.");
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_typeof(env_, value, &type);
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
if (type == napi_undefined || type == napi_null) {
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "jsCallback is nullptr, delete all callback.");
|
||||
callbacks_.clear();
|
||||
@ -105,7 +105,7 @@ void JsAbilityAutoStartupCallBack::JSCallFunction(const AutoStartupInfo &info, c
|
||||
|
||||
void JsAbilityAutoStartupCallBack::JSCallFunctionWorker(const AutoStartupInfo &info, const std::string &methodName)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
for (auto callback : callbacks_) {
|
||||
if (callback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "callback is nullptr.");
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
|
||||
napi_env env_;
|
||||
std::vector<std::shared_ptr<NativeReference>> callbacks_;
|
||||
std::mutex mutexlock;
|
||||
std::mutex mutexlock_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -72,7 +72,7 @@ napi_value CreateJsAutoStartupInfoArray(napi_env env, const std::vector<AutoStar
|
||||
}
|
||||
|
||||
if (napi_set_element(env, arrayObj, i, object) != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Inster object to array failed.");
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Insert object to array failed.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ void JSAbilityForegroundStateObserver::OnAbilityStateChanged(const AbilityStateD
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Called.");
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "The app manager may has destoryed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "The app manager may has destroyed.");
|
||||
return;
|
||||
}
|
||||
wptr<JSAbilityForegroundStateObserver> jsObserver = this;
|
||||
@ -51,7 +51,7 @@ void JSAbilityForegroundStateObserver::OnAbilityStateChanged(const AbilityStateD
|
||||
void JSAbilityForegroundStateObserver::HandleOnAbilityStateChanged(const AbilityStateData &abilityStateData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Called.");
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
for (auto &item : jsObserverObjectSet_) {
|
||||
if (item == nullptr) {
|
||||
continue;
|
||||
@ -112,7 +112,7 @@ void JSAbilityForegroundStateObserver::AddJsObserverObject(const napi_value &jsO
|
||||
}
|
||||
napi_ref ref = nullptr;
|
||||
napi_create_reference(env_, jsObserverObject, 1, &ref);
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
jsObserverObjectSet_.emplace(std::shared_ptr<NativeReference>(reinterpret_cast<NativeReference *>(ref)));
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ void JSAbilityForegroundStateObserver::RemoveJsObserverObject(const napi_value &
|
||||
}
|
||||
|
||||
auto observer = GetObserverObject(jsObserverObject);
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
if (observer != nullptr) {
|
||||
jsObserverObjectSet_.erase(observer);
|
||||
}
|
||||
@ -132,7 +132,7 @@ void JSAbilityForegroundStateObserver::RemoveJsObserverObject(const napi_value &
|
||||
|
||||
void JSAbilityForegroundStateObserver::RemoveAllJsObserverObject()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
if (!jsObserverObjectSet_.empty()) {
|
||||
jsObserverObjectSet_.clear();
|
||||
}
|
||||
@ -144,7 +144,7 @@ std::shared_ptr<NativeReference> JSAbilityForegroundStateObserver::GetObserverOb
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null.");
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
for (auto &observer : jsObserverObjectSet_) {
|
||||
if (observer == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid observer.");
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
private:
|
||||
napi_env env_;
|
||||
volatile bool valid_ = true;
|
||||
std::mutex mutexlock;
|
||||
std::mutex mutexlock_;
|
||||
std::set<std::shared_ptr<NativeReference>> jsObserverObjectSet_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -39,8 +39,8 @@ napi_value CreateJSToken(napi_env env, const sptr<IRemoteObject> target)
|
||||
env, "TokenClass", NAPI_AUTO_LENGTH, constructorcb, nullptr, 0, nullptr, &tokenClass);
|
||||
napi_value jsToken = nullptr;
|
||||
napi_new_instance(env, tokenClass, 0, nullptr, &jsToken);
|
||||
auto finalizecb = [](napi_env env, void *data, void *hint) {};
|
||||
napi_wrap(env, jsToken, static_cast<void *>(target.GetRefPtr()), finalizecb, nullptr, nullptr);
|
||||
auto finalizercb = [](napi_env env, void *data, void *hint) {};
|
||||
napi_wrap(env, jsToken, static_cast<void *>(target.GetRefPtr()), finalizercb, nullptr, nullptr);
|
||||
return jsToken;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
~JSAbilityDelegator() = default;
|
||||
|
||||
/**
|
||||
* Destory object.
|
||||
* Destroy object.
|
||||
*
|
||||
* @param env Indicates the native engine.
|
||||
* @param data Indicates the object to be destroyed.
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
static napi_value KillProcessesByBundleName(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "KillProcessesByBundleName start.");
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnkillProcessByBundleName);
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessByBundleName);
|
||||
}
|
||||
|
||||
static napi_value ClearUpApplicationData(napi_env env, napi_callback_info info)
|
||||
@ -130,7 +130,7 @@ private:
|
||||
}
|
||||
static int64_t serialNumber = 0;
|
||||
std::vector<std::string> bundleNameList;
|
||||
// unwarp observer
|
||||
// unwrap observer
|
||||
if (observer_ == nullptr) {
|
||||
observer_ = new JSAppStateObserver(env);
|
||||
}
|
||||
@ -310,9 +310,9 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnkillProcessByBundleName(napi_env env, size_t argc, napi_value* argv)
|
||||
napi_value OnKillProcessByBundleName(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnkillProcessByBundleName called");
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
int32_t errCode = 0;
|
||||
std::string bundleName;
|
||||
|
||||
@ -350,7 +350,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnkillProcessByBundleName",
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnKillProcessByBundleName",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appS
|
||||
|
||||
void JSAppStateObserver::HandleOnForegroundApplicationChanged(const AppStateData &appStateData)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::APPMGR,
|
||||
"HandleOnForegroundApplicationChanged bundleName:%{public}s, uid:%{public}d, state:%{public}d.",
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "bundleName:%{public}s, uid:%{public}d, state:%{public}d.",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
auto tmpMap = jsObserverObjectMap_;
|
||||
for (auto &item : tmpMap) {
|
||||
|
@ -29,7 +29,7 @@ using OHOS::AppExecFwk::ProcessData;
|
||||
class JSAppStateObserver : public ApplicationStateObserverStub {
|
||||
public:
|
||||
explicit JSAppStateObserver(napi_env engine);
|
||||
~JSAppStateObserver();
|
||||
virtual ~JSAppStateObserver();
|
||||
void OnForegroundApplicationChanged(const AppStateData &appStateData) override;
|
||||
void OnAbilityStateChanged(const AbilityStateData &abilityStateData) override;
|
||||
void OnExtensionStateChanged(const AbilityStateData &abilityStateData) override;
|
||||
|
@ -189,8 +189,8 @@ class ApplicationContext {
|
||||
return this.__context_impl__.setSupportedProcessCache(isSupport);
|
||||
}
|
||||
|
||||
getCurrentAppCloneIndex(){
|
||||
return this.__context_impl__.getCurrentAppCloneIndex()
|
||||
getCurrentAppCloneIndex() {
|
||||
return this.__context_impl__.getCurrentAppCloneIndex();
|
||||
}
|
||||
|
||||
set area(mode) {
|
||||
|
@ -211,7 +211,7 @@ private:
|
||||
if (type == ON_OFF_TYPE_SYNC_LOOP) {
|
||||
if (!AppExecFwk::EventRunner::IsAppMainThread()) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "LoopObserver can only be set from main thread.");
|
||||
ThrowInvaildCallerError(env);
|
||||
ThrowInvalidCallerError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
return OnSetLoopWatch(env, argc, argv);
|
||||
@ -219,7 +219,7 @@ private:
|
||||
if (type == ON_OFF_TYPE_UNHANDLED_REJECTION) {
|
||||
if (!AppExecFwk::EventRunner::IsAppMainThread()) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "UnhandledRejectionObserver can only be set from main thread.");
|
||||
ThrowInvaildCallerError(env);
|
||||
ThrowInvalidCallerError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc != ARGC_TWO) {
|
||||
@ -327,7 +327,7 @@ private:
|
||||
if (type == ON_OFF_TYPE_SYNC_LOOP) {
|
||||
if (!AppExecFwk::EventRunner::IsAppMainThread()) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "LoopObserver can only be set from main thread.");
|
||||
ThrowInvaildCallerError(env);
|
||||
ThrowInvalidCallerError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
return OnRemoveLoopWatch(env, argc, argv);
|
||||
@ -335,7 +335,7 @@ private:
|
||||
if (type == ON_OFF_TYPE_UNHANDLED_REJECTION) {
|
||||
if (!AppExecFwk::EventRunner::IsAppMainThread()) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "UnhandledRejectionObserver can only be unset from main thread.");
|
||||
ThrowInvaildCallerError(env);
|
||||
ThrowInvalidCallerError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc != ARGC_TWO && argc != ARGC_ONE) {
|
||||
@ -418,7 +418,7 @@ private:
|
||||
return res;
|
||||
}
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Remove UnhandledRjectionObserver failed");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Remove UnhandledRejectionObserver failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_OBSERVER_NOT_FOUND);
|
||||
return res;
|
||||
}
|
||||
@ -479,15 +479,15 @@ private:
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([number](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (loopObserver_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "CallbackTimeout: loopObserver_ is null.");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "loopObserver_ is null.");
|
||||
return;
|
||||
}
|
||||
if (loopObserver_->env == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "CallbackTimeout: env is null.");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "env is null.");
|
||||
return;
|
||||
}
|
||||
if (loopObserver_->observerObject == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "CallbackTimeout: observerObject is null.");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "observerObject is null.");
|
||||
return;
|
||||
}
|
||||
napi_value jsValue[] = { CreateJsValue(loopObserver_->env, number) };
|
||||
|
@ -29,7 +29,7 @@ void JSAppForegroundStateObserver::OnAppStateChanged(const AppStateData &appStat
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "The app manager may has destoryed.");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "The app manager may has destroyed.");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppForegroundStateObserver> self = this;
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
|
||||
static napi_value KillProcessesByBundleName(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnkillProcessesByBundleName);
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessesByBundleName);
|
||||
}
|
||||
|
||||
static napi_value ClearUpApplicationData(napi_env env, napi_callback_info info)
|
||||
@ -187,8 +187,8 @@ public:
|
||||
}
|
||||
napi_ref ref = nullptr;
|
||||
napi_create_reference(env, para, 1, &ref);
|
||||
NativeReference* nativeReferece = reinterpret_cast<NativeReference *>(ref);
|
||||
auto object = nativeReferece->GetNapiValue();
|
||||
NativeReference* nativeReference = reinterpret_cast<NativeReference *>(ref);
|
||||
auto object = nativeReference->GetNapiValue();
|
||||
napi_value method = nullptr;
|
||||
napi_get_named_property(env, object, methodName.c_str(), &method);
|
||||
if (method == nullptr) {
|
||||
@ -487,7 +487,7 @@ private:
|
||||
int64_t observerId = -1;
|
||||
napi_get_value_int64(env, argv[INDEX_ONE], &observerId);
|
||||
if (observer_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "observer_ is nullptr, please register first");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "observer is nullptr, please register first");
|
||||
ThrowInvalidParamError(env, "observer is nullptr, please register first");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -762,9 +762,9 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnkillProcessesByBundleName(napi_env env, size_t argc, napi_value* argv)
|
||||
napi_value OnKillProcessesByBundleName(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnkillProcessesByBundleName called");
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnKillProcessesByBundleName called");
|
||||
if (argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Params not match");
|
||||
ThrowTooFewParametersError(env);
|
||||
@ -796,7 +796,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnkillProcessesByBundleName",
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnKillProcessesByBundleName",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ JSAppStateObserver::~JSAppStateObserver() = default;
|
||||
|
||||
void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appStateData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "onForegroundApplicationChanged bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destoryed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
@ -53,8 +53,7 @@ void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appS
|
||||
|
||||
void JSAppStateObserver::HandleOnForegroundApplicationChanged(const AppStateData &appStateData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR,
|
||||
"HandleOnForegroundApplicationChanged bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
auto tmpMap = jsObserverObjectMap_;
|
||||
for (auto &item : tmpMap) {
|
||||
@ -102,7 +101,7 @@ void JSAppStateObserver::OnExtensionStateChanged(const AbilityStateData &ability
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destoryed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
@ -170,7 +169,7 @@ void JSAppStateObserver::OnProcessStateChanged(const ProcessData &processData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destoryed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
@ -204,7 +203,7 @@ void JSAppStateObserver::OnProcessDied(const ProcessData &processData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destoryed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
@ -239,7 +238,7 @@ void JSAppStateObserver::OnAppStarted(const AppStateData &appStateData)
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "onAppStarted bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destoryed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
@ -279,7 +278,7 @@ void JSAppStateObserver::OnAppStopped(const AppStateData &appStateData)
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnAppStopped bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
if (!valid_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destoryed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed");
|
||||
return;
|
||||
}
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
|
@ -48,14 +48,6 @@ CallbackInfo g_aceCallbackInfo;
|
||||
const int PARA_SIZE_IS_ONE = 1;
|
||||
const int PARA_SIZE_IS_TWO = 2;
|
||||
|
||||
/**
|
||||
* @brief FeatureAbility NAPI module registration.
|
||||
*
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param exports An empty object via the exports parameter as a convenience.
|
||||
*
|
||||
* @return The return value from Init is treated as the exports object for the module.
|
||||
*/
|
||||
napi_value FeatureAbilityInit(napi_env env, napi_value exports)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::FA, "called");
|
||||
@ -441,14 +433,6 @@ napi_value JsFeatureAbility::OnGetWindow(napi_env env, napi_callback_info info)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief FeatureAbility NAPI method : setResult.
|
||||
*
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param info The callback info passed into the callback function.
|
||||
*
|
||||
* @return The return value from NAPI C++ to JS for the module.
|
||||
*/
|
||||
napi_value NAPI_SetResult(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__);
|
||||
@ -471,14 +455,6 @@ napi_value NAPI_SetResult(napi_env env, napi_callback_info info)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SetResult processing function.
|
||||
*
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param asyncCallbackInfo Process data asynchronously.
|
||||
*
|
||||
* @return Return JS data successfully, otherwise return nullptr.
|
||||
*/
|
||||
napi_value SetResultWrap(napi_env env, napi_callback_info info, AsyncCallbackInfo *asyncCallbackInfo)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__);
|
||||
@ -633,16 +609,6 @@ napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo)
|
||||
}
|
||||
|
||||
EXTERN_C_START
|
||||
/**
|
||||
* @brief The interface of onAbilityResult provided for ACE to call back to JS.
|
||||
*
|
||||
* @param requestCode Indicates the request code returned after the ability is started.
|
||||
* @param resultCode Indicates the result code returned after the ability is started.
|
||||
* @param resultData Indicates the data returned after the ability is started.
|
||||
* @param cb The environment and call back info that the Node-API call is invoked under.
|
||||
*
|
||||
* @return The return value from NAPI C++ to JS for the module.
|
||||
*/
|
||||
void CallOnAbilityResult(int requestCode, int resultCode, const Want &resultData, CallbackInfo callbackInfo)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__);
|
||||
@ -758,15 +724,6 @@ bool InnerUnwrapWant(napi_env env, napi_value args, Want &want)
|
||||
return UnwrapWant(env, jsWant, want);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse the parameters.
|
||||
*
|
||||
* @param param Indicates the parameters saved the parse result.
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param args Indicates the arguments passed into the callback.
|
||||
*
|
||||
* @return The return value from NAPI C++ to JS for the module.
|
||||
*/
|
||||
napi_value UnwrapForResultParam(CallAbilityParam ¶m, napi_env env, napi_value args)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__);
|
||||
@ -804,15 +761,6 @@ napi_value UnwrapForResultParam(CallAbilityParam ¶m, napi_env env, napi_valu
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse the abilityResult parameters.
|
||||
*
|
||||
* @param param Indicates the want parameters saved the parse result.
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param args Indicates the arguments passed into the callback.
|
||||
*
|
||||
* @return The return value from NAPI C++ to JS for the module.
|
||||
*/
|
||||
napi_value UnwrapAbilityResult(CallAbilityParam ¶m, napi_env env, napi_value args)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__);
|
||||
|
@ -23,14 +23,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
/**
|
||||
* @brief FeatureAbilityConstantInit NAPI module registration.
|
||||
*
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param exports An empty object via the exports parameter as a convenience.
|
||||
*
|
||||
* @return The return value from Init is treated as the exports object for the module.
|
||||
*/
|
||||
napi_value FAConstantInit(napi_env env, napi_value exports)
|
||||
{
|
||||
const int Window_Configuration_Zero = 100;
|
||||
|
@ -263,7 +263,7 @@ void AnalysisValuesBucket(NativeRdb::ValuesBucket &valuesBucket, const napi_env
|
||||
uint32_t arrLen = 0;
|
||||
napi_status status = napi_get_array_length(env, keys, &arrLen);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::FA, "ValuesBucket errr");
|
||||
TAG_LOGE(AAFwkTag::FA, "ValuesBucket error");
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::FA, "ValuesBucket num:%{public}d ", arrLen);
|
||||
@ -419,7 +419,7 @@ void InsertAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
|
||||
void InsertPromiseCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, main event thread complete.");
|
||||
TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, main event thread complete.");
|
||||
DAHelperInsertCB *insertCB = static_cast<DAHelperInsertCB *>(data);
|
||||
napi_value result = nullptr;
|
||||
napi_create_int32(env, insertCB->result, &result);
|
||||
|
@ -103,7 +103,7 @@ napi_value BuildDataAbilityOperation(
|
||||
UnwrapDataAbilityPredicates(*predicates, env, jsPredicates);
|
||||
builder->WithPredicates(predicates);
|
||||
|
||||
// get expectedcount property
|
||||
// get expectedCount property
|
||||
int expectedCount = 0;
|
||||
UnwrapInt32ByPropertyName(env, param, "expectedCount", expectedCount);
|
||||
TAG_LOGI(AAFwkTag::FA, "%{public}s, expectedCount:%{public}d", __func__, expectedCount);
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_FEATURE_ABILITY_COMMON_H
|
||||
#define OHOS_ABILITY_RUNTIME_FEATURE_ABILITY_COMMON_H
|
||||
|
||||
#include "ability.h"
|
||||
#include "ability_info.h"
|
||||
#include "application_info.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_JS_FEATURE_ABILITY_COMMON_H
|
||||
#define OHOS_ABILITY_RUNTIME_JS_FEATURE_ABILITY_COMMON_H
|
||||
|
||||
#include "ability.h"
|
||||
#include "ability_info.h"
|
||||
#include "abs_shared_result_set.h"
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
napi_value CreateAbilityInfos(napi_env env, const std::vector<AbilityInfo> &abilityInfos);
|
||||
napi_value CreateAppVersionInfo(napi_env env, const std::shared_ptr<JsApplicationInfo> &appInfo);
|
||||
napi_value CreateWant(napi_env env, const std::shared_ptr<JsWant> &want);
|
||||
bool UnwarpVerifyPermissionParams(napi_env env, napi_callback_info info, JsPermissionOptions &options);
|
||||
bool UnwrapVerifyPermissionParams(napi_env env, napi_callback_info info, JsPermissionOptions &options);
|
||||
bool GetStringsValue(napi_env env, napi_value object, std::vector<std::string> &strList);
|
||||
bool GetPermissionOptions(napi_env env, napi_value object, JsPermissionOptions &options);
|
||||
void AddFreeInstallObserver(napi_env env, const AAFwk::Want &want, napi_value callback, napi_value* result);
|
||||
|
@ -2991,20 +2991,20 @@ napi_value GetAbilityNameWrap(napi_env env, napi_callback_info info, AbilityName
|
||||
napi_value NAPI_GetAbilityNameCommon(napi_env env, napi_callback_info info, AbilityType abilityType)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
|
||||
AbilityNameCB *ablityNameCB = CreateAbilityNameCBInfo(env);
|
||||
if (ablityNameCB == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s ablityNameCB == nullptr", __func__);
|
||||
AbilityNameCB *abilityNameCB = CreateAbilityNameCBInfo(env);
|
||||
if (abilityNameCB == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s abilityNameCB == nullptr", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
|
||||
ablityNameCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
|
||||
ablityNameCB->cbBase.abilityType = abilityType;
|
||||
napi_value ret = GetAbilityNameWrap(env, info, ablityNameCB);
|
||||
abilityNameCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
|
||||
abilityNameCB->cbBase.abilityType = abilityType;
|
||||
napi_value ret = GetAbilityNameWrap(env, info, abilityNameCB);
|
||||
if (ret == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s ret == nullptr", __func__);
|
||||
if (ablityNameCB != nullptr) {
|
||||
delete ablityNameCB;
|
||||
ablityNameCB = nullptr;
|
||||
if (abilityNameCB != nullptr) {
|
||||
delete abilityNameCB;
|
||||
abilityNameCB = nullptr;
|
||||
}
|
||||
ret = WrapVoidToJS(env);
|
||||
}
|
||||
@ -3131,7 +3131,7 @@ bool UnwrapParamForWant(napi_env env, napi_value args, AbilityType, CallAbilityP
|
||||
if (jsSettingObj != nullptr) {
|
||||
param.setting = AbilityStartSetting::GetEmptySetting();
|
||||
if (!UnwrapAbilityStartSetting(env, jsSettingObj, *(param.setting))) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, unwrap abilityStartSetting falied.", __func__);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, unwrap abilityStartSetting failed.", __func__);
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s abilityStartSetting", __func__);
|
||||
}
|
||||
@ -3743,7 +3743,7 @@ void StartBackgroundRunningExecuteCB(napi_env env, void *data)
|
||||
}
|
||||
const std::shared_ptr<AbilityInfo> info = asyncCallbackInfo->ability->GetAbilityInfo();
|
||||
if (info == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "abilityinfo is null");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "ability info is null");
|
||||
asyncCallbackInfo->errCode = NAPI_ERR_ACE_ABILITY;
|
||||
return;
|
||||
}
|
||||
@ -3900,7 +3900,7 @@ napi_value NAPI_StartBackgroundRunningCommon(napi_env env, napi_callback_info in
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
|
||||
AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env);
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s asyncCallbackInfo == nullpter", __func__);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s asyncCallbackInfo == nullptr", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
|
||||
@ -4018,14 +4018,14 @@ napi_value NAPI_CancelBackgroundRunningCommon(napi_env env, napi_callback_info i
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
|
||||
AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env);
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s asyncCallbackInfo == nullpter", __func__);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s asyncCallbackInfo == nullptr", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
|
||||
asyncCallbackInfo->errCode = NAPI_ERR_NO_ERROR;
|
||||
napi_value ret = CancelBackgroundRunningWrap(env, info, asyncCallbackInfo);
|
||||
if (ret == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s ret == nullpter", __func__);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s ret == nullptr", __func__);
|
||||
if (asyncCallbackInfo != nullptr) {
|
||||
delete asyncCallbackInfo;
|
||||
asyncCallbackInfo = nullptr;
|
||||
@ -4119,7 +4119,7 @@ napi_value JsNapiCommon::JsConnectAbility(napi_env env, napi_callback_info info,
|
||||
connectionCallback->Reset();
|
||||
RemoveConnectionLocked(want);
|
||||
}
|
||||
// free failedcallback here, avoid possible multi-threading problems when disconnect success
|
||||
// free failed callback here, avoid possible multi-threading problems when disconnect success
|
||||
napi_delete_reference(env, connectionCallback->failedCallbackRef);
|
||||
connectionCallback->failedCallbackRef = nullptr;
|
||||
return CreateJsValue(env, id);
|
||||
@ -4454,7 +4454,7 @@ napi_value JsNapiCommon::JsGetCacheDir(napi_env env, napi_callback_info info, co
|
||||
auto context = obj->ability_->GetAbilityContext();
|
||||
if (context == nullptr) {
|
||||
*value = static_cast<int32_t>(NAPI_ERR_ABILITY_CALL_INVALID);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "JsGetCacheDir task execute error, the abilitycontext is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "JsGetCacheDir task execute error, the ability context is nullptr");
|
||||
return;
|
||||
}
|
||||
dir->name = context->GetCacheDir();
|
||||
@ -4706,7 +4706,7 @@ napi_value JsNapiCommon::JsGetOrCreateDistributedDir(
|
||||
auto context = obj->ability_->GetAbilityContext();
|
||||
if (context == nullptr) {
|
||||
*value = static_cast<int32_t>(NAPI_ERR_ACE_ABILITY);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the abilitycontext is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability context is nullptr");
|
||||
return;
|
||||
}
|
||||
dir->name = context->GetDistributedFilesDir();
|
||||
@ -5041,7 +5041,7 @@ napi_value JsNapiCommon::CreateAppVersionInfo(napi_env env, const std::shared_pt
|
||||
return objContext;
|
||||
}
|
||||
|
||||
bool JsNapiCommon::UnwarpVerifyPermissionParams(napi_env env, napi_callback_info info, JsPermissionOptions &options)
|
||||
bool JsNapiCommon::UnwrapVerifyPermissionParams(napi_env env, napi_callback_info info, JsPermissionOptions &options)
|
||||
{
|
||||
bool flagCall = true;
|
||||
size_t argc = ARGS_MAX_COUNT;
|
||||
|
@ -2887,12 +2887,12 @@ static napi_value ConstructNapiJSContext(napi_env env)
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "CreateObject failed");
|
||||
return nullptr;
|
||||
}
|
||||
auto jsCalss = std::make_unique<NapiJsContext>();
|
||||
if (!jsCalss->DataInit(env)) {
|
||||
auto jsClass = std::make_unique<NapiJsContext>();
|
||||
if (!jsClass->DataInit(env)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "NapiJsContext init failed");
|
||||
return nullptr;
|
||||
}
|
||||
napi_wrap(env, objContext, jsCalss.release(), NapiJsContext::Finalizer, nullptr, nullptr);
|
||||
napi_wrap(env, objContext, jsClass.release(), NapiJsContext::Finalizer, nullptr, nullptr);
|
||||
napi_set_named_property(env, objContext, "stageMode", CreateJsValue(env, false));
|
||||
if (!BindNapiJSContextFunction(env, objContext)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "bind func failed");
|
||||
@ -3326,7 +3326,7 @@ napi_value NapiJsContext::OnVerifyPermission(napi_env env, napi_callback_info in
|
||||
return CreateJsNull(env);
|
||||
}
|
||||
JsPermissionOptions options;
|
||||
bool flagCall = UnwarpVerifyPermissionParams(env, info, options);
|
||||
bool flagCall = UnwrapVerifyPermissionParams(env, info, options);
|
||||
auto execute = [obj = this, permission, options, value = errorVal] () {
|
||||
if (obj->ability_ == nullptr) {
|
||||
*value = static_cast<int32_t>(NAPI_ERR_ACE_ABILITY);
|
||||
@ -3607,7 +3607,7 @@ napi_value NapiJsContext::OnGetOrCreateLocalDir(napi_env env, napi_callback_info
|
||||
auto context = obj->ability_->GetAbilityContext();
|
||||
if (context == nullptr || dir == nullptr) {
|
||||
*value = static_cast<int32_t>(NAPI_ERR_ABILITY_CALL_INVALID);
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the abilitycontext is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability context is nullptr");
|
||||
return;
|
||||
}
|
||||
dir->name = context->GetBaseDir();
|
||||
|
@ -36,7 +36,7 @@ bool UnwrapExecuteResult(napi_env env, napi_value param, InsightIntentExecuteRes
|
||||
}
|
||||
int32_t code = 0;
|
||||
if (!UnwrapInt32ByPropertyName(env, param, "code", code)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Intent result must contian a code.");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Intent result must contain a code.");
|
||||
return false;
|
||||
}
|
||||
executeResult.code = code;
|
||||
|
@ -105,8 +105,8 @@ private:
|
||||
auto requestInfo = new RequestInfo(callerToken, left, top, width, height);
|
||||
auto jsRequestInfo = RequestInfo::WrapRequestInfo(env, requestInfo);
|
||||
if (jsRequestInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "Can not wrap requestinfo from target request.");
|
||||
ThrowInvalidParamError(env, "Parameter error: Can not wrap requestinfo from target request.");
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "Can not wrap request info from target request.");
|
||||
ThrowInvalidParamError(env, "Parameter error: Can not wrap request info from target request.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= ARG_COUNT_TWO) ? nullptr : argv[INDEX_TWO];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnUnregisterMissionListener",
|
||||
NapiAsyncTask::Schedule("MissionManager::OnUnregisterMissionListener",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -350,7 +350,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= 2) ? nullptr : argv[2];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnGetMissionInfos",
|
||||
NapiAsyncTask::Schedule("MissionManager::OnGetMissionInfos",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -390,7 +390,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= 2) ? nullptr : argv[2];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnGetMissionInfo",
|
||||
NapiAsyncTask::Schedule("MissionManager::OnGetMissionInfo",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -423,7 +423,7 @@ private:
|
||||
};
|
||||
|
||||
std::shared_ptr<MissionSnapshotWrap> snapshotWrap = std::make_shared<MissionSnapshotWrap>();
|
||||
auto excute = [deviceId, missionId, isLowResolution, snapshotWrap]() {
|
||||
auto execute = [deviceId, missionId, isLowResolution, snapshotWrap]() {
|
||||
snapshotWrap->result = AbilityManagerClient::GetInstance()->GetMissionSnapshot(
|
||||
deviceId, missionId, snapshotWrap->missionSnapshot, isLowResolution);
|
||||
};
|
||||
@ -452,8 +452,8 @@ private:
|
||||
};
|
||||
napi_value lastParam = (argc > ARG_COUNT_TWO) ? argv[ARG_COUNT_TWO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnGetMissionSnapShot",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(excute), std::move(complete), &result));
|
||||
NapiAsyncTask::Schedule("MissionManager::OnGetMissionSnapShot",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -508,7 +508,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 1) ? argv[1] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnLockMission",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnLockMission",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -541,7 +541,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 1) ? argv[1] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnUnlockMission",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnUnlockMission",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -574,7 +574,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 1) ? argv[1] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnClearMission",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnClearMission",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -595,7 +595,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 0) ? argv[0] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnMoveMissionToFront",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionToFront",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -636,7 +636,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > unwrapArgc) ? argv[unwrapArgc] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnMoveMissionToFront",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionToFront",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -694,7 +694,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > unwrapArgc) ? argv[unwrapArgc] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnMoveMissionsToForeground", env,
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionsToForeground", env,
|
||||
CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -748,7 +748,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= 1) ? nullptr : argv[1];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnMoveMissionsToBackground",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionsToBackground",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= 1) ? nullptr : argv[1];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnUnregisterMissionListener",
|
||||
NapiAsyncTask::Schedule("MissionManager::OnUnregisterMissionListener",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -222,7 +222,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= 2) ? nullptr : argv[2];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnGetMissionInfos",
|
||||
NapiAsyncTask::Schedule("MissionManager::OnGetMissionInfos",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -262,7 +262,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc <= 2) ? nullptr : argv[2];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::OnGetMissionInfo",
|
||||
NapiAsyncTask::Schedule("MissionManager::OnGetMissionInfo",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -323,7 +323,7 @@ private:
|
||||
};
|
||||
napi_value lastParam = (argc > ARG_COUNT_TWO) ? argv[ARG_COUNT_TWO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("MissioManager::GetMissionSnapShot",
|
||||
NapiAsyncTask::Schedule("MissionManager::GetMissionSnapShot",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(excute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -379,7 +379,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 1) ? argv[1] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnLockMission",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnLockMission",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -412,7 +412,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 1) ? argv[1] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnUnlockMission",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnUnlockMission",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -445,7 +445,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 1) ? argv[1] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnClearMission",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnClearMission",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -466,7 +466,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > 0) ? argv[0] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnMoveMissionToFront",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionToFront",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
@ -507,7 +507,7 @@ private:
|
||||
|
||||
napi_value lastParam = (argc > unwrapArgc) ? argv[unwrapArgc] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissioManager::OnMoveMissionToFront",
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionToFront",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
@ -287,6 +287,18 @@ ohos_shared_library("abilitykit_native") {
|
||||
|
||||
defines = []
|
||||
|
||||
if (cj_frontend) {
|
||||
sources += [ "${ability_runtime_native_path}/ability/native/ability_runtime/cj_ability_object.cpp" ]
|
||||
include_dirs += [
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ability_runtime",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi",
|
||||
]
|
||||
external_deps += [
|
||||
"napi:cj_bind_ffi",
|
||||
"napi:cj_bind_native",
|
||||
]
|
||||
}
|
||||
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
|
||||
defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
|
||||
@ -545,6 +557,21 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
"node:node_header_notice",
|
||||
]
|
||||
|
||||
if (cj_frontend) {
|
||||
sources += [
|
||||
"${ability_runtime_native_path}/ability/native/ability_runtime/cj_ability_object.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/ability_runtime/cj_ui_ability.cpp",
|
||||
]
|
||||
|
||||
include_dirs += [ "${ability_runtime_path}/frameworks/cj/ffi" ]
|
||||
|
||||
external_deps += [
|
||||
"napi:cj_bind_ffi",
|
||||
"napi:cj_bind_native",
|
||||
"window_manager:cj_window_ffi",
|
||||
]
|
||||
}
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
|
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#include "ability_runtime/cj_ability_object.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::AbilityRuntime;
|
||||
|
||||
using WantHandle = void*;
|
||||
|
||||
namespace {
|
||||
// g_cjAbilityFuncs is used to save cj functions.
|
||||
// It is assigned by the global variable REGISTER_ABILITY on the cj side which invokes RegisterCJAbilityFuncs.
|
||||
// And it is never released.
|
||||
CJAbilityFuncs* g_cjAbilityFuncs = nullptr;
|
||||
} // namespace
|
||||
|
||||
void RegisterCJAbilityFuncs(void (*registerFunc)(CJAbilityFuncs*))
|
||||
{
|
||||
HILOG_INFO("RegisterCJAbilityFuncs start.");
|
||||
if (g_cjAbilityFuncs != nullptr) {
|
||||
HILOG_ERROR("Repeated registration for cj functions of CJAbility.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (registerFunc == nullptr) {
|
||||
HILOG_ERROR("RegisterCJAbilityFuncs failed, registerFunc is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
g_cjAbilityFuncs = new CJAbilityFuncs();
|
||||
registerFunc(g_cjAbilityFuncs);
|
||||
HILOG_INFO("RegisterCJAbilityFuncs end.");
|
||||
}
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
std::shared_ptr<CJAbilityObject> CJAbilityObject::LoadModule(const std::string& name)
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return nullptr;
|
||||
}
|
||||
auto id = g_cjAbilityFuncs->cjAbilityCreate(name.c_str());
|
||||
if (id == 0) {
|
||||
HILOG_ERROR(
|
||||
"Failed to invoke CJAbilityObject::LoadModule. Ability: %{public}s is not registered.", name.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<CJAbilityObject>(id);
|
||||
}
|
||||
|
||||
CJAbilityObject::~CJAbilityObject()
|
||||
{
|
||||
if (g_cjAbilityFuncs != nullptr) {
|
||||
g_cjAbilityFuncs->cjAbilityRelease(id_);
|
||||
}
|
||||
id_ = 0;
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnStart(const AAFwk::Want& want, const AAFwk::LaunchParam& launchParam) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
WantHandle wantHandle = const_cast<AAFwk::Want*>(&want);
|
||||
CJLaunchParam param;
|
||||
param.launchReason = launchParam.launchReason;
|
||||
param.lastExitReason = launchParam.lastExitReason;
|
||||
g_cjAbilityFuncs->cjAbilityOnStart(id_, wantHandle, param);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnStop() const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
g_cjAbilityFuncs->cjAbilityOnStop(id_);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnSceneCreated(OHOS::Rosen::CJWindowStageImpl* cjWindowStage) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
WindowStagePtr windowStage = reinterpret_cast<WindowStagePtr>(cjWindowStage);
|
||||
g_cjAbilityFuncs->cjAbilityOnSceneCreated(id_, windowStage);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnSceneRestored(OHOS::Rosen::CJWindowStageImpl* cjWindowStage) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
WindowStagePtr windowStage = reinterpret_cast<WindowStagePtr>(cjWindowStage);
|
||||
g_cjAbilityFuncs->cjAbilityOnSceneRestored(id_, windowStage);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnSceneDestroyed() const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
g_cjAbilityFuncs->cjAbilityOnSceneDestroyed(id_);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnForeground(const Want& want) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
WantHandle wantHandle = const_cast<AAFwk::Want*>(&want);
|
||||
g_cjAbilityFuncs->cjAbilityOnForeground(id_, wantHandle);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnBackground() const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
g_cjAbilityFuncs->cjAbilityOnBackground(id_);
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnConfigurationUpdated(const std::shared_ptr<AppExecFwk::Configuration>& configuration) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CJAbilityObject::OnNewWant(const AAFwk::Want& want, const AAFwk::LaunchParam& launchParam) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
WantHandle wantHandle = const_cast<AAFwk::Want*>(&want);
|
||||
CJLaunchParam param;
|
||||
param.launchReason = launchParam.launchReason;
|
||||
param.lastExitReason = launchParam.lastExitReason;
|
||||
g_cjAbilityFuncs->cjAbilityOnNewWant(id_, wantHandle, param);
|
||||
}
|
||||
|
||||
void CJAbilityObject::Dump(const std::vector<std::string>& params, std::vector<std::string>& info) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
|
||||
VectorStringHandle paramHandle = const_cast<std::vector<std::string>*>(¶ms);
|
||||
VectorStringHandle cjInfo = g_cjAbilityFuncs->cjAbilityDump(id_, paramHandle);
|
||||
if (cjInfo == nullptr) {
|
||||
HILOG_ERROR("CJ info nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
auto infoHandle = reinterpret_cast<std::vector<std::string>*>(cjInfo);
|
||||
for (std::string item : *infoHandle) {
|
||||
info.push_back(item);
|
||||
}
|
||||
// infoHandle is created in cj.
|
||||
delete infoHandle;
|
||||
infoHandle = nullptr;
|
||||
}
|
||||
|
||||
int32_t CJAbilityObject::OnContinue(AAFwk::WantParams& wantParams) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return ContinuationManager::OnContinueResult::REJECT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CJAbilityObject::Init(AbilityHandle ability) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
HILOG_ERROR("CJ functions for CJAbility are not registered");
|
||||
return;
|
||||
}
|
||||
g_cjAbilityFuncs->cjAbilityInit(id_, ability);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -0,0 +1,760 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#include "cj_ui_ability.h"
|
||||
|
||||
#include <regex>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ability_business_error.h"
|
||||
#include "ability_delegator_registry.h"
|
||||
#include "ability_recovery.h"
|
||||
#include "ability_start_setting.h"
|
||||
#include "app_recovery.h"
|
||||
#include "context/application_context.h"
|
||||
#include "connection_manager.h"
|
||||
#include "context/context.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "insight_intent_executor_info.h"
|
||||
#include "insight_intent_executor_mgr.h"
|
||||
#include "insight_intent_execute_param.h"
|
||||
#include "cj_runtime.h"
|
||||
#include "cj_ability_object.h"
|
||||
#include "time_util.h"
|
||||
#include "scene_board_judgement.h"
|
||||
#include "string_wrapper.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const std::string PAGE_STACK_PROPERTY_NAME = "pageStack";
|
||||
const std::string METHOD_NAME = "WindowScene::GoForeground";
|
||||
const std::string SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME = "ohos.extra.param.key.supportContinuePageStack";
|
||||
#endif
|
||||
// Numerical base (radix) that determines the valid characters and their interpretation.
|
||||
const int32_t BASE_DISPLAY_ID_NUM (10);
|
||||
}
|
||||
|
||||
UIAbility *CJUIAbility::Create(const std::unique_ptr<Runtime> &runtime)
|
||||
{
|
||||
return new (std::nothrow) CJUIAbility(static_cast<CJRuntime &>(*runtime));
|
||||
}
|
||||
|
||||
CJUIAbility::CJUIAbility(CJRuntime &cjRuntime) : cjRuntime_(cjRuntime)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
}
|
||||
|
||||
CJUIAbility::~CJUIAbility()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
if (abilityContext_ != nullptr) {
|
||||
abilityContext_->Unbind();
|
||||
}
|
||||
}
|
||||
|
||||
void CJUIAbility::Init(std::shared_ptr<AppExecFwk::AbilityLocalRecord> record,
|
||||
const std::shared_ptr<OHOSApplication> application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (record == nullptr) {
|
||||
HILOG_ERROR("AbilityLocalRecord is nullptr.");
|
||||
return;
|
||||
}
|
||||
auto abilityInfo = record->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
HILOG_ERROR("AbilityInfo is nullptr.");
|
||||
return;
|
||||
}
|
||||
UIAbility::Init(record, application, handler, token);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (abilityContext_ != nullptr) {
|
||||
AppExecFwk::AppRecovery::GetInstance().AddAbility(
|
||||
shared_from_this(), abilityContext_->GetAbilityInfo(), abilityContext_->GetToken());
|
||||
}
|
||||
#endif
|
||||
SetAbilityContext(abilityInfo);
|
||||
}
|
||||
|
||||
void CJUIAbility::SetAbilityContext(
|
||||
const std::shared_ptr<AbilityInfo> &abilityInfo)
|
||||
{
|
||||
if (!abilityInfo) {
|
||||
HILOG_ERROR("abilityInfo is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
cjAbilityObj_ = CJAbilityObject::LoadModule(abilityInfo->name);
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("Failed to get CJAbility object.");
|
||||
return;
|
||||
}
|
||||
cjAbilityObj_->Init(this);
|
||||
}
|
||||
|
||||
void CJUIAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("Begin ability is %{public}s.", GetAbilityName().c_str());
|
||||
UIAbility::OnStart(want, sessionInfo);
|
||||
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
std::string methodName = "OnStart";
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
cjAbilityObj_->OnStart(want, GetLaunchParam());
|
||||
AddLifecycleEventAfterCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call PostPerformStart.");
|
||||
delegator->PostPerformStart(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
HILOG_INFO("End ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
void CJUIAbility::AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||
{
|
||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
||||
auto entry = std::to_string(TimeUtil::SystemTimeMillisecond()) + "; CJUIAbility::" + methodName +
|
||||
"; the " + methodName + " begin.";
|
||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
||||
}
|
||||
|
||||
void CJUIAbility::AddLifecycleEventAfterCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||
{
|
||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
||||
auto entry = std::to_string(TimeUtil::SystemTimeMillisecond()) + "; CJUIAbility::" + methodName +
|
||||
"; the " + methodName + " end.";
|
||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
||||
}
|
||||
|
||||
int32_t CJUIAbility::OnShare(WantParams &wantParams)
|
||||
{
|
||||
HILOG_DEBUG("Begin.");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void CJUIAbility::OnStop()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin.");
|
||||
if (abilityContext_) {
|
||||
HILOG_DEBUG("Set terminating true.");
|
||||
abilityContext_->SetTerminating(true);
|
||||
}
|
||||
UIAbility::OnStop();
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
cjAbilityObj_->OnStop();
|
||||
CJUIAbility::OnStopCallback();
|
||||
HILOG_DEBUG("End.");
|
||||
}
|
||||
|
||||
void CJUIAbility::OnStop(AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInfo, bool &isAsyncCallback)
|
||||
{
|
||||
if (callbackInfo == nullptr) {
|
||||
isAsyncCallback = false;
|
||||
OnStop();
|
||||
return;
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin");
|
||||
if (abilityContext_) {
|
||||
HILOG_DEBUG("Set terminating true.");
|
||||
abilityContext_->SetTerminating(true);
|
||||
}
|
||||
|
||||
UIAbility::OnStop();
|
||||
cjAbilityObj_->OnStop();
|
||||
OnStopCallback();
|
||||
HILOG_DEBUG("End.");
|
||||
}
|
||||
|
||||
void CJUIAbility::OnStopCallback()
|
||||
{
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call PostPerformStop.");
|
||||
delegator->PostPerformStop(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
|
||||
bool ret = ConnectionManager::GetInstance().DisconnectCaller(AbilityContext::token_);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("The service connection is disconnected.");
|
||||
}
|
||||
ConnectionManager::GetInstance().ReportConnectionLeakEvent(getpid(), gettid());
|
||||
HILOG_DEBUG("The service connection is not disconnected.");
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void CJUIAbility::OnSceneCreated()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin ability is %{public}s.", GetAbilityName().c_str());
|
||||
UIAbility::OnSceneCreated();
|
||||
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
cjWindowStage_ = OHOS::Rosen::CJWindowStageImpl::CreateCJWindowStage(GetScene());
|
||||
if (!cjWindowStage_) {
|
||||
HILOG_ERROR("Failed to create CJWindowStage object.");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "onWindowStageCreate");
|
||||
std::string methodName = "OnSceneCreated";
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
cjAbilityObj_->OnSceneCreated(cjWindowStage_.get());
|
||||
AddLifecycleEventAfterCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
}
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call PostPerformScenceCreated.");
|
||||
delegator->PostPerformScenceCreated(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
|
||||
HILOG_DEBUG("End ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
void CJUIAbility::OnSceneRestored()
|
||||
{
|
||||
UIAbility::OnSceneRestored();
|
||||
HILOG_DEBUG("called.");
|
||||
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cjWindowStage_) {
|
||||
cjWindowStage_ = OHOS::Rosen::CJWindowStageImpl::CreateCJWindowStage(scene_);
|
||||
if (!cjWindowStage_) {
|
||||
HILOG_ERROR("Failed to create CJWindowStage object.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cjAbilityObj_->OnSceneRestored(cjWindowStage_.get());
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call PostPerformScenceRestored.");
|
||||
delegator->PostPerformScenceRestored(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
}
|
||||
|
||||
void CJUIAbility::OnSceneDestroyed()
|
||||
{
|
||||
HILOG_DEBUG("Begin ability is %{public}s.", GetAbilityName().c_str());
|
||||
UIAbility::onSceneDestroyed();
|
||||
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
cjAbilityObj_->OnSceneDestroyed();
|
||||
|
||||
if (scene_ != nullptr) {
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window != nullptr) {
|
||||
HILOG_DEBUG("Call window UnregisterDisplayMoveListener.");
|
||||
window->UnregisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
}
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call delegator PostPerformScenceDestroyed.");
|
||||
delegator->PostPerformScenceDestroyed(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
HILOG_DEBUG("End ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
void CJUIAbility::OnForeground(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin ability is %{public}s.", GetAbilityName().c_str());
|
||||
|
||||
UIAbility::OnForeground(want);
|
||||
CallOnForegroundFunc(want);
|
||||
}
|
||||
|
||||
void CJUIAbility::CallOnForegroundFunc(const Want &want)
|
||||
{
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
std::string methodName = "OnForeground";
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
cjAbilityObj_->OnForeground(want);
|
||||
AddLifecycleEventAfterCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call PostPerformForeground.");
|
||||
delegator->PostPerformForeground(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
|
||||
HILOG_DEBUG("End ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
void CJUIAbility::OnBackground()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin ability is %{public}s.", GetAbilityName().c_str());
|
||||
|
||||
UIAbility::OnBackground();
|
||||
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
std::string methodName = "OnBackground";
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::BACKGROUND, methodName);
|
||||
cjAbilityObj_->OnBackground();
|
||||
AddLifecycleEventAfterCall(FreezeUtil::TimeoutState::BACKGROUND, methodName);
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call PostPerformBackground.");
|
||||
delegator->PostPerformBackground(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
|
||||
HILOG_DEBUG("End ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
bool CJUIAbility::OnBackPress()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin ability: %{public}s.", GetAbilityName().c_str());
|
||||
UIAbility::OnBackPress();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CJUIAbility::OnPrepareTerminate()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Begin ability: %{public}s.", GetAbilityName().c_str());
|
||||
UIAbility::OnPrepareTerminate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CJUIAbility::GetPageStackFromWant(const Want &want, std::string &pageStack)
|
||||
{
|
||||
auto stringObj = AAFwk::IString::Query(want.GetParams().GetParam(PAGE_STACK_PROPERTY_NAME));
|
||||
if (stringObj != nullptr) {
|
||||
pageStack = AAFwk::String::Unbox(stringObj);
|
||||
}
|
||||
}
|
||||
|
||||
bool CJUIAbility::IsRestorePageStack(const Want &want)
|
||||
{
|
||||
return want.GetBoolParam(SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME, true);
|
||||
}
|
||||
|
||||
void CJUIAbility::RestorePageStack(const Want &want)
|
||||
{
|
||||
if (IsRestorePageStack(want)) {
|
||||
std::string pageStack;
|
||||
GetPageStackFromWant(want, pageStack);
|
||||
}
|
||||
}
|
||||
|
||||
void CJUIAbility::AbilityContinuationOrRecover(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
// multi-instance ability continuation
|
||||
HILOG_DEBUG("Launch reason is %{public}d.", launchParam_.launchReason);
|
||||
if (IsRestoredInContinuation()) {
|
||||
RestorePageStack(want);
|
||||
OnSceneRestored();
|
||||
NotifyContinuationResult(want, true);
|
||||
} else if (ShouldRecoverState(want)) {
|
||||
std::string pageStack = abilityRecovery_->GetSavedPageStack(AppExecFwk::StateReason::DEVELOPER_REQUEST);
|
||||
OnSceneRestored();
|
||||
} else {
|
||||
OnSceneCreated();
|
||||
}
|
||||
}
|
||||
|
||||
void CJUIAbility::DoOnForeground(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (scene_ == nullptr) {
|
||||
if ((abilityContext_ == nullptr) || (sceneListener_ == nullptr)) {
|
||||
HILOG_ERROR("AbilityContext or sceneListener_ is nullptr .");
|
||||
return;
|
||||
}
|
||||
scene_ = std::make_shared<Rosen::WindowScene>();
|
||||
InitSceneDoOnForeground(scene_, want);
|
||||
} else {
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window == nullptr) {
|
||||
HILOG_ERROR("MainWindow is nullptr .");
|
||||
return;
|
||||
}
|
||||
if (want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) {
|
||||
HILOG_ERROR("want has parameter PARAM_RESV_WINDOW_MODE.");
|
||||
auto windowMode = want.GetIntParam(
|
||||
Want::PARAM_RESV_WINDOW_MODE, AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
|
||||
window->SetWindowMode(static_cast<Rosen::WindowMode>(windowMode));
|
||||
windowMode_ = windowMode;
|
||||
HILOG_DEBUG("Set window mode is %{public}d .", windowMode);
|
||||
}
|
||||
}
|
||||
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window == nullptr) {
|
||||
HILOG_ERROR("MainWindow is nullptr .");
|
||||
return;
|
||||
}
|
||||
if (securityFlag_) {
|
||||
window->SetSystemPrivacyMode(true);
|
||||
}
|
||||
|
||||
HILOG_INFO("Move scene to foreground, sceneFlag_: %{public}d .", UIAbility::sceneFlag_);
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::FOREGROUND, METHOD_NAME);
|
||||
scene_->GoForeground(UIAbility::sceneFlag_);
|
||||
HILOG_DEBUG("End.");
|
||||
}
|
||||
|
||||
void CJUIAbility::InitSceneDoOnForeground(std::shared_ptr<Rosen::WindowScene> scene, const Want &want)
|
||||
{
|
||||
int32_t displayId = static_cast<int32_t>(Rosen::DisplayManager::GetInstance().GetDefaultDisplayId());
|
||||
if (setting_ != nullptr) {
|
||||
std::string strDisplayId = setting_->GetProperty(OHOS::AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY);
|
||||
std::regex formatRegex("[0-9]{0,9}$");
|
||||
std::smatch sm;
|
||||
bool flag = std::regex_match(strDisplayId, sm, formatRegex);
|
||||
if (flag && !strDisplayId.empty()) {
|
||||
displayId = strtol(strDisplayId.c_str(), nullptr, BASE_DISPLAY_ID_NUM);
|
||||
HILOG_DEBUG("Success displayId is %{public}d .", displayId);
|
||||
} else {
|
||||
HILOG_ERROR("Failed to formatRegex: [%{public}s] .", strDisplayId.c_str());
|
||||
}
|
||||
}
|
||||
Rosen::WMError ret = Rosen::WMError::WM_OK;
|
||||
auto option = GetWindowOption(want);
|
||||
auto sessionToken = GetSessionToken();
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() && sessionToken != nullptr) {
|
||||
abilityContext_->SetWeakSessionToken(sessionToken);
|
||||
ret = scene_->Init(displayId, abilityContext_, sceneListener_, option, sessionToken);
|
||||
} else {
|
||||
ret = scene_->Init(displayId, abilityContext_, sceneListener_, option);
|
||||
}
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
HILOG_ERROR("Failed to init window scene .");
|
||||
return;
|
||||
}
|
||||
|
||||
AbilityContinuationOrRecover(want);
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window) {
|
||||
HILOG_DEBUG("Call RegisterDisplayMoveListener, windowId: %{public}d .", window->GetWindowId());
|
||||
abilityDisplayMoveListener_ = new AbilityDisplayMoveListener(weak_from_this());
|
||||
if (abilityDisplayMoveListener_ == nullptr) {
|
||||
HILOG_ERROR("abilityDisplayMoveListener_ is nullptr .");
|
||||
return;
|
||||
}
|
||||
window->RegisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
}
|
||||
|
||||
void CJUIAbility::RequestFocus(const Want &want)
|
||||
{
|
||||
HILOG_INFO("Lifecycle: begin .");
|
||||
if (scene_ == nullptr) {
|
||||
HILOG_ERROR("scene_ is nullptr .");
|
||||
return;
|
||||
}
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) {
|
||||
auto windowMode = want.GetIntParam(
|
||||
Want::PARAM_RESV_WINDOW_MODE, AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
|
||||
window->SetWindowMode(static_cast<Rosen::WindowMode>(windowMode));
|
||||
HILOG_DEBUG("Set window mode is %{public}d .", windowMode);
|
||||
}
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::FOREGROUND, METHOD_NAME);
|
||||
scene_->GoForeground(UIAbility::sceneFlag_);
|
||||
HILOG_INFO("Lifecycle: end .");
|
||||
}
|
||||
|
||||
void CJUIAbility::ContinuationRestore(const Want &want)
|
||||
{
|
||||
HILOG_DEBUG("Called .");
|
||||
if (!IsRestoredInContinuation() || scene_ == nullptr) {
|
||||
HILOG_ERROR("Is not in continuation or scene_ is nullptr .");
|
||||
return;
|
||||
}
|
||||
RestorePageStack(want);
|
||||
OnSceneRestored();
|
||||
NotifyContinuationResult(want, true);
|
||||
}
|
||||
|
||||
std::shared_ptr<Rosen::CJWindowStageImpl> CJUIAbility::GetCJWindowStage()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
if (cjWindowStage_ == nullptr) {
|
||||
HILOG_ERROR("CJWindowSatge is nullptr .");
|
||||
}
|
||||
return cjWindowStage_;
|
||||
}
|
||||
|
||||
const CJRuntime &CJUIAbility::GetCJRuntime()
|
||||
{
|
||||
return cjRuntime_;
|
||||
}
|
||||
|
||||
void CJUIAbility::ExecuteInsightIntentRepeateForeground(const Want &want,
|
||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||
{
|
||||
HILOG_DEBUG("called .");
|
||||
if (executeParam == nullptr) {
|
||||
HILOG_WARN("Intention execute param invalid.");
|
||||
RequestFocus(want);
|
||||
InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), ERR_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
auto asyncCallback = [weak = weak_from_this(), want](InsightIntentExecuteResult result) {
|
||||
HILOG_DEBUG("Begin request focus .");
|
||||
auto ability = weak.lock();
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ability is nullptr .");
|
||||
return;
|
||||
}
|
||||
ability->RequestFocus(want);
|
||||
};
|
||||
callback->Push(asyncCallback);
|
||||
|
||||
InsightIntentExecutorInfo executeInfo;
|
||||
auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("Get Intention executor failed.");
|
||||
InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback),
|
||||
static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CJUIAbility::ExecuteInsightIntentMoveToForeground(const Want &want,
|
||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
if (executeParam == nullptr) {
|
||||
HILOG_WARN("Intention execute param invalid.");
|
||||
OnForeground(want);
|
||||
InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), ERR_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
UIAbility::OnForeground(want);
|
||||
|
||||
auto asyncCallback = [weak = weak_from_this(), want](InsightIntentExecuteResult result) {
|
||||
HILOG_DEBUG("Begin call onForeground.");
|
||||
auto ability = weak.lock();
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ability is nullptr.");
|
||||
return;
|
||||
}
|
||||
ability->CallOnForegroundFunc(want);
|
||||
};
|
||||
callback->Push(asyncCallback);
|
||||
|
||||
InsightIntentExecutorInfo executeInfo;
|
||||
auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("Get Intention executor failed.");
|
||||
InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback),
|
||||
static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool CJUIAbility::GetInsightIntentExecutorInfo(const Want &want,
|
||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||
InsightIntentExecutorInfo& executeInfo)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
auto context = GetAbilityContext();
|
||||
if (executeParam == nullptr || context == nullptr || abilityInfo_ == nullptr || cjWindowStage_ == nullptr) {
|
||||
HILOG_ERROR("Param invalid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const WantParams &wantParams = want.GetParams();
|
||||
executeInfo.srcEntry = wantParams.GetStringParam("ohos.insightIntent.srcEntry");
|
||||
executeInfo.hapPath = abilityInfo_->hapPath;
|
||||
executeInfo.esmodule = abilityInfo_->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
||||
executeInfo.windowMode = windowMode_;
|
||||
executeInfo.token = context->GetToken();
|
||||
executeInfo.executeParam = executeParam;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t CJUIAbility::OnContinue(WantParams &wantParams)
|
||||
{
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::REJECT;
|
||||
}
|
||||
auto res = cjAbilityObj_->OnContinue(wantParams);
|
||||
HILOG_INFO("CJAbility::OnContinue end, return value is %{public}d", res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t CJUIAbility::OnSaveState(int32_t reason, WantParams &wantParams)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CJUIAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
UIAbility::OnConfigurationUpdated(configuration);
|
||||
HILOG_DEBUG("Called.");
|
||||
auto fullConfig = GetAbilityContext()->GetConfiguration();
|
||||
if (!fullConfig) {
|
||||
HILOG_ERROR("configuration is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
cjAbilityObj_->OnConfigurationUpdated(fullConfig);
|
||||
HILOG_INFO("CJAbility::OnConfigurationUpdated end");
|
||||
}
|
||||
|
||||
void CJUIAbility::OnMemoryLevel(int level)
|
||||
{
|
||||
UIAbility::OnMemoryLevel(level);
|
||||
HILOG_DEBUG("Called.");
|
||||
}
|
||||
|
||||
void CJUIAbility::UpdateContextConfiguration()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
}
|
||||
|
||||
void CJUIAbility::OnNewWant(const Want &want)
|
||||
{
|
||||
HILOG_DEBUG("Begin.");
|
||||
UIAbility::OnNewWant(want);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (scene_) {
|
||||
scene_->OnNewWant(want);
|
||||
}
|
||||
#endif
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
std::string methodName = "OnNewWant";
|
||||
AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
cjAbilityObj_->OnNewWant(want, GetLaunchParam());
|
||||
AddLifecycleEventAfterCall(FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
|
||||
HILOG_DEBUG("End.");
|
||||
}
|
||||
|
||||
void CJUIAbility::OnAbilityResult(int requestCode, int resultCode, const Want &resultData)
|
||||
{
|
||||
HILOG_DEBUG("Begin .");
|
||||
UIAbility::OnAbilityResult(requestCode, resultCode, resultData);
|
||||
if (abilityContext_ == nullptr) {
|
||||
HILOG_ERROR("abilityContext_ is nullptr .");
|
||||
return;
|
||||
}
|
||||
abilityContext_->OnAbilityResult(requestCode, resultCode, resultData);
|
||||
HILOG_DEBUG("End .");
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> CJUIAbility::CallRequest()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AppExecFwk::ADelegatorAbilityProperty> CJUIAbility::CreateADelegatorAbilityProperty()
|
||||
{
|
||||
if (abilityContext_ == nullptr) {
|
||||
HILOG_ERROR("abilityContext_ is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
auto property = std::make_shared<AppExecFwk::ADelegatorAbilityProperty>();
|
||||
property->token_ = abilityContext_->GetToken();
|
||||
property->name_ = GetAbilityName();
|
||||
property->moduleName_ = GetModuleName();
|
||||
if (GetApplicationInfo() == nullptr || GetApplicationInfo()->bundleName.empty()) {
|
||||
property->fullName_ = GetAbilityName();
|
||||
} else {
|
||||
std::string::size_type pos = GetAbilityName().find(GetApplicationInfo()->bundleName);
|
||||
if (pos == std::string::npos || pos != 0) {
|
||||
property->fullName_ = GetApplicationInfo()->bundleName + "." + GetAbilityName();
|
||||
} else {
|
||||
property->fullName_ = GetAbilityName();
|
||||
}
|
||||
}
|
||||
property->lifecycleState_ = GetState();
|
||||
return property;
|
||||
}
|
||||
|
||||
void CJUIAbility::Dump(const std::vector<std::string> ¶ms, std::vector<std::string> &info)
|
||||
{
|
||||
UIAbility::Dump(params, info);
|
||||
HILOG_DEBUG("Called.");
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
return;
|
||||
}
|
||||
cjAbilityObj_->Dump(params, info);
|
||||
HILOG_DEBUG("Dump info size: %{public}zu.", info.size());
|
||||
}
|
||||
|
||||
std::shared_ptr<CJAbilityObject> CJUIAbility::GetCJAbility()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
if (cjAbilityObj_ == nullptr) {
|
||||
HILOG_ERROR("cjAbility object is nullptr.");
|
||||
}
|
||||
return cjAbilityObj_;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -27,6 +27,8 @@ constexpr const char *VIEW_DATA_BUNDLE_NAME = "bundleName";
|
||||
constexpr const char *VIEW_DATA_MODULE_NAME = "moduleName";
|
||||
constexpr const char *VIEW_DATA_ABILITY_NAME = "abilityName";
|
||||
constexpr const char *VIEW_DATA_PAGEURL = "pageUrl";
|
||||
constexpr const char *VIEW_DATA_USER_SELECTED = "isUserSelected";
|
||||
constexpr const char *VIEW_DATA_OTHER_ACCOUNT = "isOtherAccount";
|
||||
constexpr const char *VIEW_DATA_PAGE_NODE_INFOS = "pageNodeInfos";
|
||||
constexpr const char *VIEW_DATA_VIEW_DATA = "viewData";
|
||||
constexpr const char *VIEW_DATA_TYPE = "type";
|
||||
@ -73,6 +75,12 @@ napi_value JsAutoFillExtensionUtil::WrapViewData(const napi_env env, const Abili
|
||||
jsValue = WrapStringToJS(env, viewData.pageUrl);
|
||||
SetPropertyValueByPropertyName(env, jsObject, VIEW_DATA_PAGEURL, jsValue);
|
||||
|
||||
jsValue = WrapBoolToJS(env, viewData.isUserSelected);
|
||||
SetPropertyValueByPropertyName(env, jsObject, VIEW_DATA_USER_SELECTED, jsValue);
|
||||
|
||||
jsValue = WrapBoolToJS(env, viewData.isOtherAccount);
|
||||
SetPropertyValueByPropertyName(env, jsObject, VIEW_DATA_OTHER_ACCOUNT, jsValue);
|
||||
|
||||
napi_value jsArray = nullptr;
|
||||
NAPI_CALL(env, napi_create_array(env, &jsArray));
|
||||
napi_value jsSubValue = nullptr;
|
||||
@ -183,6 +191,8 @@ void JsAutoFillExtensionUtil::UnwrapViewData(
|
||||
viewData.abilityName = UnwrapStringFromJS(env, jsValue, "");
|
||||
jsValue = GetPropertyValueByPropertyName(env, jsViewData, VIEW_DATA_PAGEURL, napi_string);
|
||||
viewData.pageUrl = UnwrapStringFromJS(env, jsValue, "");
|
||||
UnwrapBooleanByPropertyName(env, jsViewData, VIEW_DATA_USER_SELECTED, viewData.isUserSelected);
|
||||
UnwrapBooleanByPropertyName(env, jsViewData, VIEW_DATA_OTHER_ACCOUNT, viewData.isOtherAccount);
|
||||
jsValue = GetPropertyValueByPropertyName(env, jsViewData, VIEW_DATA_PAGE_NODE_INFOS, napi_object);
|
||||
if (jsValue != nullptr) {
|
||||
uint32_t jsProCount = 0;
|
||||
|
@ -54,7 +54,7 @@ bool NativeChildIpcProcess::Init(const std::shared_ptr<ChildProcessStartInfo> &i
|
||||
}
|
||||
|
||||
if (!LoadNativeLib(info)) {
|
||||
iNotify->OnError(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB));
|
||||
iNotify->OnError(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_LIB_LOADING_FAILED));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ void NativeChildIpcProcess::OnStart()
|
||||
OHIPCRemoteStub *ipcStub = funcNativeLibOnConnect_();
|
||||
if (ipcStub == nullptr || ipcStub->remote == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib OnConnect function return null stub");
|
||||
mainProcessCb_->OnError(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT));
|
||||
mainProcessCb_->OnError(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_CONNECTION_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "js_ui_ability.h"
|
||||
#include "cj_ui_ability.h"
|
||||
#include "ohos_application.h"
|
||||
#include "reverse_continuation_scheduler_primary_stage.h"
|
||||
#include "runtime.h"
|
||||
@ -54,6 +55,8 @@ UIAbility *UIAbility::Create(const std::unique_ptr<Runtime> &runtime)
|
||||
switch (runtime->GetLanguage()) {
|
||||
case Runtime::Language::JS:
|
||||
return JsUIAbility::Create(runtime);
|
||||
case Runtime::Language::CJ:
|
||||
return CJUIAbility::Create(runtime);
|
||||
default:
|
||||
return new (std::nothrow) UIAbility();
|
||||
}
|
||||
|
@ -887,7 +887,7 @@ napi_value JsUIExtensionContentSession::OnStartAbilityByType(napi_env env, NapiC
|
||||
}
|
||||
|
||||
bool JsUIExtensionContentSession::CheckStartAbilityByTypeParam(napi_env env,
|
||||
NapiCallbackInfo& info, std::string type, AAFwk::WantParams wantParam)
|
||||
NapiCallbackInfo& info, std::string& type, AAFwk::WantParams& wantParam)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "start");
|
||||
|
||||
|
@ -26,20 +26,20 @@ using namespace OHOS::AbilityRuntime;
|
||||
|
||||
namespace {
|
||||
|
||||
std::mutex g_MutexCallBackObj;
|
||||
std::mutex g_mutexCallBackObj;
|
||||
sptr<IRemoteObject> g_CallbackStub;
|
||||
OH_Ability_OnNativeChildProcessStarted g_Callback = nullptr;
|
||||
|
||||
const std::map<ChildProcessManagerErrorCode, Ability_NativeChildProcess_ErrCode> CPM_ERRCODE_MAP = {
|
||||
{ ChildProcessManagerErrorCode::ERR_OK, NCP_NOERROR },
|
||||
{ ChildProcessManagerErrorCode::ERR_OK, NCP_NO_ERROR },
|
||||
{ ChildProcessManagerErrorCode::ERR_MULTI_PROCESS_MODEL_DISABLED, NCP_ERR_MULTI_PROCESS_DISABLED },
|
||||
{ ChildProcessManagerErrorCode::ERR_ALREADY_IN_CHILD_PROCESS, NCP_ERR_ALREADY_IN_CHILD },
|
||||
{ ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED, NCP_ERR_SERVICE },
|
||||
{ ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED, NCP_ERR_SERVICE },
|
||||
{ ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED, NCP_ERR_SERVICE_ERROR },
|
||||
{ ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED, NCP_ERR_SERVICE_ERROR },
|
||||
{ ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS, NCP_ERR_NOT_SUPPORTED },
|
||||
{ ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES, NCP_ERR_MAX_CHILD_PROCESSES_REACHED },
|
||||
{ ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB, NCP_ERR_CHILD_PROCESS_LOAD_LIB },
|
||||
{ ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT, NCP_ERR_CHILD_PROCESS_CONNECT },
|
||||
{ ChildProcessManagerErrorCode::ERR_LIB_LOADING_FAILED, NCP_ERR_LIB_LOADING_FAILED },
|
||||
{ ChildProcessManagerErrorCode::ERR_CONNECTION_FAILED, NCP_ERR_CONNECTION_FAILED },
|
||||
};
|
||||
|
||||
int CvtChildProcessManagerErrCode(ChildProcessManagerErrorCode cpmErr)
|
||||
@ -54,7 +54,7 @@ int CvtChildProcessManagerErrCode(ChildProcessManagerErrorCode cpmErr)
|
||||
|
||||
void OnNativeChildProcessStartedWapper(int errCode, OHIPCRemoteProxy *ipcProxy)
|
||||
{
|
||||
std::unique_lock autoLock(g_MutexCallBackObj);
|
||||
std::unique_lock autoLock(g_mutexCallBackObj);
|
||||
if (g_Callback != nullptr) {
|
||||
g_Callback(CvtChildProcessManagerErrCode(static_cast<ChildProcessManagerErrorCode>(errCode)), ipcProxy);
|
||||
g_Callback = nullptr;
|
||||
@ -80,7 +80,7 @@ int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNative
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
std::unique_lock autoLock(g_MutexCallBackObj);
|
||||
std::unique_lock autoLock(g_mutexCallBackObj);
|
||||
if (g_Callback != nullptr || g_CallbackStub != nullptr) {
|
||||
TAG_LOGW(AAFwkTag::PROCESSMGR, "Another native process process starting, try again later");
|
||||
return NCP_ERR_BUSY;
|
||||
@ -100,5 +100,5 @@ int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNative
|
||||
|
||||
g_Callback = onProcessStarted;
|
||||
g_CallbackStub = callbackStub;
|
||||
return NCP_NOERROR;
|
||||
return NCP_NO_ERROR;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ bool CJRuntime::LoadCJAppLibrary(const AppLibPathVec& appLibPaths)
|
||||
void* handle = nullptr;
|
||||
for (const auto& libPath : appLibPaths) {
|
||||
for (auto& itor : std::filesystem::directory_iterator(libPath)) {
|
||||
// According to the convention, the names of Cangjie generated products must contain the following keywords
|
||||
// According to the convention, the names of cj generated products must contain the following keywords
|
||||
if (itor.path().string().find("ohos_app_cangjie") == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void ThrowError(napi_env env, const AbilityErrorCode& err)
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(err), GetErrorMsg(err)));
|
||||
}
|
||||
|
||||
void ThrowInvaildCallerError(napi_env env)
|
||||
void ThrowInvalidCallerError(napi_env env)
|
||||
{
|
||||
napi_throw(env, CreateJsError(env,
|
||||
static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_CALLER),
|
||||
|
@ -514,6 +514,11 @@ enum {
|
||||
* Result(2097251) not support twin.
|
||||
*/
|
||||
ERR_MULTI_APP_NOT_SUPPORTED,
|
||||
|
||||
/**
|
||||
* Result(2097252) for unlock screen failed in developer mode.
|
||||
*/
|
||||
ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -62,12 +62,19 @@ public:
|
||||
* @param bundleInfos resident process bundle infos.
|
||||
*/
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process OnRemoteDied
|
||||
* @param abilityTokens abilities in died process.
|
||||
*/
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override;
|
||||
|
||||
private:
|
||||
int32_t HandleOnAppStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleNotifyConfigurationChange(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleNotifyStartResidentProcess(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnAppRemoteDied(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AppStateCallbackFunc = int32_t (AppStateCallbackHost::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AppStateCallbackFunc> memberFuncMap_;
|
||||
|
@ -57,6 +57,12 @@ public:
|
||||
*/
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process OnRemoteDied
|
||||
* @param abilityTokens abilities in died process.
|
||||
*/
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
static inline BrokerDelegator<AppStateCallbackProxy> delegator_;
|
||||
|
@ -63,11 +63,18 @@ public:
|
||||
*/
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) {}
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process OnRemoteDied
|
||||
* @param abilityTokens abilities in died process.
|
||||
*/
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) {}
|
||||
|
||||
enum class Message {
|
||||
TRANSACT_ON_APP_STATE_CHANGED = 0,
|
||||
TRANSACT_ON_ABILITY_REQUEST_DONE,
|
||||
TRANSACT_ON_NOTIFY_CONFIG_CHANGE,
|
||||
TRANSACT_ON_NOTIFY_START_RESIDENT_PROCESS
|
||||
TRANSACT_ON_NOTIFY_START_RESIDENT_PROCESS,
|
||||
TRANSACT_ON_APP_REMOTE_DIED
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
@ -38,6 +38,8 @@ AppStateCallbackHost::AppStateCallbackHost()
|
||||
&AppStateCallbackHost::HandleNotifyConfigurationChange;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_START_RESIDENT_PROCESS)] =
|
||||
&AppStateCallbackHost::HandleNotifyStartResidentProcess;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_APP_REMOTE_DIED)] =
|
||||
&AppStateCallbackHost::HandleOnAppRemoteDied;
|
||||
}
|
||||
|
||||
AppStateCallbackHost::~AppStateCallbackHost()
|
||||
@ -87,6 +89,11 @@ void AppStateCallbackHost::NotifyStartResidentProcess(std::vector<AppExecFwk::Bu
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
}
|
||||
|
||||
void AppStateCallbackHost::OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
}
|
||||
|
||||
int32_t AppStateCallbackHost::HandleOnAppStateChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
@ -143,5 +150,25 @@ int32_t AppStateCallbackHost::HandleNotifyStartResidentProcess(MessageParcel &da
|
||||
NotifyStartResidentProcess(bundleInfos);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppStateCallbackHost::HandleOnAppRemoteDied(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::vector<sptr<IRemoteObject>> abilityTokens;
|
||||
int32_t infoSize = data.ReadInt32();
|
||||
if (infoSize > CYCLE_LIMIT) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "infoSize is too large");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
for (int32_t i = 0; i < infoSize; i++) {
|
||||
sptr<IRemoteObject> obj = data.ReadRemoteObject();
|
||||
if (!obj) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Read token failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
abilityTokens.emplace_back(obj);
|
||||
}
|
||||
OnAppRemoteDied(abilityTokens);
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -138,6 +138,35 @@ void AppStateCallbackProxy::NotifyStartResidentProcess(std::vector<AppExecFwk::B
|
||||
}
|
||||
}
|
||||
|
||||
void AppStateCallbackProxy::OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(abilityTokens.size())) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "write token size failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &token : abilityTokens) {
|
||||
if (!data.WriteRemoteObject(token.GetRefPtr())) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "write token failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto ret = SendTransactCmd(
|
||||
static_cast<uint32_t>(IAppStateCallback::Message::TRANSACT_ON_APP_REMOTE_DIED),
|
||||
data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AppStateCallbackProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
|
@ -33,8 +33,8 @@ enum class ChildProcessManagerErrorCode {
|
||||
ERR_GET_APP_MGR_START_PROCESS_FAILED = 7,
|
||||
ERR_UNSUPPORT_NATIVE_CHILD_PROCESS = 8,
|
||||
ERR_MAX_NATIVE_CHILD_PROCESSES = 9,
|
||||
ERR_NATIVE_CHILD_PROCESS_LOAD_LIB = 10,
|
||||
ERR_NATIVE_CHILD_PROCESS_CONNECT = 11,
|
||||
ERR_LIB_LOADING_FAILED = 10,
|
||||
ERR_CONNECTION_FAILED = 11,
|
||||
};
|
||||
|
||||
const std::map<ChildProcessManagerErrorCode, AbilityErrorCode> INTERNAL_ERR_CODE_MAP = {
|
||||
|
@ -24,7 +24,7 @@ namespace AbilityRuntime {
|
||||
|
||||
void ThrowError(napi_env env, int32_t errCode, const std::string& errorMsg = "");
|
||||
void ThrowError(napi_env env, const AbilityErrorCode& err);
|
||||
void ThrowInvaildCallerError(napi_env env);
|
||||
void ThrowInvalidCallerError(napi_env env);
|
||||
void ThrowTooFewParametersError(napi_env env);
|
||||
void ThrowInvalidNumParametersError(napi_env env);
|
||||
void ThrowNoPermissionError(napi_env env, const std::string& permission);
|
||||
|
@ -13,15 +13,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H
|
||||
#define OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H
|
||||
#ifndef OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H
|
||||
#define OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H
|
||||
|
||||
#include "ipc_cparcel.h"
|
||||
|
||||
/**
|
||||
* @addtogroup ChildProcess
|
||||
* @{
|
||||
*
|
||||
* @brief Provides the APIs to manage child processes.
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @since 12
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file native_child_process.h
|
||||
*
|
||||
* @brief Defines the functions for native child process management.
|
||||
* @brief Declares the APIs used to create a native child process and establish an IPC channel between the parent and
|
||||
* child processes.
|
||||
*
|
||||
* @library libchild_process.so
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @since 12
|
||||
@ -32,104 +44,128 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief native child process error code
|
||||
* @brief Enumerates the error codes used by the native child process module.
|
||||
* @since 12
|
||||
*/
|
||||
enum Ability_NativeChildProcess_ErrCode {
|
||||
typedef enum Ability_NativeChildProcess_ErrCode {
|
||||
/**
|
||||
* @error The operation completed successfully
|
||||
* @error Operation successful.
|
||||
*/
|
||||
NCP_NOERROR = 0,
|
||||
NCP_NO_ERROR = 0,
|
||||
|
||||
/**
|
||||
* @error Invalid param
|
||||
* @error Invalid parameter.
|
||||
*/
|
||||
NCP_ERR_INVALID_PARAM = 401,
|
||||
|
||||
/**
|
||||
* @error Unsupport start native process
|
||||
* @error Creating a native child process is not supported.
|
||||
*/
|
||||
NCP_ERR_NOT_SUPPORTED = 801,
|
||||
|
||||
/**
|
||||
* @error Internal error
|
||||
* @error Internal error.
|
||||
*/
|
||||
NCP_ERR_INTERNAL = 16000050,
|
||||
|
||||
/**
|
||||
* @error Can not start another during child process startup, try again after current child process started
|
||||
* @error A new child process cannot be created during the startup of another native child process.
|
||||
* You can try again after the child process is started.
|
||||
*/
|
||||
NCP_ERR_BUSY = 16010001,
|
||||
|
||||
/**
|
||||
* @error Start native child time out
|
||||
* @error Starting the native child process times out.
|
||||
*/
|
||||
NCP_ERR_TIMEOUT = 16010002,
|
||||
|
||||
/**
|
||||
* @error Service process error
|
||||
* @error Server error.
|
||||
*/
|
||||
NCP_ERR_SERVICE = 16010003,
|
||||
NCP_ERR_SERVICE_ERROR = 16010003,
|
||||
|
||||
/**
|
||||
* @error Multi process disabled, can not start child process
|
||||
* @error The multi-process mode is disabled. A child process cannot be started.
|
||||
*/
|
||||
NCP_ERR_MULTI_PROCESS_DISABLED = 16010004,
|
||||
|
||||
/**
|
||||
* @error Already in child process, only main process can start child
|
||||
* @error A process cannot be created in a child process.
|
||||
*/
|
||||
NCP_ERR_ALREADY_IN_CHILD = 16010005,
|
||||
|
||||
/**
|
||||
* @error Max native child processes reached, can not start another
|
||||
* @error The number of native child processes reaches the maximum.
|
||||
*/
|
||||
NCP_ERR_MAX_CHILD_PROCESSES_REACHED = 16010006,
|
||||
|
||||
/**
|
||||
* @error Child process load library failed
|
||||
* @error The child process fails to load the dynamic library because the file does not exist
|
||||
* or the corresponding method is not implemented or exported.
|
||||
*/
|
||||
NCP_ERR_CHILD_PROCESS_LOAD_LIB = 16010007,
|
||||
NCP_ERR_LIB_LOADING_FAILED = 16010007,
|
||||
|
||||
/**
|
||||
* @error Faild to invoke OnConnect method in library
|
||||
* @error The child process fails to call the OnConnect method of the dynamic library.
|
||||
* An invalid IPC object pointer may be returned.
|
||||
*/
|
||||
NCP_ERR_CHILD_PROCESS_CONNECT = 16010008,
|
||||
};
|
||||
NCP_ERR_CONNECTION_FAILED = 16010008,
|
||||
} Ability_NativeChildProcess_ErrCode;
|
||||
|
||||
|
||||
/**
|
||||
* @brief callback function for notify the child process start result, see <b>OH_Ability_CreateNativeChildProcess</b>
|
||||
* @brief Defines a callback function for notifying the child process startup result.
|
||||
*
|
||||
* @param errCode Zero if successful, an error otherwise, see <v>Ability_NativeChildProcess_ErrCode</b> for detail
|
||||
* @param remoteProxy IPC object implemented in the sharded lib loaded by child process; will be nullptr when failed
|
||||
* @param errCode Error code corresponding to the callback function. The following values are available:
|
||||
* {@link NCP_NO_ERROR} if the child process is created successfully.\n
|
||||
* {@link NCP_ERR_LIB_LOADING_FAILED} if loading the dynamic library file fails or the necessary export function
|
||||
* is not implemented in the dynamic library.\n
|
||||
* {@link NCP_ERR_CONNECTION_FAILED} if the OnConnect method implemented in the dynamic library does not return
|
||||
* a valid IPC stub pointer.\n
|
||||
* For details, see {@link Ability_NativeChildProcess_ErrCode}.
|
||||
* @param remoteProxy Pointer to the IPC object of the child process. If an exception occurs, the value may be nullptr.
|
||||
* The object must be released by calling {@link OH_IPCRemoteProxy_Destory} when it is no longer needed.
|
||||
* @see OH_Ability_CreateNativeChildProcess
|
||||
* @see OH_IPCRemoteProxy_Destory
|
||||
* @since 12
|
||||
*/
|
||||
typedef void (*OH_Ability_OnNativeChildProcessStarted)(int errCode, OHIPCRemoteProxy *remoteProxy);
|
||||
|
||||
/**
|
||||
* @brief Create native child process for app and load shared library specified by param,
|
||||
* process startup result is asynchronously notified via callback
|
||||
* Lib file must be implemented and exported follow functions:
|
||||
* 1. OHIPCRemoteStub* NativeChildProcess_OnConnect()
|
||||
* 2. void NativeChildProcess_MainProc()
|
||||
* @brief Creates a child process, loads the specified dynamic library file, and returns the startup result
|
||||
* asynchronously through a callback parameter.
|
||||
* The callback notification is an independent thread. When implementing the callback function,
|
||||
* pay attention to thread synchronization and do not perform time-consuming operations to avoid long-time blocking.
|
||||
*
|
||||
* Processing logic be like follows:
|
||||
* Main Process:
|
||||
* 1. Call OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback)
|
||||
* Child Process:
|
||||
* 2. dlopen(libName)
|
||||
* 3. dlsym("NativeChildProcess_OnConnect") & dlsym("NativeChildProcess_MainProc")
|
||||
* 4. ipcRemote = NativeChildProcess_OnConnect()
|
||||
* 5. NativeChildProcess_MainProc()
|
||||
* Main Process:
|
||||
* 6. onProcessStartedCallback(ipcRemote, errCode)
|
||||
* Child Process:
|
||||
* 7. Process exit after NativeChildProcess_MainProc() method returned
|
||||
* The dynamic library specified must implement and export the following functions:\n
|
||||
* 1. OHIPCRemoteStub* NativeChildProcess_OnConnect()\n
|
||||
* 2. void NativeChildProcess_MainProc()\n
|
||||
*
|
||||
* @param libName Name of the library file loaded by child process, can not be nullptr
|
||||
* @param onProcessStarted Callback for notify the child process start result
|
||||
* @return Zero if successful, an error otherwise, see <b>Ability_NativeChildProcess_ErrCode</b> for detail
|
||||
* The processing logic sequence is shown in the following pseudocode: \n
|
||||
* Main process: \n
|
||||
* 1. OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback)\n
|
||||
* Child process: \n
|
||||
* 2. dlopen(libName)\n
|
||||
* 3. dlsym("NativeChildProcess_OnConnect")\n
|
||||
* 4. dlsym("NativeChildProcess_MainProc")\n
|
||||
* 5. ipcRemote = NativeChildProcess_OnConnect()\n
|
||||
* 6. NativeChildProcess_MainProc()\n
|
||||
* Main process: \n
|
||||
* 7. onProcessStartedCallback(ipcRemote, errCode)\n
|
||||
* Child process: \n
|
||||
* 8. The child process exits after the NativeChildProcess_MainProc() function is returned. \n
|
||||
*
|
||||
* @param libName Name of the dynamic library file loaded in the child process. The value cannot be nullptr.
|
||||
* @param onProcessStarted Pointer to the callback function for notifying the child process startup result.
|
||||
* The value cannot be nullptr. For details, see {@link OH_Ability_OnNativeChildProcessStarted}.
|
||||
* @return Returns {@link NCP_NO_ERROR} if the call is successful, but the actual startup result is notified by the
|
||||
* callback function.\n
|
||||
* Returns {@link NCP_ERR_INVALID_PARAM} if the dynamic library name or callback function pointer is invalid.\n
|
||||
* Returns {@link NCP_ERR_NOT_SUPPORTED} if the device does not support the creation of native child processes.\n
|
||||
* Returns {@link NCP_ERR_MULTI_PROCESS_DISABLED} if the multi-process mode is disabled on the device.\n
|
||||
* Returns {@link NCP_ERR_ALREADY_IN_CHILD} if it is not allowed to create another child process in the child process.\n
|
||||
* Returns {@link NCP_ERR_MAX_CHILD_PROCESSES_REACHED} if the maximum number of native child processes is reached.\n
|
||||
* For details, see {@link Ability_NativeChildProcess_ErrCode}.
|
||||
* @see OH_Ability_OnNativeChildProcessStarted
|
||||
* @since 12
|
||||
*/
|
||||
@ -141,4 +177,5 @@ int OH_Ability_CreateNativeChildProcess(const char* libName,
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H
|
||||
/** @} */
|
||||
#endif // OHOS_ABILITY_RUNTIME_C_NATIVE_CHILD_PROCESS_H
|
||||
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_CJ_ABILITY_OBJECT_H
|
||||
#define OHOS_ABILITY_RUNTIME_CJ_ABILITY_OBJECT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ability.h"
|
||||
#include "cj_runtime.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#ifdef WINDOWS_PLATFORM
|
||||
#define CJ_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define CJ_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
using AbilityHandle = void*;
|
||||
using WantHandle = void*;
|
||||
using WindowStagePtr = void*;
|
||||
using VectorStringHandle = void*;
|
||||
|
||||
extern "C" {
|
||||
struct CJConfiguration {
|
||||
bool isValid;
|
||||
const char* language;
|
||||
int32_t colorMode;
|
||||
int32_t direction;
|
||||
int32_t screenDensity;
|
||||
int32_t displayId;
|
||||
};
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
struct CJLaunchParam {
|
||||
int32_t launchReason;
|
||||
int32_t lastExitReason;
|
||||
};
|
||||
|
||||
struct CJAbilityFuncs {
|
||||
int64_t (*cjAbilityCreate)(const char* name);
|
||||
void (*cjAbilityRelease)(int64_t id);
|
||||
void (*cjAbilityOnStart)(int64_t id, WantHandle want, CJLaunchParam launchParam);
|
||||
void (*cjAbilityOnStop)(int64_t id);
|
||||
void (*cjAbilityOnSceneCreated)(int64_t id, WindowStagePtr cjWindowStage);
|
||||
void (*cjAbilityOnSceneRestored)(int64_t id, WindowStagePtr cjWindowStage);
|
||||
void (*cjAbilityOnSceneDestroyed)(int64_t id);
|
||||
void (*cjAbilityOnForeground)(int64_t id, WantHandle want);
|
||||
void (*cjAbilityOnBackground)(int64_t id);
|
||||
void (*cjAbilityOnConfigurationUpdated)(int64_t id, CJConfiguration configuration);
|
||||
void (*cjAbilityOnNewWant)(int64_t id, WantHandle want, CJLaunchParam launchParam);
|
||||
VectorStringHandle (*cjAbilityDump)(int64_t id, VectorStringHandle params);
|
||||
int32_t (*cjAbilityOnContinue)(int64_t id, const char* params);
|
||||
void (*cjAbilityInit)(int64_t id, void* ability);
|
||||
};
|
||||
|
||||
CJ_EXPORT void RegisterCJAbilityFuncs(void (*registerFunc)(CJAbilityFuncs*));
|
||||
}
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
namespace Rosen {
|
||||
class CJWindowStageImpl;
|
||||
}
|
||||
|
||||
namespace AbilityRuntime {
|
||||
class CJAbilityObject {
|
||||
public:
|
||||
static std::shared_ptr<CJAbilityObject> LoadModule(const std::string& name);
|
||||
|
||||
explicit CJAbilityObject(int64_t id) : id_(id) {}
|
||||
~CJAbilityObject();
|
||||
void OnStart(const AAFwk::Want& want, const AAFwk::LaunchParam& launchParam) const;
|
||||
void OnStop() const;
|
||||
void OnSceneCreated(OHOS::Rosen::CJWindowStageImpl* cjWindowStage) const;
|
||||
void OnSceneRestored(OHOS::Rosen::CJWindowStageImpl* cjWindowStage) const;
|
||||
void OnSceneDestroyed() const;
|
||||
void OnForeground(const AAFwk::Want& want) const;
|
||||
void OnBackground() const;
|
||||
void OnConfigurationUpdated(const std::shared_ptr<AppExecFwk::Configuration>& configuration) const;
|
||||
void OnNewWant(const AAFwk::Want& want, const AAFwk::LaunchParam& launchParam) const;
|
||||
void Dump(const std::vector<std::string>& params, std::vector<std::string>& info) const;
|
||||
int32_t OnContinue(AAFwk::WantParams &wantParams) const;
|
||||
void Init(AbilityHandle ability) const;
|
||||
|
||||
private:
|
||||
int64_t id_ = 0;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FOUNDATION_APPEXECFWK_OHOS_CJ_ABILITY_PROXY_H
|
@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_CJ_UI_ABILITY_H
|
||||
#define OHOS_ABILITY_RUNTIME_CJ_UI_ABILITY_H
|
||||
|
||||
#include "ability_delegator_infos.h"
|
||||
#include "freeze_util.h"
|
||||
#include "ui_ability.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "window_stage_impl.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
namespace AbilityRuntime {
|
||||
class CJRuntime;
|
||||
class CJAbilityObject;
|
||||
struct InsightIntentExecutorInfo;
|
||||
using AbilityHandler = AppExecFwk::AbilityHandler;
|
||||
using AbilityInfo = AppExecFwk::AbilityInfo;
|
||||
using OHOSApplication = AppExecFwk::OHOSApplication;
|
||||
using Want = AppExecFwk::Want;
|
||||
using AbilityStartSetting = AppExecFwk::AbilityStartSetting;
|
||||
using Configuration = AppExecFwk::Configuration;
|
||||
using InsightIntentExecuteResult = AppExecFwk::InsightIntentExecuteResult;
|
||||
using InsightIntentExecuteParam = AppExecFwk::InsightIntentExecuteParam;
|
||||
using InsightIntentExecutorAsyncCallback = AppExecFwk::InsightIntentExecutorAsyncCallback;
|
||||
|
||||
class CJUIAbility : public UIAbility {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a JsUIAbility instance through the singleton pattern
|
||||
* @param runtime The runtime of the ability
|
||||
* @return Returns the JsUIability Instance point
|
||||
*/
|
||||
static UIAbility *Create(const std::unique_ptr<Runtime> &runtime);
|
||||
|
||||
explicit CJUIAbility(CJRuntime &cjRuntime);
|
||||
~CJUIAbility() override;
|
||||
|
||||
/**
|
||||
* @brief Init the UIability
|
||||
* @param abilityInfo Indicate the Ability information
|
||||
* @param ohosAppObject Indicates the main process
|
||||
* @param handler the UIability EventHandler object
|
||||
* @param token the remote token
|
||||
*/
|
||||
void Init(std::shared_ptr<AppExecFwk::AbilityLocalRecord> record,
|
||||
const std::shared_ptr<OHOSApplication> application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token) override;
|
||||
|
||||
/**
|
||||
* @brief OnStart,Start JsUIability
|
||||
* @param want Indicates the {@link Want} structure containing startup information about the ability
|
||||
* @param sessionInfo Indicates the sessionInfo
|
||||
*/
|
||||
void OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo = nullptr) override;
|
||||
|
||||
/**
|
||||
* @brief Called when this ability enters the <b>STATE_STOP</b> state.
|
||||
* The ability in the <b>STATE_STOP</b> is being destroyed.
|
||||
* You can override this function to implement your own processing logic.
|
||||
*/
|
||||
void OnStop() override;
|
||||
|
||||
/**
|
||||
* @brief Called when this ability enters the <b>STATE_STOP</b> state.
|
||||
* The ability in the <b>STATE_STOP</b> is being destroyed.
|
||||
* You can override this function to implement your own processing logic.
|
||||
* @param callbackInfo Indicates the lifecycle transaction callback information
|
||||
* @param isAsyncCallback Indicates whether it is an asynchronous lifecycle callback
|
||||
*/
|
||||
void OnStop(AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInfo, bool &isAsyncCallback) override;
|
||||
|
||||
/**
|
||||
* @brief The callback of OnStop.
|
||||
*/
|
||||
void OnStopCallback() override;
|
||||
|
||||
/**
|
||||
* @brief Prepare user data of local Ability.
|
||||
* @param wantParams Indicates the user data to be saved.
|
||||
* @return If the ability is willing to continue and data saved successfully, it returns 0;
|
||||
* otherwise, it returns errcode.
|
||||
*/
|
||||
int32_t OnContinue(WantParams &wantParams) override;
|
||||
|
||||
/**
|
||||
* @brief Update configuration
|
||||
* @param configuration Indicates the updated configuration information.
|
||||
*/
|
||||
void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
|
||||
/**
|
||||
* @brief Update Contextconfiguration
|
||||
*/
|
||||
void UpdateContextConfiguration() override;
|
||||
|
||||
/**
|
||||
* @brief Called when the system configuration is updated.
|
||||
* @param level Indicates the memory trim level, which shows the current memory usage status.
|
||||
*/
|
||||
void OnMemoryLevel(int level) override;
|
||||
|
||||
/**
|
||||
* @brief Called when the launch mode of an ability is set to singleInstance. This happens when you re-launch an
|
||||
* ability that has been at the top of the ability stack.
|
||||
* @param want Indicates the new Want containing information about the ability.
|
||||
*/
|
||||
void OnNewWant(const Want &want) override;
|
||||
|
||||
/**
|
||||
* @brief Prepare user data of local Ability.
|
||||
* @param reason the reason why framework invoke this function
|
||||
* @param wantParams Indicates the user data to be saved.
|
||||
* @return result code defined in abilityConstants
|
||||
*/
|
||||
int32_t OnSaveState(int32_t reason, WantParams &wantParams) override;
|
||||
|
||||
/**
|
||||
* @brief Called when startAbilityForResult(ohos.aafwk.content.Want,int) is called to start an ability and the
|
||||
* result is returned. This method is called only on Page abilities. You can start a new ability to perform some
|
||||
* calculations and use setResult (int,ohos.aafwk.content.Want) to return the calculation result. Then the system
|
||||
* calls back the current method to use the returned data to execute its own logic.
|
||||
* @param requestCode Indicates the request code returned after the ability is started. You can define the request
|
||||
* code to identify the results returned by abilities. The value ranges from 0 to 65535.
|
||||
* @param resultCode Indicates the result code returned after the ability is started. You can define the result code
|
||||
* to identify an error.
|
||||
* @param want Indicates the data returned after the ability is started. You can define the data returned. The
|
||||
* value can be null.
|
||||
*/
|
||||
void OnAbilityResult(int requestCode, int resultCode, const Want &resultData) override;
|
||||
|
||||
/**
|
||||
* @brief request a remote object of callee from this ability.
|
||||
* @return Returns the remote object of callee.
|
||||
*/
|
||||
sptr<IRemoteObject> CallRequest() override;
|
||||
|
||||
/**
|
||||
* @brief dump ability info
|
||||
* @param params dump params that indicate different dump targets
|
||||
* @param info dump ability info
|
||||
*/
|
||||
void Dump(const std::vector<std::string> ¶ms, std::vector<std::string> &info) override;
|
||||
|
||||
std::shared_ptr<CJAbilityObject> GetCJAbility();
|
||||
|
||||
/**
|
||||
* @brief Callback when the ability is shared.You can override this function to implement your own sharing logic.
|
||||
* @param wantParams Indicates the user data to be saved.
|
||||
* @return the result of OnShare
|
||||
*/
|
||||
int32_t OnShare(WantParams &wantParams) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
/**
|
||||
* @brief Called after instantiating WindowScene.
|
||||
* You can override this function to implement your own processing logic.
|
||||
*/
|
||||
void OnSceneCreated() override;
|
||||
|
||||
/**
|
||||
* @brief Called after ability stoped.
|
||||
* You can override this function to implement your own processing logic.
|
||||
*/
|
||||
void OnSceneDestroyed() ;
|
||||
|
||||
/**
|
||||
* @brief Called after ability restored.
|
||||
* You can override this function to implement your own processing logic.
|
||||
*/
|
||||
void OnSceneRestored() override;
|
||||
|
||||
/**
|
||||
* @brief Called when this ability enters the <b>STATE_FOREGROUND</b> state.
|
||||
* The ability in the <b>STATE_FOREGROUND</b> state is visible.
|
||||
* You can override this function to implement your own processing logic.
|
||||
*/
|
||||
void OnForeground(const Want &want) override;
|
||||
|
||||
/**
|
||||
* @brief Call "onForeground" js function barely.
|
||||
*
|
||||
* @param want Want
|
||||
*/
|
||||
void CallOnForegroundFunc(const Want &want) override;
|
||||
|
||||
/**
|
||||
* @brief Request focus for current window, can be override.
|
||||
*
|
||||
* @param want Want
|
||||
*/
|
||||
void RequestFocus(const Want &want) override;
|
||||
|
||||
/**
|
||||
* @brief Called when this ability enters the <b>STATE_BACKGROUND</b> state.
|
||||
* The ability in the <b>STATE_BACKGROUND</b> state is invisible.
|
||||
* You can override this function to implement your own processing logic.
|
||||
*/
|
||||
void OnBackground() override;
|
||||
|
||||
/**
|
||||
* Called when back press is dispatched.
|
||||
* Return true if ability will be moved to background; return false if will be terminated
|
||||
*/
|
||||
bool OnBackPress() override;
|
||||
|
||||
/**
|
||||
* @brief Called when ability prepare terminate.
|
||||
* @return Return true if ability need to stop terminating; return false if ability need to terminate.
|
||||
*/
|
||||
bool OnPrepareTerminate() override;
|
||||
|
||||
/**
|
||||
* @brief Get CJWindow Stage
|
||||
* @return Returns the current CJWindowStage
|
||||
*/
|
||||
std::shared_ptr<Rosen::CJWindowStageImpl> GetCJWindowStage();
|
||||
|
||||
/**
|
||||
* @brief Get CJRuntime
|
||||
* @return Returns the current CJRuntime
|
||||
*/
|
||||
const CJRuntime &GetCJRuntime();
|
||||
|
||||
/**
|
||||
* @brief Execute insight intention when an ability is in foreground, schedule it to foreground repeatly.
|
||||
*
|
||||
* @param want Want.
|
||||
* @param executeParam insight intention execute param.
|
||||
* @param callback insight intention async callback.
|
||||
*/
|
||||
void ExecuteInsightIntentRepeateForeground(const Want &want,
|
||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback) override;
|
||||
|
||||
/**
|
||||
* @brief Execute insight intention when an ability didn't started or in background, schedule it to foreground.
|
||||
*
|
||||
* @param want Want.
|
||||
* @param executeParam insight intention execute param.
|
||||
* @param callback insight intention async callback.
|
||||
*/
|
||||
void ExecuteInsightIntentMoveToForeground(const Want &want,
|
||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback) override;
|
||||
|
||||
protected:
|
||||
void DoOnForeground(const Want &want) override;
|
||||
void ContinuationRestore(const Want &want) override;
|
||||
|
||||
private:
|
||||
bool IsRestorePageStack(const Want &want);
|
||||
void RestorePageStack(const Want &want);
|
||||
void GetPageStackFromWant(const Want &want, std::string &pageStack);
|
||||
void AbilityContinuationOrRecover(const Want &want);
|
||||
inline bool GetInsightIntentExecutorInfo(const Want &want,
|
||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||
InsightIntentExecutorInfo& executeInfo);
|
||||
|
||||
std::shared_ptr<Rosen::CJWindowStageImpl> cjWindowStage_;
|
||||
int32_t windowMode_ = 0;
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::shared_ptr<AppExecFwk::ADelegatorAbilityProperty> CreateADelegatorAbilityProperty();
|
||||
sptr<IRemoteObject> SetNewRuleFlagToCallee(napi_env env, napi_value remoteJsObj);
|
||||
void SetAbilityContext(const std::shared_ptr<AbilityInfo> &abilityInfo);
|
||||
void InitSceneDoOnForeground(std::shared_ptr<Rosen::WindowScene> scene, const Want &want);
|
||||
void AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState state, const std::string &methodName) const;
|
||||
void AddLifecycleEventAfterCall(FreezeUtil::TimeoutState state, const std::string &methodName) const;
|
||||
|
||||
CJRuntime &cjRuntime_;
|
||||
std::shared_ptr<CJAbilityObject> cjAbilityObj_;
|
||||
sptr<IRemoteObject> remoteCallee_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_CJ_UI_ABILITY_H
|
@ -119,8 +119,8 @@ protected:
|
||||
std::shared_ptr<NapiAsyncTask> asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions);
|
||||
void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
|
||||
NapiAsyncTask::CompleteCallback& complete);
|
||||
bool CheckStartAbilityByTypeParam(napi_env env, NapiCallbackInfo& info, std::string type,
|
||||
AAFwk::WantParams wantParam);
|
||||
bool CheckStartAbilityByTypeParam(napi_env env, NapiCallbackInfo& info, std::string& type,
|
||||
AAFwk::WantParams& wantParam);
|
||||
|
||||
private:
|
||||
sptr<AAFwk::SessionInfo> sessionInfo_;
|
||||
|
@ -31,6 +31,7 @@ config("abilityms_config") {
|
||||
include_dirs = [
|
||||
"include/",
|
||||
"include/rdb/",
|
||||
"include/screen_lock/",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
"${ability_runtime_services_path}/appdfr/include",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include",
|
||||
@ -204,7 +205,10 @@ ohos_shared_library("abilityms") {
|
||||
external_deps += [ "dlp_permission_service:libdlp_permission_sdk" ]
|
||||
}
|
||||
|
||||
defines = []
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines += [ "SUPPORT_GRAPHICS" ]
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"i18n:intl_util",
|
||||
@ -212,6 +216,7 @@ ohos_shared_library("abilityms") {
|
||||
"image_framework:image_native",
|
||||
"input:libmmi-client",
|
||||
"resource_management:global_resmgr",
|
||||
"screenlock_mgr:screenlock_client",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libmodal_system_ui_extension_client",
|
||||
"window_manager:libwm",
|
||||
@ -221,6 +226,11 @@ ohos_shared_library("abilityms") {
|
||||
]
|
||||
}
|
||||
|
||||
if (ability_runtime_power) {
|
||||
defines += [ "SUPPORT_POWER" ]
|
||||
external_deps += [ "power_manager:powermgr_client" ]
|
||||
}
|
||||
|
||||
version_script = "libabilityms.map"
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
|
@ -14,7 +14,6 @@
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
abilityms_files = [
|
||||
"src/ability_app_state_observer.cpp",
|
||||
"src/preload_uiext_state_observer.cpp",
|
||||
"src/ability_background_connection.cpp",
|
||||
"src/ability_connect_manager.cpp",
|
||||
@ -80,6 +79,7 @@ abilityms_files = [
|
||||
"src/extension_record_factory.cpp",
|
||||
"src/ui_extension_record.cpp",
|
||||
"src/ui_extension_record_factory.cpp",
|
||||
"src/screen_lock/unlock_screen_manager.cpp",
|
||||
"src/start_options.cpp",
|
||||
"src/user_callback_proxy.cpp",
|
||||
"src/call_container.cpp",
|
||||
@ -140,6 +140,7 @@ if (ability_runtime_graphics) {
|
||||
"src/implicit_start_processor.cpp",
|
||||
"src/system_dialog_scheduler.cpp",
|
||||
"src/ability_first_frame_state_observer_manager.cpp",
|
||||
"src/screen_lock/unlock_screen_callback.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_ABILITY_APP_STATE_OBSERVER_H
|
||||
#define OHOS_ABILITY_RUNTIME_ABILITY_APP_STATE_OBSERVER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "application_state_observer_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class AbilityRecord;
|
||||
class AbilityAppStateObserver : public AppExecFwk::ApplicationStateObserverStub {
|
||||
public:
|
||||
AbilityAppStateObserver(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
virtual void OnProcessDied(const AppExecFwk::ProcessData &processData) override;
|
||||
|
||||
private:
|
||||
std::weak_ptr<AbilityRecord> abilityRecord_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_ABILITY_APP_STATE_OBSERVER_H
|
@ -1752,6 +1752,8 @@ protected:
|
||||
|
||||
void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
|
||||
|
||||
void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override;
|
||||
|
||||
private:
|
||||
int TerminateAbilityWithFlag(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE,
|
||||
const Want *resultWant = nullptr, bool flag = true);
|
||||
|
@ -57,7 +57,6 @@ class ConnectionRecord;
|
||||
class Mission;
|
||||
class MissionList;
|
||||
class CallContainer;
|
||||
class AbilityAppStateObserver;
|
||||
|
||||
constexpr const char* ABILITY_TOKEN_NAME = "AbilityToken";
|
||||
constexpr const char* LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
|
||||
@ -1001,7 +1000,6 @@ private:
|
||||
*/
|
||||
void GetAbilityTypeString(std::string &typeStr);
|
||||
void OnSchedulerDied(const wptr<IRemoteObject> &remote);
|
||||
void RemoveAppStateObserver(bool force = false);
|
||||
void GrantUriPermission(Want &want, std::string targetBundleName, bool isSandboxApp, uint32_t tokenId);
|
||||
void GrantDmsUriPermission(Want &want, std::string targetBundleName);
|
||||
bool IsDmsCall(Want &want);
|
||||
@ -1177,7 +1175,6 @@ private:
|
||||
// scene session
|
||||
sptr<SessionInfo> sessionInfo_ = nullptr;
|
||||
mutable ffrt::mutex sessionLock_;
|
||||
sptr<AbilityAppStateObserver> abilityAppStateObserver_;
|
||||
std::map<uint64_t, AbilityWindowState> abilityWindowStateMap_;
|
||||
sptr<SessionInfo> uiExtRequestSessionInfo_ = nullptr;
|
||||
|
||||
|
@ -93,6 +93,8 @@ public:
|
||||
virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) {}
|
||||
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) {}
|
||||
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) {}
|
||||
};
|
||||
|
||||
class StartSpecifiedAbilityResponse : public AppExecFwk::StartSpecifiedAbilityResponseStub {
|
||||
@ -461,6 +463,8 @@ protected:
|
||||
*/
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
|
||||
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override;
|
||||
|
||||
private:
|
||||
std::mutex lock_;
|
||||
bool isInit_ {false};
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
||||
#define OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "screenlock_manager.h"
|
||||
#include "screenlock_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class UnlockScreenCallback : public ScreenLock::ScreenLockCallbackStub {
|
||||
public:
|
||||
explicit UnlockScreenCallback();
|
||||
~UnlockScreenCallback() override;
|
||||
void OnCallBack(const int32_t screenLockResult) override;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
||||
#define OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
||||
|
||||
#include "nocopyable.h"
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
#include "power_mgr_client.h"
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "unlock_screen_callback.h"
|
||||
#include "screenlock_manager.h"
|
||||
#include "screenlock_common.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class UnlockScreenManager {
|
||||
public:
|
||||
static UnlockScreenManager &GetInstance();
|
||||
~UnlockScreenManager();
|
||||
bool UnlockScreen();
|
||||
private:
|
||||
UnlockScreenManager();
|
||||
DISALLOW_COPY_AND_MOVE(UnlockScreenManager);
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_MANAGER_H
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 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.
|
||||
*/
|
||||
|
||||
#include "ability_app_state_observer.h"
|
||||
#include "ability_record.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
AbilityAppStateObserver::AbilityAppStateObserver(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
: abilityRecord_(abilityRecord) {}
|
||||
void AbilityAppStateObserver::OnProcessDied(const AppExecFwk::ProcessData &processData)
|
||||
{
|
||||
auto abilityRecord = abilityRecord_.lock();
|
||||
if (abilityRecord) {
|
||||
const auto &abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
if (abilityInfo.bundleName == processData.bundleName &&
|
||||
processData.processType == AppExecFwk::ProcessType::NORMAL &&
|
||||
abilityInfo.type == AppExecFwk::AbilityType::PAGE) {
|
||||
abilityRecord->OnProcessDied();
|
||||
}
|
||||
if (abilityRecord->IsSceneBoard() && abilityRecord->GetPid() == processData.pid) {
|
||||
abilityRecord->OnProcessDied();
|
||||
}
|
||||
} else {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "AbilityRecord null");
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -101,6 +101,7 @@
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "extension_record_manager.h"
|
||||
#include "ui_extension_utils.h"
|
||||
#include "unlock_screen_manager.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
#include "uri_utils.h"
|
||||
#include "view_data.h"
|
||||
@ -538,6 +539,10 @@ int AbilityManagerService::StartAbility(const Want &want, int32_t userId, int re
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Developer Mode is false.");
|
||||
return ERR_NOT_DEVELOPER_MODE;
|
||||
}
|
||||
if (!UnlockScreenManager::GetInstance().UnlockScreen()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Screen need passord to unlock");
|
||||
return ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "coldStart:%{public}d", want.GetBoolParam("coldStart", false));
|
||||
bool startWithAccount = want.GetBoolParam(START_ABILITY_TYPE, false);
|
||||
if (startWithAccount || IsCrossUserCall(userId)) {
|
||||
@ -1201,6 +1206,10 @@ int AbilityManagerService::StartAbilityDetails(const Want &want, const AbilitySt
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Developer Mode is false.");
|
||||
return ERR_NOT_DEVELOPER_MODE;
|
||||
}
|
||||
if (!UnlockScreenManager::GetInstance().UnlockScreen()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Screen need passord to unlock");
|
||||
return ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE;
|
||||
}
|
||||
AbilityUtil::RemoveWantKey(const_cast<Want &>(want));
|
||||
StartAbilityParams startParams(const_cast<Want &>(want));
|
||||
startParams.callerToken = callerToken;
|
||||
@ -9892,6 +9901,20 @@ void AbilityManagerService::NotifyStartResidentProcess(std::vector<AppExecFwk::B
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityManagerService::OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens)
|
||||
{
|
||||
std::shared_ptr<AbilityRecord> abilityRecord;
|
||||
for (auto &token : abilityTokens) {
|
||||
abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
if (abilityRecord == nullptr) {
|
||||
continue;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "App OnRemoteDied, ability is %{public}s, app is %{public}s",
|
||||
abilityRecord->GetAbilityInfo().name.c_str(), abilityRecord->GetAbilityInfo().bundleName.c_str());
|
||||
abilityRecord->OnProcessDied();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::OpenFile(const Uri& uri, uint32_t flag)
|
||||
{
|
||||
auto accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
|
@ -1488,13 +1488,13 @@ int AbilityManagerStub::ContinueMissionOfBundleNameInner(MessageParcel &data, Me
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
std::unique_ptr<WantParams> wantParams(data.ReadParcelable<WantParams>());
|
||||
continueMissionInfo.wantParams = *wantParams;
|
||||
continueMissionInfo.srcBundleName = data.ReadString();
|
||||
continueMissionInfo.continueType = data.ReadString();
|
||||
if (wantParams == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "ContinueMissionInner wantParams readParcelable failed!");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
continueMissionInfo.wantParams = *wantParams;
|
||||
continueMissionInfo.srcBundleName = data.ReadString();
|
||||
continueMissionInfo.continueType = data.ReadString();
|
||||
int32_t result = ContinueMission(continueMissionInfo, callback);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "ContinueMissionInner result = %{public}d", result);
|
||||
return result;
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include "constants.h"
|
||||
#include "ability_app_state_observer.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_resident_process_rdb.h"
|
||||
@ -248,7 +247,6 @@ AbilityRecord::~AbilityRecord()
|
||||
}
|
||||
}
|
||||
want_.CloseAllFd();
|
||||
RemoveAppStateObserver(true);
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRecord> AbilityRecord::CreateAbilityRecord(const AbilityRequest &abilityRequest)
|
||||
@ -275,30 +273,9 @@ std::shared_ptr<AbilityRecord> AbilityRecord::CreateAbilityRecord(const AbilityR
|
||||
abilityRecord->collaboratorType_ = abilityRequest.collaboratorType;
|
||||
abilityRecord->missionAffinity_ = abilityRequest.want.GetStringParam(PARAM_MISSION_AFFINITY_KEY);
|
||||
|
||||
// Before the ability attaches
|
||||
abilityRecord->abilityAppStateObserver_ = sptr<AbilityAppStateObserver>(
|
||||
new AbilityAppStateObserver(abilityRecord));
|
||||
DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->RegisterApplicationStateObserver(
|
||||
abilityRecord->abilityAppStateObserver_, {abilityRequest.abilityInfo.bundleName});
|
||||
return abilityRecord;
|
||||
}
|
||||
|
||||
void AbilityRecord::RemoveAppStateObserver(bool force)
|
||||
{
|
||||
if (!force && IsSceneBoard()) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Special ability no need to RemoveAppStateObserver.");
|
||||
return;
|
||||
}
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler && abilityAppStateObserver_) {
|
||||
handler->SubmitTask([appStateObserver = abilityAppStateObserver_]() {
|
||||
DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->UnregisterApplicationStateObserver(
|
||||
appStateObserver);
|
||||
});
|
||||
abilityAppStateObserver_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool AbilityRecord::Init()
|
||||
{
|
||||
lifecycleDeal_ = std::make_unique<LifecycleDeal>();
|
||||
@ -1432,7 +1409,6 @@ void AbilityRecord::SetScheduler(const sptr<IAbilityScheduler> &scheduler)
|
||||
}
|
||||
});
|
||||
}
|
||||
RemoveAppStateObserver();
|
||||
isReady_ = true;
|
||||
scheduler_ = scheduler;
|
||||
lifecycleDeal_->SetScheduler(scheduler);
|
||||
@ -2408,7 +2384,10 @@ void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
void AbilityRecord::OnProcessDied()
|
||||
{
|
||||
std::lock_guard<ffrt::mutex> guard(lock_);
|
||||
RemoveAppStateObserver(true);
|
||||
if (!IsSceneBoard() && scheduler_ != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "OnProcessDied: '%{public}s', attached.", abilityInfo_.name.c_str());
|
||||
return;
|
||||
}
|
||||
isWindowAttached_ = false;
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
|
@ -239,6 +239,13 @@ void AppScheduler::NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo
|
||||
callback->NotifyStartResidentProcess(bundleInfos);
|
||||
}
|
||||
|
||||
void AppScheduler::OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens)
|
||||
{
|
||||
auto callback = callback_.lock();
|
||||
CHECK_POINTER(callback);
|
||||
callback->OnAppRemoteDied(abilityTokens);
|
||||
}
|
||||
|
||||
int AppScheduler::KillApplication(const std::string &bundleName)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "[%{public}s(%{public}s)] enter", __FILE__, __FUNCTION__);
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "unlock_screen_callback.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
UnlockScreenCallback::~UnlockScreenCallback() {}
|
||||
|
||||
UnlockScreenCallback::UnlockScreenCallback() {}
|
||||
|
||||
void UnlockScreenCallback::OnCallBack(const int32_t screenLockResult)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Unlock Screen result is %{public}d", screenLockResult);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#include "unlock_screen_manager.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#include "parameters.h"
|
||||
#include "permission_verification.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
constexpr char DEVELOPER_MODE_STATE[] = "const.security.developermode.state";
|
||||
}
|
||||
|
||||
UnlockScreenManager::~UnlockScreenManager() {}
|
||||
|
||||
UnlockScreenManager::UnlockScreenManager() {}
|
||||
|
||||
UnlockScreenManager &UnlockScreenManager::GetInstance()
|
||||
{
|
||||
static UnlockScreenManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool UnlockScreenManager::UnlockScreen()
|
||||
{
|
||||
bool isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
bool isDeveloperMode = system::GetBoolParameter(DEVELOPER_MODE_STATE, false);
|
||||
if (!isShellCall) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "not aa start call, just start ability");
|
||||
return true;
|
||||
}
|
||||
if (!isDeveloperMode) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "not devlop mode, just start ability");
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
bool isScreenLocked = OHOS::ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked();
|
||||
bool isScreenSecured = OHOS::ScreenLock::ScreenLockManager::GetInstance()->GetSecure();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "isScreenLocked: %{public}d, isScreenSecured: %{public}d",
|
||||
isScreenLocked, isScreenSecured);
|
||||
if (isScreenLocked && isScreenSecured) {
|
||||
return false;
|
||||
}
|
||||
if (isScreenLocked) {
|
||||
sptr<UnlockScreenCallback> listener = sptr<UnlockScreenCallback>(new (std::nothrow) UnlockScreenCallback());
|
||||
IN_PROCESS_CALL(OHOS::ScreenLock::ScreenLockManager::GetInstance()->Unlock(
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool isScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "isScreenOn: %{public}d", isScreenOn);
|
||||
if (!isScreenOn) {
|
||||
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -542,12 +542,16 @@ public:
|
||||
|
||||
bool IsEmptyKeepAliveApp() const;
|
||||
|
||||
bool IsMainProcess() const;
|
||||
|
||||
void SetEmptyKeepAliveAppState(bool isEmptyKeepAliveApp);
|
||||
|
||||
void SetKeepAliveEnableState(bool isKeepAliveEnable);
|
||||
|
||||
void SetSingleton(bool isSingleton);
|
||||
|
||||
void SetMainProcess(bool isMainProcess);
|
||||
|
||||
void SetStageModelState(bool isStageBasedModel);
|
||||
|
||||
std::list<std::shared_ptr<ModuleRunningRecord>> GetAllModuleRecord() const;
|
||||
@ -849,6 +853,7 @@ private:
|
||||
|
||||
bool isKeepAliveApp_ = false; // Only resident processes can be set to true, please choose carefully
|
||||
bool isEmptyKeepAliveApp_ = false; // Only empty resident processes can be set to true, please choose carefully
|
||||
bool isMainProcess_ = true; // Only MainProcess can be keepalive
|
||||
bool isSingleton_ = false;
|
||||
bool isStageBasedModel_ = false;
|
||||
ApplicationState curState_ = ApplicationState::APP_STATE_CREATE; // current state of this process
|
||||
|
@ -104,6 +104,11 @@ public:
|
||||
*/
|
||||
explicit AppSpawnClient(bool isNWebSpawn = false);
|
||||
|
||||
/**
|
||||
* Constructor by service name
|
||||
*/
|
||||
explicit AppSpawnClient(const char* serviceName);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
|
@ -59,10 +59,13 @@ public:
|
||||
|
||||
std::shared_ptr<AppSpawnClient> GetNWebSpawnClient();
|
||||
|
||||
std::shared_ptr<AppSpawnClient> GetCJSpawnClient();
|
||||
|
||||
private:
|
||||
std::shared_ptr<AppSpawnClient> appSpawnClient_;
|
||||
std::shared_ptr<BundleMgrHelper> bundleManagerHelper_;
|
||||
std::shared_ptr<AppSpawnClient> nwebSpawnClient_;
|
||||
std::shared_ptr<AppSpawnClient> cjAppSpawnClient_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -217,6 +217,15 @@ int32_t GetUserIdByUid(int32_t uid)
|
||||
{
|
||||
return uid / BASE_USER_RANGE;
|
||||
}
|
||||
|
||||
bool isCjAbility(const std::string& info)
|
||||
{
|
||||
std::string cjCheckFlag = ".cj";
|
||||
if (info.length() < cjCheckFlag.length()) {
|
||||
return false;
|
||||
}
|
||||
return info.substr(info.length() - cjCheckFlag.length()) == cjCheckFlag;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
using OHOS::AppExecFwk::Constants::PERMISSION_GRANTED;
|
||||
@ -636,6 +645,7 @@ void AppMgrServiceInner::LoadAbilityNoAppRecord(const std::shared_ptr<AppRunning
|
||||
}
|
||||
if (hapModuleInfo.isStageBasedModel && !IsMainProcess(appInfo, hapModuleInfo)) {
|
||||
appRecord->SetEmptyKeepAliveAppState(false);
|
||||
appRecord->SetMainProcess(false);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "The process %{public}s will not keepalive", hapModuleInfo.process.c_str());
|
||||
}
|
||||
// As taskHandler_ is busy now, the task should be submit to other task queue.
|
||||
@ -2750,10 +2760,40 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
|
||||
return;
|
||||
};
|
||||
|
||||
bool findEntryHapModuleInfo = false;
|
||||
bool isCJApp = false;
|
||||
AppExecFwk::HapModuleInfo entryHapModuleInfo;
|
||||
if (!bundleInfo.hapModuleInfos.empty()) {
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
if (hapModuleInfo.moduleType == AppExecFwk::ModuleType::ENTRY) {
|
||||
findEntryHapModuleInfo = true;
|
||||
entryHapModuleInfo = hapModuleInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!findEntryHapModuleInfo) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "HandleLaunchApplication find entry hap module info failed!");
|
||||
entryHapModuleInfo = bundleInfo.hapModuleInfos.back();
|
||||
}
|
||||
if (!entryHapModuleInfo.abilityInfos.empty()) {
|
||||
isCJApp = isCjAbility(entryHapModuleInfo.abilityInfos.front().srcEntrance);
|
||||
}
|
||||
}
|
||||
|
||||
SetProcessJITState(appRecord);
|
||||
PerfProfile::GetInstance().SetAppForkStartTime(GetTickCount());
|
||||
pid_t pid = 0;
|
||||
ErrCode errCode = remoteClientManager_->GetSpawnClient()->StartProcess(startMsg, pid);
|
||||
ErrCode errCode = ERR_OK;
|
||||
if (isCJApp) {
|
||||
if (!remoteClientManager_->GetCJSpawnClient()) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "cj appSpawnClient is null");
|
||||
appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId());
|
||||
return;
|
||||
}
|
||||
errCode = remoteClientManager_->GetCJSpawnClient()->StartProcess(startMsg, pid);
|
||||
} else {
|
||||
errCode = remoteClientManager_->GetSpawnClient()->StartProcess(startMsg, pid);
|
||||
}
|
||||
if (FAILED(errCode)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed to spawn new app process, errCode %{public}08x", errCode);
|
||||
appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId());
|
||||
@ -3026,6 +3066,15 @@ void AppMgrServiceInner::OnRemoteDied(const wptr<IRemoteObject> &remote, bool is
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<sptr<IRemoteObject>> abilityTokens;
|
||||
for (const auto &token : appRecord->GetAbilities()) {
|
||||
abilityTokens.emplace_back(token.first);
|
||||
}
|
||||
for (const auto &callback : appStateCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAppRemoteDied(abilityTokens);
|
||||
}
|
||||
}
|
||||
ClearData(appRecord);
|
||||
}
|
||||
|
||||
@ -3777,6 +3826,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
|
||||
}
|
||||
if (hapModuleInfo.isStageBasedModel && !IsMainProcess(appInfo, hapModuleInfo)) {
|
||||
appRecord->SetEmptyKeepAliveAppState(false);
|
||||
appRecord->SetMainProcess(false);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "The process %{public}s will not keepalive", hapModuleInfo.process.c_str());
|
||||
}
|
||||
auto wantPtr = std::make_shared<AAFwk::Want>(want);
|
||||
|
@ -1370,7 +1370,7 @@ bool AppRunningRecord::IsTerminating()
|
||||
|
||||
bool AppRunningRecord::IsKeepAliveApp() const
|
||||
{
|
||||
return isKeepAliveApp_ && isSingleton_;
|
||||
return isKeepAliveApp_ && isSingleton_ && isMainProcess_;
|
||||
}
|
||||
|
||||
void AppRunningRecord::SetKeepAliveEnableState(bool isKeepAliveEnable)
|
||||
@ -1388,6 +1388,16 @@ void AppRunningRecord::SetEmptyKeepAliveAppState(bool isEmptyKeepAliveApp)
|
||||
isEmptyKeepAliveApp_ = isEmptyKeepAliveApp;
|
||||
}
|
||||
|
||||
bool AppRunningRecord::IsMainProcess() const
|
||||
{
|
||||
return isMainProcess_;
|
||||
}
|
||||
|
||||
void AppRunningRecord::SetMainProcess(bool isMainProcess)
|
||||
{
|
||||
isMainProcess_ = isMainProcess;
|
||||
}
|
||||
|
||||
void AppRunningRecord::SetSingleton(bool isSingleton)
|
||||
{
|
||||
isSingleton_ = isSingleton;
|
||||
|
@ -48,6 +48,23 @@ AppSpawnClient::AppSpawnClient(bool isNWebSpawn)
|
||||
state_ = SpawnConnectionState::STATE_NOT_CONNECT;
|
||||
}
|
||||
|
||||
AppSpawnClient::AppSpawnClient(const char* serviceName)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "AppspawnCreateClient");
|
||||
std::string serviceName__ = serviceName;
|
||||
if (serviceName__ == APPSPAWN_SERVER_NAME) {
|
||||
serviceName_ = APPSPAWN_SERVER_NAME;
|
||||
} else if (serviceName__ == CJAPPSPAWN_SERVER_NAME) {
|
||||
serviceName_ = CJAPPSPAWN_SERVER_NAME;
|
||||
} else if (serviceName__ == NWEBSPAWN_SERVER_NAME) {
|
||||
serviceName_ = NWEBSPAWN_SERVER_NAME;
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "unknown service name");
|
||||
serviceName_ = NWEBSPAWN_SERVER_NAME;
|
||||
}
|
||||
state_ = SpawnConnectionState::STATE_NOT_CONNECT;
|
||||
}
|
||||
|
||||
AppSpawnClient::~AppSpawnClient()
|
||||
{
|
||||
CloseConnection();
|
||||
|
@ -24,7 +24,8 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
RemoteClientManager::RemoteClientManager()
|
||||
: appSpawnClient_(std::make_shared<AppSpawnClient>()), nwebSpawnClient_(std::make_shared<AppSpawnClient>(true))
|
||||
: appSpawnClient_(std::make_shared<AppSpawnClient>()), nwebSpawnClient_(std::make_shared<AppSpawnClient>(true)),
|
||||
cjAppSpawnClient_(std::make_shared<AppSpawnClient>("cjappspawn"))
|
||||
{}
|
||||
|
||||
RemoteClientManager::~RemoteClientManager()
|
||||
@ -60,5 +61,13 @@ std::shared_ptr<AppSpawnClient> RemoteClientManager::GetNWebSpawnClient()
|
||||
{
|
||||
return nwebSpawnClient_;
|
||||
}
|
||||
|
||||
std::shared_ptr<AppSpawnClient> RemoteClientManager::GetCJSpawnClient()
|
||||
{
|
||||
if (cjAppSpawnClient_) {
|
||||
return cjAppSpawnClient_;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -357,6 +357,7 @@ group("unittest") {
|
||||
"ability_scheduler_proxy_test:unittest",
|
||||
"ability_scheduler_stub_test:unittest",
|
||||
"ability_service_extension_test:unittest",
|
||||
"ability_service_log_test:unittest",
|
||||
"ability_service_start_test:unittest",
|
||||
"ability_timeout_test",
|
||||
"ability_token_proxy_test:unittest",
|
||||
|
@ -945,6 +945,54 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartExtensionAbilityInner_0
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RequestModalUIExtensionInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RequestModalUIExtensionInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RequestModalUIExtensionInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RequestModalUIExtensionInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RequestModalUIExtensionInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: PreloadUIExtensionAbilityInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService PreloadUIExtensionAbilityInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function PreloadUIExtensionAbilityInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_PreloadUIExtensionAbilityInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->PreloadUIExtensionAbilityInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: StartUIExtensionAbilityInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService StartUIExtensionAbilityInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function StartUIExtensionAbilityInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartUIExtensionAbilityInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->StartUIExtensionAbilityInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: StopExtensionAbilityInner
|
||||
@ -1073,6 +1121,22 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ConnectAbilityWithTypeInner_
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ConnectUIExtensionAbilityInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService ConnectUIExtensionAbilityInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function ConnectUIExtensionAbilityInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ConnectUIExtensionAbilityInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->ConnectUIExtensionAbilityInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: DisconnectAbilityInner
|
||||
@ -1169,6 +1233,22 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartAbilityForOptionsInner_
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: CloseUIAbilityBySCBInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService CloseUIAbilityBySCBInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function CloseUIAbilityBySCBInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_CloseUIAbilityBySCBInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->CloseUIAbilityBySCBInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetWantSenderInner
|
||||
@ -1425,6 +1505,24 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ContinueMissionOfBundleNameI
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ContinueMissionOfBundleNameInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService ContinueMissionOfBundleNameInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function ContinueMissionOfBundleNameInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ContinueMissionOfBundleNameInner_002, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
Want want;
|
||||
data.WriteParcelable(&want);
|
||||
auto res = stub_->ContinueMissionOfBundleNameInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ContinueAbilityInner
|
||||
@ -1521,6 +1619,22 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UnlockMissionForCleanupInner
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SetLockedStateInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SetLockedStateInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function SetLockedStateInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_SetLockedStateInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->SetLockedStateInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RegisterMissionListenerInner
|
||||
@ -1715,6 +1829,22 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartAbilityByCallInner_001,
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: StartUIAbilityBySCBInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService StartUIAbilityBySCBInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function StartUIAbilityBySCBInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartUIAbilityBySCBInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->StartUIAbilityBySCBInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ReleaseCallInner
|
||||
@ -2310,6 +2440,22 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_FreeInstallAbilityFromRemote
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: AddFreeInstallObserverInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService AddFreeInstallObserverInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function AddFreeInstallObserverInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_AddFreeInstallObserverInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->AddFreeInstallObserverInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: DumpAbilityInfoDoneInner
|
||||
@ -2326,6 +2472,54 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_DumpAbilityInfoDoneInner_001
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: UpdateMissionSnapShotFromWMSInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService UpdateMissionSnapShotFromWMSInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function UpdateMissionSnapShotFromWMSInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UpdateMissionSnapShotFromWMSInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->UpdateMissionSnapShotFromWMSInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: EnableRecoverAbilityInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService EnableRecoverAbilityInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function EnableRecoverAbilityInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_EnableRecoverAbilityInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->EnableRecoverAbilityInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: HandleRequestDialogService
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService HandleRequestDialogService
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function HandleRequestDialogService is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_HandleRequestDialogService_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->HandleRequestDialogService(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: HandleReportDrawnCompleted_001
|
||||
* @tc.name: HandleReportDrawnCompleted
|
||||
@ -2339,6 +2533,54 @@ HWTEST_F(AbilityManagerStubTest, HandleReportDrawnCompleted_001, TestSize.Level1
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: AcquireShareDataInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService AcquireShareDataInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function AcquireShareDataInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_AcquireShareDataInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->AcquireShareDataInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ShareDataDoneInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService ShareDataDoneInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function ShareDataDoneInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ShareDataDoneInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->ShareDataDoneInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetAbilityTokenByCalleeObjInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService GetAbilityTokenByCalleeObjInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function GetAbilityTokenByCalleeObjInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetAbilityTokenByCalleeObjInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->GetAbilityTokenByCalleeObjInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
@ -2423,6 +2665,22 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetDlpConnectionInfosInner_0
|
||||
EXPECT_EQ(res, ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetConnectionDataInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService GetConnectionDataInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function GetConnectionDataInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetConnectionDataInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->GetConnectionDataInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SetMissionContinueStateInner
|
||||
@ -2503,6 +2761,86 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_CompleteFirstFrameDrawingInn
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: CompleteFirstFrameDrawingBySCBInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService CompleteFirstFrameDrawingBySCBInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function CompleteFirstFrameDrawingBySCBInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_CompleteFirstFrameDrawingBySCBInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->CompleteFirstFrameDrawingBySCBInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetDialogSessionInfoInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService GetDialogSessionInfoInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function GetDialogSessionInfoInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetDialogSessionInfoInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->GetDialogSessionInfoInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SendDialogResultInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SendDialogResultInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function SendDialogResultInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_SendDialogResultInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->SendDialogResultInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RegisterAbilityFirstFrameStateObserverInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RegisterAbilityFirstFrameStateObserverInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RegisterAbilityFirstFrameStateObserverInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RegisterAbilityFirstFrameStateObserverInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RegisterAbilityFirstFrameStateObserverInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: UnregisterAbilityFirstFrameStateObserverInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService UnregisterAbilityFirstFrameStateObserverInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function UnregisterAbilityFirstFrameStateObserverInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UnregisterAbilityFirstFrameStateObserverInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->UnregisterAbilityFirstFrameStateObserverInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: CallRequestDone
|
||||
@ -2562,6 +2900,134 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_IsValidMissionIdsInner_002,
|
||||
EXPECT_EQ(stub_->IsValidMissionIdsInner(data, reply), NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ForceExitAppInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService ForceExitAppInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function ForceExitAppInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ForceExitAppInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->ForceExitAppInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RecordAppExitReasonInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RecordAppExitReasonInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RecordAppExitReasonInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RecordAppExitReasonInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RecordAppExitReasonInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RecordProcessExitReasonInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RecordProcessExitReasonInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RecordProcessExitReasonInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RecordProcessExitReasonInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RecordProcessExitReasonInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SetRootSceneSessionInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SetRootSceneSessionInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function SetRootSceneSessionInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_SetRootSceneSessionInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->SetRootSceneSessionInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: CallUIAbilityBySCBInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService CallUIAbilityBySCBInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function CallUIAbilityBySCBInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_CallUIAbilityBySCBInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->CallUIAbilityBySCBInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SetSessionManagerServiceInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SetSessionManagerServiceInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function SetSessionManagerServiceInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_SetSessionManagerServiceInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->CallUIAbilityBySCBInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RegisterIAbilityManagerCollaboratorInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RegisterIAbilityManagerCollaboratorInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RegisterIAbilityManagerCollaboratorInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RegisterIAbilityManagerCollaboratorInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RegisterIAbilityManagerCollaboratorInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: UnregisterIAbilityManagerCollaboratorInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService UnregisterIAbilityManagerCollaboratorInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function UnregisterIAbilityManagerCollaboratorInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UnregisterIAbilityManagerCollaboratorInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->UnregisterIAbilityManagerCollaboratorInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: PrepareTerminateAbilityBySCBInner
|
||||
@ -2583,6 +3049,38 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_PrepareTerminateAbilityBySCB
|
||||
EXPECT_EQ(stub_->PrepareTerminateAbilityBySCBInner(data, reply), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RegisterStatusBarDelegateInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RegisterStatusBarDelegateInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RegisterStatusBarDelegateInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RegisterStatusBarDelegateInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RegisterStatusBarDelegateInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: KillProcessWithPrepareTerminateInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService KillProcessWithPrepareTerminateInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function KillProcessWithPrepareTerminateInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_KillProcessWithPrepareTerminateInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->KillProcessWithPrepareTerminateInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RegisterSessionHandlerInner
|
||||
@ -2649,6 +3147,230 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_IsAbilityControllerStartInne
|
||||
EXPECT_EQ(stub_->IsAbilityControllerStartInner(data, reply), NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ExecuteIntentInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService ExecuteIntentInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function ExecuteIntentInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ExecuteIntentInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->ExecuteIntentInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: StartAbilityByInsightIntentInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService StartAbilityByInsightIntentInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function StartAbilityByInsightIntentInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartAbilityByInsightIntentInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->StartAbilityByInsightIntentInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ExecuteInsightIntentDoneInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService ExecuteInsightIntentDoneInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function ExecuteInsightIntentDoneInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ExecuteInsightIntentDoneInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->ExecuteInsightIntentDoneInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SetApplicationAutoStartupByEDMInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SetApplicationAutoStartupByEDMInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function SetApplicationAutoStartupByEDMInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_SetApplicationAutoStartupByEDMInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->SetApplicationAutoStartupByEDMInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: CancelApplicationAutoStartupByEDMInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService CancelApplicationAutoStartupByEDMInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function CancelApplicationAutoStartupByEDMInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_CancelApplicationAutoStartupByEDMInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->CancelApplicationAutoStartupByEDMInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: OpenFileInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService OpenFileInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function OpenFileInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_OpenFileInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->OpenFileInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_DEAD_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: RequestAssertFaultDialogInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService RequestAssertFaultDialogInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function RequestAssertFaultDialogInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_RequestAssertFaultDialogInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->RequestAssertFaultDialogInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_NULL_OBJECT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: NotifyDebugAssertResultInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService NotifyDebugAssertResultInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function NotifyDebugAssertResultInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_NotifyDebugAssertResultInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->NotifyDebugAssertResultInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: UpdateSessionInfoBySCBInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService UpdateSessionInfoBySCBInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function UpdateSessionInfoBySCBInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UpdateSessionInfoBySCBInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->UpdateSessionInfoBySCBInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: OpenAtomicServiceInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService OpenAtomicServiceInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function OpenAtomicServiceInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_OpenAtomicServiceInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->OpenAtomicServiceInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: IsEmbeddedOpenAllowedInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService IsEmbeddedOpenAllowedInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function IsEmbeddedOpenAllowedInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_IsEmbeddedOpenAllowedInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->IsEmbeddedOpenAllowedInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: StartShortcutInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService StartShortcutInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function StartShortcutInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_StartShortcutInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->StartShortcutInner(data, reply);
|
||||
EXPECT_EQ(res, ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetAbilityStateByPersistentIdInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService GetAbilityStateByPersistentIdInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function GetAbilityStateByPersistentIdInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetAbilityStateByPersistentIdInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->GetAbilityStateByPersistentIdInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: TransferAbilityResultForExtensionInner
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService TransferAbilityResultForExtensionInner
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the function TransferAbilityResultForExtensionInner is normal flow.
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_TransferAbilityResultForExtensionInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->TransferAbilityResultForExtensionInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbilityManagerStub_RegisterAppDebugListenerInner_001
|
||||
* @tc.desc: Test the status of RegisterAppDebugListenerInner, check empty AppDebugListener.
|
||||
|
37
test/unittest/ability_service_log_test/BUILD.gn
Normal file
37
test/unittest/ability_service_log_test/BUILD.gn
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright (c) 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("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
ohos_unittest("ability_service_log_test") {
|
||||
module_out_path = "ability_runtime/service_log"
|
||||
|
||||
include_dirs = [ "${ability_runtime_path}/services/common/include" ]
|
||||
|
||||
sources = [ "ability_service_log_test.cpp" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/common:common_config" ]
|
||||
|
||||
cflags = []
|
||||
|
||||
deps = []
|
||||
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [ ":ability_service_log_test" ]
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using UTAAFwkTag = OHOS::AAFwk::AAFwkLogTag;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class AbilityServiceLogTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void AbilityServiceLogTest::SetUpTestCase(void)
|
||||
{}
|
||||
|
||||
void AbilityServiceLogTest::TearDownTestCase(void)
|
||||
{}
|
||||
|
||||
void AbilityServiceLogTest::SetUp()
|
||||
{}
|
||||
|
||||
void AbilityServiceLogTest::TearDown()
|
||||
{}
|
||||
|
||||
/*
|
||||
* Feature: HILOG
|
||||
* Function: Create
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: Create
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: NA
|
||||
*/
|
||||
HWTEST_F(AbilityServiceLogTest, Log_0100, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AbilityServiceLog_0100 start";
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityServiceLog_0100 info start");
|
||||
TAG_LOGD(AAFwkTag::TEST, "AbilityServiceLog_0100 debug start");
|
||||
TAG_LOGW(AAFwkTag::TEST, "AbilityServiceLog_0100 warn start");
|
||||
TAG_LOGE(AAFwkTag::TEST, "AbilityServiceLog_0100 error start");
|
||||
TAG_LOGF(AAFwkTag::TEST, "AbilityServiceLog_0100 fatal start");
|
||||
GTEST_LOG_(INFO) << "AbilityServiceLog_0100 end";
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: HILOG
|
||||
* Function: Create
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: Create
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: NA
|
||||
*/
|
||||
HWTEST_F(AbilityServiceLogTest, Log_0200, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AbilityServiceLog_0200 start";
|
||||
TAG_LOGI(AAFwkTag::END, "AbilityServiceLog_0200 info start");
|
||||
TAG_LOGD(AAFwkTag::END, "AbilityServiceLog_0200 debug start");
|
||||
TAG_LOGW(AAFwkTag::END, "AbilityServiceLog_0200 warn start");
|
||||
TAG_LOGE(AAFwkTag::END, "AbilityServiceLog_0200 error start");
|
||||
TAG_LOGF(AAFwkTag::END, "AbilityServiceLog_0200 fatal start");
|
||||
GTEST_LOG_(INFO) << "AbilityServiceLog_0200 end";
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: HILOG
|
||||
* Function: Create
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: Create
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: NA
|
||||
*/
|
||||
HWTEST_F(AbilityServiceLogTest, Log_0300, TestSize.Level1)
|
||||
{
|
||||
size_t tag = 255;
|
||||
GTEST_LOG_(INFO) << "AbilityServiceLog_0300 start";
|
||||
TAG_LOGI(static_cast<AAFwkTag>(tag), "AbilityServiceLog_0300 info start");
|
||||
TAG_LOGD(static_cast<AAFwkTag>(tag), "AbilityServiceLog_0300 debug start");
|
||||
TAG_LOGW(static_cast<AAFwkTag>(tag), "AbilityServiceLog_0300 warn start");
|
||||
TAG_LOGE(static_cast<AAFwkTag>(tag), "AbilityServiceLog_0300 error start");
|
||||
TAG_LOGF(static_cast<AAFwkTag>(tag), "AbilityServiceLog_0300 fatal start");
|
||||
GTEST_LOG_(INFO) << "AbilityServiceLog_0300 end";
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -64,6 +64,21 @@ HWTEST_F(DistributedClientTest, GetDmsProxy_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetDmsProxy_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetDmsProxy_0200
|
||||
* @tc.name: GetDmsProxy
|
||||
* @tc.desc: GetDmsProxy Test, return is nullptr.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, GetDmsProxy_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetDmsProxy_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
auto result = client->GetDmsProxy();
|
||||
EXPECT_EQ(result, nullptr);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetDmsProxy_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartRemoteAbility_0100
|
||||
* @tc.name: StartRemoteAbility
|
||||
@ -86,6 +101,26 @@ HWTEST_F(DistributedClientTest, StartRemoteAbility_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteAbility_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartRemoteAbility_0200
|
||||
* @tc.name: StartRemoteAbility
|
||||
* @tc.desc: StartRemoteAbility Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StartRemoteAbility_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteAbility_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
int32_t callerUid = 5;
|
||||
uint32_t accessToken = 0;
|
||||
int32_t requestCode = 0;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->StartRemoteAbility(want, callerUid, accessToken, requestCode);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteAbility_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ConnectRemoteAbility_0100
|
||||
* @tc.name: ConnectRemoteAbility
|
||||
@ -121,6 +156,24 @@ HWTEST_F(DistributedClientTest, ConnectRemoteAbility_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ConnectRemoteAbility_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ConnectRemoteAbility_0300
|
||||
* @tc.name: ConnectRemoteAbility
|
||||
* @tc.desc: ConnectRemoteAbility Test, when remote is nullptr, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, ConnectRemoteAbility_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ConnectRemoteAbility_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
sptr<IRemoteObject> connect = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->ConnectRemoteAbility(want, connect);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ConnectRemoteAbility_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DisconnectRemoteAbility_0100
|
||||
* @tc.name: DisconnectRemoteAbility
|
||||
@ -163,6 +216,26 @@ HWTEST_F(DistributedClientTest, DisconnectRemoteAbility_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest DisconnectRemoteAbility_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: DisconnectRemoteAbility_0300
|
||||
* @tc.name: DisconnectRemoteAbility
|
||||
* @tc.desc: DisconnectRemoteAbility Test, when remote is nullptr, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, DisconnectRemoteAbility_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest DisconnectRemoteAbility_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
int32_t callerUid = 0;
|
||||
uint32_t accessToken = 0;
|
||||
OHOS::AAFwk::Want want;
|
||||
sptr<IRemoteObject> connect = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
client->ConnectRemoteAbility(want, connect);
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->DisconnectRemoteAbility(connect, callerUid, accessToken);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest DisconnectRemoteAbility_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ContinueMission_0100
|
||||
* @tc.name: ContinueMission
|
||||
@ -204,6 +277,27 @@ HWTEST_F(DistributedClientTest, ContinueMission_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ContinueMission_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ContinueMission_0300
|
||||
* @tc.name: ContinueMission
|
||||
* @tc.desc: ContinueMission Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, ContinueMission_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ContinueMission_300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::string srcDeviceId = "deviceId";
|
||||
std::string dstDeviceId = "deviceId";
|
||||
int32_t missionId = 0 ;
|
||||
OHOS::AAFwk::WantParams wantParams;
|
||||
sptr<IRemoteObject> callback = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->ContinueMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ContinueMission_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ContinueMissionBundleName_0100
|
||||
* @tc.name: ContinueMissionBundleName
|
||||
@ -254,6 +348,31 @@ HWTEST_F(DistributedClientTest, ContinueMissionBundleName_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ContinueMissionBundleName_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ContinueMissionBundleName_0300
|
||||
* @tc.name: ContinueMissionBundleName
|
||||
* @tc.desc: ContinueMissionBundleName Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, ContinueMissionBundleName_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ContinueMissionBundleName_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::string srcDeviceId = "";
|
||||
std::string dstDeviceId = "";
|
||||
AAFwk::WantParams wantParams;
|
||||
OHOS::AAFwk::ContinueMissionInfo continueMissionInfo;
|
||||
continueMissionInfo.dstDeviceId = dstDeviceId;
|
||||
continueMissionInfo.srcDeviceId = srcDeviceId;
|
||||
continueMissionInfo.bundleName = "bundleName";
|
||||
continueMissionInfo.wantParams = wantParams;
|
||||
sptr<IRemoteObject> callback = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->ContinueMission(continueMissionInfo, callback);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ContinueMissionBundleName_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: NotifyCompleteContinuation_0100
|
||||
* @tc.name: NotifyCompleteContinuation
|
||||
@ -275,6 +394,25 @@ HWTEST_F(DistributedClientTest, NotifyCompleteContinuation_0100, TestSize.Level3
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest NotifyCompleteContinuation_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: NotifyCompleteContinuation_0200
|
||||
* @tc.name: NotifyCompleteContinuation
|
||||
* @tc.desc: NotifyCompleteContinuation Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, NotifyCompleteContinuation_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest NotifyCompleteContinuation_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::u16string devId = to_utf16("deviceId");
|
||||
int32_t sessionId = 0;
|
||||
bool isSuccess = true;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
auto result = client->NotifyCompleteContinuation(devId, sessionId, isSuccess);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest NotifyCompleteContinuation_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartSyncRemoteMissions_0100
|
||||
* @tc.name: StartSyncRemoteMissions
|
||||
@ -296,6 +434,24 @@ HWTEST_F(DistributedClientTest, StartSyncRemoteMissions_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartSyncRemoteMissions_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartSyncRemoteMissions_0200
|
||||
* @tc.name: StartSyncRemoteMissions
|
||||
* @tc.desc: StartSyncRemoteMissions Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StartSyncRemoteMissions_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartSyncRemoteMissions_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::string devId = "";
|
||||
bool fixConflict = true;
|
||||
int64_t tag = 0;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->StartSyncRemoteMissions(devId, fixConflict, tag);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartSyncRemoteMissions_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StopSyncRemoteMissions_0100
|
||||
* @tc.name: StopSyncRemoteMissions
|
||||
@ -315,6 +471,22 @@ HWTEST_F(DistributedClientTest, StopSyncRemoteMissions_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StopSyncRemoteMissions_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StopSyncRemoteMissions_0200
|
||||
* @tc.name: StopSyncRemoteMissions
|
||||
* @tc.desc: StopSyncRemoteMissions Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StopSyncRemoteMissions_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StopSyncRemoteMissions_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::string devId = "";
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->StopSyncRemoteMissions(devId);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StopSyncRemoteMissions_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterMissionListener_0100
|
||||
* @tc.name: RegisterMissionListener
|
||||
@ -335,6 +507,23 @@ HWTEST_F(DistributedClientTest, RegisterMissionListener_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterMissionListener_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterMissionListener_0200
|
||||
* @tc.name: RegisterMissionListener
|
||||
* @tc.desc: RegisterMissionListener Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, RegisterMissionListener_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterMissionListener_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::u16string devId = to_utf16("deviceId");
|
||||
sptr<IRemoteObject> obj = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->RegisterMissionListener(devId, obj);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterMissionListener_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterOnListener_0100
|
||||
* @tc.name: RegisterOnListener
|
||||
@ -354,6 +543,22 @@ HWTEST_F(DistributedClientTest, RegisterOnListener_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterOnListener_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterOnListener_0100
|
||||
* @tc.name: RegisterOnListener
|
||||
* @tc.desc: RegisterOnListener Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, RegisterOnListener_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterOnListener_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
sptr<IRemoteObject> obj = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->RegisterOnListener("type", obj);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterOnListener_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterOffListener_0100
|
||||
* @tc.name: RegisterOffListener
|
||||
@ -374,6 +579,23 @@ HWTEST_F(DistributedClientTest, RegisterOffListener_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterOffListener_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterOffListener_0200
|
||||
* @tc.name: RegisterOffListener
|
||||
* @tc.desc: RegisterOffListener Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, RegisterOffListener_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterOffListener_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
sptr<IRemoteObject> obj = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
client->RegisterOnListener("type", obj);
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->RegisterOffListener("type", obj);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest RegisterOffListener_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: UnRegisterMissionListener_0100
|
||||
* @tc.name: UnRegisterMissionListener
|
||||
@ -395,6 +617,24 @@ HWTEST_F(DistributedClientTest, UnRegisterMissionListener_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest UnRegisterMissionListener_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: UnRegisterMissionListener_0200
|
||||
* @tc.name: UnRegisterMissionListener
|
||||
* @tc.desc: UnRegisterMissionListener Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, UnRegisterMissionListener_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest UnRegisterMissionListener_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::u16string devId = to_utf16("deviceId");
|
||||
sptr<IRemoteObject> obj = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
client->RegisterMissionListener(devId, obj);
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->UnRegisterMissionListener(devId, obj);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest UnRegisterMissionListener_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetMissionInfos_0100
|
||||
* @tc.name: GetMissionInfos
|
||||
@ -416,6 +656,24 @@ HWTEST_F(DistributedClientTest, GetMissionInfos_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetMissionInfos_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetMissionInfos_0200
|
||||
* @tc.name: GetMissionInfos
|
||||
* @tc.desc: GetMissionInfosTest, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, GetMissionInfos_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetMissionInfos_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::string deviceId = "";
|
||||
int32_t numMissions = 0;
|
||||
std::vector<AAFwk::MissionInfo> missionInfos;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->GetMissionInfos(deviceId, numMissions, missionInfos);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetMissionInfos_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetRemoteMissionSnapshotInfo_0100
|
||||
* @tc.name: GetRemoteMissionSnapshotInfo
|
||||
@ -454,6 +712,24 @@ HWTEST_F(DistributedClientTest, GetRemoteMissionSnapshotInfo_0200, TestSize.Leve
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetRemoteMissionSnapshotInfo_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetRemoteMissionSnapshotInfo_0300
|
||||
* @tc.name: GetRemoteMissionSnapshotInfo
|
||||
* @tc.desc: GetRemoteMissionSnapshotInfo Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, GetRemoteMissionSnapshotInfo_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetRemoteMissionSnapshotInfo_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
std::string deviceId ="deviceId";
|
||||
int32_t numMissions = 0;
|
||||
std::unique_ptr<OHOS::AAFwk::MissionSnapshot> missionSnapshot = std::make_unique<OHOS::AAFwk::MissionSnapshot>();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->GetRemoteMissionSnapshotInfo(deviceId, numMissions, missionSnapshot);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest GetRemoteMissionSnapshotInfo_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ReadMissionInfosFromParcel_0100
|
||||
* @tc.name: ReadMissionInfosFromParcel
|
||||
@ -608,6 +884,26 @@ HWTEST_F(DistributedClientTest, StartContinuation_0100, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartContinuation_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartContinuation_0200
|
||||
* @tc.name: StartContinuation
|
||||
* @tc.desc: StartContinuation Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StartContinuation_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartContinuation_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
int32_t missionId = 0;
|
||||
int32_t callerUid = -1;
|
||||
int32_t status =0;
|
||||
uint32_t accessToken = 0;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->StartContinuation(want, missionId, callerUid, status, accessToken);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartContinuation_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartRemoteAbilityByCall_0100
|
||||
* @tc.name: StartRemoteAbilityByCall
|
||||
@ -643,6 +939,23 @@ HWTEST_F(DistributedClientTest, StartRemoteAbilityByCall_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteAbilityByCall_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartRemoteAbilityByCall_0300
|
||||
* @tc.name: StartRemoteAbilityByCall
|
||||
* @tc.desc: StartRemoteAbilityByCall Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StartRemoteAbilityByCall_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteAbilityByCall_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
sptr<IRemoteObject> connect = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->StartRemoteAbilityByCall(want, connect);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteAbilityByCall_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ReleaseRemoteAbility_0100
|
||||
* @tc.name: ReleaseRemoteAbility
|
||||
@ -683,6 +996,28 @@ HWTEST_F(DistributedClientTest, ReleaseRemoteAbility_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ReleaseRemoteAbility_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ReleaseRemoteAbility_0300
|
||||
* @tc.name: ReleaseRemoteAbility
|
||||
* @tc.desc: ReleaseRemoteAbility Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, ReleaseRemoteAbility_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ReleaseRemoteAbility_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
int32_t callerUid = 0;
|
||||
uint32_t accessToken = 0;
|
||||
int32_t requestCode = 0;
|
||||
client->StartRemoteAbility(want, callerUid, accessToken, requestCode);
|
||||
AppExecFwk::ElementName element;
|
||||
sptr<IRemoteObject> connect = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->ReleaseRemoteAbility(connect, element);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest ReleaseRemoteAbility_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartRemoteFreeInstall_0100
|
||||
* @tc.name: StartRemoteFreeInstall
|
||||
@ -724,6 +1059,26 @@ HWTEST_F(DistributedClientTest, StartRemoteFreeInstall_0200, TestSize.Level3)
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteFreeInstall_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StartRemoteFreeInstall_0300
|
||||
* @tc.name: StartRemoteFreeInstall
|
||||
* @tc.desc: StartRemoteFreeInstall Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StartRemoteFreeInstall_0300, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteFreeInstall_0300 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
int32_t callerUid = 0;
|
||||
int32_t requestCode = 0;
|
||||
uint32_t accessToken = 0;
|
||||
sptr<IRemoteObject> callback = new (std::nothrow) OHOS::AAFwk::AbilityConnectCallback();
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->StartRemoteFreeInstall(want, callerUid, requestCode, accessToken, callback);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StartRemoteFreeInstall_0300 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: WriteInfosToParcel_0100
|
||||
* @tc.name: WriteInfosToParcel
|
||||
@ -763,6 +1118,25 @@ HWTEST_F(DistributedClientTest, StopRemoteExtensionAbility_0100, TestSize.Level1
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StopRemoteExtensionAbility_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: StopRemoteExtensionAbility_0200
|
||||
* @tc.name: StopRemoteExtensionAbility
|
||||
* @tc.desc: StopRemoteExtensionAbility Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, StopRemoteExtensionAbility_0200, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StopRemoteExtensionAbility_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
OHOS::AAFwk::Want want;
|
||||
constexpr int32_t callerUid = 0;
|
||||
constexpr uint32_t accessToken = 0;
|
||||
constexpr int32_t extensionType = 3;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
auto result = client->StopRemoteExtensionAbility(want, callerUid, accessToken, extensionType);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest StopRemoteExtensionAbility_0200 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: SetMissionContinueState_0100
|
||||
* @tc.name: SetMissionContinueState
|
||||
@ -781,4 +1155,21 @@ HWTEST_F(DistributedClientTest, SetMissionContinueState_0100, TestSize.Level3)
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
}
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest SetMissionContinueState_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: SetMissionContinueState_0200
|
||||
* @tc.name: SetMissionContinueState
|
||||
* @tc.desc: SetMissionContinueState Test, return INVALID_PARAMETERS_ERR.
|
||||
*/
|
||||
HWTEST_F(DistributedClientTest, SetMissionContinueState_0200, TestSize.Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest SetMissionContinueState_0200 start";
|
||||
auto client = std::make_shared<OHOS::AAFwk::DistributedClient>();
|
||||
int32_t missionId = 0 ;
|
||||
OHOS::AAFwk::ContinueState state = OHOS::AAFwk::ContinueState::CONTINUESTATE_ACTIVE;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
int32_t result = client->SetMissionContinueState(missionId, state);
|
||||
EXPECT_EQ(result, OHOS::AAFwk::INVALID_PARAMETERS_ERR);
|
||||
GTEST_LOG_(INFO) << "DistributedClientTest SetMissionContinueState_0200 end";
|
||||
}
|
@ -298,6 +298,10 @@ ErrCode AbilityManagerShellCommand::CreateMessageMap()
|
||||
KILL_PROCESS_KEEP_ALIVE,
|
||||
"error: keep alive process can not be killed.",
|
||||
},
|
||||
{
|
||||
ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE,
|
||||
"error: unlock screen failed in developer mode."
|
||||
}
|
||||
};
|
||||
|
||||
return OHOS::ERR_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user