mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
add setOnNewWantSkipScenarios
Signed-off-by: zhongshield1 <zhangzezhong8@huawei-partners.com>
This commit is contained in:
@@ -59,6 +59,9 @@ constexpr const char *PRELOAD_UI_EXTENSION_ABILITY_SIGNATURE =
|
||||
"C{@ohos.app.ability.Want.Want}C{utils.AbilityUtils.AsyncCallbackWrapper}:";
|
||||
constexpr const char *CLEAR_PRELOAD_UI_EXTENSION_ABILITY_SIGNATURE = "iC{utils.AbilityUtils.AsyncCallbackWrapper}:";
|
||||
constexpr const char *CLEAR_PRELOAD_UI_EXTENSION_ABILITIES_SIGNATURE = "C{utils.AbilityUtils.AsyncCallbackWrapper}:";
|
||||
constexpr const char *NOTIFY_SAVE_AS_RESULT_SIGNATURE =
|
||||
"C{ability.abilityResult.AbilityResult}iC{utils.AbilityUtils.AsyncCallbackWrapper}:";
|
||||
constexpr const char *NOTIFY_SAVE_AS_RESULT_CHECK_SIGNATURE = "C{ability.abilityResult.AbilityResult}:";
|
||||
constexpr int32_t ERR_FAILURE = -1;
|
||||
const std::string MAX_UINT64_VALUE = "18446744073709551615";
|
||||
std::shared_ptr<AppExecFwk::EventHandler> mainHandler_ = nullptr;
|
||||
@@ -147,6 +150,9 @@ public:
|
||||
static void NativeClearPreloadedUIExtensionAbility(ani_env *env, ani_int preloadId, ani_object callback);
|
||||
static void NativeClearPreloadedUIExtensionAbilities(ani_env *env, ani_object callback);
|
||||
static void CheckPreloadUIExtensionAbilityPermission(ani_env *env);
|
||||
static void nativeNotifySaveAsResult(ani_env *env, ani_object aniParameter,
|
||||
ani_int requestCode, ani_object callback);
|
||||
static void nativeNotifySaveAsResultCheck(ani_env *env, ani_object aniParameter);
|
||||
|
||||
private:
|
||||
static sptr<AppExecFwk::IAbilityManager> GetAbilityManagerInstance();
|
||||
@@ -1037,6 +1043,46 @@ void EtsAbilityManager::NativeClearPreloadedUIExtensionAbilities(ani_env *env, a
|
||||
}
|
||||
}
|
||||
|
||||
void EtsAbilityManager::nativeNotifySaveAsResultCheck(ani_env *env, ani_object aniParameter)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "call NotifySaveAsResultCheck");
|
||||
if (env == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "null env");
|
||||
return;
|
||||
}
|
||||
AppExecFwk::Want want;
|
||||
int resultCode = ERR_OK;
|
||||
if (!AppExecFwk::UnWrapAbilityResult(env, aniParameter, resultCode, want)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "unwrap abilityResult failed");
|
||||
EtsErrorUtil::ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void EtsAbilityManager::nativeNotifySaveAsResult(
|
||||
ani_env *env, ani_object aniParameter, ani_int requestCode, ani_object callback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "call NotifySaveAsResult");
|
||||
if (env == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "null env");
|
||||
return;
|
||||
}
|
||||
AppExecFwk::Want want;
|
||||
int resultCode = ERR_OK;
|
||||
if (!AppExecFwk::UnWrapAbilityResult(env, aniParameter, resultCode, want)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "unwrap abilityResult failed");
|
||||
return;
|
||||
}
|
||||
ErrCode errorCode = AAFwk::AbilityManagerClient::GetInstance()->
|
||||
NotifySaveAsResult(want, resultCode, static_cast<int32_t>(requestCode));
|
||||
if (errorCode != ERR_OK) {
|
||||
AppExecFwk::AsyncCallback(env, callback,
|
||||
EtsErrorUtil::CreateErrorByNativeErr(env, static_cast<int32_t>(errorCode)), nullptr);
|
||||
return;
|
||||
}
|
||||
AppExecFwk::AsyncCallback(env, callback, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void EtsAbilityManagerRegistryInit(ani_env *env)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "call EtsAbilityManagerRegistryInit");
|
||||
@@ -1118,6 +1164,10 @@ void EtsAbilityManagerRegistryInit(ani_env *env)
|
||||
reinterpret_cast<void *>(EtsAbilityManager::NativeClearPreloadedUIExtensionAbilities) },
|
||||
ani_native_function { "nativeCheckPreloadUIExtensionAbilityPermission", ETS_ABILITY_MANAGER_SIGNATURE_VOID,
|
||||
reinterpret_cast<void *>(EtsAbilityManager::CheckPreloadUIExtensionAbilityPermission) },
|
||||
ani_native_function { "nativeNotifySaveAsResult", NOTIFY_SAVE_AS_RESULT_SIGNATURE,
|
||||
reinterpret_cast<void *>(EtsAbilityManager::nativeNotifySaveAsResult) },
|
||||
ani_native_function { "nativeNotifySaveAsResultCheck", NOTIFY_SAVE_AS_RESULT_CHECK_SIGNATURE,
|
||||
reinterpret_cast<void *>(EtsAbilityManager::nativeNotifySaveAsResultCheck) },
|
||||
};
|
||||
status = env->Namespace_BindNativeFunctions(ns, methods.data(), methods.size());
|
||||
if (status != ANI_OK) {
|
||||
|
||||
@@ -116,6 +116,7 @@ ohos_shared_library("ani_common") {
|
||||
"resource_management:resourceManager_ani",
|
||||
"runtime_core:ani",
|
||||
"runtime_core:ani_helpers",
|
||||
"window_manager:ani_window_animation_utils",
|
||||
]
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_ANI_COMMON_APP_STATE_FILTER
|
||||
#define OHOS_ABILITY_RUNTIME_ANI_COMMON_APP_STATE_FILTER
|
||||
|
||||
#include "application_state_filter.h"
|
||||
#include "ani.h"
|
||||
#include "application_state_filter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
#include "ani_common_app_state_filter.h"
|
||||
|
||||
#include "application_state_filter.h"
|
||||
#include "ani_common_util.h"
|
||||
#include "application_state_filter.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "process_options.h"
|
||||
#include "start_window_option.h"
|
||||
#include "parcel.h"
|
||||
#include "ani_window_animation_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@@ -110,6 +111,16 @@ void UnwrapStartOptionsWindowOptions(ani_env *env, ani_object param, AAFwk::Star
|
||||
startOptions.SetMaxWindowHeight(maxWindowHeight);
|
||||
startOptions.maxWindowHeightUsed_ = true;
|
||||
}
|
||||
|
||||
ani_ref windowEtsObject = nullptr;
|
||||
ani_status status = ANI_ERROR;
|
||||
if ((status = env->Object_GetPropertyByName_Ref(param, "windowCreateParams", &windowEtsObject)) == ANI_OK) {
|
||||
Rosen::WindowCreateParams windowCreateParams;
|
||||
if (Rosen::ConvertWindowCreateParamsFromAniValue(
|
||||
env, static_cast<ani_object>(windowEtsObject), windowCreateParams)) {
|
||||
startOptions.windowCreateParams_ = std::make_shared<Rosen::WindowCreateParams>(windowCreateParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SetSupportWindowModes(ani_env *env, ani_object param, AAFwk::StartOptions &startOptions)
|
||||
|
||||
@@ -614,12 +614,17 @@ ani_object NativeCreateSystemHspModuleResourceManager(ani_env *env, ani_object a
|
||||
}
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager = nullptr;
|
||||
int32_t retCode = context->CreateSystemHspModuleResourceManager(bundleName, moduleName, resourceManager);
|
||||
if (resourceManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null resourceManager, errorCode:%{public}d", retCode);
|
||||
EtsErrorUtil::ThrowError(env, retCode);
|
||||
if (resourceManager == nullptr && retCode == ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SYSTEM_HSP) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null resourceManager");
|
||||
EtsErrorUtil::ThrowRuntimeError(env, ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SYSTEM_HSP);
|
||||
return reinterpret_cast<ani_object>(undefRef);
|
||||
}
|
||||
return Global::Resource::ResMgrAddon::CreateResMgr(env, "", resourceManager, context);
|
||||
if (resourceManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null resourceManager, errorCode:%{public}d", retCode);
|
||||
EtsErrorUtil::ThrowRuntimeError(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
return reinterpret_cast<ani_object>(undefRef);
|
||||
}
|
||||
return Global::Resource::ResMgrAddon::CreateResMgr(env, "", resourceManager, nullptr);
|
||||
}
|
||||
|
||||
ani_object CreateContextObject(ani_env* env, ani_class contextClass, std::shared_ptr<Context> nativeContext)
|
||||
|
||||
@@ -504,6 +504,12 @@ ani_int EtsAppManager::OnOnApplicationStateInner(ani_env *env, ani_string type,
|
||||
std::lock_guard<std::mutex> lock(appStateObserverLock_);
|
||||
if (appStateObserver_ == nullptr) {
|
||||
appStateObserver_ = new (std::nothrow) AbilityRuntime::EtsAppStateObserver(aniVM);
|
||||
if (appStateObserver_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "create appStateObserver_ failed");
|
||||
AbilityRuntime::EtsErrorUtil::ThrowError(env,
|
||||
static_cast<int32_t>(AbilityRuntime::AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return ANI_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (appStateObserver_->GetEtsObserverMapSize() == 0) {
|
||||
@@ -592,6 +598,12 @@ ani_int EtsAppManager::OnOnApplicationStateWithAppStateFilter(ani_env *env, ani_
|
||||
std::lock_guard<std::mutex> lock(appStateObserverLock_);
|
||||
if (appStateObserver_ == nullptr) {
|
||||
appStateObserver_ = new (std::nothrow) AbilityRuntime::EtsAppStateObserver(aniVM);
|
||||
if (appStateObserver_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "create appStateObserver_ failed");
|
||||
AbilityRuntime::EtsErrorUtil::ThrowError(env,
|
||||
static_cast<int32_t>(AbilityRuntime::AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return ANI_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<std::string> bundleNameList;
|
||||
|
||||
@@ -151,6 +151,7 @@ public:
|
||||
static void OpenLinkCheck(ani_env *env, ani_object aniObj, ani_string aniLink);
|
||||
static void OpenAtomicServiceCheck(ani_env *env, ani_object aniObj);
|
||||
static void StartAbilityForResultWithAccountCheck(ani_env *env, ani_object aniObj);
|
||||
static void SetOnNewWantSkipScenarios(ani_env *env, ani_object aniObj, ani_int etsScenarios, ani_object callback);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
@@ -241,6 +242,7 @@ private:
|
||||
void OnRequestDialogService(ani_env *env, ani_object aniObj, ani_object wantObj, ani_object call);
|
||||
void OnStartAbilityWithAccount(
|
||||
ani_env *env, ani_object aniObj, ani_object aniWant, ani_int aniAccountId, ani_object aniOpt, ani_object call);
|
||||
void OnSetOnNewWantSkipScenarios(ani_env *env, ani_object aniObj, ani_int etsScenarios, ani_object callback);
|
||||
void OnStartAbilityAsCaller(ani_env *env, ani_object aniObj, ani_object wantObj, ani_object startOptionsObj,
|
||||
ani_object callbackObj);
|
||||
void UnwrapCompletionHandlerInStartOptions(ani_env *env, ani_object param, AAFwk::StartOptions &options);
|
||||
|
||||
@@ -837,6 +837,18 @@ void EtsAbilityContext::StartRecentAbility(ani_env *env, ani_object aniObj, ani_
|
||||
etsContext->OnStartAbility(env, aniObj, wantObj, startOptionsObj, callbackObj, true);
|
||||
}
|
||||
|
||||
void EtsAbilityContext::SetOnNewWantSkipScenarios(ani_env *env, ani_object aniObj, ani_int etsScenarios,
|
||||
ani_object callback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "SetOnNewWantSkipScenarios called");
|
||||
auto etsContext = GetEtsAbilityContext(env, aniObj);
|
||||
if (etsContext == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "null etsContext");
|
||||
return;
|
||||
}
|
||||
etsContext->OnSetOnNewWantSkipScenarios(env, aniObj, etsScenarios, callback);
|
||||
}
|
||||
|
||||
int32_t EtsAbilityContext::GenerateRequestCode()
|
||||
{
|
||||
static int32_t curRequestCode_ = 0;
|
||||
@@ -1278,7 +1290,6 @@ void EtsAbilityContext::OnOpenLink(ani_env *env, ani_object aniObj, ani_string a
|
||||
if (ret == AAFwk::ERR_OPEN_LINK_START_ABILITY_DEFAULT_OK) {
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "start ability by default succeeded");
|
||||
freeInstallObserver_->OnInstallFinishedByUrl(startTime, link, ERR_OK);
|
||||
return;
|
||||
}
|
||||
freeInstallObserver_->OnInstallFinishedByUrl(startTime, link, ret);
|
||||
std::string requestId = want.GetStringParam(KEY_REQUEST_ID);
|
||||
@@ -2256,9 +2267,20 @@ void EtsAbilityContext::OpenAtomicServiceInner(ani_env *env, ani_object aniObj,
|
||||
};
|
||||
want.SetParam(AAFwk::Want::PARAM_RESV_FOR_RESULT, true);
|
||||
auto requestCode = GenerateRequestCode();
|
||||
ErrCode ErrCode = context->OpenAtomicService(want, options, requestCode, std::move(task));
|
||||
if (ErrCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "OpenAtomicService failed, ErrCode: %{public}d", ErrCode);
|
||||
ErrCode errCode = context->OpenAtomicService(want, options, requestCode, std::move(task));
|
||||
if (errCode != 0) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "OpenAtomicService failed: %{public}d", errCode);
|
||||
if (freeInstallObserver_ != nullptr) {
|
||||
std::string bundleName = want.GetElement().GetBundleName();
|
||||
std::string abilityName = want.GetElement().GetAbilityName();
|
||||
freeInstallObserver_->OnInstallFinished(bundleName, abilityName, startTime, errCode);
|
||||
}
|
||||
if (!options.requestId_.empty()) {
|
||||
nlohmann::json jsonObject = nlohmann::json {
|
||||
{ JSON_KEY_ERR_MSG, "failed to call openAtomicService" }
|
||||
};
|
||||
context->OnRequestFailure(options.requestId_, want.GetElement(), jsonObject.dump());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2892,6 +2914,29 @@ void EtsAbilityContext::OnStartAbilityWithAccount(
|
||||
}
|
||||
}
|
||||
|
||||
void EtsAbilityContext::OnSetOnNewWantSkipScenarios(ani_env *env, ani_object aniObj, ani_int etsScenarios,
|
||||
ani_object callback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "OnSetOnNewWantSkipScenarios called");
|
||||
auto context = context_.lock();
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "context null");
|
||||
AppExecFwk::AsyncCallback(env, callback,
|
||||
EtsErrorUtil::CreateError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT), nullptr);
|
||||
return;
|
||||
}
|
||||
int32_t scenarios = static_cast<int32_t>(etsScenarios);
|
||||
ErrCode innerErrCode = ERR_OK;
|
||||
innerErrCode = context->SetOnNewWantSkipScenarios(scenarios);
|
||||
if (innerErrCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "SetOnNewWantSkipScenarios failed, innerErrCode: %{public}d", innerErrCode);
|
||||
AppExecFwk::AsyncCallback(env, callback, EtsErrorUtil::CreateError(env, AbilityErrorCode::ERROR_CODE_INNER),
|
||||
nullptr);
|
||||
return;
|
||||
}
|
||||
AppExecFwk::AsyncCallback(env, callback, EtsErrorUtil::CreateErrorByNativeErr(env, ERR_OK), nullptr);
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool BindNativeMethods(ani_env *env, ani_class &cls)
|
||||
{
|
||||
@@ -3055,6 +3100,9 @@ bool BindNativeMethods(ani_env *env, ani_class &cls)
|
||||
"C{@ohos.app.ability.AbilityConstant.AbilityConstant.ContinueState}"
|
||||
"C{utils.AbilityUtils.AsyncCallbackWrapper}:",
|
||||
reinterpret_cast<void*>(EtsAbilityContext::SetMissionContinueState) },
|
||||
ani_native_function { "nativeSetOnNewWantSkipScenarios",
|
||||
"iC{utils.AbilityUtils.AsyncCallbackWrapper}:",
|
||||
reinterpret_cast<void*>(EtsAbilityContext::SetOnNewWantSkipScenarios) },
|
||||
};
|
||||
if ((status = env->Class_BindNativeMethods(cls, functions.data(), functions.size())) != ANI_OK) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "Class_BindNativeMethods failed status: %{public}d", status);
|
||||
|
||||
@@ -1275,9 +1275,20 @@ void EtsUIExtensionContext::OpenAtomicServiceInner(ani_env *env, ani_object aniO
|
||||
};
|
||||
want.SetParam(AAFwk::Want::PARAM_RESV_FOR_RESULT, true);
|
||||
auto requestCode = context->GenerateCurRequestCode();
|
||||
ErrCode ErrCode = context->OpenAtomicService(want, options, requestCode, std::move(task));
|
||||
if (ErrCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "OpenAtomicService failed, ErrCode: %{public}d", ErrCode);
|
||||
ErrCode errCode = context->OpenAtomicService(want, options, requestCode, std::move(task));
|
||||
if (errCode != 0) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "OpenAtomicService failed: %{public}d", errCode);
|
||||
if (freeInstallObserver_ != nullptr) {
|
||||
std::string bundleName = want.GetElement().GetBundleName();
|
||||
std::string abilityName = want.GetElement().GetAbilityName();
|
||||
freeInstallObserver_->OnInstallFinished(bundleName, abilityName, startTime, errCode);
|
||||
}
|
||||
if (!options.requestId_.empty()) {
|
||||
nlohmann::json jsonObject = nlohmann::json {
|
||||
{ JSON_KEY_ERR_MSG, "failed to call openAtomicService" }
|
||||
};
|
||||
context->OnRequestFailure(options.requestId_, want.GetElement(), jsonObject.dump());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import contextConstant from '@ohos.app.ability.contextConstant';
|
||||
import image from '@ohos.multimedia.image';
|
||||
import bundleManager from '@ohos.bundle.bundleManager';
|
||||
import CompletionHandler from '@ohos.app.ability.CompletionHandler';
|
||||
import window from '@ohos.window';
|
||||
|
||||
export default class StartOptions {
|
||||
windowMode?: int;
|
||||
@@ -38,4 +39,5 @@ export default class StartOptions {
|
||||
maxWindowHeight?: int;
|
||||
completionHandler?: CompletionHandler;
|
||||
hideStartWindow?: boolean;
|
||||
windowCreateParams?: window.WindowCreateParams;
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import { Configuration } from '@ohos.app.ability.Configuration';
|
||||
import _AbilityForegroundStateObserver from 'application.AbilityForegroundStateObserver';
|
||||
import { ExtensionRunningInfo as _ExtensionRunningInfo } from './application/ExtensionRunningInfo';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import { AbilityResult } from 'ability.abilityResult';
|
||||
|
||||
export default namespace abilityManager {
|
||||
loadLibraryWithPermissionCheck("ability_manager_ani_kit.z", "@ohos.app.ability.abilityManager")
|
||||
@@ -58,6 +59,8 @@ export default namespace abilityManager {
|
||||
export native function nativePreloadUIExtensionAbility(want: Want, callback: AsyncCallbackWrapper<int>): void;
|
||||
export native function nativeClearPreloadedUIExtensionAbility(preloadId: int, callback: AsyncCallbackWrapper<void>): void;
|
||||
export native function nativeClearPreloadedUIExtensionAbilities(callback: AsyncCallbackWrapper<void>): void;
|
||||
export native function nativeNotifySaveAsResult(parameter: AbilityResult, requestCode: int, callback: AsyncCallbackWrapper<void>): void;
|
||||
export native function nativeNotifySaveAsResultCheck(parameter: AbilityResult): void;
|
||||
|
||||
export function getForegroundUIAbilities():Promise<Array<AbilityStateData>> {
|
||||
let p = new Promise<Array<AbilityStateData>>((resolve: (data: Array<AbilityStateData>) => void, reject: (error: Error) => void): void => {
|
||||
@@ -352,6 +355,30 @@ export default namespace abilityManager {
|
||||
});
|
||||
}
|
||||
|
||||
export function notifySaveAsResult(parameter: AbilityResult, requestCode: int, callback: AsyncCallback<void>): void {
|
||||
abilityManager.nativeNotifySaveAsResultCheck(parameter);
|
||||
let myCall = new AsyncCallbackWrapper<void>(callback);
|
||||
taskpool.execute( (): void => {
|
||||
abilityManager.nativeNotifySaveAsResult(parameter, requestCode, myCall);
|
||||
});
|
||||
}
|
||||
|
||||
export function notifySaveAsResult(parameter: AbilityResult, requestCode: int): Promise<void> {
|
||||
abilityManager.nativeNotifySaveAsResultCheck(parameter);
|
||||
return new Promise<void>((resolve: (data: undefined) => void, reject: (err: BusinessError) => void): void => {
|
||||
let asyncCall = new AsyncCallbackWrapper<void>((err: BusinessError | null) => {
|
||||
if (err == null || err.code == 0) {
|
||||
resolve(undefined);
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
taskpool.execute((): void => {
|
||||
abilityManager.nativeNotifySaveAsResult(parameter, requestCode, asyncCall);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export enum AbilityState {
|
||||
INITIAL = 0,
|
||||
FOCUS = 2,
|
||||
|
||||
@@ -213,6 +213,8 @@ export default class UIAbilityContext extends Context {
|
||||
private native nativeStartAbilityForResultWithAccountCheck(): void;
|
||||
private native nativeSetMissionWindowIcon(windowIcon: image.PixelMap, callback: AsyncCallbackWrapper<void>): void;
|
||||
|
||||
private native nativeSetOnNewWantSkipScenarios(scenarios: int, callback: AsyncCallbackWrapper<void>): void;
|
||||
|
||||
startAbility(want: Want, callback: AsyncCallback<void>): void {
|
||||
let myCall = new AsyncCallbackWrapper<void>(callback);
|
||||
taskpool.execute((): void => {
|
||||
@@ -1079,4 +1081,21 @@ hideAbility(): Promise<void> {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setOnNewWantSkipScenarios(scenarios: int): Promise<void> {
|
||||
return new Promise<void>((resolve: (data: undefined) => void, reject: (err: BusinessError) => void): void => {
|
||||
let callback = new AsyncCallbackWrapper<void>((err: BusinessError | null) => {
|
||||
if (err == null || err.code == 0) {
|
||||
resolve(undefined);
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
taskpool.execute((): void => {
|
||||
this.nativeSetOnNewWantSkipScenarios(scenarios, callback);
|
||||
}).catch((err: Error): void => {
|
||||
reject(err as BusinessError);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user