!11030 ams拉起scb时支持传递恢复字段

Merge pull request !11030 from hanchenZz/send_app_recovery
This commit is contained in:
openharmony_ci 2024-10-15 15:04:21 +00:00 committed by Gitee
commit db062646c7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
26 changed files with 58 additions and 45 deletions

View File

@ -941,10 +941,11 @@ public:
/**
* @brief start user.
* @param accountId accountId.
* @param accountId is appRecovery or not.
*
* @return Returns ERR_OK on success, others on failure.
*/
ErrCode StartUser(int accountId, sptr<IUserCallback> callback);
ErrCode StartUser(int accountId, sptr<IUserCallback> callback, bool isAppRecovery = false);
/**
* @brief stop user.

View File

@ -1000,10 +1000,10 @@ public:
/**
* @brief start user.
* @param accountId accountId.
*
* @param isAppRecovery is appRecovery or not.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int StartUser(int userId, sptr<IUserCallback> callback) = 0;
virtual int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery = false) = 0;
/**
* @brief stop user.

View File

@ -808,10 +808,10 @@ public:
/**
* @brief start user.
* @param accountId accountId.
*
* @param isAppRecovery is appRecovery or not.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int StartUser(int userId, sptr<IUserCallback> callback) override;
virtual int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery = false) override;
/**
* @brief stop user.

View File

@ -1157,7 +1157,7 @@ public:
*/
sptr<IRemoteObject> GetAbilityTokenByMissionId(int32_t missionId);
virtual int StartUser(int userId, sptr<IUserCallback> callback) override;
virtual int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery = false) override;
virtual int StopUser(int userId, const sptr<IUserCallback> &callback) override;
@ -1878,7 +1878,7 @@ private:
* start highest priority ability.
*
*/
void StartHighestPriorityAbility(int32_t userId, bool isBoot);
void StartHighestPriorityAbility(int32_t userId, bool isBoot, bool isAppRecovery = false);
/**
* connect bms.
*
@ -1981,7 +1981,8 @@ private:
void StopFreezingScreen();
void UserStarted(int32_t userId);
void SwitchToUser(int32_t userId);
void SwitchToUser(int32_t oldUserId, int32_t userId, sptr<IUserCallback> callback);
void SwitchToUser(int32_t oldUserId, int32_t userId, sptr<IUserCallback> callback,
bool isAppRecovery = false);
void SwitchManagers(int32_t userId, bool switchUser = true);
void StartUserApps();
void PauseOldUser(int32_t userId);

View File

@ -74,7 +74,7 @@ public:
* @param isForeground whether user should brout to foreground.
* @return 0 if the user has been successfully started.
*/
void StartUser(int32_t userId, sptr<IUserCallback> callback);
void StartUser(int32_t userId, sptr<IUserCallback> callback, bool isAppRecovery = false);
/**
* Stop user, if it is running..
@ -110,7 +110,8 @@ private:
std::shared_ptr<UserItem> GetOrCreateUserItem(int32_t userId);
void SetCurrentUserId(int32_t userId);
void BroadcastUserStarted(int32_t userId);
void MoveUserToForeground(int32_t oldUserId, int32_t newUserId, sptr<IUserCallback> callback);
void MoveUserToForeground(int32_t oldUserId, int32_t newUserId, sptr<IUserCallback> callback,
bool isAppRecovery = false);
void UserBootDone(std::shared_ptr<UserItem> &item);
void BroadcastUserBackground(int32_t userId);
void BroadcastUserForeground(int32_t userId);

View File

@ -1160,12 +1160,13 @@ ErrCode AbilityManagerClient::StopSyncRemoteMissions(const std::string &devId)
return abms->StopSyncRemoteMissions(devId);
}
ErrCode AbilityManagerClient::StartUser(int accountId, sptr<IUserCallback> callback)
ErrCode AbilityManagerClient::StartUser(int accountId, sptr<IUserCallback> callback, bool isAppRecovery)
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "accountId:%{public}d", accountId);
TAG_LOGI(AAFwkTag::ABILITYMGR, "accountId:%{public}d, isAppRecovery:%{public}d",
accountId, isAppRecovery);
auto abms = GetAbilityManager();
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
return abms->StartUser(accountId, callback);
return abms->StartUser(accountId, callback, isAppRecovery);
}
ErrCode AbilityManagerClient::StopUser(int accountId, sptr<IUserCallback> callback)

View File

@ -2968,7 +2968,7 @@ int AbilityManagerProxy::MoveMissionsToBackground(const std::vector<int32_t>& mi
return reply.ReadInt32();
}
int AbilityManagerProxy::StartUser(int userId, sptr<IUserCallback> callback)
int AbilityManagerProxy::StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery)
{
MessageParcel data;
if (!WriteInterfaceToken(data)) {
@ -2987,7 +2987,10 @@ int AbilityManagerProxy::StartUser(int userId, sptr<IUserCallback> callback)
return ERR_INVALID_VALUE;
}
}
if (!data.WriteBool(isAppRecovery)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write isAppRecovery fail");
return IPC_PROXY_ERR;
}
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
auto error = SendRequest(AbilityManagerInterfaceCode::START_USER, data, reply, option);

View File

@ -6182,7 +6182,7 @@ int32_t AbilityManagerService::GetUserId() const
return U0_USER_ID;
}
void AbilityManagerService::StartHighestPriorityAbility(int32_t userId, bool isBoot)
void AbilityManagerService::StartHighestPriorityAbility(int32_t userId, bool isBoot, bool isAppRecovery)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s", __func__);
auto bms = AbilityUtil::GetBundleManagerHelper();
@ -6231,7 +6231,9 @@ void AbilityManagerService::StartHighestPriorityAbility(int32_t userId, bool isB
// wait BOOT_ANIMATION_STARTED to start LAUNCHER
WaitBootAnimationStart();
#endif
if (isAppRecovery) {
abilityWant.SetParam("ohos.app.logout_recovery", true);
}
/* note: OOBE APP need disable itself, otherwise, it will be started when restart system everytime */
(void)StartAbility(abilityWant, userId, DEFAULT_INVAL_VALUE);
}
@ -7450,7 +7452,7 @@ int AbilityManagerService::JudgeAbilityVisibleControl(const AppExecFwk::AbilityI
return ABILITY_VISIBLE_FALSE_DENY_REQUEST;
}
int AbilityManagerService::StartUser(int userId, sptr<IUserCallback> callback)
int AbilityManagerService::StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery)
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "startUser in service:%{public}d", userId);
if (IPCSkeleton::GetCallingUid() != ACCOUNT_MGR_SERVICE_UID) {
@ -7462,7 +7464,7 @@ int AbilityManagerService::StartUser(int userId, sptr<IUserCallback> callback)
}
if (userController_) {
userController_->StartUser(userId, callback);
userController_->StartUser(userId, callback, isAppRecovery);
}
return 0;
}
@ -8066,10 +8068,12 @@ void AbilityManagerService::UserStarted(int32_t userId)
subManagersHelper_->InitSubManagers(userId, false);
}
void AbilityManagerService::SwitchToUser(int32_t oldUserId, int32_t userId, sptr<IUserCallback> callback)
void AbilityManagerService::SwitchToUser(int32_t oldUserId, int32_t userId, sptr<IUserCallback> callback,
bool isAppRecovery)
{
TAG_LOGI(AAFwkTag::ABILITYMGR,
"%{public}s, oldUserId:%{public}d, newUserId:%{public}d", __func__, oldUserId, userId);
"%{public}s, oldUserId:%{public}d, newUserId:%{public}d, isAppRecovery:%{public}d", __func__,
oldUserId, userId, isAppRecovery);
SwitchManagers(userId);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
PauseOldUser(oldUserId);
@ -8078,7 +8082,7 @@ void AbilityManagerService::SwitchToUser(int32_t oldUserId, int32_t userId, sptr
}
callback->OnStartUserDone(userId, ERR_OK);
bool isBoot = oldUserId == U0_USER_ID ? true : false;
StartHighestPriorityAbility(userId, isBoot);
StartHighestPriorityAbility(userId, isBoot, isAppRecovery);
if (taskHandler_) {
taskHandler_->SubmitTask([abilityMs = shared_from_this(), userId]() {
TAG_LOGI(AAFwkTag::ABILITYMGR, "StartResidentApps userId:%{public}d", userId);

View File

@ -2325,7 +2325,8 @@ int AbilityManagerStub::StartUserInner(MessageParcel &data, MessageParcel &reply
TAG_LOGE(AAFwkTag::ABILITYMGR, "callback invalid value");
return ERR_INVALID_VALUE;
}
int result = StartUser(userId, callback);
bool isAppRecovery = data.ReadBool();
int result = StartUser(userId, callback, isAppRecovery);
if (!reply.WriteInt32(result)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "startUser fail");
return ERR_INVALID_VALUE;

View File

@ -81,7 +81,7 @@ void UserController::ClearAbilityUserItems(int32_t userId)
}
}
void UserController::StartUser(int32_t userId, sptr<IUserCallback> callback)
void UserController::StartUser(int32_t userId, sptr<IUserCallback> callback, bool isAppRecovery)
{
if (userId < 0 || userId == USER_ID_NO_HEAD) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUserId invalid:%{public}d", userId);
@ -142,7 +142,7 @@ void UserController::StartUser(int32_t userId, sptr<IUserCallback> callback)
}
UserBootDone(userItem);
MoveUserToForeground(oldUserId, userId, callback);
MoveUserToForeground(oldUserId, userId, callback, isAppRecovery);
}
int32_t UserController::StopUser(int32_t userId)
@ -285,13 +285,14 @@ void UserController::SetCurrentUserId(int32_t userId)
DelayedSingleton<AppScheduler>::GetInstance()->SetCurrentUserId(userId);
}
void UserController::MoveUserToForeground(int32_t oldUserId, int32_t newUserId, sptr<IUserCallback> callback)
void UserController::MoveUserToForeground(int32_t oldUserId, int32_t newUserId, sptr<IUserCallback> callback,
bool isAppRecovery)
{
auto manager = DelayedSingleton<AbilityManagerService>::GetInstance();
if (!manager) {
return;
}
manager->SwitchToUser(oldUserId, newUserId, callback);
manager->SwitchToUser(oldUserId, newUserId, callback, isAppRecovery);
BroadcastUserBackground(oldUserId);
BroadcastUserForeground(newUserId);
}

