• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "js_app_control.h"
16 
17 #include <string>
18 
19 #include "app_log_wrapper.h"
20 #include "app_control_interface.h"
21 #include "bundle_mgr_interface.h"
22 #include "bundle_mgr_proxy.h"
23 #include "bundle_errors.h"
24 #include "business_error.h"
25 #include "common_func.h"
26 #include "ipc_skeleton.h"
27 #include "napi_arg.h"
28 #include "napi_constants.h"
29 
30 namespace OHOS {
31 namespace AppExecFwk {
32 using namespace OHOS::AAFwk;
33 namespace {
34 const std::string PARAM_TYPE_CHECK_ERROR = "param type check error";
35 const std::string TYPE_WANT = "want";
36 const std::string PERMISSION_DISPOSED_STATUS = "ohos.permission.MANAGE_DISPOSED_APP_STATUS";
37 const std::string SET_DISPOSED_STATUS = "SetDisposedStatus";
38 const std::string GET_DISPOSED_STATUS = "GetDisposedStatus";
39 const std::string DELETE_DISPOSED_STATUS = "DeleteDisposedStatus";
40 const std::string SET_DISPOSED_STATUS_SYNC = "SetDisposedStatusSync";
41 const std::string DELETE_DISPOSED_STATUS_SYNC = "DeleteDisposedStatusSync";
42 const std::string GET_DISPOSED_STATUS_SYNC = "GetDisposedStatusSync";
43 const std::string APP_ID = "appId";
44 const std::string DISPOSED_WANT = "disposedWant";
45 }
GetAppControlProxy()46 static OHOS::sptr<OHOS::AppExecFwk::IAppControlMgr> GetAppControlProxy()
47 {
48     auto bundleMgr = CommonFunc::GetBundleMgr();
49     if (bundleMgr == nullptr) {
50         APP_LOGE("CommonFunc::GetBundleMgr failed.");
51         return nullptr;
52     }
53     auto appControlProxy = bundleMgr->GetAppControlProxy();
54     if (appControlProxy == nullptr) {
55         APP_LOGE("GetAppControlProxy failed.");
56         return nullptr;
57     }
58     return appControlProxy;
59 }
60 
InnerGetDisposedStatus(napi_env,const std::string & appId,Want & disposedWant)61 static ErrCode InnerGetDisposedStatus(napi_env, const std::string& appId, Want& disposedWant)
62 {
63     auto appControlProxy = GetAppControlProxy();
64     if (appControlProxy == nullptr) {
65         APP_LOGE("AppControlProxy is null.");
66         return ERROR_SYSTEM_ABILITY_NOT_FOUND;
67     }
68     ErrCode ret = appControlProxy->GetDisposedStatus(appId, disposedWant);
69     return CommonFunc::ConvertErrCode(ret);
70 }
71 
InnerSetDisposedStatus(napi_env,const std::string & appId,Want & disposedWant)72 static ErrCode InnerSetDisposedStatus(napi_env, const std::string& appId, Want& disposedWant)
73 {
74     auto appControlProxy = GetAppControlProxy();
75     if (appControlProxy == nullptr) {
76         APP_LOGE("AppControlProxy is null.");
77         return ERROR_SYSTEM_ABILITY_NOT_FOUND;
78     }
79     ErrCode ret = appControlProxy->SetDisposedStatus(appId, disposedWant);
80     return CommonFunc::ConvertErrCode(ret);
81 }
82 
InnerDeleteDisposedStatus(napi_env,const std::string & appId)83 static ErrCode InnerDeleteDisposedStatus(napi_env, const std::string& appId)
84 {
85     auto appControlProxy = GetAppControlProxy();
86     if (appControlProxy == nullptr) {
87         APP_LOGE("AppControlProxy is null.");
88         return ERROR_SYSTEM_ABILITY_NOT_FOUND;
89     }
90     ErrCode ret = appControlProxy->DeleteDisposedStatus(appId);
91     return CommonFunc::ConvertErrCode(ret);
92 }
93 
SetDisposedStatusExec(napi_env env,void * data)94 void SetDisposedStatusExec(napi_env env, void *data)
95 {
96     DisposedStatus *asyncCallbackInfo = reinterpret_cast<DisposedStatus *>(data);
97     if (asyncCallbackInfo == nullptr) {
98         APP_LOGE("%{public}s, asyncCallbackInfo == nullptr.", __func__);
99         return;
100     }
101     if (asyncCallbackInfo->err == NO_ERROR) {
102         asyncCallbackInfo->err = InnerSetDisposedStatus(env, asyncCallbackInfo->appId,
103             asyncCallbackInfo->want);
104     }
105 }
106 
SetDisposedStatusComplete(napi_env env,napi_status status,void * data)107 void SetDisposedStatusComplete(napi_env env, napi_status status, void *data)
108 {
109     DisposedStatus *asyncCallbackInfo = reinterpret_cast<DisposedStatus *>(data);
110     if (asyncCallbackInfo == nullptr) {
111         APP_LOGE("asyncCallbackInfo is null in %{public}s", __func__);
112         return;
113     }
114     std::unique_ptr<DisposedStatus> callbackPtr {asyncCallbackInfo};
115     napi_value result[1] = {0};
116     if (asyncCallbackInfo->err == NO_ERROR) {
117         NAPI_CALL_RETURN_VOID(env, napi_get_null(env, &result[0]));
118     } else {
119         APP_LOGE("SetDisposedStatus err = %{public}d", asyncCallbackInfo->err);
120         result[0] = BusinessError::CreateCommonError(
121             env, asyncCallbackInfo->err, SET_DISPOSED_STATUS, PERMISSION_DISPOSED_STATUS);
122     }
123     CommonFunc::NapiReturnDeferred<DisposedStatus>(env, asyncCallbackInfo, result, ARGS_SIZE_ONE);
124 }
125 
SetDisposedStatus(napi_env env,napi_callback_info info)126 napi_value SetDisposedStatus(napi_env env, napi_callback_info info)
127 {
128     APP_LOGD("begin to SetDisposedStatus");
129     NapiArg args(env, info);
130     DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env);
131     if (asyncCallbackInfo == nullptr) {
132         APP_LOGE("asyncCallbackInfo is null.");
133         return nullptr;
134     }
135     std::unique_ptr<DisposedStatus> callbackPtr {asyncCallbackInfo};
136     if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_THREE)) {
137         APP_LOGE("Napi func init failed");
138         BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
139         return nullptr;
140     }
141     for (size_t i = 0; i < args.GetMaxArgc(); ++i) {
142         napi_valuetype valueType = napi_undefined;
143         napi_typeof(env, args[i], &valueType);
144         if (i == ARGS_POS_ZERO) {
145             if (!CommonFunc::ParseString(env, args[i], asyncCallbackInfo->appId)) {
146                 APP_LOGE("appId invalid!");
147                 BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
148                 return nullptr;
149             }
150             asyncCallbackInfo->err = asyncCallbackInfo->appId.size() == 0 ? ERROR_INVALID_APPID : NO_ERROR;
151         } else if (i == ARGS_POS_ONE) {
152             if (!CommonFunc::ParseWantWithoutVerification(env, args[i], asyncCallbackInfo->want)) {
153                 APP_LOGE("disposed want invalid!");
154                 BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_WANT, TYPE_WANT);
155                 return nullptr;
156             }
157         } else if (i == ARGS_POS_TWO) {
158             if (valueType == napi_function) {
159                 NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback));
160             } else {
161                 APP_LOGD("SetDisposedStatus extra arg ignored");
162             }
163         } else {
164             APP_LOGE("SetDisposedStatus arg err!");
165             BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_TYPE_CHECK_ERROR);
166             return nullptr;
167         }
168     }
169     auto promise = CommonFunc::AsyncCallNativeMethod<DisposedStatus>(
170         env, asyncCallbackInfo, "SetDisposedStatus", SetDisposedStatusExec, SetDisposedStatusComplete);
171     callbackPtr.release();
172     APP_LOGD("call SetDisposedStatus done.");
173     return promise;
174 }
175 
SetDisposedStatusSync(napi_env env,napi_callback_info info)176 napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info)
177 {
178     APP_LOGD("begin to SetDisposedStatusSync");
179     NapiArg args(env, info);
180     napi_value nRet;
181     napi_get_undefined(env, &nRet);
182     if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_TWO)) {
183         APP_LOGE("Napi func init failed");
184         BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
185         return nRet;
186     }
187     std::string appId;
188     if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
189         APP_LOGE("appId %{public}s invalid!", appId.c_str());
190         BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
191         return nRet;
192     }
193     if (appId.size() == 0) {
194         napi_value businessError = BusinessError::CreateCommonError(
195             env, ERROR_INVALID_APPID, SET_DISPOSED_STATUS_SYNC);
196         napi_throw(env, businessError);
197         return nullptr;
198     }
199     OHOS::AAFwk::Want want;
200     if (!CommonFunc::ParseWantWithoutVerification(env, args[ARGS_POS_ONE], want)) {
201         APP_LOGE("want invalid!");
202         BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_WANT, TYPE_WANT);
203         return nRet;
204     }
205     auto appControlProxy = GetAppControlProxy();
206     if (appControlProxy == nullptr) {
207         APP_LOGE("AppControlProxy is null.");
208         napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND,
209             SET_DISPOSED_STATUS_SYNC);
210         napi_throw(env, error);
211         return nRet;
212     }
213     ErrCode ret = appControlProxy->SetDisposedStatus(appId, want);
214     ret = CommonFunc::ConvertErrCode(ret);
215     if (ret != NO_ERROR) {
216         APP_LOGE("SetDisposedStatusSync err = %{public}d", ret);
217         napi_value businessError = BusinessError::CreateCommonError(
218             env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS);
219         napi_throw(env, businessError);
220     }
221     APP_LOGD("call SetDisposedStatusSync done.");
222     return nRet;
223 }
224 
DeleteDisposedStatusExec(napi_env env,void * data)225 void DeleteDisposedStatusExec(napi_env env, void *data)
226 {
227     DisposedStatus *asyncCallbackInfo = reinterpret_cast<DisposedStatus *>(data);
228     if (asyncCallbackInfo == nullptr) {
229         APP_LOGE("asyncCallbackInfo is null in %{public}s", __func__);
230         return;
231     }
232     if (asyncCallbackInfo->err == NO_ERROR) {
233         asyncCallbackInfo->err = InnerDeleteDisposedStatus(env, asyncCallbackInfo->appId);
234     }
235 }
236 
DeleteDisposedStatusComplete(napi_env env,napi_status,void * data)237 void DeleteDisposedStatusComplete(napi_env env, napi_status, void *data)
238 {
239     DisposedStatus *asyncCallbackInfo = reinterpret_cast<DisposedStatus *>(data);
240     if (asyncCallbackInfo == nullptr) {
241         APP_LOGE("asyncCallbackInfo is null in %{public}s", __func__);
242         return;
243     }
244     std::unique_ptr<DisposedStatus> callbackPtr {asyncCallbackInfo};
245     napi_value result[1] = {0};
246     if (asyncCallbackInfo->err == NO_ERROR) {
247         NAPI_CALL_RETURN_VOID(env, napi_get_null(env, &result[0]));
248     } else {
249         APP_LOGE("DeleteDisposedStatus err = %{public}d", asyncCallbackInfo->err);
250         result[0] = BusinessError::CreateCommonError(
251             env, asyncCallbackInfo->err, DELETE_DISPOSED_STATUS, PERMISSION_DISPOSED_STATUS);
252     }
253     CommonFunc::NapiReturnDeferred<DisposedStatus>(env, asyncCallbackInfo, result, ARGS_SIZE_ONE);
254 }
255 
DeleteDisposedStatus(napi_env env,napi_callback_info info)256 napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info)
257 {
258     APP_LOGD("begin to DeleteDisposedStatus.");
259     NapiArg args(env, info);
260     DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env);
261     if (asyncCallbackInfo == nullptr) {
262         APP_LOGE("asyncCallbackInfo is null.");
263         return nullptr;
264     }
265     std::unique_ptr<DisposedStatus> callbackPtr {asyncCallbackInfo};
266     if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) {
267         APP_LOGE("param count invalid.");
268         BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
269         return nullptr;
270     }
271     for (size_t i = 0; i < args.GetMaxArgc(); ++i) {
272         napi_valuetype valueType = napi_undefined;
273         napi_typeof(env, args[i], &valueType);
274         if (i == ARGS_POS_ZERO) {
275             if (!CommonFunc::ParseString(env, args[i], asyncCallbackInfo->appId)) {
276                 APP_LOGE("appId invalid!");
277                 BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
278                 return nullptr;
279             }
280             if (asyncCallbackInfo->appId.size() == 0) {
281                 asyncCallbackInfo->err = ERROR_INVALID_APPID;
282             }
283         } else if (i == ARGS_POS_ONE) {
284             if (valueType == napi_function) {
285                 NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback));
286             } else {
287                 APP_LOGD("DeleteDisposedStatus extra arg ignored");
288             }
289         } else {
290             APP_LOGE("DeleteDisposedStatus arg err!");
291             BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_TYPE_CHECK_ERROR);
292             return nullptr;
293         }
294     }
295     auto promise = CommonFunc::AsyncCallNativeMethod<DisposedStatus>(
296         env, asyncCallbackInfo, "DeleteDisposedStatus", DeleteDisposedStatusExec, DeleteDisposedStatusComplete);
297     callbackPtr.release();
298     APP_LOGD("call DeleteDisposedStatus done.");
299     return promise;
300 }
301 
DeleteDisposedStatusSync(napi_env env,napi_callback_info info)302 napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info)
303 {
304     APP_LOGD("begin to DeleteDisposedStatusSync.");
305     NapiArg args(env, info);
306     napi_value nRet;
307     napi_get_undefined(env, &nRet);
308     if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) {
309         APP_LOGE("param count invalid.");
310         BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
311         return nRet;
312     }
313     std::string appId;
314     if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
315         APP_LOGE("appId %{public}s invalid!", appId.c_str());
316         BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
317         return nRet;
318     }
319     if (appId.size() == 0) {
320         napi_value businessError = BusinessError::CreateCommonError(
321             env, ERROR_INVALID_APPID, DELETE_DISPOSED_STATUS_SYNC);
322         napi_throw(env, businessError);
323         return nullptr;
324     }
325     auto appControlProxy = GetAppControlProxy();
326     if (appControlProxy == nullptr) {
327         APP_LOGE("AppControlProxy is null");
328         napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND,
329             DELETE_DISPOSED_STATUS_SYNC);
330         napi_throw(env, error);
331         return nRet;
332     }
333     ErrCode ret = appControlProxy->DeleteDisposedStatus(appId);
334     ret = CommonFunc::ConvertErrCode(ret);
335     if (ret != NO_ERROR) {
336         APP_LOGE("DeleteDisposedStatusSync err = %{public}d", ret);
337         napi_value businessError = BusinessError::CreateCommonError(
338             env, ret, DELETE_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS);
339         napi_throw(env, businessError);
340     }
341     APP_LOGD("call DeleteDisposedStatusSync done.");
342     return nRet;
343 }
344 
GetDisposedStatusExec(napi_env env,void * data)345 void GetDisposedStatusExec(napi_env env, void *data)
346 {
347     DisposedStatus *asyncCallbackInfo = reinterpret_cast<DisposedStatus *>(data);
348     if (asyncCallbackInfo == nullptr) {
349         APP_LOGE("asyncCallbackInfo is null in %{public}s", __func__);
350         return;
351     }
352     if (asyncCallbackInfo->err == NO_ERROR) {
353         asyncCallbackInfo->err = InnerGetDisposedStatus(env, asyncCallbackInfo->appId,
354             asyncCallbackInfo->want);
355     }
356 }
357 
GetDisposedStatusComplete(napi_env env,napi_status status,void * data)358 void GetDisposedStatusComplete(napi_env env, napi_status status, void *data)
359 {
360     DisposedStatus *asyncCallbackInfo = reinterpret_cast<DisposedStatus *>(data);
361     if (asyncCallbackInfo == nullptr) {
362         APP_LOGE("asyncCallbackInfo is null in %{public}s", __func__);
363         return;
364     }
365     std::unique_ptr<DisposedStatus> callbackPtr {asyncCallbackInfo};
366     napi_value result[2] = {0};
367     if (asyncCallbackInfo->err == NO_ERROR) {
368         NAPI_CALL_RETURN_VOID(env, napi_get_null(env, &result[0]));
369         NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &result[1]));
370         CommonFunc::ConvertWantInfo(env, result[1], asyncCallbackInfo->want);
371     } else {
372         APP_LOGE("GetDisposedStatus err = %{public}d", asyncCallbackInfo->err);
373         result[0] = BusinessError::CreateCommonError(
374             env, asyncCallbackInfo->err, GET_DISPOSED_STATUS, PERMISSION_DISPOSED_STATUS);
375     }
376     CommonFunc::NapiReturnDeferred<DisposedStatus>(env, asyncCallbackInfo, result, ARGS_SIZE_TWO);
377 }
378 
GetDisposedStatus(napi_env env,napi_callback_info info)379 napi_value GetDisposedStatus(napi_env env, napi_callback_info info)
380 {
381     APP_LOGD("NAPI GetDisposedStatus called");
382     NapiArg args(env, info);
383     DisposedStatus *asyncCallbackInfo = new (std::nothrow) DisposedStatus(env);
384     if (asyncCallbackInfo == nullptr) {
385         APP_LOGE("asyncCallbackInfo is null.");
386         return nullptr;
387     }
388     std::unique_ptr<DisposedStatus> callbackPtr {asyncCallbackInfo};
389     if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) {
390         APP_LOGE("param count invalid.");
391         BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
392         return nullptr;
393     }
394     for (size_t i = 0; i < args.GetMaxArgc(); i++) {
395         napi_valuetype valueType = napi_undefined;
396         napi_typeof(env, args[i], &valueType);
397         if (i == ARGS_POS_ZERO) {
398             if (!CommonFunc::ParseString(env, args[i], asyncCallbackInfo->appId)) {
399                 APP_LOGE("appId %{public}s invalid!", asyncCallbackInfo->appId.c_str());
400                 BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
401                 return nullptr;
402             }
403             if (asyncCallbackInfo->appId.size() == 0) {
404                 asyncCallbackInfo->err = ERROR_INVALID_APPID;
405             }
406         } else if (i == ARGS_POS_ONE) {
407             if (valueType == napi_function) {
408                 NAPI_CALL(env, napi_create_reference(env, args[i], NAPI_RETURN_ONE, &asyncCallbackInfo->callback));
409             } else {
410                 APP_LOGD("GetDisposedStatus extra arg ignored");
411             }
412         } else {
413             APP_LOGE("GetDisposedStatus arg err!");
414             BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_TYPE_CHECK_ERROR);
415             return nullptr;
416         }
417     }
418     auto promise = CommonFunc::AsyncCallNativeMethod<DisposedStatus>(
419         env, asyncCallbackInfo, "GetDisposedStatus", GetDisposedStatusExec, GetDisposedStatusComplete);
420     callbackPtr.release();
421     APP_LOGD("call GetDisposedStatus done.");
422     return promise;
423 }
424 
GetDisposedStatusSync(napi_env env,napi_callback_info info)425 napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info)
426 {
427     APP_LOGD("NAPI GetDisposedStatusSync called");
428     NapiArg args(env, info);
429     if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) {
430         APP_LOGE("param count invalid.");
431         BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
432         return nullptr;
433     }
434     std::string appId;
435     if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
436         APP_LOGE("appId %{public}s invalid!", appId.c_str());
437         BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
438         return nullptr;
439     }
440     if (appId.size() == 0) {
441         napi_value businessError = BusinessError::CreateCommonError(
442             env, ERROR_INVALID_APPID, GET_DISPOSED_STATUS_SYNC);
443         napi_throw(env, businessError);
444         return nullptr;
445     }
446     auto appControlProxy = GetAppControlProxy();
447     if (appControlProxy == nullptr) {
448         APP_LOGE("AppControlProxy is null");
449         napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND,
450             GET_DISPOSED_STATUS_SYNC);
451         napi_throw(env, error);
452         return nullptr;
453     }
454     OHOS::AAFwk::Want disposedWant;
455     ErrCode ret = appControlProxy->GetDisposedStatus(appId, disposedWant);
456     ret = CommonFunc::ConvertErrCode(ret);
457     if (ret != ERR_OK) {
458         APP_LOGE("GetDisposedStatusSync failed");
459         napi_value businessError = BusinessError::CreateCommonError(
460             env, ret, GET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS);
461         napi_throw(env, businessError);
462         return nullptr;
463     }
464     napi_value nWant = nullptr;
465     NAPI_CALL(env, napi_create_object(env, &nWant));
466     CommonFunc::ConvertWantInfo(env, nWant, disposedWant);
467     APP_LOGD("call GetDisposedStatusSync done.");
468     return nWant;
469 }
470 }
471 }