mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
2856fd0af7
@ -458,10 +458,6 @@ enum {
|
||||
* Result(29360229) for calling StartAbility failed during continuation.
|
||||
*/
|
||||
CONTINUE_CALL_START_ABILITY_FAILED = 29360229,
|
||||
/**
|
||||
* Result(29360230) for sink Ability abnormal termination during continuation.
|
||||
*/
|
||||
CONTINUE_SINK_ABILITY_TERMINATED = 29360230,
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
class DSchedContinue;
|
||||
class AppStateObserver : public AppExecFwk::ApplicationStateObserverStub {
|
||||
public:
|
||||
/**
|
||||
@ -57,16 +56,9 @@ public:
|
||||
* @param processData Process data.
|
||||
*/
|
||||
void OnProcessDied(const AppExecFwk::ProcessData& processData) override;
|
||||
|
||||
AppStateObserver();
|
||||
|
||||
AppStateObserver(const std::shared_ptr<DSchedContinue> dContinue, const std::string abilityName);
|
||||
|
||||
private:
|
||||
std::mutex countLock_;
|
||||
std::map<sptr<IRemoteObject>, int32_t> connectAbilityMap_;
|
||||
std::weak_ptr<DSchedContinue> dschedContinue_;
|
||||
std::string abilityName_;
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "app_state_observer.h"
|
||||
#include "distributedWant/distributed_want.h"
|
||||
#include "distributedWant/distributed_want_params.h"
|
||||
#include "distributed_sched_interface.h"
|
||||
@ -196,8 +195,6 @@ private:
|
||||
bool CheckQuickStartConfiguration();
|
||||
std::string GetAbilityNameByContinueType();
|
||||
void SetEventData();
|
||||
bool RegisterAppStateObserver(const std::string abilityName);
|
||||
void UnregisterAppStateObserver();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DSchedContinueStateMachine> stateMachine_;
|
||||
@ -215,7 +212,6 @@ private:
|
||||
int32_t softbusSessionId_ = 0;
|
||||
sptr<IRemoteObject> callback_ = nullptr;
|
||||
EventNotify eventData_;
|
||||
sptr<AppStateObserver> appStateObserver_ = nullptr;
|
||||
};
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
|
@ -198,7 +198,6 @@ public:
|
||||
int32_t CheckTargetPermission(const OHOS::AAFwk::Want& want, const CallerInfo& callerInfo,
|
||||
const AccountInfo& accountInfo, int32_t flag, bool needQueryExtension);
|
||||
ErrCode QueryOsAccount(int32_t& activeAccountId);
|
||||
sptr<AppExecFwk::IAppMgr> GetAppManager();
|
||||
|
||||
#ifdef DMSFWK_INTERACTIVE_ADAPTER
|
||||
bool CheckRemoteOsType(const std::string& netwokId) override;
|
||||
@ -275,6 +274,7 @@ private:
|
||||
bool RegisterAppStateObserver(const OHOS::AAFwk::Want& want, const CallerInfo& callerInfo,
|
||||
const sptr<IRemoteObject>& srcConnect, const sptr<IRemoteObject>& callbackWrapper);
|
||||
void UnregisterAppStateObserver(const sptr<IRemoteObject>& callbackWrapper);
|
||||
sptr<AppExecFwk::IAppMgr> GetAppManager();
|
||||
int32_t SaveConnectToken(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect);
|
||||
void SetCleanMissionFlag(const OHOS::AAFwk::Want& want, int32_t missionId);
|
||||
void RemoveConnectAbilityInfo(const std::string& deviceId);
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "app_state_observer.h"
|
||||
#include "distributed_sched_service.h"
|
||||
#include "dsched_continue.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "element_name.h"
|
||||
|
||||
@ -26,16 +25,6 @@ const std::string TAG = "AppStateObserver";
|
||||
constexpr int32_t FOREGROUND = 2;
|
||||
constexpr int32_t BACKGROUND = 4;
|
||||
constexpr int32_t NOTIFY_COUNT = 2;
|
||||
constexpr int32_t ABILITY_STATE_TERMINATED = 5;
|
||||
}
|
||||
|
||||
AppStateObserver::AppStateObserver()
|
||||
{
|
||||
}
|
||||
|
||||
AppStateObserver::AppStateObserver(const std::shared_ptr<DSchedContinue> dContinue, const std::string abilityName)
|
||||
: dschedContinue_(dContinue), abilityName_(abilityName)
|
||||
{
|
||||
}
|
||||
|
||||
void AppStateObserver::OnForegroundApplicationChanged(const AppExecFwk::AppStateData& appStateData)
|
||||
@ -45,15 +34,6 @@ void AppStateObserver::OnForegroundApplicationChanged(const AppExecFwk::AppState
|
||||
void AppStateObserver::OnAbilityStateChanged(const AppExecFwk::AbilityStateData& abilityStateData)
|
||||
{
|
||||
HILOGD("OnAbilityStateChanged called.");
|
||||
if (abilityStateData.abilityState == ABILITY_STATE_TERMINATED && abilityStateData.abilityName == abilityName_) {
|
||||
std::shared_ptr<DSchedContinue> dContinue = dschedContinue_.lock();
|
||||
if (dContinue != nullptr) {
|
||||
HILOGE("ability terminated, excute OnContinueEnd");
|
||||
dContinue->OnContinueEnd(CONTINUE_SINK_ABILITY_TERMINATED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (abilityStateData.abilityState != FOREGROUND && abilityStateData.abilityState != BACKGROUND) {
|
||||
HILOGD("ability state neither foreground nor background");
|
||||
return;
|
||||
|
@ -36,14 +36,12 @@
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "mission/distributed_bm_storage.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "parcel_helper.h"
|
||||
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
|
||||
#include "mission/dms_continue_send_manager.h"
|
||||
#endif
|
||||
#include "scene_board_judgement.h"
|
||||
#include "softbus_adapter/transport/dsched_transport_softbus_adapter.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
@ -127,7 +125,6 @@ DSchedContinue::~DSchedContinue()
|
||||
}
|
||||
eventThread_.join();
|
||||
eventHandler_ = nullptr;
|
||||
UnregisterAppStateObserver();
|
||||
HILOGI("DSchedContinue delete end");
|
||||
}
|
||||
|
||||
@ -938,50 +935,9 @@ int32_t DSchedContinue::StartAbility(const OHOS::AAFwk::Want& want, int32_t requ
|
||||
HILOGE("StartAbility failed %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
if (appStateObserver_ == nullptr) {
|
||||
RegisterAppStateObserver(want.GetElement().GetAbilityName());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DSchedContinue::RegisterAppStateObserver(const std::string abilityName)
|
||||
{
|
||||
HILOGI("register app state observer called");
|
||||
sptr<AppExecFwk::IAppMgr> appObject = DistributedSchedService::GetInstance().GetAppManager();
|
||||
if (appObject == nullptr) {
|
||||
HILOGE("failed to get app manager service");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string bundleName = continueInfo_.sinkBundleName_;
|
||||
std::vector<std::string> bundleNameList = {bundleName};
|
||||
auto dContinue = std::shared_ptr<DSchedContinue>(shared_from_this());
|
||||
appStateObserver_ = sptr<AppStateObserver>(new (std::nothrow) AppStateObserver(dContinue, abilityName));
|
||||
int ret = appObject->RegisterApplicationStateObserver(appStateObserver_, bundleNameList);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("failed to register application state observer, ret = %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DSchedContinue::UnregisterAppStateObserver()
|
||||
{
|
||||
HILOGI("unregister app state observer called");
|
||||
sptr<AppExecFwk::IAppMgr> appObject = DistributedSchedService::GetInstance().GetAppManager();
|
||||
if (appObject == nullptr) {
|
||||
HILOGE("failed to get app manager service");
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = appObject->UnregisterApplicationStateObserver(appStateObserver_);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("failed to unregister application state observer, ret = %{public}d", ret);
|
||||
return;
|
||||
}
|
||||
HILOGI("unregister application state observer success");
|
||||
}
|
||||
|
||||
int32_t DSchedContinue::ExecuteNotifyComplete(int32_t result)
|
||||
{
|
||||
HILOGI("ExecuteNotifyComplete start, continueInfo: %{public}s", continueInfo_.toString().c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user