View File

@ -306,7 +306,7 @@ ErrCode AbilityManagerClient::StopSyncRemoteMissions(const std::string& devId)
return abms->StopSyncRemoteMissions(devId);
}
ErrCode AbilityManagerClient::StartUser(int accountId, sptr<IUserCallback> callback)
ErrCode AbilityManagerClient::StartUser(int accountId, sptr<IUserCallback> callback, bool isAppRecovery)
{
if (g_remoteObject == nullptr) {
return ABILITY_SERVICE_NOT_CONNECTED;

View File

@ -208,7 +208,7 @@ public:
return 0;
}
int StartUser(int accountId, sptr<IUserCallback> callback)
int StartUser(int accountId, sptr<IUserCallback> callback, bool isAppRecovery)
{
return 0;
}

View File

@ -173,7 +173,7 @@ public:
int UninstallApp(const std::string& bundleName, int32_t uid) override;
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -60,7 +60,7 @@ void MockAbilityDelegatorStub::DumpState(const std::string& args, std::vector<st
return;
}
int MockAbilityDelegatorStub::StartUser(int userId, sptr<IUserCallback> callback)
int MockAbilityDelegatorStub::StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery)
{
return 0;
}
@ -253,7 +253,7 @@ int MockAbilityDelegatorStub2::StopServiceAbility(const Want& want, int32_t user
return 0;
}
int MockAbilityDelegatorStub2::StartUser(int userId, sptr<IUserCallback> callback)
int MockAbilityDelegatorStub2::StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery)
{
return 0;
}

