已合并
appindex适配 #20364
yi创建于 6 天前
appindex适配 #20364
已合并
共 57 个文件变更+273-213
| @@ -219,7 +219,7 @@ void EtsAppManager::PreloadApplication(ani_env *env, ani_object callback, ani_st | |||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | ani_status status = ANI_OK; | 221 | ani_status status = ANI_OK; |
| 222 | - int32_t appIndex = 0; | 222 | + int32_t appIndex = -1; |
| 223 | ani_boolean isUndefined = false; | 223 | ani_boolean isUndefined = false; |
| 224 | if ((status = env->Reference_IsUndefined(aniAppIndex, &isUndefined)) != ANI_OK) { | 224 | if ((status = env->Reference_IsUndefined(aniAppIndex, &isUndefined)) != ANI_OK) { |
| 225 | TAG_LOGE(AAFwkTag::APPMGR, "Failed to check undefined status : %{public}d", status); | 225 | TAG_LOGE(AAFwkTag::APPMGR, "Failed to check undefined status : %{public}d", status); |
| @@ -911,7 +911,7 @@ void EtsAppManager::KillProcessesByBundleNameInner(ani_env *env, ani_object call | |||
| 911 | env, "Parse param bundleName failed, must be a string."), nullptr); | 911 | env, "Parse param bundleName failed, must be a string."), nullptr); |
| 912 | return; | 912 | return; |
| 913 | } | 913 | } |
| 914 | - int32_t appIndex = 0; | 914 | + int32_t appIndex = -1; |
| 915 | ani_status status = ANI_OK; | 915 | ani_status status = ANI_OK; |
| 916 | ani_boolean isUndefined = false; | 916 | ani_boolean isUndefined = false; |
| 917 | if ((status = env->Reference_IsUndefined(etsAppIndex, &isUndefined)) != ANI_OK) { | 917 | if ((status = env->Reference_IsUndefined(etsAppIndex, &isUndefined)) != ANI_OK) { |
| @@ -994,7 +994,7 @@ void EtsAppManager::KillProcessWithAccountInner(ani_env *env, ani_object callbac | |||
| 994 | return; | 994 | return; |
| 995 | } | 995 | } |
| 996 | TAG_LOGD(AAFwkTag::APPMGR, "KillProcessWithAccount accountId:%{public}d", aniAccountId); | 996 | TAG_LOGD(AAFwkTag::APPMGR, "KillProcessWithAccount accountId:%{public}d", aniAccountId); |
| 997 | - int32_t appIndex = 0; | 997 | + int32_t appIndex = -1; |
| 998 | ani_status status = ANI_OK; | 998 | ani_status status = ANI_OK; |
| 999 | ani_boolean isUndefined = false; | 999 | ani_boolean isUndefined = false; |
| 1000 | if ((status = env->Reference_IsUndefined(aniAppIndex, &isUndefined)) != ANI_OK) { | 1000 | if ((status = env->Reference_IsUndefined(aniAppIndex, &isUndefined)) != ANI_OK) { |
| @@ -844,7 +844,7 @@ private: | |||
| 844 | if (argc > ARGC_ONE && ConvertFromJsValue(env, argv[INDEX_ONE], clearPageStack)) { | 844 | if (argc > ARGC_ONE && ConvertFromJsValue(env, argv[INDEX_ONE], clearPageStack)) { |
| 845 | hasClearPageStack = true; | 845 | hasClearPageStack = true; |
| 846 | } | 846 | } |
| 847 | - int32_t appIndex = 0; | 847 | + int32_t appIndex = -1; |
| 848 | if (hasClearPageStack && argc == ARGC_THREE && !ConvertFromJsValue(env, argv[INDEX_TWO], appIndex)) { | 848 | if (hasClearPageStack && argc == ARGC_THREE && !ConvertFromJsValue(env, argv[INDEX_TWO], appIndex)) { |
| 849 | TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed"); | 849 | TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed"); |
| 850 | ThrowInvalidParamError(env, "Parse param appIndex failed, must be a number."); | 850 | ThrowInvalidParamError(env, "Parse param appIndex failed, must be a number."); |
| @@ -1087,7 +1087,7 @@ private: | |||
| 1087 | if (argc > ARGC_TWO && ConvertFromJsValue(env, argv[INDEX_TWO], clearPageStack)) { | 1087 | if (argc > ARGC_TWO && ConvertFromJsValue(env, argv[INDEX_TWO], clearPageStack)) { |
| 1088 | hasClearPageStack = true; | 1088 | hasClearPageStack = true; |
| 1089 | } | 1089 | } |
| 1090 | - int32_t appIndex = 0; | 1090 | + int32_t appIndex = -1; |
| 1091 | if (hasClearPageStack && argc == ARGC_FOUR && !ConvertFromJsValue(env, argv[INDEX_THREE], appIndex)) { | 1091 | if (hasClearPageStack && argc == ARGC_FOUR && !ConvertFromJsValue(env, argv[INDEX_THREE], appIndex)) { |
| 1092 | ThrowInvalidParamError(env, "Parse param appIndex failed, must be a number."); | 1092 | ThrowInvalidParamError(env, "Parse param appIndex failed, must be a number."); |
| 1093 | return CreateJsUndefined(env); | 1093 | return CreateJsUndefined(env); |
| @@ -46,7 +46,7 @@ struct UriPermissionParam { | |||
| 46 | std::string uriStr; | 46 | std::string uriStr; |
| 47 | int32_t flag = 0; | 47 | int32_t flag = 0; |
| 48 | std::string bundleName; | 48 | std::string bundleName; |
| 49 | - int32_t appIndex = 0; | 49 | + int32_t appIndex = -1; |
| 50 | bool hasAppIndex = false; | 50 | bool hasAppIndex = false; |
| 51 | std::string key; | 51 | std::string key; |
| 52 | int32_t callerTokenId = 0; | 52 | int32_t callerTokenId = 0; |
| @@ -1062,6 +1062,18 @@ ErrCode BundleMgrHelper::GetAppClonePreference(const std::string &bundleName, in | |||
| 1062 | return bundleMgr->GetAppClonePreference(bundleName, userId, preference); | 1062 | return bundleMgr->GetAppClonePreference(bundleName, userId, preference); |
| 1063 | } | 1063 | } |
| 1064 | 1064 | ||
| 1065 | +ErrCode BundleMgrHelper::GetDualModeBundleInfo(const std::string &bundleName, int32_t userId, | ||
| 1066 | + DualModeBundleInfo &preference) | ||
| 1067 | +{ | ||
| 1068 | + auto bundleMgr = Connect(); | ||
| 1069 | + if (bundleMgr == nullptr) { | ||
| 1070 | + TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "null bundleMgr"); | ||
| 1071 | + return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; | ||
| 1072 | + } | ||
| 1073 | + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); | ||
| 1074 | + return bundleMgr->GetDualModeBundleInfo(bundleName, userId, preference); | ||
| 1075 | +} | ||
| 1076 | + | ||
| 1065 | ErrCode BundleMgrHelper::GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) | 1077 | ErrCode BundleMgrHelper::GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) |
| 1066 | { | 1078 | { |
| 1067 | TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called"); | 1079 | TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called"); |
| @@ -1199,7 +1199,7 @@ public: | |||
| 1199 | * GET_BUNDLE_INFO_FAILED when the bundle cannot be resolved; | 1199 | * GET_BUNDLE_INFO_FAILED when the bundle cannot be resolved; |
| 1200 | * KILL_PROCESS_KEEP_ALIVE for persistent apps; KILL_PROCESS_FAILED on failure. | 1200 | * KILL_PROCESS_KEEP_ALIVE for persistent apps; KILL_PROCESS_FAILED on failure. |
| 1201 | */ | 1201 | */ |
| 1202 | - ErrCode KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 1202 | + ErrCode KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 1203 | const std::string& reason = "Abilityms::KillProcess"); | 1203 | const std::string& reason = "Abilityms::KillProcess"); |
| 1204 | 1204 | ||
| 1205 | 1205 | ||
| @@ -1865,7 +1865,7 @@ public: | |||
| 1865 | * @param appIndex App clone index; only appIndex = 0 is supported. | 1865 | * @param appIndex App clone index; only appIndex = 0 is supported. |
| 1866 | * @return Returns ERR_OK on success; CHECK_PERMISSION_FAILED for others. | 1866 | * @return Returns ERR_OK on success; CHECK_PERMISSION_FAILED for others. |
| 1867 | */ | 1867 | */ |
| 1868 | - ErrCode LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = 0); | 1868 | + ErrCode LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = -1); |
| 1869 | 1869 | ||
| 1870 | /** | 1870 | /** |
| 1871 | * @brief Report the pre-launch completion time (ms) of a game. | 1871 | * @brief Report the pre-launch completion time (ms) of a game. |
| @@ -1003,7 +1003,7 @@ public: | |||
| 1003 | * @param bundleName. | 1003 | * @param bundleName. |
| 1004 | * @return Returns ERR_OK on success, others on failure. | 1004 | * @return Returns ERR_OK on success, others on failure. |
| 1005 | */ | 1005 | */ |
| 1006 | - virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 1006 | + virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 1007 | const std::string& reason = "Abilityms::KillProcess") = 0; | 1007 | const std::string& reason = "Abilityms::KillProcess") = 0; |
| 1008 | 1008 | ||
| 1009 | 1009 | ||
| @@ -1052,7 +1052,7 @@ public: | |||
| 1052 | * @return Returns ERR_OK on success, others on failure. | 1052 | * @return Returns ERR_OK on success, others on failure. |
| 1053 | */ | 1053 | */ |
| 1054 | virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, | 1054 | virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, |
| 1055 | - int32_t appIndex = 0) | 1055 | + int32_t appIndex = -1) |
| 1056 | { | 1056 | { |
| 1057 | return 0; | 1057 | return 0; |
| 1058 | } | 1058 | } |
| @@ -1969,7 +1969,7 @@ public: | |||
| 1969 | * @param appIndex app clone index. Currently, only appIndex = 0 is supported. | 1969 | * @param appIndex app clone index. Currently, only appIndex = 0 is supported. |
| 1970 | * @return Returns ERR_OK on success, others on failure. | 1970 | * @return Returns ERR_OK on success, others on failure. |
| 1971 | */ | 1971 | */ |
| 1972 | - virtual int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = 0) | 1972 | + virtual int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = -1) |
| 1973 | { | 1973 | { |
| 1974 | return 0; | 1974 | return 0; |
| 1975 | } | 1975 | } |
| @@ -33,7 +33,7 @@ struct DialogAbilityInfo { | |||
| 33 | int32_t bundleLabelId = 0; | 33 | int32_t bundleLabelId = 0; |
| 34 | int32_t abilityIconId = 0; | 34 | int32_t abilityIconId = 0; |
| 35 | int32_t abilityLabelId = 0; | 35 | int32_t abilityLabelId = 0; |
| 36 | - int32_t appIndex = 0; | 36 | + int32_t appIndex = -1; |
| 37 | std::string bundleName; | 37 | std::string bundleName; |
| 38 | std::string moduleName; | 38 | std::string moduleName; |
| 39 | std::string abilityName; | 39 | std::string abilityName; |
| @@ -59,7 +59,7 @@ struct ModularObjectExtensionInfo : public Parcelable { | |||
| 59 | std::string bundleName; | 59 | std::string bundleName; |
| 60 | std::string moduleName; | 60 | std::string moduleName; |
| 61 | std::string abilityName; | 61 | std::string abilityName; |
| 62 | - int32_t appIndex = 0; | 62 | + int32_t appIndex = -1; |
| 63 | MoeLaunchMode launchMode = MoeLaunchMode::IN_PROCESS; | 63 | MoeLaunchMode launchMode = MoeLaunchMode::IN_PROCESS; |
| 64 | MoeProcessMode processMode = MoeProcessMode::BUNDLE; | 64 | MoeProcessMode processMode = MoeProcessMode::BUNDLE; |
| 65 | MoeThreadMode threadMode = MoeThreadMode::BUNDLE; | 65 | MoeThreadMode threadMode = MoeThreadMode::BUNDLE; |
| @@ -157,7 +157,7 @@ public: | |||
| 157 | * @return ERR_OK, return back success, others fail. | 157 | * @return ERR_OK, return back success, others fail. |
| 158 | */ | 158 | */ |
| 159 | virtual int KillProcessWithAccount(const std::string &bundleName, const int accountId, | 159 | virtual int KillProcessWithAccount(const std::string &bundleName, const int accountId, |
| 160 | - const bool clearPageStack = false, int32_t appIndex = 0) = 0; | 160 | + const bool clearPageStack = false, int32_t appIndex = -1) = 0; |
| 161 | 161 | ||
| 162 | /** | 162 | /** |
| 163 | * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; | 163 | * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; |
| @@ -185,7 +185,7 @@ public: | |||
| 185 | * @param bundleName, bundle name in Application record. | 185 | * @param bundleName, bundle name in Application record. |
| 186 | * @return ERR_OK, return back success, others fail. | 186 | * @return ERR_OK, return back success, others fail. |
| 187 | */ | 187 | */ |
| 188 | - virtual int KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 188 | + virtual int KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 189 | const std::string &reason = "KillApplication") = 0; | 189 | const std::string &reason = "KillApplication") = 0; |
| 190 | 190 | ||
| 191 | /** | 191 | /** |
| @@ -196,7 +196,7 @@ public: | |||
| 196 | * @param appIndex, appIndex. | 196 | * @param appIndex, appIndex. |
| 197 | * @return ERR_OK, return back success, others fail. | 197 | * @return ERR_OK, return back success, others fail. |
| 198 | */ | 198 | */ |
| 199 | - virtual int ForceKillApplication(const std::string &bundleName, const int userId = -1, const int appIndex = 0) = 0; | 199 | + virtual int ForceKillApplication(const std::string &bundleName, const int userId = -1, const int appIndex = -1) = 0; |
| 200 | 200 | ||
| 201 | /** | 201 | /** |
| 202 | * KillApplicationWithUserId, call KillApplicationWithUserId() through proxy object, kill the application. | 202 | * KillApplicationWithUserId, call KillApplicationWithUserId() through proxy object, kill the application. |
| @@ -207,7 +207,7 @@ public: | |||
| 207 | * @return ERR_OK, return back success, others fail. | 207 | * @return ERR_OK, return back success, others fail. |
| 208 | */ | 208 | */ |
| 209 | virtual int KillApplicationWithUserId(const std::string &bundleName, | 209 | virtual int KillApplicationWithUserId(const std::string &bundleName, |
| 210 | - const int userId = -1, const int appIndex = 0) = 0; | 210 | + const int userId = -1, const int appIndex = -1) = 0; |
| 211 | 211 | ||
| 212 | /** | 212 | /** |
| 213 | * KillProcessesByAccessTokenId, call KillProcessesByAccessTokenId() through proxy object, | 213 | * KillProcessesByAccessTokenId, call KillProcessesByAccessTokenId() through proxy object, |
| @@ -145,7 +145,7 @@ public: | |||
| 145 | * @return ERR_OK, return back success, others fail. | 145 | * @return ERR_OK, return back success, others fail. |
| 146 | */ | 146 | */ |
| 147 | virtual int32_t KillProcessWithAccount(const std::string &bundleName, const int accountId, | 147 | virtual int32_t KillProcessWithAccount(const std::string &bundleName, const int accountId, |
| 148 | - const bool clearPageStack = false, int32_t appIndex = 0) override; | 148 | + const bool clearPageStack = false, int32_t appIndex = -1) override; |
| 149 | 149 | ||
| 150 | /** | 150 | /** |
| 151 | * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; | 151 | * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; |
| @@ -174,7 +174,7 @@ public: | |||
| 174 | * @return ERR_OK, return back success, others fail. | 174 | * @return ERR_OK, return back success, others fail. |
| 175 | */ | 175 | */ |
| 176 | virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, | 176 | virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, |
| 177 | - int32_t appIndex = 0, const std::string &reason = "KillApplication") override; | 177 | + int32_t appIndex = -1, const std::string &reason = "KillApplication") override; |
| 178 | 178 | ||
| 179 | /** | 179 | /** |
| 180 | * ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application. | 180 | * ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application. |
| @@ -185,7 +185,7 @@ public: | |||
| 185 | * @return ERR_OK, return back success, others fail. | 185 | * @return ERR_OK, return back success, others fail. |
| 186 | */ | 186 | */ |
| 187 | virtual int ForceKillApplication(const std::string &bundleName, const int userId = -1, | 187 | virtual int ForceKillApplication(const std::string &bundleName, const int userId = -1, |
| 188 | - const int appIndex = 0) override; | 188 | + const int appIndex = -1) override; |
| 189 | 189 | ||
| 190 | /** | 190 | /** |
| 191 | * KillApplicationWithUserId, call KillApplicationWithUserId() through proxy object, kill the application. | 191 | * KillApplicationWithUserId, call KillApplicationWithUserId() through proxy object, kill the application. |
| @@ -196,7 +196,7 @@ public: | |||
| 196 | * @return ERR_OK, return back success, others fail. | 196 | * @return ERR_OK, return back success, others fail. |
| 197 | */ | 197 | */ |
| 198 | virtual int KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, | 198 | virtual int KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, |
| 199 | - const int appIndex = 0) override; | 199 | + const int appIndex = -1) override; |
| 200 | 200 | ||
| 201 | /** | 201 | /** |
| 202 | * KillProcessesByAccessTokenId, call KillProcessesByAccessTokenId() through proxy object, | 202 | * KillProcessesByAccessTokenId, call KillProcessesByAccessTokenId() through proxy object, |
| @@ -254,7 +254,7 @@ public: | |||
| 254 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. | 254 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. |
| 255 | */ | 255 | */ |
| 256 | virtual AppMgrResultCode KillApplication(const std::string &bundleName, bool clearPageStack = false, | 256 | virtual AppMgrResultCode KillApplication(const std::string &bundleName, bool clearPageStack = false, |
| 257 | - int32_t appIndex = 0, const std::string &reason = "KillApplication"); | 257 | + int32_t appIndex = -1, const std::string &reason = "KillApplication"); |
| 258 | 258 | ||
| 259 | /** | 259 | /** |
| 260 | * Force kill the application. Restricted: the server only accepts calls from | 260 | * Force kill the application. Restricted: the server only accepts calls from |
| @@ -269,7 +269,7 @@ public: | |||
| 269 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. | 269 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. |
| 270 | */ | 270 | */ |
| 271 | virtual AppMgrResultCode ForceKillApplication(const std::string &bundleName, const int userId = -1, | 271 | virtual AppMgrResultCode ForceKillApplication(const std::string &bundleName, const int userId = -1, |
| 272 | - const int appIndex = 0); | 272 | + const int appIndex = -1); |
| 273 | 273 | ||
| 274 | /** | 274 | /** |
| 275 | * Kill the application for the specified user. Same permission policy as | 275 | * Kill the application for the specified user. Same permission policy as |
| @@ -284,7 +284,7 @@ public: | |||
| 284 | * Note: killing an app that is not running is treated as success. | 284 | * Note: killing an app that is not running is treated as success. |
| 285 | */ | 285 | */ |
| 286 | virtual AppMgrResultCode KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, | 286 | virtual AppMgrResultCode KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, |
| 287 | - const int appIndex = 0); | 287 | + const int appIndex = -1); |
| 288 | 288 | ||
| 289 | /** | 289 | /** |
| 290 | * Kill all processes whose access token id equals accessTokenId. | 290 | * Kill all processes whose access token id equals accessTokenId. |
| @@ -698,7 +698,7 @@ public: | |||
| 698 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. | 698 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. |
| 699 | */ | 699 | */ |
| 700 | virtual AppMgrResultCode UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, | 700 | virtual AppMgrResultCode UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, |
| 701 | - int32_t appIndex = 0); | 701 | + int32_t appIndex = -1); |
| 702 | 702 | ||
| 703 | /** | 703 | /** |
| 704 | * Register an observer to receive OnConfigurationUpdated callbacks. | 704 | * Register an observer to receive OnConfigurationUpdated callbacks. |
| @@ -1371,7 +1371,7 @@ public: | |||
| 1371 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. | 1371 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. |
| 1372 | */ | 1372 | */ |
| 1373 | virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, | 1373 | virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, |
| 1374 | - AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0); | 1374 | + AppExecFwk::PreloadMode preloadMode, int32_t appIndex = -1); |
| 1375 | 1375 | ||
| 1376 | /** | 1376 | /** |
| 1377 | * Create an application image (process snapshot) for fast cold start: the | 1377 | * Create an application image (process snapshot) for fast cold start: the |
| @@ -1391,7 +1391,7 @@ public: | |||
| 1391 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. | 1391 | * ERROR_SERVICE_NOT_CONNECTED when the service is unavailable. |
| 1392 | */ | 1392 | */ |
| 1393 | int32_t MakeImage(const AAFwk::Want &want, int32_t userId, | 1393 | int32_t MakeImage(const AAFwk::Want &want, int32_t userId, |
| 1394 | - AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0, sptr<IImageErrorHandler> errorHandler = nullptr); | 1394 | + AppExecFwk::PreloadMode preloadMode, int32_t appIndex = -1, sptr<IImageErrorHandler> errorHandler = nullptr); |
| 1395 | 1395 | ||
| 1396 | /** | 1396 | /** |
| 1397 | * Destroy a previously created application image identified by its checkpoint | 1397 | * Destroy a previously created application image identified by its checkpoint |
| @@ -84,7 +84,7 @@ public: | |||
| 84 | * @return Returns ERR_OK on success, others on failure. | 84 | * @return Returns ERR_OK on success, others on failure. |
| 85 | */ | 85 | */ |
| 86 | virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, | 86 | virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, |
| 87 | - AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0) | 87 | + AppExecFwk::PreloadMode preloadMode, int32_t appIndex = -1) |
| 88 | { | 88 | { |
| 89 | return 0; | 89 | return 0; |
| 90 | } | 90 | } |
| @@ -99,7 +99,7 @@ public: | |||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | virtual int32_t MakeImage(const AAFwk::Want &want, int32_t userId, | 101 | virtual int32_t MakeImage(const AAFwk::Want &want, int32_t userId, |
| 102 | - AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0, sptr<IImageErrorHandler> errorHandler = nullptr) | 102 | + AppExecFwk::PreloadMode preloadMode, int32_t appIndex = -1, sptr<IImageErrorHandler> errorHandler = nullptr) |
| 103 | { | 103 | { |
| 104 | return 0; | 104 | return 0; |
| 105 | } | 105 | } |
| @@ -617,7 +617,7 @@ public: | |||
| 617 | * @return Returns ERR_OK on success, others on failure. | 617 | * @return Returns ERR_OK on success, others on failure. |
| 618 | */ | 618 | */ |
| 619 | virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, | 619 | virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, |
| 620 | - int32_t appIndex = 0) = 0; | 620 | + int32_t appIndex = -1) = 0; |
| 621 | 621 | ||
| 622 | /** | 622 | /** |
| 623 | * Register configuration observer. | 623 | * Register configuration observer. |
| @@ -54,7 +54,7 @@ public: | |||
| 54 | * @return Returns ERR_OK on success, others on failure. | 54 | * @return Returns ERR_OK on success, others on failure. |
| 55 | */ | 55 | */ |
| 56 | virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, | 56 | virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, |
| 57 | - AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0) override; | 57 | + AppExecFwk::PreloadMode preloadMode, int32_t appIndex = -1) override; |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | * Launch Application Finished | 60 | * Launch Application Finished |
| @@ -63,7 +63,7 @@ public: | |||
| 63 | virtual void PreloadModuleFinished(const int32_t recordId) override; | 63 | virtual void PreloadModuleFinished(const int32_t recordId) override; |
| 64 | 64 | ||
| 65 | virtual int32_t MakeImage(const AAFwk::Want &want, int32_t userId, AppExecFwk::PreloadMode preloadMode, | 65 | virtual int32_t MakeImage(const AAFwk::Want &want, int32_t userId, AppExecFwk::PreloadMode preloadMode, |
| 66 | - int32_t appIndex = 0, sptr<IImageErrorHandler> errorHandler = nullptr) override; | 66 | + int32_t appIndex = -1, sptr<IImageErrorHandler> errorHandler = nullptr) override; |
| 67 | 67 | ||
| 68 | virtual int32_t DestroyImage(uint64_t checkpointId, sptr<IImageErrorHandler> errorHandler = nullptr) override; | 68 | virtual int32_t DestroyImage(uint64_t checkpointId, sptr<IImageErrorHandler> errorHandler = nullptr) override; |
| 69 | 69 | ||
| @@ -518,7 +518,7 @@ public: | |||
| 518 | const AppExecFwk::ConfigurationPolicy &policy, const int32_t userId = -1) override; | 518 | const AppExecFwk::ConfigurationPolicy &policy, const int32_t userId = -1) override; |
| 519 | 519 | ||
| 520 | virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, | 520 | virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, |
| 521 | - int32_t appIndex = 0) override; | 521 | + int32_t appIndex = -1) override; |
| 522 | 522 | ||
| 523 | virtual int32_t RegisterConfigurationObserver(const sptr<IConfigurationObserver> &observer, | 523 | virtual int32_t RegisterConfigurationObserver(const sptr<IConfigurationObserver> &observer, |
| 524 | const int32_t userId = -1) override; | 524 | const int32_t userId = -1) override; |
| @@ -53,7 +53,7 @@ struct AppProcessData : public Parcelable { | |||
| 53 | static AppProcessData *Unmarshalling(Parcel &parcel); | 53 | static AppProcessData *Unmarshalling(Parcel &parcel); |
| 54 | 54 | ||
| 55 | bool isFocused = false; | 55 | bool isFocused = false; |
| 56 | - int32_t appIndex = 0; | 56 | + int32_t appIndex = -1; |
| 57 | ApplicationState appState = ApplicationState::APP_STATE_CREATE; | 57 | ApplicationState appState = ApplicationState::APP_STATE_CREATE; |
| 58 | pid_t pid = 0; | 58 | pid_t pid = 0; |
| 59 | std::vector<AppData> appDatas; | 59 | std::vector<AppData> appDatas; |
| @@ -66,7 +66,7 @@ struct AppStateData : public Parcelable { | |||
| 66 | int32_t uid = 0; | 66 | int32_t uid = 0; |
| 67 | int32_t callerUid = -1; | 67 | int32_t callerUid = -1; |
| 68 | int32_t state = 0; | 68 | int32_t state = 0; |
| 69 | - int32_t appIndex = 0; | 69 | + int32_t appIndex = -1; |
| 70 | uint32_t accessTokenId = 0; | 70 | uint32_t accessTokenId = 0; |
| 71 | int32_t preloadMode = -1; | 71 | int32_t preloadMode = -1; |
| 72 | ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED; | 72 | ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED; |
| @@ -85,7 +85,7 @@ public: | |||
| 85 | * @note Temporary authorization: the grant is revoked automatically when the target | 85 | * @note Temporary authorization: the grant is revoked automatically when the target |
| 86 | * application exits (ClearPermissionTokenByMap). Sandbox applications cannot call. | 86 | * application exits (ClearPermissionTokenByMap). Sandbox applications cannot call. |
| 87 | */ | 87 | */ |
| 88 | - int GrantUriPermission(const Uri &uri, uint32_t flag, const std::string targetBundleName, int32_t appIndex = 0, | 88 | + int GrantUriPermission(const Uri &uri, uint32_t flag, const std::string targetBundleName, int32_t appIndex = -1, |
| 89 | uint32_t initiatorTokenId = 0); | 89 | uint32_t initiatorTokenId = 0); |
| 90 | 90 | ||
| 91 | /** | 91 | /** |
| @@ -116,7 +116,7 @@ public: | |||
| 116 | * granted. Temporary authorization, auto-revoked on target application exit. | 116 | * granted. Temporary authorization, auto-revoked on target application exit. |
| 117 | */ | 117 | */ |
| 118 | int GrantUriPermission(const std::vector<Uri> &uriVec, uint32_t flag, const std::string targetBundleName, | 118 | int GrantUriPermission(const std::vector<Uri> &uriVec, uint32_t flag, const std::string targetBundleName, |
| 119 | - int32_t appIndex = 0, uint32_t initiatorTokenId = 0); | 119 | + int32_t appIndex = -1, uint32_t initiatorTokenId = 0); |
| 120 | 120 | ||
| 121 | /** | 121 | /** |
| 122 | * @brief Privileged batch grant of URI permission, skipping the caller's own permission | 122 | * @brief Privileged batch grant of URI permission, skipping the caller's own permission |
| @@ -156,7 +156,7 @@ public: | |||
| 156 | * the target application exits. Sandbox applications cannot call. | 156 | * the target application exits. Sandbox applications cannot call. |
| 157 | */ | 157 | */ |
| 158 | int32_t GrantUriPermissionPrivileged(const std::vector<Uri> &uriVec, uint32_t flag, | 158 | int32_t GrantUriPermissionPrivileged(const std::vector<Uri> &uriVec, uint32_t flag, |
| 159 | - const std::string &targetBundleName, int32_t appIndex = 0, uint32_t initiatorTokenId = 0, | 159 | + const std::string &targetBundleName, int32_t appIndex = -1, uint32_t initiatorTokenId = 0, |
| 160 | int32_t hideSensitiveType = DEFAULT_HIDE_SENSITIVE_TYPE); | 160 | int32_t hideSensitiveType = DEFAULT_HIDE_SENSITIVE_TYPE); |
| 161 | 161 | ||
| 162 | /** | 162 | /** |
| @@ -257,7 +257,7 @@ public: | |||
| 257 | * @note Permission required: caller must be a system application (or the pasteboard | 257 | * @note Permission required: caller must be a system application (or the pasteboard |
| 258 | * broker uid). | 258 | * broker uid). |
| 259 | */ | 259 | */ |
| 260 | - int RevokeUriPermissionManually(const Uri &uri, const std::string bundleName, int32_t appIndex = 0); | 260 | + int RevokeUriPermissionManually(const Uri &uri, const std::string bundleName, int32_t appIndex = -1); |
| 261 | 261 | ||
| 262 | /** | 262 | /** |
| 263 | * @brief Verify whether a token ID holds the read/write permission on a URI, including | 263 | * @brief Verify whether a token ID holds the read/write permission on a URI, including |
| @@ -118,6 +118,7 @@ public: | |||
| 118 | ExtensionAbilityInfo &extensionInfo, int32_t userId); | 118 | ExtensionAbilityInfo &extensionInfo, int32_t userId); |
| 119 | ErrCode GetCloneAppIndexes(const std::string &bundleName, std::vector<int32_t> &appIndexes, int32_t userId); | 119 | ErrCode GetCloneAppIndexes(const std::string &bundleName, std::vector<int32_t> &appIndexes, int32_t userId); |
| 120 | ErrCode GetAppClonePreference(const std::string &bundleName, int32_t userId, AppClonePreference &preference); | 120 | ErrCode GetAppClonePreference(const std::string &bundleName, int32_t userId, AppClonePreference &preference); |
| 121 | + ErrCode GetDualModeBundleInfo(const std::string &bundleName, int32_t userId, DualModeBundleInfo &preference); | ||
| 121 | ErrCode GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo); | 122 | ErrCode GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo); |
| 122 | std::string GetStringById( | 123 | std::string GetStringById( |
| 123 | const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId); | 124 | const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId); |
| @@ -732,7 +732,7 @@ public: | |||
| 732 | * @param bundleName. | 732 | * @param bundleName. |
| 733 | * @return Returns ERR_OK on success, others on failure. | 733 | * @return Returns ERR_OK on success, others on failure. |
| 734 | */ | 734 | */ |
| 735 | - virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 735 | + virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 736 | const std::string& reason = "Abilityms::KillProcess") override; | 736 | const std::string& reason = "Abilityms::KillProcess") override; |
| 737 | 737 | ||
| 738 | 738 | ||
| @@ -775,7 +775,7 @@ public: | |||
| 775 | * @return Returns ERR_OK on success, others on failure. | 775 | * @return Returns ERR_OK on success, others on failure. |
| 776 | */ | 776 | */ |
| 777 | virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, | 777 | virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, |
| 778 | - int32_t appIndex = 0) override; | 778 | + int32_t appIndex = -1) override; |
| 779 | 779 | ||
| 780 | virtual sptr<IWantSender> GetWantSender( | 780 | virtual sptr<IWantSender> GetWantSender( |
| 781 | const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override; | 781 | const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override; |
| @@ -1477,7 +1477,7 @@ public: | |||
| 1477 | * @param appIndex app clone index. Currently, only appIndex = 0 is supported. | 1477 | * @param appIndex app clone index. Currently, only appIndex = 0 is supported. |
| 1478 | * @return Returns ERR_OK on success, others on failure. | 1478 | * @return Returns ERR_OK on success, others on failure. |
| 1479 | */ | 1479 | */ |
| 1480 | - virtual int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = 0) override; | 1480 | + virtual int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = -1) override; |
| 1481 | 1481 | ||
| 1482 | /** | 1482 | /** |
| 1483 | * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. | 1483 | * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. |
| @@ -1040,7 +1040,7 @@ public: | |||
| 1040 | * @param bundleName. | 1040 | * @param bundleName. |
| 1041 | * @return Returns ERR_OK on success, others on failure. | 1041 | * @return Returns ERR_OK on success, others on failure. |
| 1042 | */ | 1042 | */ |
| 1043 | - virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 1043 | + virtual int KillProcess(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 1044 | const std::string& reason = "Abilityms::KillProcess") override; | 1044 | const std::string& reason = "Abilityms::KillProcess") override; |
| 1045 | 1045 | ||
| 1046 | /** | 1046 | /** |
| @@ -1072,7 +1072,7 @@ public: | |||
| 1072 | * @return Returns ERR_OK on success, others on failure. | 1072 | * @return Returns ERR_OK on success, others on failure. |
| 1073 | */ | 1073 | */ |
| 1074 | virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, | 1074 | virtual int32_t UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg, |
| 1075 | - int32_t appIndex = 0) override; | 1075 | + int32_t appIndex = -1) override; |
| 1076 | 1076 | ||
| 1077 | virtual sptr<IWantSender> GetWantSender( | 1077 | virtual sptr<IWantSender> GetWantSender( |
| 1078 | const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override; | 1078 | const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override; |
| @@ -2110,7 +2110,7 @@ public: | |||
| 2110 | * @param appIndex app clone index. Currently, only appIndex = 0 is supported. | 2110 | * @param appIndex app clone index. Currently, only appIndex = 0 is supported. |
| 2111 | * @return Returns ERR_OK on success, others on failure. | 2111 | * @return Returns ERR_OK on success, others on failure. |
| 2112 | */ | 2112 | */ |
| 2113 | - virtual int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = 0) override; | 2113 | + virtual int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = -1) override; |
| 2114 | 2114 | ||
| 2115 | /** | 2115 | /** |
| 2116 | * @brief Cancel game prelaunch and kill the game process. | 2116 | * @brief Cancel game prelaunch and kill the game process. |
| @@ -3360,7 +3360,7 @@ private: | |||
| 3360 | int32_t RequestDialogServiceInner(const Want &want, const sptr<IRemoteObject> &callerToken, | 3360 | int32_t RequestDialogServiceInner(const Want &want, const sptr<IRemoteObject> &callerToken, |
| 3361 | int requestCode, int32_t userId); | 3361 | int requestCode, int32_t userId); |
| 3362 | 3362 | ||
| 3363 | - bool CheckCallingTokenId(const std::string &bundleName, int32_t userId = INVALID_USER_ID, int32_t appIndex = 0); | 3363 | + bool CheckCallingTokenId(const std::string &bundleName, int32_t userId = INVALID_USER_ID, int32_t appIndex = -1); |
| 3364 | bool IsCallerSceneBoard(); | 3364 | bool IsCallerSceneBoard(); |
| 3365 | 3365 | ||
| 3366 | void ReleaseAbilityTokenMap(const sptr<IRemoteObject> &token); | 3366 | void ReleaseAbilityTokenMap(const sptr<IRemoteObject> &token); |
| @@ -80,7 +80,7 @@ struct AppInfo { | |||
| 80 | std::vector<AppData> appData; | 80 | std::vector<AppData> appData; |
| 81 | pid_t pid = 0; | 81 | pid_t pid = 0; |
| 82 | int32_t userId = -1; | 82 | int32_t userId = -1; |
| 83 | - int32_t appIndex = 0; | 83 | + int32_t appIndex = -1; |
| 84 | AppState state; | 84 | AppState state; |
| 85 | }; | 85 | }; |
| 86 | /** | 86 | /** |
| @@ -360,7 +360,7 @@ public: | |||
| 360 | * | 360 | * |
| 361 | * @param bundleName. | 361 | * @param bundleName. |
| 362 | */ | 362 | */ |
| 363 | - int KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 363 | + int KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 364 | const std::string &reason = "KillApplication"); | 364 | const std::string &reason = "KillApplication"); |
| 365 | 365 | ||
| 366 | /** | 366 | /** |
| @@ -372,7 +372,7 @@ public: | |||
| 372 | * @return ERR_OK, return back success, others fail. | 372 | * @return ERR_OK, return back success, others fail. |
| 373 | */ | 373 | */ |
| 374 | int ForceKillApplication(const std::string &bundleName, const int userId = -1, | 374 | int ForceKillApplication(const std::string &bundleName, const int userId = -1, |
| 375 | - const int appIndex = 0); | 375 | + const int appIndex = -1); |
| 376 | 376 | ||
| 377 | /** | 377 | /** |
| 378 | * KillApplicationWithUserId, kill designated user application. | 378 | * KillApplicationWithUserId, kill designated user application. |
| @@ -382,7 +382,7 @@ public: | |||
| 382 | * @param appIndex, appIndex. | 382 | * @param appIndex, appIndex. |
| 383 | * @return ERR_OK, return back success, others fail. | 383 | * @return ERR_OK, return back success, others fail. |
| 384 | */ | 384 | */ |
| 385 | - int KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, const int appIndex = 0); | 385 | + int KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, const int appIndex = -1); |
| 386 | 386 | ||
| 387 | /** | 387 | /** |
| 388 | * KillProcessesByAccessTokenId. | 388 | * KillProcessesByAccessTokenId. |
| @@ -30,7 +30,7 @@ struct AbilityInterceptorParam { | |||
| 30 | isWithUI(isWithUI), callerToken(callerToken), shouldBlockAllAppStartFunc_(shouldBlockAllAppStartFunc){}; | 30 | isWithUI(isWithUI), callerToken(callerToken), shouldBlockAllAppStartFunc_(shouldBlockAllAppStartFunc){}; |
| 31 | AbilityInterceptorParam(const Want &want, int requestCode, int32_t userId, bool isWithUI, | 31 | AbilityInterceptorParam(const Want &want, int requestCode, int32_t userId, bool isWithUI, |
| 32 | const sptr<IRemoteObject> &callerToken, const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo, | 32 | const sptr<IRemoteObject> &callerToken, const std::shared_ptr<AppExecFwk::AbilityInfo> &abilityInfo, |
| 33 | - bool isStartAsCaller = false, int32_t appIndex = 0, const StartOptions* startOptions = nullptr) : want(want), | 33 | + bool isStartAsCaller = false, int32_t appIndex = -1, const StartOptions* startOptions = nullptr) : want(want), |
| 34 | requestCode(requestCode), userId(userId), isWithUI(isWithUI), callerToken(callerToken), | 34 | requestCode(requestCode), userId(userId), isWithUI(isWithUI), callerToken(callerToken), |
| 35 | abilityInfo(abilityInfo), isStartAsCaller(isStartAsCaller), appIndex(appIndex), startOptions(startOptions){}; | 35 | abilityInfo(abilityInfo), isStartAsCaller(isStartAsCaller), appIndex(appIndex), startOptions(startOptions){}; |
| 36 | const Want &want; | 36 | const Want &want; |
| @@ -40,7 +40,7 @@ struct AbilityInterceptorParam { | |||
| 40 | sptr<IRemoteObject> callerToken = nullptr; | 40 | sptr<IRemoteObject> callerToken = nullptr; |
| 41 | std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo; // target abilityInfo get in afterCheckExecuter_ | 41 | std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo; // target abilityInfo get in afterCheckExecuter_ |
| 42 | bool isStartAsCaller = false; | 42 | bool isStartAsCaller = false; |
| 43 | - int32_t appIndex = 0; | 43 | + int32_t appIndex = -1; |
| 44 | std::function<bool(void)> shouldBlockAllAppStartFunc_; | 44 | std::function<bool(void)> shouldBlockAllAppStartFunc_; |
| 45 | bool isTargetPlugin = false; //Is it pulling up a plugin | 45 | bool isTargetPlugin = false; //Is it pulling up a plugin |
| 46 | std::string hostBundleName; | 46 | std::string hostBundleName; |
| @@ -48,9 +48,9 @@ private: | |||
| 48 | void HandleBundleChanged(const EventFwk::CommonEventData &data); | 48 | void HandleBundleChanged(const EventFwk::CommonEventData &data); |
| 49 | 49 | ||
| 50 | void LoadModularObjectExtensionInfos(int32_t userId = -1); | 50 | void LoadModularObjectExtensionInfos(int32_t userId = -1); |
| 51 | - void InsertModularObjectExtensionInfo(const std::string &bundleName, int32_t userId, int32_t appIndex = 0); | 51 | + void InsertModularObjectExtensionInfo(const std::string &bundleName, int32_t userId, int32_t appIndex = -1); |
| 52 | - void UpdateModularObjectExtensionInfos(const std::string &bundleName, int32_t userId, int32_t appIndex = 0); | 52 | + void UpdateModularObjectExtensionInfos(const std::string &bundleName, int32_t userId, int32_t appIndex = -1); |
| 53 | - void RemoveModularObjectExtensionInfo(const std::string &bundleName, int32_t userId, int32_t appIndex = 0); | 53 | + void RemoveModularObjectExtensionInfo(const std::string &bundleName, int32_t userId, int32_t appIndex = -1); |
| 54 | void ProcessMetadata(const std::vector<AppExecFwk::Metadata> &metadata, AAFwk::ModularObjectExtensionInfo &info); | 54 | void ProcessMetadata(const std::vector<AppExecFwk::Metadata> &metadata, AAFwk::ModularObjectExtensionInfo &info); |
| 55 | void GetModularObjectExtensionInfos(const AppExecFwk::BundleInfo &bundleInfo, | 55 | void GetModularObjectExtensionInfos(const AppExecFwk::BundleInfo &bundleInfo, |
| 56 | std::vector<AAFwk::ModularObjectExtensionInfo> &infos); | 56 | std::vector<AAFwk::ModularObjectExtensionInfo> &infos); |
| @@ -152,7 +152,7 @@ public: | |||
| 152 | 152 | ||
| 153 | public: | 153 | public: |
| 154 | sptr<IWantSender> GetWantSender(int32_t callingUid, int32_t uid, const bool isSystemApp, | 154 | sptr<IWantSender> GetWantSender(int32_t callingUid, int32_t uid, const bool isSystemApp, |
| 155 | - const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex = 0, | 155 | + const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex = -1, |
| 156 | int32_t publisherUid = 0); | 156 | int32_t publisherUid = 0); |
| 157 | int32_t SendWantSender(sptr<IWantSender> target, SenderInfo &senderInfo); | 157 | int32_t SendWantSender(sptr<IWantSender> target, SenderInfo &senderInfo); |
| 158 | int32_t SendLocalWantSender(const SenderInfo &senderInfo); | 158 | int32_t SendLocalWantSender(const SenderInfo &senderInfo); |
| @@ -190,7 +190,7 @@ public: | |||
| 190 | 190 | ||
| 191 | private: | 191 | private: |
| 192 | sptr<IWantSender> GetWantSenderLocked(const int32_t callingUid, const int32_t uid, const int32_t userId, | 192 | sptr<IWantSender> GetWantSenderLocked(const int32_t callingUid, const int32_t uid, const int32_t userId, |
| 193 | - WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex = 0, | 193 | + WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex = -1, |
| 194 | int32_t publisherUid = 0); | 194 | int32_t publisherUid = 0); |
| 195 | void MakeWantSenderCanceledLocked(PendingWantRecord &record); | 195 | void MakeWantSenderCanceledLocked(PendingWantRecord &record); |
| 196 | 196 | ||
| @@ -46,7 +46,7 @@ public: | |||
| 46 | */ | 46 | */ |
| 47 | int32_t PreloadApplication(const std::string &bundleName, int32_t userId, int32_t appIndex); | 47 | int32_t PreloadApplication(const std::string &bundleName, int32_t userId, int32_t appIndex); |
| 48 | 48 | ||
| 49 | - int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = 0); | 49 | + int32_t LaunchGameCustomized(const std::string &bundleName, int32_t userId, int32_t appIndex = -1); |
| 50 | 50 | ||
| 51 | int32_t PreloadApplicationVerification(const std::string &bundleName, int32_t userId, int32_t appIndex, Want &want, | 51 | int32_t PreloadApplicationVerification(const std::string &bundleName, int32_t userId, int32_t appIndex, Want &want, |
| 52 | AppExecFwk::AbilityInfo &abilityInfo); | 52 | AppExecFwk::AbilityInfo &abilityInfo); |
| @@ -63,7 +63,7 @@ struct DialogAppInfo { | |||
| 63 | bool visible = true; | 63 | bool visible = true; |
| 64 | bool isAppLink = false; | 64 | bool isAppLink = false; |
| 65 | AppExecFwk::MultiAppModeData multiAppMode; | 65 | AppExecFwk::MultiAppModeData multiAppMode; |
| 66 | - int32_t appIndex = 0; | 66 | + int32_t appIndex = -1; |
| 67 | }; | 67 | }; |
| 68 | /** | 68 | /** |
| 69 | * @class SystemDialogScheduler | 69 | * @class SystemDialogScheduler |
| @@ -130,7 +130,7 @@ constexpr const char* BUNDLE_NAME_SELECTOR_DIALOG = "com.ohos.amsdialog"; | |||
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | [[maybe_unused]] static std::string ConvertBundleNameSingleton(const std::string &bundleName, const std::string &name, | 132 | [[maybe_unused]] static std::string ConvertBundleNameSingleton(const std::string &bundleName, const std::string &name, |
| 133 | - const std::string &moduleName, const int32_t appIndex = 0) | 133 | + const std::string &moduleName, const int32_t appIndex = -1) |
| 134 | { | 134 | { |
| 135 | std::string strName; | 135 | std::string strName; |
| 136 | if (appIndex == 0) { | 136 | if (appIndex == 0) { |
| @@ -66,13 +66,7 @@ struct StartAbilityInfo { | |||
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | struct StartAbilityUtils { | 68 | struct StartAbilityUtils { |
| 69 | - /** | 69 | + static bool GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken, int userId, int32_t &appIndex); |
| 70 | - * Get the app clone index from the caller record or the want. | ||
| 71 | - */ | ||
| 72 | - static bool GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken, int32_t &appIndex); | ||
| 73 | - /** | ||
| 74 | - * Get the application info from the cached start info or BMS. | ||
| 75 | - */ | ||
| 76 | static bool GetApplicationInfo(const std::string &bundleName, int32_t userId, | 70 | static bool GetApplicationInfo(const std::string &bundleName, int32_t userId, |
| 77 | AppExecFwk::ApplicationInfo &appInfo); | 71 | AppExecFwk::ApplicationInfo &appInfo); |
| 78 | /** | 72 | /** |
| @@ -105,10 +99,7 @@ struct StartAbilityUtils { | |||
| 105 | * Process the app clone index for a UI ability start. | 99 | * Process the app clone index for a UI ability start. |
| 106 | */ | 100 | */ |
| 107 | static int32_t StartUIAbilitiesProcessAppIndex(Want &want, | 101 | static int32_t StartUIAbilitiesProcessAppIndex(Want &want, |
| 108 | - sptr<IRemoteObject> callerToken, int32_t &appIndex); | 102 | + sptr<IRemoteObject> callerToken, int userId, int32_t &appIndex); |
| 109 | - /** | ||
| 110 | - * Check whether a self-redirection should be disallowed for an open link. | ||
| 111 | - */ | ||
| 112 | static int32_t HandleSelfRedirection(bool isFromOpenLink, | 103 | static int32_t HandleSelfRedirection(bool isFromOpenLink, |
| 113 | const std::vector<AppExecFwk::AbilityInfo> &abilityInfos); | 104 | const std::vector<AppExecFwk::AbilityInfo> &abilityInfos); |
| 114 | /** | 105 | /** |
| @@ -32,7 +32,7 @@ struct GrantUriPermissionInfo { | |||
| 32 | std::string targetAbilityName = ""; | 32 | std::string targetAbilityName = ""; |
| 33 | uint32_t callerTokenId = 0; | 33 | uint32_t callerTokenId = 0; |
| 34 | uint32_t flag = 0; | 34 | uint32_t flag = 0; |
| 35 | - int32_t appIndex = 0; | 35 | + int32_t appIndex = -1; |
| 36 | int32_t userId = -1; | 36 | int32_t userId = -1; |
| 37 | int32_t targetUid = -1; | 37 | int32_t targetUid = -1; |
| 38 | int32_t callerUid = -1; | 38 | int32_t callerUid = -1; |
| @@ -1449,11 +1449,11 @@ int AbilityManagerService::StartAbilityInner(StartAbilityWrapParam ¶m) | |||
| 1449 | return cloneRet; | 1449 | return cloneRet; |
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | - int32_t appIndex = 0; | 1452 | + int32_t appIndex = -1; |
| 1453 | if (!sandboxAbilityInfo.bundleName.empty()) { | 1453 | if (!sandboxAbilityInfo.bundleName.empty()) { |
| 1454 | appIndex = sandboxAbilityInfo.applicationInfo.appIndex; | 1454 | appIndex = sandboxAbilityInfo.applicationInfo.appIndex; |
| 1455 | TAG_LOGD(AAFwkTag::ABILITYMGR, "Using sandbox clone appIndex: %{public}d from sandboxAbilityInfo", appIndex); | 1455 | TAG_LOGD(AAFwkTag::ABILITYMGR, "Using sandbox clone appIndex: %{public}d from sandboxAbilityInfo", appIndex); |
| 1456 | - } else if (!StartAbilityUtils::GetAppIndex(param.want, param.callerToken, appIndex)) { | 1456 | + } else if (!StartAbilityUtils::GetAppIndex(param.want, param.callerToken, validUserId, appIndex)) { |
| 1457 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, "GetAppIndex failed"); | 1457 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, "GetAppIndex failed"); |
| 1458 | return ERR_APP_CLONE_INDEX_INVALID; | 1458 | return ERR_APP_CLONE_INDEX_INVALID; |
| 1459 | } | 1459 | } |
| @@ -2112,8 +2112,8 @@ int AbilityManagerService::StartAbilityDetails(const Want &want, const AbilitySt | |||
| 2112 | 2112 | ||
| 2113 | int32_t validUserId = oriValidUserId; | 2113 | int32_t validUserId = oriValidUserId; |
| 2114 | StartAbilityUtils::ResolveTargetAppCloneIndex(want, callerToken, validUserId); | 2114 | StartAbilityUtils::ResolveTargetAppCloneIndex(want, callerToken, validUserId); |
| 2115 | - int32_t appIndex = 0; | 2115 | + int32_t appIndex = -1; |
| 2116 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 2116 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, validUserId, appIndex)) { |
| 2117 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, "GetAppIndex failed"); | 2117 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, "GetAppIndex failed"); |
| 2118 | return ERR_APP_CLONE_INDEX_INVALID; | 2118 | return ERR_APP_CLONE_INDEX_INVALID; |
| 2119 | } | 2119 | } |
| @@ -2468,8 +2468,8 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St | |||
| 2468 | 2468 | ||
| 2469 | int32_t validUserId = oriValidUserId; | 2469 | int32_t validUserId = oriValidUserId; |
| 2470 | StartAbilityUtils::ResolveTargetAppCloneIndex(want, callerToken, validUserId); | 2470 | StartAbilityUtils::ResolveTargetAppCloneIndex(want, callerToken, validUserId); |
| 2471 | - int32_t appIndex = 0; | 2471 | + int32_t appIndex = -1; |
| 2472 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 2472 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, validUserId, appIndex)) { |
| 2473 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, "GetAppIndex failed"); | 2473 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, "GetAppIndex failed"); |
| 2474 | return ERR_APP_CLONE_INDEX_INVALID; | 2474 | return ERR_APP_CLONE_INDEX_INVALID; |
| 2475 | } | 2475 | } |
| @@ -2797,7 +2797,7 @@ int32_t AbilityManagerService::CheckWantForSplitMode(const AAFwk::Want &secondar | |||
| 2797 | if (ret != ERR_OK) { | 2797 | if (ret != ERR_OK) { |
| 2798 | return ret; | 2798 | return ret; |
| 2799 | } | 2799 | } |
| 2800 | - ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(const_cast<Want &>(secondaryWant), callerToken, appIndex); | 2800 | + ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(const_cast<Want &>(secondaryWant), callerToken, validUserId, appIndex); |
| 2801 | if (ret != ERR_OK) { | 2801 | if (ret != ERR_OK) { |
| 2802 | return ret; | 2802 | return ret; |
| 2803 | } | 2803 | } |
| @@ -2831,7 +2831,7 @@ int32_t AbilityManagerService::StartUIAbilitiesInSplitWindowModeHandleWant(const | |||
| 2831 | int32_t validUserId = GetValidUserId(userId); | 2831 | int32_t validUserId = GetValidUserId(userId); |
| 2832 | uint32_t specifyTokenId = 0; | 2832 | uint32_t specifyTokenId = 0; |
| 2833 | int32_t requestCode = DEFAULT_INVAL_VALUE; | 2833 | int32_t requestCode = DEFAULT_INVAL_VALUE; |
| 2834 | - int32_t appIndex = 0; | 2834 | + int32_t appIndex = -1; |
| 2835 | 2835 | ||
| 2836 | CHECK_TRUE_RETURN_RET(!CloneForAccountUtil::ProcessAppIndex(const_cast<Want &>(secondaryWant), validUserId), | 2836 | CHECK_TRUE_RETURN_RET(!CloneForAccountUtil::ProcessAppIndex(const_cast<Want &>(secondaryWant), validUserId), |
| 2837 | RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); | 2837 | RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); |
| @@ -3017,8 +3017,8 @@ int32_t AbilityManagerService::StartUIAbilitiesHandleWant(const Want &want, sptr | |||
| 3017 | return ret; | 3017 | return ret; |
| 3018 | } | 3018 | } |
| 3019 | 3019 | ||
| 3020 | - int32_t appIndex = 0; | 3020 | + int32_t appIndex = -1; |
| 3021 | - ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(const_cast<Want &>(want), callerToken, appIndex); | 3021 | + ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(const_cast<Want &>(want), callerToken, validUserId, appIndex); |
| 3022 | if (ret != ERR_OK) { | 3022 | if (ret != ERR_OK) { |
| 3023 | return ret; | 3023 | return ret; |
| 3024 | } | 3024 | } |
| @@ -3459,7 +3459,7 @@ int AbilityManagerService::StartUIAbilityBySCBDefault(sptr<SessionInfo> sessionI | |||
| 3459 | SendAbilityEvent(EventName::START_ABILITY, HISYSEVENT_BEHAVIOR, eventInfo); | 3459 | SendAbilityEvent(EventName::START_ABILITY, HISYSEVENT_BEHAVIOR, eventInfo); |
| 3460 | 3460 | ||
| 3461 | auto requestCode = sessionInfo->requestCode; | 3461 | auto requestCode = sessionInfo->requestCode; |
| 3462 | - int32_t appIndex = 0; | 3462 | + int32_t appIndex = -1; |
| 3463 | auto sandboxCloneParams = std::make_shared<SandboxCloneParams>(); | 3463 | auto sandboxCloneParams = std::make_shared<SandboxCloneParams>(); |
| 3464 | AbilitySessionInfo abilitySessionInfo; | 3464 | AbilitySessionInfo abilitySessionInfo; |
| 3465 | auto uiAbilityManager = GetUIAbilityManagerByUserId(currentUserId); | 3465 | auto uiAbilityManager = GetUIAbilityManagerByUserId(currentUserId); |
| @@ -3477,7 +3477,7 @@ int AbilityManagerService::StartUIAbilityBySCBDefault(sptr<SessionInfo> sessionI | |||
| 3477 | TAG_LOGE(AAFwkTag::ABILITYMGR, "HandleSandboxCloneLaunch failed: %{public}d", cloneRet); | 3477 | TAG_LOGE(AAFwkTag::ABILITYMGR, "HandleSandboxCloneLaunch failed: %{public}d", cloneRet); |
| 3478 | return cloneRet; | 3478 | return cloneRet; |
| 3479 | } | 3479 | } |
| 3480 | - } else if (!StartAbilityUtils::GetAppIndex(sessionInfo->want, sessionInfo->callerToken, appIndex)) { | 3480 | + } else if (!StartAbilityUtils::GetAppIndex(sessionInfo->want, sessionInfo->callerToken, currentUserId, appIndex)) { |
| 3481 | TAG_LOGE(AAFwkTag::ABILITYMGR, "get app index error"); | 3481 | TAG_LOGE(AAFwkTag::ABILITYMGR, "get app index error"); |
| 3482 | return ERR_APP_CLONE_INDEX_INVALID; | 3482 | return ERR_APP_CLONE_INDEX_INVALID; |
| 3483 | } | 3483 | } |
| @@ -4393,7 +4393,7 @@ int AbilityManagerService::PreloadUIExtensionAbilityInner( | |||
| 4393 | CHECK_POINTER_AND_RETURN(bms, ERR_INVALID_VALUE); | 4393 | CHECK_POINTER_AND_RETURN(bms, ERR_INVALID_VALUE); |
| 4394 | int32_t callerUid = IPCSkeleton::GetCallingUid(); | 4394 | int32_t callerUid = IPCSkeleton::GetCallingUid(); |
| 4395 | int32_t callerAppIndex = 0; | 4395 | int32_t callerAppIndex = 0; |
| 4396 | - int32_t appIndex = 0; | 4396 | + int32_t appIndex = -1; |
| 4397 | if (want.HasParameter(Want::PARAM_APP_CLONE_INDEX_KEY)) { | 4397 | if (want.HasParameter(Want::PARAM_APP_CLONE_INDEX_KEY)) { |
| 4398 | appIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0); | 4398 | appIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0); |
| 4399 | } | 4399 | } |
| @@ -4691,8 +4691,8 @@ int32_t AbilityManagerService::StartExtensionAbilityInner(const Want &want, cons | |||
| 4691 | CHECK_TRUE_RETURN_RET(!CloneForAccountUtil::ProcessAppIndex(const_cast<Want &>(want), validUserId, true), | 4691 | CHECK_TRUE_RETURN_RET(!CloneForAccountUtil::ProcessAppIndex(const_cast<Want &>(want), validUserId, true), |
| 4692 | RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); | 4692 | RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); |
| 4693 | 4693 | ||
| 4694 | - int32_t appIndex = 0; | 4694 | + int32_t appIndex = -1; |
| 4695 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 4695 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, validUserId, appIndex)) { |
| 4696 | if (extensionType == AppExecFwk::ExtensionAbilityType::UI_SERVICE) { | 4696 | if (extensionType == AppExecFwk::ExtensionAbilityType::UI_SERVICE) { |
| 4697 | eventInfo->errReason = "GetAppIndex error"; | 4697 | eventInfo->errReason = "GetAppIndex error"; |
| 4698 | SendExtensionReport(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, true); | 4698 | SendExtensionReport(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, true); |
| @@ -7113,7 +7113,7 @@ sptr<IWantSender> AbilityManagerService::GetWantSenderByUserId(const WantSenderI | |||
| 7113 | bool isSystemApp = AAFwk::PermissionVerification::GetInstance()->IsSystemAppCall(); | 7113 | bool isSystemApp = AAFwk::PermissionVerification::GetInstance()->IsSystemAppCall(); |
| 7114 | int32_t userId = -1; | 7114 | int32_t userId = -1; |
| 7115 | int32_t appUid = -1; | 7115 | int32_t appUid = -1; |
| 7116 | - int32_t appIndex = 0; | 7116 | + int32_t appIndex = -1; |
| 7117 | if (isSACall || callerUserId == U0_USER_ID) { | 7117 | if (isSACall || callerUserId == U0_USER_ID) { |
| 7118 | if (isSpecifyUserId) { | 7118 | if (isSpecifyUserId) { |
| 7119 | userId = wantSenderInfo.userId; | 7119 | userId = wantSenderInfo.userId; |
| @@ -7180,7 +7180,7 @@ sptr<IWantSender> AbilityManagerService::GetWantSender( | |||
| 7180 | bool isSpecifyUidBySa = (uid != -1) && (AAFwk::PermissionVerification::GetInstance()->IsSACall()); | 7180 | bool isSpecifyUidBySa = (uid != -1) && (AAFwk::PermissionVerification::GetInstance()->IsSACall()); |
| 7181 | 7181 | ||
| 7182 | int32_t appUid = -1; | 7182 | int32_t appUid = -1; |
| 7183 | - int32_t appIndex = 0; | 7183 | + int32_t appIndex = -1; |
| 7184 | std::string bundleName = ""; | 7184 | std::string bundleName = ""; |
| 7185 | if (!wantSenderInfo.allWants.empty()) { | 7185 | if (!wantSenderInfo.allWants.empty()) { |
| 7186 | bundleName = wantSenderInfo.allWants.back().want.GetBundleNameRef(); | 7186 | bundleName = wantSenderInfo.allWants.back().want.GetBundleNameRef(); |
| @@ -8988,8 +8988,8 @@ int AbilityManagerService::GenerateAbilityRequest(const Want &want, int requestC | |||
| 8988 | 8988 | ||
| 8989 | auto abilityInfo = StartAbilityUtils::startAbilityInfo; | 8989 | auto abilityInfo = StartAbilityUtils::startAbilityInfo; |
| 8990 | if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetBundleNameRef()) { | 8990 | if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetBundleNameRef()) { |
| 8991 | - int32_t appIndex = 0; | 8991 | + int32_t appIndex = -1; |
| 8992 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 8992 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, userId, appIndex)) { |
| 8993 | return ERR_APP_CLONE_INDEX_INVALID; | 8993 | return ERR_APP_CLONE_INDEX_INVALID; |
| 8994 | } | 8994 | } |
| 8995 | Want localWant = want; | 8995 | Want localWant = want; |
| @@ -9092,7 +9092,7 @@ int AbilityManagerService::GenerateExtensionAbilityRequest(const Want &want, Abi | |||
| 9092 | if (abilityRecord != nullptr) { | 9092 | if (abilityRecord != nullptr) { |
| 9093 | request.callerTokenRecordId = abilityRecord->GetRecordId(); | 9093 | request.callerTokenRecordId = abilityRecord->GetRecordId(); |
| 9094 | std::string extensionTypeStr = want.GetStringParam(UIEXTENSION_TYPE_KEY); | 9094 | std::string extensionTypeStr = want.GetStringParam(UIEXTENSION_TYPE_KEY); |
| 9095 | - int32_t appIndex = 0; | 9095 | + int32_t appIndex = -1; |
| 9096 | if (want.HasParameter(Want::PARAM_APP_CLONE_INDEX_KEY)) { | 9096 | if (want.HasParameter(Want::PARAM_APP_CLONE_INDEX_KEY)) { |
| 9097 | appIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0); | 9097 | appIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0); |
| 9098 | } | 9098 | } |
| @@ -9120,8 +9120,8 @@ int AbilityManagerService::GenerateExtensionAbilityRequest(const Want &want, Abi | |||
| 9120 | 9120 | ||
| 9121 | auto abilityInfo = StartAbilityUtils::startAbilityInfo; | 9121 | auto abilityInfo = StartAbilityUtils::startAbilityInfo; |
| 9122 | if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetBundleNameRef()) { | 9122 | if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetBundleNameRef()) { |
| 9123 | - int32_t appIndex = 0; | 9123 | + int32_t appIndex = -1; |
| 9124 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 9124 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, userId, appIndex)) { |
| 9125 | return ERR_APP_CLONE_INDEX_INVALID; | 9125 | return ERR_APP_CLONE_INDEX_INVALID; |
| 9126 | } | 9126 | } |
| 9127 | std::string nHostBundleName = GetHostBundleName(hostBundleName, callerToken); | 9127 | std::string nHostBundleName = GetHostBundleName(hostBundleName, callerToken); |
| @@ -9335,6 +9335,13 @@ int AbilityManagerService::KillProcess(const std::string &bundleName, bool clear | |||
| 9335 | CHECK_POINTER_AND_RETURN(bms, KILL_PROCESS_FAILED); | 9335 | CHECK_POINTER_AND_RETURN(bms, KILL_PROCESS_FAILED); |
| 9336 | int32_t userId = AbilityRuntime::UserController::GetInstance().GetCallerUserId(); | 9336 | int32_t userId = AbilityRuntime::UserController::GetInstance().GetCallerUserId(); |
| 9337 | AppExecFwk::BundleInfo bundleInfo; | 9337 | AppExecFwk::BundleInfo bundleInfo; |
| 9338 | + if(appIndex == -1) { | ||
| 9339 | + AppExecFwk::DualModeBundleInfo bundleModeinfo; | ||
| 9340 | + auto ret = bms->GetDualModeBundleInfo(bundleName, userId, bundleModeinfo); | ||
| 9341 | + if (ret == ERR_OK) { | ||
| 9342 | + appIndex = bundleModeinfo.appIndex; | ||
| 9343 | + } | ||
| 9344 | + } | ||
| 9338 | if (IN_PROCESS_CALL(bms->GetCloneBundleInfoExt(bundleName, | 9345 | if (IN_PROCESS_CALL(bms->GetCloneBundleInfoExt(bundleName, |
| 9339 | static_cast<uint32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), | 9346 | static_cast<uint32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), |
| 9340 | appIndex, userId, bundleInfo)) != ERR_OK) { | 9347 | appIndex, userId, bundleInfo)) != ERR_OK) { |
| @@ -9407,6 +9414,13 @@ int32_t AbilityManagerService::UninstallAppInner(const std::string &bundleName, | |||
| 9407 | } | 9414 | } |
| 9408 | 9415 | ||
| 9409 | auto userId = uid / BASE_USER_RANGE; | 9416 | auto userId = uid / BASE_USER_RANGE; |
| 9417 | + if(appIndex == -1) { | ||
| 9418 | + AppExecFwk::DualModeBundleInfo bundleInfo; | ||
| 9419 | + auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); | ||
| 9420 | + if (bundleMgrHelper->GetDualModeBundleInfo(bundleName, userId, bundleInfo) == ERR_OK) { | ||
| 9421 | + appIndex = bundleInfo.appIndex; | ||
| 9422 | + } | ||
| 9423 | + } | ||
| 9410 | if (isUpgrade) { | 9424 | if (isUpgrade) { |
| 9411 | CHECK_POINTER_AND_RETURN(appExitReasonHelper_, ERR_NULL_OBJECT); | 9425 | CHECK_POINTER_AND_RETURN(appExitReasonHelper_, ERR_NULL_OBJECT); |
| 9412 | HandleAppUpgradeProcess(bundleName, uid, appIndex, exitMsg); | 9426 | HandleAppUpgradeProcess(bundleName, uid, appIndex, exitMsg); |
| @@ -10476,8 +10490,8 @@ int AbilityManagerService::StartAbilityByCallWithErrMsg(const Want &want, const | |||
| 10476 | RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); | 10490 | RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); |
| 10477 | 10491 | ||
| 10478 | AbilityUtil::RemoveWantKey(const_cast<Want &>(want)); | 10492 | AbilityUtil::RemoveWantKey(const_cast<Want &>(want)); |
| 10479 | - int32_t appIndex = 0; | 10493 | + int32_t appIndex = -1; |
| 10480 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 10494 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, oriValidUserId, appIndex)) { |
| 10481 | errMsg = "app index is error"; | 10495 | errMsg = "app index is error"; |
| 10482 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, | 10496 | AbilityEventUtil::SendStartAbilityErrorEvent(*eventInfo, ERR_APP_CLONE_INDEX_INVALID, |
| 10483 | "startAbilityByCall app index is invalid"); | 10497 | "startAbilityByCall app index is invalid"); |
| @@ -11811,8 +11825,9 @@ int AbilityManagerService::StartUserTest(const Want &want, const sptr<IRemoteObj | |||
| 11811 | CHECK_TRUE_RETURN_RET(!CloneForAccountUtil::ProcessAppIndex(const_cast<Want &>(want), | 11825 | CHECK_TRUE_RETURN_RET(!CloneForAccountUtil::ProcessAppIndex(const_cast<Want &>(want), |
| 11812 | GetValidUserId(DEFAULT_INVAL_VALUE)), RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); | 11826 | GetValidUserId(DEFAULT_INVAL_VALUE)), RESOLVE_ABILITY_ERR, "CloneForAccountUtil::ProcessAppIndex failed"); |
| 11813 | 11827 | ||
| 11814 | - int32_t appIndex = 0; | 11828 | + int32_t appIndex = -1; |
| 11815 | - if (!StartAbilityUtils::GetAppIndex(want, nullptr, appIndex) || appIndex != 0) { | 11829 | + if (!StartAbilityUtils::GetAppIndex(want, nullptr, userId, appIndex) || (appIndex != 0 && |
| 11830 | + appIndex != AbilityRuntime::GlobalConstant::PC_TABLET_INDEX)) { | ||
| 11816 | TAG_LOGE(AAFwkTag::ABILITYMGR, "Not support app clone"); | 11831 | TAG_LOGE(AAFwkTag::ABILITYMGR, "Not support app clone"); |
| 11817 | return ERR_NOT_SUPPORT_APP_CLONE; | 11832 | return ERR_NOT_SUPPORT_APP_CLONE; |
| 11818 | } | 11833 | } |
| @@ -17194,9 +17209,9 @@ int32_t AbilityManagerService::PreStartInner(const FreeInstallInfo& taskInfo) | |||
| 17194 | 17209 | ||
| 17195 | int32_t oriValidUserId = GetValidUserId(taskInfo.userId); | 17210 | int32_t oriValidUserId = GetValidUserId(taskInfo.userId); |
| 17196 | 17211 | ||
| 17197 | - int32_t appIndex = 0; | 17212 | + int32_t appIndex = -1; |
| 17198 | StartAbilityInfoWrap threadLocalInfo(want, oriValidUserId, | 17213 | StartAbilityInfoWrap threadLocalInfo(want, oriValidUserId, |
| 17199 | - StartAbilityUtils::GetAppIndex(want, callerToken, appIndex), callerToken); | 17214 | + StartAbilityUtils::GetAppIndex(want, callerToken, oriValidUserId, appIndex), callerToken); |
| 17200 | 17215 | ||
| 17201 | AbilityRequest abilityRequest = { | 17216 | AbilityRequest abilityRequest = { |
| 17202 | .requestCode = taskInfo.requestCode, | 17217 | .requestCode = taskInfo.requestCode, |
| @@ -17360,8 +17375,8 @@ int AbilityManagerService::StartUIAbilityByPreInstallInner(sptr<SessionInfo> ses | |||
| 17360 | int32_t oriValidUserId = GetValidUserId(userId); | 17375 | int32_t oriValidUserId = GetValidUserId(userId); |
| 17361 | int32_t validUserId = oriValidUserId; | 17376 | int32_t validUserId = oriValidUserId; |
| 17362 | 17377 | ||
| 17363 | - int32_t appIndex = 0; | 17378 | + int32_t appIndex = -1; |
| 17364 | - if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { | 17379 | + if (!StartAbilityUtils::GetAppIndex(want, callerToken, validUserId, appIndex)) { |
| 17365 | TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s GetAppIndex failed", __func__); | 17380 | TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s GetAppIndex failed", __func__); |
| 17366 | return ERR_APP_CLONE_INDEX_INVALID; | 17381 | return ERR_APP_CLONE_INDEX_INVALID; |
| 17367 | } | 17382 | } |
| @@ -193,7 +193,7 @@ std::shared_ptr<AbilityRecord> AbilityRecord::CreateAbilityRecord(const AbilityR | |||
| 193 | void AbilityRecord::Init(const AbilityRequest &abilityRequest) | 193 | void AbilityRecord::Init(const AbilityRequest &abilityRequest) |
| 194 | { | 194 | { |
| 195 | SetUid(abilityRequest.uid); | 195 | SetUid(abilityRequest.uid); |
| 196 | - int32_t appIndex = 0; | 196 | + int32_t appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; |
| 197 | if (abilityRequest.isWebSandBoxClone) { | 197 | if (abilityRequest.isWebSandBoxClone) { |
| 198 | appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; | 198 | appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; |
| 199 | InitSandboxCloneParams(abilityRequest); | 199 | InitSandboxCloneParams(abilityRequest); |
| @@ -134,7 +134,7 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason) | |||
| 134 | } | 134 | } |
| 135 | auto uid = IPCSkeleton::GetCallingUid(); | 135 | auto uid = IPCSkeleton::GetCallingUid(); |
| 136 | std::string bundleName; | 136 | std::string bundleName; |
| 137 | - int32_t appIndex = 0; | 137 | + int32_t appIndex = -1; |
| 138 | auto ret = IN_PROCESS_CALL(AbilityUtil::GetBundleManagerHelper()->GetNameAndIndexForUid(uid, bundleName, appIndex)); | 138 | auto ret = IN_PROCESS_CALL(AbilityUtil::GetBundleManagerHelper()->GetNameAndIndexForUid(uid, bundleName, appIndex)); |
| 139 | if (ret != ERR_OK) { | 139 | if (ret != ERR_OK) { |
| 140 | TAG_LOGE(AAFwkTag::ABILITYMGR, "GetNameAndIndexForUid failed, ret: %{public}d", ret); | 140 | TAG_LOGE(AAFwkTag::ABILITYMGR, "GetNameAndIndexForUid failed, ret: %{public}d", ret); |
| @@ -124,7 +124,12 @@ bool EcologicalRuleInterceptor::DoProcess(Want &want, int32_t userId) | |||
| 124 | } | 124 | } |
| 125 | want.SetElement(launchWant.GetElement()); | 125 | want.SetElement(launchWant.GetElement()); |
| 126 | 126 | ||
| 127 | - int32_t appIndex = 0; | 127 | + int32_t appIndex = -1; |
| 128 | + AppExecFwk::DualModeBundleInfo bundleInfo; | ||
| 129 | + auto appRecord = bundleMgrHelper->GetDualModeBundleInfo(want.GetBundleNameRef(), userId, bundleInfo); | ||
| 130 | + if (appRecord == ERR_OK) { | ||
| 131 | + appIndex = bundleInfo.appIndex; | ||
| 132 | + } | ||
| 128 | auto startAbilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, | 133 | auto startAbilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, |
| 129 | userId, appIndex, nullptr); | 134 | userId, appIndex, nullptr); |
| 130 | if (startAbilityInfo == nullptr || startAbilityInfo->status != ERR_OK) { | 135 | if (startAbilityInfo == nullptr || startAbilityInfo->status != ERR_OK) { |
| @@ -163,7 +168,12 @@ ErrCode EcologicalRuleInterceptor::QueryAtomicServiceStartupRule(Want &want, spt | |||
| 163 | CHECK_RET_RETURN_RET(errCode, "GetLaunchWantForBundle failed"); | 168 | CHECK_RET_RETURN_RET(errCode, "GetLaunchWantForBundle failed"); |
| 164 | want.SetElement(launchWant.GetElement()); | 169 | want.SetElement(launchWant.GetElement()); |
| 165 | 170 | ||
| 166 | - int32_t appIndex = 0; | 171 | + int32_t appIndex = -1; |
| 172 | + AppExecFwk::DualModeBundleInfo bundleInfo; | ||
| 173 | + auto appRecord = bundleMgrHelper->GetDualModeBundleInfo(want.GetBundleNameRef(), userId, bundleInfo); | ||
| 174 | + if (appRecord == ERR_OK) { | ||
| 175 | + appIndex = bundleInfo.appIndex; | ||
| 176 | + } | ||
| 167 | auto startAbilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, userId, appIndex, nullptr); | 177 | auto startAbilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, userId, appIndex, nullptr); |
| 168 | CHECK_POINTER_AND_RETURN_LOG(startAbilityInfo, INNER_ERR, "null startAbilityInfo"); | 178 | CHECK_POINTER_AND_RETURN_LOG(startAbilityInfo, INNER_ERR, "null startAbilityInfo"); |
| 169 | CHECK_RET_RETURN_RET(startAbilityInfo->status, "Get targetApplicationInfo failed"); | 179 | CHECK_RET_RETURN_RET(startAbilityInfo->status, "Get targetApplicationInfo failed"); |
| @@ -571,7 +571,7 @@ bool MissionListManager::HandleReusedMissionAndAbility(const AbilityRequest &abi | |||
| 571 | 571 | ||
| 572 | std::string MissionListManager::GetMissionName(const AbilityRequest &abilityRequest) const | 572 | std::string MissionListManager::GetMissionName(const AbilityRequest &abilityRequest) const |
| 573 | { | 573 | { |
| 574 | - int32_t appIndex = 0; | 574 | + int32_t appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; |
| 575 | (void)AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want, appIndex); | 575 | (void)AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want, appIndex); |
| 576 | return AbilityUtil::ConvertBundleNameSingleton(abilityRequest.abilityInfo.bundleName, | 576 | return AbilityUtil::ConvertBundleNameSingleton(abilityRequest.abilityInfo.bundleName, |
| 577 | abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName, appIndex); | 577 | abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName, appIndex); |
| @@ -92,6 +92,14 @@ int32_t PreloadManagerService::LaunchGameCustomized(const std::string &bundleNam | |||
| 92 | TAG_LOGE(AAFwkTag::ABILITYMGR, "verify preload game failed"); | 92 | TAG_LOGE(AAFwkTag::ABILITYMGR, "verify preload game failed"); |
| 93 | return ret; | 93 | return ret; |
| 94 | } | 94 | } |
| 95 | + if (appIndex == -1) { | ||
| 96 | + AppExecFwk::DualModeBundleInfo bundleinfo; | ||
| 97 | + auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); | ||
| 98 | + auto appRecord = bundleMgrHelper->GetDualModeBundleInfo(bundleName, userId, bundleinfo); | ||
| 99 | + if (appRecord == ERR_OK) { | ||
| 100 | + appIndex = bundleinfo.appIndex; | ||
| 101 | + } | ||
| 102 | + } | ||
| 95 | 103 | ||
| 96 | bool isGameSACall = IPCSkeleton::GetCallingUid() == AbilityRuntime::GlobalConstant::GAME_SA_UID; | 104 | bool isGameSACall = IPCSkeleton::GetCallingUid() == AbilityRuntime::GlobalConstant::GAME_SA_UID; |
| 97 | bool isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall(); | 105 | bool isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall(); |
| @@ -497,7 +497,7 @@ UIAbilityRecordPtr UIAbilityLifecycleManager::GenerateAbilityRecord(AbilityReque | |||
| 497 | UIAbilityRecordPtr UIAbilityLifecycleManager::FindRecordFromTmpMap( | 497 | UIAbilityRecordPtr UIAbilityLifecycleManager::FindRecordFromTmpMap( |
| 498 | const AbilityRequest &abilityRequest) | 498 | const AbilityRequest &abilityRequest) |
| 499 | { | 499 | { |
| 500 | - int32_t appIndex = 0; | 500 | + int32_t appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; |
| 501 | if (abilityRequest.want.HasParameter(ServerConstant::DLP_INDEX)) { | 501 | if (abilityRequest.want.HasParameter(ServerConstant::DLP_INDEX)) { |
| 502 | appIndex = abilityRequest.want.GetIntParam(ServerConstant::DLP_INDEX, 0); | 502 | appIndex = abilityRequest.want.GetIntParam(ServerConstant::DLP_INDEX, 0); |
| 503 | } else { | 503 | } else { |
| @@ -2686,12 +2686,7 @@ bool UIAbilityLifecycleManager::CheckProperties(const UIAbilityRecordPtr &abilit | |||
| 2686 | { | 2686 | { |
| 2687 | CHECK_POINTER_RETURN_BOOL(abilityRecord); | 2687 | CHECK_POINTER_RETURN_BOOL(abilityRecord); |
| 2688 | const auto& abilityInfo = abilityRecord->GetAbilityInfo(); | 2688 | const auto& abilityInfo = abilityRecord->GetAbilityInfo(); |
| 2689 | - int32_t appIndex = 0; | 2689 | + int32_t appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; |
| 2690 | - if (abilityRequest.isWebSandBoxClone) { | ||
| 2691 | - appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; | ||
| 2692 | - } else { | ||
| 2693 | - (void)AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want, appIndex); | ||
| 2694 | - } | ||
| 2695 | auto instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY); | 2690 | auto instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY); |
| 2696 | return abilityInfo.launchMode == launchMode && abilityRequest.abilityInfo.name == abilityInfo.name && | 2691 | return abilityInfo.launchMode == launchMode && abilityRequest.abilityInfo.name == abilityInfo.name && |
| 2697 | abilityRequest.abilityInfo.bundleName == abilityInfo.bundleName && | 2692 | abilityRequest.abilityInfo.bundleName == abilityInfo.bundleName && |
| @@ -4528,12 +4523,7 @@ void UIAbilityLifecycleManager::EnableListForSCBRecovery() | |||
| 4528 | UIAbilityRecordPtr UIAbilityLifecycleManager::FindRecordFromSessionMap( | 4523 | UIAbilityRecordPtr UIAbilityLifecycleManager::FindRecordFromSessionMap( |
| 4529 | const AbilityRequest &abilityRequest) | 4524 | const AbilityRequest &abilityRequest) |
| 4530 | { | 4525 | { |
| 4531 | - int32_t appIndex = 0; | 4526 | + int32_t appIndex = abilityRequest.abilityInfo.applicationInfo.appIndex; |
| 4532 | - if (abilityRequest.want.HasParameter(ServerConstant::DLP_INDEX)) { | ||
| 4533 | - appIndex = abilityRequest.want.GetIntParam(ServerConstant::DLP_INDEX, 0); | ||
| 4534 | - } else { | ||
| 4535 | - appIndex = abilityRequest.abilityInfo.appIndex; | ||
| 4536 | - } | ||
| 4537 | auto instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY); | 4527 | auto instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY); |
| 4538 | for (const auto &[sessionId, abilityRecord] : sessionAbilityMap_) { | 4528 | for (const auto &[sessionId, abilityRecord] : sessionAbilityMap_) { |
| 4539 | if (abilityRecord) { | 4529 | if (abilityRecord) { |
| @@ -135,7 +135,8 @@ int32_t AbilityPermissionUtil::CheckMultiInstanceAndAppClone(Want &want, int32_t | |||
| 135 | } | 135 | } |
| 136 | if (appInfo.multiAppMode.multiAppModeType == AppExecFwk::MultiAppModeType::UNSPECIFIED) { | 136 | if (appInfo.multiAppMode.multiAppModeType == AppExecFwk::MultiAppModeType::UNSPECIFIED) { |
| 137 | if (!instanceKey.empty() || isCreating || | 137 | if (!instanceKey.empty() || isCreating || |
| 138 | - (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX)) { | 138 | + (appIndex != 0 && appIndex != AbilityRuntime::GlobalConstant::PC_TABLET_INDEX && |
| 139 | + AbilityRuntime::GlobalConstant::IsAppCloneIndex(appIndex))) { | ||
| 139 | TAG_LOGE(AAFwkTag::ABILITYMGR, "Not support multi-instance or appClone"); | 140 | TAG_LOGE(AAFwkTag::ABILITYMGR, "Not support multi-instance or appClone"); |
| 140 | return ERR_MULTI_APP_NOT_SUPPORTED; | 141 | return ERR_MULTI_APP_NOT_SUPPORTED; |
| 141 | } | 142 | } |
| @@ -63,17 +63,15 @@ bool MultiAppUtils::GetPreferredAppCloneIndex(const std::string &bundleName, int | |||
| 63 | TAG_LOGD(AAFwkTag::ABILITYMGR, "GetAppClonePreference failed, ret:%{public}d", ret); | 63 | TAG_LOGD(AAFwkTag::ABILITYMGR, "GetAppClonePreference failed, ret:%{public}d", ret); |
| 64 | return false; | 64 | return false; |
| 65 | } | 65 | } |
| 66 | - if (preference.mode == AppExecFwk::AppClonePreferenceMode::MAIN_APP) { | 66 | + if (preference.mode == AppExecFwk::AppClonePreferenceMode::ALWAYS_ASK) { |
| 67 | - appIndex = 0; | ||
| 68 | - return true; | ||
| 69 | - } | ||
| 70 | - if (preference.mode != AppExecFwk::AppClonePreferenceMode::CLONE_APP) { | ||
| 71 | return false; | 67 | return false; |
| 72 | } | 68 | } |
| 73 | - if (preference.appIndex <= 0 || preference.appIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { | 69 | + |
| 70 | + if (!AbilityRuntime::GlobalConstant::IsAppCloneIndex(preference.appIndex)) { | ||
| 74 | TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid default clone index:%{public}d", preference.appIndex); | 71 | TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid default clone index:%{public}d", preference.appIndex); |
| 75 | return false; | 72 | return false; |
| 76 | } | 73 | } |
| 74 | + | ||
| 77 | appIndex = preference.appIndex; | 75 | appIndex = preference.appIndex; |
| 78 | return true; | 76 | return true; |
| 79 | } | 77 | } |
| @@ -79,8 +79,8 @@ int32_t StartOptionsUtils::CheckProcessOptionsInner(const Want &want, const Star | |||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | StartAbilityUtils::ResolveTargetAppCloneIndex(want, callerToken, userId); | 81 | StartAbilityUtils::ResolveTargetAppCloneIndex(want, callerToken, userId); |
| 82 | - int32_t appIndex = 0; | 82 | + int32_t appIndex = -1; |
| 83 | - appIndex = !StartAbilityUtils::GetAppIndex(want, callerToken, appIndex) ? 0 : appIndex; | 83 | + appIndex = !StartAbilityUtils::GetAppIndex(want, callerToken, userId, appIndex) ? 0 : appIndex; |
| 84 | CHECK_TRUE_RETURN_RET(!DelayedSingleton<AbilityManagerService>::GetInstance()->CheckCallingTokenId( | 84 | CHECK_TRUE_RETURN_RET(!DelayedSingleton<AbilityManagerService>::GetInstance()->CheckCallingTokenId( |
| 85 | element.GetBundleName(), userId, appIndex), ERR_NOT_SELF_APPLICATION, "not self application"); | 85 | element.GetBundleName(), userId, appIndex), ERR_NOT_SELF_APPLICATION, "not self application"); |
| 86 | 86 | ||
| @@ -158,7 +158,7 @@ public: | |||
| 158 | * @return ERR_OK, return back success, others fail. | 158 | * @return ERR_OK, return back success, others fail. |
| 159 | */ | 159 | */ |
| 160 | virtual int32_t KillProcessWithAccount(const std::string &bundleName, const int accountId, | 160 | virtual int32_t KillProcessWithAccount(const std::string &bundleName, const int accountId, |
| 161 | - const bool clearPageStack = false, int32_t appIndex = 0) override; | 161 | + const bool clearPageStack = false, int32_t appIndex = -1) override; |
| 162 | 162 | ||
| 163 | /** | 163 | /** |
| 164 | * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; | 164 | * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; |
| @@ -187,7 +187,7 @@ public: | |||
| 187 | * @return ERR_OK, return back success, others fail. | 187 | * @return ERR_OK, return back success, others fail. |
| 188 | */ | 188 | */ |
| 189 | virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, | 189 | virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, |
| 190 | - int32_t appIndex = 0, const std::string &reason = "KillApplication") override; | 190 | + int32_t appIndex = -1, const std::string &reason = "KillApplication") override; |
| 191 | 191 | ||
| 192 | /** | 192 | /** |
| 193 | * ForceKillApplication, force kill the application. | 193 | * ForceKillApplication, force kill the application. |
| @@ -198,7 +198,7 @@ public: | |||
| 198 | * @return ERR_OK, return back success, others fail. | 198 | * @return ERR_OK, return back success, others fail. |
| 199 | */ | 199 | */ |
| 200 | virtual int32_t ForceKillApplication(const std::string &bundleName, const int userId = -1, | 200 | virtual int32_t ForceKillApplication(const std::string &bundleName, const int userId = -1, |
| 201 | - const int appIndex = 0) override; | 201 | + const int appIndex = -1) override; |
| 202 | 202 | ||
| 203 | /** | 203 | /** |
| 204 | * KillApplicationWithUserId, force kill the application. | 204 | * KillApplicationWithUserId, force kill the application. |
| @@ -209,7 +209,7 @@ public: | |||
| 209 | * @return ERR_OK, return back success, others fail. | 209 | * @return ERR_OK, return back success, others fail. |
| 210 | */ | 210 | */ |
| 211 | virtual int32_t KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, | 211 | virtual int32_t KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, |
| 212 | - const int appIndex = 0) override; | 212 | + const int appIndex = -1) override; |
| 213 | 213 | ||
| 214 | /** | 214 | /** |
| 215 | * KillProcessesByAccessTokenId. | 215 | * KillProcessesByAccessTokenId. |
| @@ -88,7 +88,7 @@ public: | |||
| 88 | AppExecFwk::PreloadMode preloadMode, int32_t appIndex) override; | 88 | AppExecFwk::PreloadMode preloadMode, int32_t appIndex) override; |
| 89 | 89 | ||
| 90 | virtual int32_t MakeImage(const AAFwk::Want &want, int32_t userId, | 90 | virtual int32_t MakeImage(const AAFwk::Want &want, int32_t userId, |
| 91 | - AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0, | 91 | + AppExecFwk::PreloadMode preloadMode, int32_t appIndex = -1, |
| 92 | sptr<IImageErrorHandler> errorHandler = nullptr) override; | 92 | sptr<IImageErrorHandler> errorHandler = nullptr) override; |
| 93 | 93 | ||
| 94 | virtual int32_t DestroyImage(uint64_t checkpointId, sptr<IImageErrorHandler> errorHandler = nullptr) override; | 94 | virtual int32_t DestroyImage(uint64_t checkpointId, sptr<IImageErrorHandler> errorHandler = nullptr) override; |
| @@ -531,7 +531,7 @@ public: | |||
| 531 | * @return Returns ERR_OK on success, others on failure. | 531 | * @return Returns ERR_OK on success, others on failure. |
| 532 | */ | 532 | */ |
| 533 | virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, | 533 | virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, |
| 534 | - int32_t appIndex = 0) override; | 534 | + int32_t appIndex = -1) override; |
| 535 | 535 | ||
| 536 | /** | 536 | /** |
| 537 | * @brief register a configuration observer which will receive notifies when updated. | 537 | * @brief register a configuration observer which will receive notifies when updated. |
| @@ -414,7 +414,7 @@ public: | |||
| 414 | * | 414 | * |
| 415 | * @return ERR_OK, return back success, others fail. | 415 | * @return ERR_OK, return back success, others fail. |
| 416 | */ | 416 | */ |
| 417 | - virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0, | 417 | + virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = -1, |
| 418 | const std::string &reason = "KillApplication"); | 418 | const std::string &reason = "KillApplication"); |
| 419 | 419 | ||
| 420 | /** | 420 | /** |
| @@ -426,7 +426,7 @@ public: | |||
| 426 | * @return ERR_OK, return back success, others fail. | 426 | * @return ERR_OK, return back success, others fail. |
| 427 | */ | 427 | */ |
| 428 | virtual int32_t ForceKillApplication(const std::string &bundleName, const int userId = -1, | 428 | virtual int32_t ForceKillApplication(const std::string &bundleName, const int userId = -1, |
| 429 | - const int appIndex = 0); | 429 | + const int appIndex = -1); |
| 430 | 430 | ||
| 431 | /** | 431 | /** |
| 432 | * KillApplicationWithUserId, force kill the application. | 432 | * KillApplicationWithUserId, force kill the application. |
| @@ -437,7 +437,7 @@ public: | |||
| 437 | * @return ERR_OK, return back success, others fail. | 437 | * @return ERR_OK, return back success, others fail. |
| 438 | */ | 438 | */ |
| 439 | virtual int32_t KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, | 439 | virtual int32_t KillApplicationWithUserId(const std::string &bundleName, const int userId = -1, |
| 440 | - const int appIndex = 0); | 440 | + const int appIndex = -1); |
| 441 | 441 | ||
| 442 | /** | 442 | /** |
| 443 | * KillProcessesByAccessTokenId. | 443 | * KillProcessesByAccessTokenId. |
| @@ -1883,10 +1883,10 @@ public: | |||
| 1883 | 1883 | ||
| 1884 | private: | 1884 | private: |
| 1885 | int32_t ForceKillApplicationInner(const std::string &bundleName, const int userId = -1, | 1885 | int32_t ForceKillApplicationInner(const std::string &bundleName, const int userId = -1, |
| 1886 | - const int appIndex = 0); | 1886 | + const int appIndex = -1); |
| 1887 | 1887 | ||
| 1888 | int32_t KillApplicationWithUserIdInner(const std::string &bundleName, const int userId = -1, | 1888 | int32_t KillApplicationWithUserIdInner(const std::string &bundleName, const int userId = -1, |
| 1889 | - const int appIndex = 0); | 1889 | + const int appIndex = -1); |
| 1890 | 1890 | ||
| 1891 | std::string FaultTypeToString(FaultDataType type); | 1891 | std::string FaultTypeToString(FaultDataType type); |
| 1892 | 1892 | ||
| @@ -2105,7 +2105,7 @@ private: | |||
| 2105 | void HandleAddAbilityStageTimeOut(std::shared_ptr<AppRunningRecord> appRecord); | 2105 | void HandleAddAbilityStageTimeOut(std::shared_ptr<AppRunningRecord> appRecord); |
| 2106 | 2106 | ||
| 2107 | bool GetBundleAndHapInfo(const AbilityInfo &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo, | 2107 | bool GetBundleAndHapInfo(const AbilityInfo &abilityInfo, const std::shared_ptr<ApplicationInfo> &appInfo, |
| 2108 | - BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo, int32_t appIndex = 0) const; | 2108 | + BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo, int32_t appIndex = -1) const; |
| 2109 | AppProcessData WrapAppProcessData(const std::shared_ptr<AppRunningRecord> &appRecord, | 2109 | AppProcessData WrapAppProcessData(const std::shared_ptr<AppRunningRecord> &appRecord, |
| 2110 | const ApplicationState state, bool isFromWindowFocusChanged = false); | 2110 | const ApplicationState state, bool isFromWindowFocusChanged = false); |
| 2111 | 2111 | ||
| @@ -26,7 +26,7 @@ | |||
| 26 | namespace OHOS { | 26 | namespace OHOS { |
| 27 | namespace AppExecFwk { | 27 | namespace AppExecFwk { |
| 28 | struct PreloadRequest { | 28 | struct PreloadRequest { |
| 29 | - int32_t appIndex = 0; // not used | 29 | + int32_t appIndex = -1; // not used |
| 30 | AppExecFwk::PreloadMode preloadMode; | 30 | AppExecFwk::PreloadMode preloadMode; |
| 31 | std::shared_ptr<AbilityInfo> abilityInfo = nullptr; | 31 | std::shared_ptr<AbilityInfo> abilityInfo = nullptr; |
| 32 | std::shared_ptr<ApplicationInfo> appInfo = nullptr; | 32 | std::shared_ptr<ApplicationInfo> appInfo = nullptr; |
| @@ -84,7 +84,8 @@ static uint64_t BuildStartFlags(const AAFwk::Want &want, const ApplicationInfo & | |||
| 84 | startFlags = startFlags | (START_FLAG_BASE << StartFlags::EXTENSION_CONTROLLED); | 84 | startFlags = startFlags | (START_FLAG_BASE << StartFlags::EXTENSION_CONTROLLED); |
| 85 | } | 85 | } |
| 86 | if ((applicationInfo.multiAppMode.multiAppModeType == MultiAppModeType::APP_CLONE && applicationInfo.appIndex > 0 && | 86 | if ((applicationInfo.multiAppMode.multiAppModeType == MultiAppModeType::APP_CLONE && applicationInfo.appIndex > 0 && |
| 87 | - applicationInfo.appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) || | 87 | + applicationInfo.appIndex != AbilityRuntime::GlobalConstant::PC_TABLET_INDEX && |
| 88 | + AbilityRuntime::GlobalConstant::IsAppCloneIndex(applicationInfo.appIndex)) || | ||
| 88 | AbilityRuntime::GlobalConstant::IsSandboxCloneIndex(applicationInfo.appIndex)) { | 89 | AbilityRuntime::GlobalConstant::IsSandboxCloneIndex(applicationInfo.appIndex)) { |
| 89 | startFlags = startFlags | (START_FLAG_BASE << APP_FLAGS_CLONE_ENABLE); | 90 | startFlags = startFlags | (START_FLAG_BASE << APP_FLAGS_CLONE_ENABLE); |
| 90 | } | 91 | } |
| @@ -547,12 +547,7 @@ void AppMgrServiceInner::StartSpecifiedProcess(const AAFwk::Want &want, const Ap | |||
| 547 | HapModuleInfo hapModuleInfo; | 547 | HapModuleInfo hapModuleInfo; |
| 548 | auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo); | 548 | auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo); |
| 549 | 549 | ||
| 550 | - int32_t appIndex = 0; | 550 | + int32_t appIndex = abilityInfo.applicationInfo.appIndex; |
| 551 | - if (want.HasParameter(DLP_INDEX)) { | ||
| 552 | - appIndex = want.GetIntParam(DLP_INDEX, 0); | ||
| 553 | - } else { | ||
| 554 | - appIndex = abilityInfo.appIndex; | ||
| 555 | - } | ||
| 556 | if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { | 551 | if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { |
| 557 | return; | 552 | return; |
| 558 | } | 553 | } |
| @@ -1954,6 +1949,15 @@ bool AppMgrServiceInner::CheckPreloadAppRecordExist(const std::string &bundleNam | |||
| 1954 | TAG_LOGE(AAFwkTag::APPMGR, "null appPreloader"); | 1949 | TAG_LOGE(AAFwkTag::APPMGR, "null appPreloader"); |
| 1955 | return false; | 1950 | return false; |
| 1956 | } | 1951 | } |
| 1952 | + if (appIndex == -1) { | ||
| 1953 | + AppExecFwk::DualModeBundleInfo bundleinfo; | ||
| 1954 | + auto bundleMgrHelper = remoteClientManager_->GetBundleManagerHelper(); | ||
| 1955 | + auto ret = bundleMgrHelper->GetDualModeBundleInfo(bundleName, userId, bundleinfo); | ||
| 1956 | + if (ret == ERR_OK) { | ||
| 1957 | + appIndex = bundleinfo.appIndex; | ||
| 1958 | + } | ||
| 1959 | + } | ||
| 1960 | + | ||
| 1957 | PreloadRequest request; | 1961 | PreloadRequest request; |
| 1958 | auto ret = appPreloader_->GeneratePreloadRequest(bundleName, userId, appIndex, request); | 1962 | auto ret = appPreloader_->GeneratePreloadRequest(bundleName, userId, appIndex, request); |
| 1959 | if (ret != ERR_OK) { | 1963 | if (ret != ERR_OK) { |
| @@ -2169,7 +2173,7 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s | |||
| 2169 | BundleInfo bundleInfo; | 2173 | BundleInfo bundleInfo; |
| 2170 | bool isProcCache = false; | 2174 | bool isProcCache = false; |
| 2171 | HapModuleInfo hapModuleInfo; | 2175 | HapModuleInfo hapModuleInfo; |
| 2172 | - int32_t appIndex = 0; | 2176 | + int32_t appIndex = appInfo->appIndex; |
| 2173 | if (loadParam->selfPid > 0) { | 2177 | if (loadParam->selfPid > 0) { |
| 2174 | if (!GetBundleAndHapInfo(*abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { | 2178 | if (!GetBundleAndHapInfo(*abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { |
| 2175 | TAG_LOGE(AAFwkTag::APPMGR, "getBundleAndHapInfo fail"); | 2179 | TAG_LOGE(AAFwkTag::APPMGR, "getBundleAndHapInfo fail"); |
| @@ -4989,13 +4993,9 @@ std::shared_ptr<AppRunningRecord> AppMgrServiceInner::CreateAppRunningRecord( | |||
| 4989 | appRecord->SetPerfCmd(want->GetStringParam(PERF_CMD)); | 4993 | appRecord->SetPerfCmd(want->GetStringParam(PERF_CMD)); |
| 4990 | appRecord->SetErrorInfoEnhance(want->GetBoolParam(ERROR_INFO_ENHANCE, false)); | 4994 | appRecord->SetErrorInfoEnhance(want->GetBoolParam(ERROR_INFO_ENHANCE, false)); |
| 4991 | appRecord->SetMultiThread(want->GetBoolParam(MULTI_THREAD, false)); | 4995 | appRecord->SetMultiThread(want->GetBoolParam(MULTI_THREAD, false)); |
| 4992 | - int32_t appIndex = 0; | 4996 | + int32_t appIndex = abilityInfo->applicationInfo.appIndex; |
| 4993 | - if (want->HasParameter(DLP_INDEX)) { | ||
| 4994 | - appIndex = want->GetIntParam(DLP_INDEX, 0); | ||
| 4995 | - } else { | ||
| 4996 | - appIndex = abilityInfo->appIndex; | ||
| 4997 | - } | ||
| 4998 | appRecord->SetAppIndex(appIndex); | 4997 | appRecord->SetAppIndex(appIndex); |
| 4998 | + | ||
| 4999 | if (loadParam->isGamePrelaunch) { | 4999 | if (loadParam->isGamePrelaunch) { |
| 5000 | appRecord->SetPreloadMode(AppExecFwk::PreloadMode::GAME_PRELAUNCH); | 5000 | appRecord->SetPreloadMode(AppExecFwk::PreloadMode::GAME_PRELAUNCH); |
| 5001 | } | 5001 | } |
| @@ -7534,12 +7534,7 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptr<IR | |||
| 7534 | testRecord->userId = userId; | 7534 | testRecord->userId = userId; |
| 7535 | appRecord->SetUserTestInfo(testRecord); | 7535 | appRecord->SetUserTestInfo(testRecord); |
| 7536 | 7536 | ||
| 7537 | - int32_t appIndex = 0; | 7537 | + int32_t appIndex = info.applicationInfo.appIndex; |
| 7538 | - if (want.HasParameter(DLP_INDEX)) { | ||
| 7539 | - appIndex = want.GetIntParam(DLP_INDEX, 0); | ||
| 7540 | - } else { | ||
| 7541 | - appIndex = appInfo->appIndex; | ||
| 7542 | - } | ||
| 7543 | uint64_t startFlags = AppspawnUtil::BuildStartFlags(want, info.applicationInfo); | 7538 | uint64_t startFlags = AppspawnUtil::BuildStartFlags(want, info.applicationInfo); |
| 7544 | StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, info, appInfo->bundleName, | 7539 | StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, info, appInfo->bundleName, |
| 7545 | appIndex, appExistFlag); | 7540 | appIndex, appExistFlag); |
| @@ -7643,12 +7638,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap | |||
| 7643 | HapModuleInfo hapModuleInfo; | 7638 | HapModuleInfo hapModuleInfo; |
| 7644 | auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo); | 7639 | auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo); |
| 7645 | 7640 | ||
| 7646 | - int32_t appIndex = 0; | 7641 | + int32_t appIndex = abilityInfo.applicationInfo.appIndex; |
| 7647 | - if (want.HasParameter(DLP_INDEX)) { | ||
| 7648 | - appIndex = want.GetIntParam(DLP_INDEX, 0); | ||
| 7649 | - } else { | ||
| 7650 | - appIndex = abilityInfo.appIndex; | ||
| 7651 | - } | ||
| 7652 | if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { | 7642 | if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { |
| 7653 | return; | 7643 | return; |
| 7654 | } | 7644 | } |
| @@ -12841,12 +12831,7 @@ bool AppMgrServiceInner::IsSpecifiedModuleLoaded(const AAFwk::Want &want, const | |||
| 12841 | return false; | 12831 | return false; |
| 12842 | } | 12832 | } |
| 12843 | auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo); | 12833 | auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo); |
| 12844 | - int32_t appIndex = 0; | 12834 | + int32_t appIndex = abilityInfo.applicationInfo.appIndex; |
| 12845 | - if (want.HasParameter(DLP_INDEX)) { | ||
| 12846 | - appIndex = want.GetIntParam(DLP_INDEX, 0); | ||
| 12847 | - } else { | ||
| 12848 | - appIndex = abilityInfo.appIndex; | ||
| 12849 | - } | ||
| 12850 | BundleInfo bundleInfo; | 12835 | BundleInfo bundleInfo; |
| 12851 | HapModuleInfo hapModuleInfo; | 12836 | HapModuleInfo hapModuleInfo; |
| 12852 | if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { | 12837 | if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { |
| @@ -13189,7 +13174,7 @@ bool AppMgrServiceInner::IsBlockedByDisposeRules(const std::string &bundleName, | |||
| 13189 | { | 13174 | { |
| 13190 | HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "GetAbilityRunningControlRule"); | 13175 | HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "GetAbilityRunningControlRule"); |
| 13191 | int32_t ret = ERR_OK; | 13176 | int32_t ret = ERR_OK; |
| 13192 | - if (appIndex > 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { | 13177 | + if (appIndex > 0 && AbilityRuntime::GlobalConstant::IsAppCloneIndex(appIndex)) { |
| 13193 | ret = IN_PROCESS_CALL(appControlMgr->GetAbilityRunningControlRule(bundleName, | 13178 | ret = IN_PROCESS_CALL(appControlMgr->GetAbilityRunningControlRule(bundleName, |
| 13194 | userId, disposedRuleList, appIndex)); | 13179 | userId, disposedRuleList, appIndex)); |
| 13195 | } else { | 13180 | } else { |
| @@ -68,7 +68,7 @@ void StartAbilityUtilsFuzztest1(bool boolParam, std::string &stringParam, int32_ | |||
| 68 | { | 68 | { |
| 69 | Want want; | 69 | Want want; |
| 70 | sptr<Token> callerToken = GetFuzzAbilityToken(); | 70 | sptr<Token> callerToken = GetFuzzAbilityToken(); |
| 71 | - StartAbilityUtils::GetAppIndex(want, callerToken, int32Param); | 71 | + StartAbilityUtils::GetAppIndex(want, callerToken, userId, int32Param); |
| 72 | AppExecFwk::ApplicationInfo appInfo; | 72 | AppExecFwk::ApplicationInfo appInfo; |
| 73 | StartAbilityUtils::GetApplicationInfo(stringParam, int32Param, appInfo); | 73 | StartAbilityUtils::GetApplicationInfo(stringParam, int32Param, appInfo); |
| 74 | AppExecFwk::AbilityInfo abilityInfo; | 74 | AppExecFwk::AbilityInfo abilityInfo; |
| @@ -134,8 +134,8 @@ void StartAbilityUtilsFuzztest1(bool boolParam, std::string &stringParam, int32_ | |||
| 134 | sptr<Token> nullToken = nullptr; | 134 | sptr<Token> nullToken = nullptr; |
| 135 | 135 | ||
| 136 | int32_t appIndex = 0; | 136 | int32_t appIndex = 0; |
| 137 | - StartAbilityUtils::GetAppIndex(want, callerToken, appIndex); | 137 | + StartAbilityUtils::GetAppIndex(want, callerToken, userId, appIndex); |
| 138 | - StartAbilityUtils::GetAppIndex(want, nullToken, appIndex); | 138 | + StartAbilityUtils::GetAppIndex(want, nullToken, userId, appIndex); |
| 139 | 139 | ||
| 140 | AppExecFwk::ApplicationInfo appInfo; | 140 | AppExecFwk::ApplicationInfo appInfo; |
| 141 | 141 | ||
| @@ -15,7 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | - | 18 | +#include "bundle_info.h" |
| 19 | namespace OHOS { | 19 | namespace OHOS { |
| 20 | namespace AppExecFwk { | 20 | namespace AppExecFwk { |
| 21 | 21 | ||
| @@ -401,5 +401,12 @@ ErrCode BundleMgrHelper::GetPluginExtensionInfo(const std::string &hostBundleNam | |||
| 401 | { | 401 | { |
| 402 | return ERR_OK; | 402 | return ERR_OK; |
| 403 | } | 403 | } |
| 404 | + | ||
| 405 | +ErrCode BundleMgrHelper::GetDualModeBundleInfo(const std::string& bundleName, int32_t userId, | ||
| 406 | + DualModeBundleInfo &preference) | ||
| 407 | +{ | ||
| 408 | + preference.appIndex = 0; | ||
| 409 | + return ERR_OK; | ||
| 410 | +} | ||
| 404 | } // namespace AppExecFwk | 411 | } // namespace AppExecFwk |
| 405 | } // namespace OHOS | 412 | } // namespace OHOS |
| @@ -60,5 +60,13 @@ bool BundleMgrHelper::GetApplicationInfo( | |||
| 60 | appInfo = applicationInfo; | 60 | appInfo = applicationInfo; |
| 61 | return retGetApplicationInfo; | 61 | return retGetApplicationInfo; |
| 62 | } | 62 | } |
| 63 | + | ||
| 64 | +int32_t BundleMgrHelper::GetDualModeBundleInfo(const std::string& bundleName, int32_t userId, | ||
| 65 | + DualModeBundleInfo &preference) | ||
| 66 | +{ | ||
| 67 | + preference.appIndex = 0; | ||
| 68 | + return 0; | ||
| 69 | +} | ||
| 70 | + | ||
| 63 | } // namespace AppExecFwk | 71 | } // namespace AppExecFwk |
| 64 | } // namespace OHOS | 72 | } // namespace OHOS |
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | namespace OHOS { | 22 | namespace OHOS { |
| 22 | namespace AppExecFwk { | 23 | namespace AppExecFwk { |
| @@ -81,6 +82,8 @@ public: | |||
| 81 | return 0; | 82 | return 0; |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 85 | + int32_t GetDualModeBundleInfo(const std::string &bundleName, int32_t userId, DualModeBundleInfo &preference); | ||
| 86 | + | ||
| 84 | public: | 87 | public: |
| 85 | static int32_t retGetLaunchWantForBundle; | 88 | static int32_t retGetLaunchWantForBundle; |
| 86 | static Want launchWant; | 89 | static Want launchWant; |
| @@ -20,7 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | - | 23 | +#include "bundle_info.h" |
| 24 | namespace OHOS { | 24 | namespace OHOS { |
| 25 | 25 | ||
| 26 | namespace AppExecFwk { | 26 | namespace AppExecFwk { |
| @@ -35,6 +35,8 @@ public: | |||
| 35 | int32_t GetLaunchWantForBundle(const std::string &bundleName, AAFwk::Want &want, int32_t userId); | 35 | int32_t GetLaunchWantForBundle(const std::string &bundleName, AAFwk::Want &want, int32_t userId); |
| 36 | 36 | ||
| 37 | bool QueryAbilityInfo(const AAFwk::Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo); | 37 | bool QueryAbilityInfo(const AAFwk::Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo); |
| 38 | + | ||
| 39 | + int32_t GetDualModeBundleInfo(const std::string &bundleName, int32_t userId, DualModeBundleInfo &preference); | ||
| 38 | }; | 40 | }; |
| 39 | } // namespace AppExecFwk | 41 | } // namespace AppExecFwk |
| 40 | } // namespace OHOS | 42 | } // namespace OHOS |
| @@ -13,9 +13,9 @@ | |||
| 13 | * limitations under the License. | 13 | * limitations under the License. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | - | ||
| 17 | - | ||
| 18 | 16 | ||
| 17 | + | ||
| 18 | + | ||
| 19 | namespace OHOS { | 19 | namespace OHOS { |
| 20 | namespace AppExecFwk { | 20 | namespace AppExecFwk { |
| 21 | 21 | ||
| @@ -43,5 +43,13 @@ bool BundleMgrHelper::QueryAbilityInfo(const AAFwk::Want& want, int32_t flags, i | |||
| 43 | abilityInfo = AAFwk::MyStatus::GetInstance().queryAbilityInfo_; | 43 | abilityInfo = AAFwk::MyStatus::GetInstance().queryAbilityInfo_; |
| 44 | return AAFwk::MyStatus::GetInstance().retQueryAbilityInfo_; | 44 | return AAFwk::MyStatus::GetInstance().retQueryAbilityInfo_; |
| 45 | } | 45 | } |
| 46 | + | ||
| 47 | +int32_t BundleMgrHelper::GetDualModeBundleInfo(const std::string& bundleName, int32_t userId, | ||
| 48 | + DualModeBundleInfo &preference) | ||
| 49 | +{ | ||
| 50 | + preference.appIndex = 0; | ||
| 51 | + return 0; | ||
| 52 | +} | ||
| 53 | + | ||
| 46 | } // namespace AppExecFwk | 54 | } // namespace AppExecFwk |
| 47 | } // namespace OHOS | 55 | } // namespace OHOS |
| @@ -754,7 +754,7 @@ HWTEST_F(StartAbilityUtilsTest, StartUIAbilitiesProcessAppIndex_001, TestSize.Le | |||
| 754 | abilityRecord->abilityInfo_.applicationInfo.appIndex = -2; | 754 | abilityRecord->abilityInfo_.applicationInfo.appIndex = -2; |
| 755 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); | 755 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); |
| 756 | 756 | ||
| 757 | - StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, appIndex); | 757 | + StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, 0, appIndex); |
| 758 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); | 758 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); |
| 759 | EXPECT_EQ(appCloneIndex, appIndex); | 759 | EXPECT_EQ(appCloneIndex, appIndex); |
| 760 | EXPECT_EQ(appIndex, 0); | 760 | EXPECT_EQ(appIndex, 0); |
| @@ -781,7 +781,7 @@ HWTEST_F(StartAbilityUtilsTest, StartUIAbilitiesProcessAppIndex_002, TestSize.Le | |||
| 781 | abilityRecord->abilityInfo_.applicationInfo.appIndex = -2; | 781 | abilityRecord->abilityInfo_.applicationInfo.appIndex = -2; |
| 782 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); | 782 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); |
| 783 | 783 | ||
| 784 | - int32_t ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, appIndex); | 784 | + int32_t ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, 0, appIndex); |
| 785 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); | 785 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); |
| 786 | EXPECT_EQ(appCloneIndex, appIndex); | 786 | EXPECT_EQ(appCloneIndex, appIndex); |
| 787 | EXPECT_EQ(appIndex, 1); | 787 | EXPECT_EQ(appIndex, 1); |
| @@ -809,7 +809,7 @@ HWTEST_F(StartAbilityUtilsTest, StartUIAbilitiesProcessAppIndex_003, TestSize.Le | |||
| 809 | abilityRecord->abilityInfo_.applicationInfo.appIndex = -2; | 809 | abilityRecord->abilityInfo_.applicationInfo.appIndex = -2; |
| 810 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); | 810 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); |
| 811 | 811 | ||
| 812 | - int32_t ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, appIndex); | 812 | + int32_t ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, 0, appIndex); |
| 813 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); | 813 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); |
| 814 | EXPECT_EQ(appCloneIndex, appIndex); | 814 | EXPECT_EQ(appCloneIndex, appIndex); |
| 815 | EXPECT_EQ(appIndex, -5); | 815 | EXPECT_EQ(appIndex, -5); |
| @@ -839,7 +839,7 @@ HWTEST_F(StartAbilityUtilsTest, StartUIAbilitiesProcessAppIndex_004, TestSize.Le | |||
| 839 | MyStatus::GetInstance().appClonePreference_.appIndex = 2; | 839 | MyStatus::GetInstance().appClonePreference_.appIndex = 2; |
| 840 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); | 840 | sptr<IRemoteObject> callerToken = abilityRecord->GetToken(); |
| 841 | 841 | ||
| 842 | - int32_t ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, appIndex); | 842 | + int32_t ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(want, callerToken, 0, appIndex); |
| 843 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); | 843 | int32_t appCloneIndex = want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1); |
| 844 | EXPECT_EQ(appCloneIndex, appIndex); | 844 | EXPECT_EQ(appCloneIndex, appIndex); |
| 845 | EXPECT_EQ(appIndex, 0); | 845 | EXPECT_EQ(appIndex, 0); |
| @@ -23,7 +23,7 @@ | |||
| 23 | namespace OHOS { | 23 | namespace OHOS { |
| 24 | namespace AAFwk { | 24 | namespace AAFwk { |
| 25 | struct StartAbilityUtils { | 25 | struct StartAbilityUtils { |
| 26 | - static bool GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken, int32_t &appIndex); | 26 | + static bool GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken, int userId, int32_t &appIndex); |
| 27 | static void SetTargetCloneIndexInSameBundle(const Want &want, sptr<IRemoteObject> callerToken); | 27 | static void SetTargetCloneIndexInSameBundle(const Want &want, sptr<IRemoteObject> callerToken); |
| 28 | static void ResolveTargetAppCloneIndex(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId); | 28 | static void ResolveTargetAppCloneIndex(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId); |
| 29 | }; | 29 | }; |
| @@ -20,7 +20,7 @@ | |||
| 20 | namespace OHOS { | 20 | namespace OHOS { |
| 21 | namespace AAFwk { | 21 | namespace AAFwk { |
| 22 | 22 | ||
| 23 | -bool StartAbilityUtils::GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken, int32_t &appIndex) | 23 | +bool StartAbilityUtils::GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken, int userId, int32_t &appIndex) |
| 24 | { | 24 | { |
| 25 | appIndex = 0; | 25 | appIndex = 0; |
| 26 | return true; | 26 | return true; |
| @@ -30,15 +30,6 @@ constexpr int32_t VALID_REQUEST_CODE_LENGTH = 49; | |||
| 30 | } | 30 | } |
| 31 | bool StartupUtil::GetAppIndex(const AAFwk::Want &want, int32_t &appIndex) | 31 | bool StartupUtil::GetAppIndex(const AAFwk::Want &want, int32_t &appIndex) |
| 32 | { | 32 | { |
| 33 | - if (want.HasParameter(ServerConstant::DLP_INDEX)) { | ||
| 34 | - appIndex = want.GetIntParam(ServerConstant::DLP_INDEX, 0); | ||
| 35 | - return AbilityRuntime::GlobalConstant::IsDlpIndex(appIndex); | ||
| 36 | - } | ||
| 37 | - if (want.HasParameter(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY)) { | ||
| 38 | - appIndex = want.GetIntParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, 0); | ||
| 39 | - return AbilityRuntime::GlobalConstant::IsAppCloneIndex(appIndex); | ||
| 40 | - } | ||
| 41 | - appIndex = 0; | ||
| 42 | return true; | 33 | return true; |
| 43 | } | 34 | } |
| 44 | 35 | ||


🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)
🟠 获取 BundleMgrHelper 后缺失非空校验
位置:
L77-L78| 严重程度: High❓ 问题描述
在 GetAppIndex 函数的新增逻辑中,通过 AbilityUtil::GetBundleManagerHelper() 获取了 bundleMgrHelper 指针,随后直接调用其 GetDualModeBundleInfo 方法,未进行非空校验。如果系统服务未连接或异常导致返回 nullptr,将引发空指针解引用崩溃。此问题同样存在于 ecological_rule_interceptor.cpp 和 preload_manager_service.cpp 中。
💡 修复建议
修改建议:在调用 GetDualModeBundleInfo 之前,增加对 bundleMgrHelper 的非空校验,若为空则打印日志并安全返回。
76: AppExecFwk::BundleInfoDualMode bundleinfo; 77: auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); 78: if (bundleMgrHelper == nullptr) { 79: appIndex = -1; 80: TAG_LOGE(AAFwkTag::ABILITYMGR, "bundleMgrHelper is null"); 81: return false; 82: } 83: auto ret = IN_PROCESS_CALL(bundleMgrHelper->GetDualModeBundleInfo(want.GetBundleNameRef(), userId, bundleinfo));