View File

@ -125,7 +125,7 @@ public:
MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token,
const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam));
MOCK_METHOD2(SetMissionContinueState, int(const sptr<IRemoteObject>& token, const AAFwk::ContinueState& state));
int StartUser(int userId, sptr<IUserCallback> callback) override;
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override;
int StopUser(int userId, const sptr<IUserCallback>& callback) override;
int LogoutUser(int32_t userId) override;
int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
@ -305,7 +305,7 @@ public:
MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token,
const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam));
MOCK_METHOD2(SetMissionContinueState, int(const sptr<IRemoteObject>& token, const AAFwk::ContinueState& state));
int StartUser(int userId, sptr<IUserCallback> callback) override;
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override;
int StopUser(int userId, const sptr<IUserCallback>& callback) override;
int LogoutUser(int32_t userId) override;
int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;

View File

@ -165,7 +165,7 @@ public:
MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token,
const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam));
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -179,7 +179,7 @@ public:
return 0;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -130,7 +130,7 @@ public:
return 0;
}
virtual int StartUser(int userId, sptr<IUserCallback> callback) override
virtual int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -220,7 +220,7 @@ public:
return;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -220,7 +220,7 @@ public:
return;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -236,7 +236,7 @@ public:
return;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -283,7 +283,7 @@ public:
{
return 0;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -223,7 +223,7 @@ public:
return 0;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -194,7 +194,7 @@ public:
return;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -151,7 +151,7 @@ public:
MOCK_METHOD4(ShareDataDone, int32_t(const sptr<IRemoteObject> &token,
const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam));
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}

View File

@ -146,7 +146,7 @@ public:
return 0;
}
int StartUser(int userId, sptr<IUserCallback> callback) override
int StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery) override
{
return 0;
}