mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-19 07:58:03 +00:00
add user
Signed-off-by: unknown <sijunjie@huawei.com>
This commit is contained in:
parent
2b59ed5e0c
commit
123ab548ae
@ -179,6 +179,9 @@ private:
|
||||
bool LoadAllMissionInfo();
|
||||
|
||||
void GetMatchedMission(const std::string &bundleName, int32_t uid, std::list<int32_t> &missions);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void CreateWhitePixelMap(Snapshot &snapshot) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
int32_t currentMissionId_ = MIN_MISSION_ID;
|
||||
|
@ -14,11 +14,24 @@
|
||||
*/
|
||||
|
||||
#include "mission_info_mgr.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "image_source.h"
|
||||
#include "media_errors.h"
|
||||
#endif
|
||||
#include "nlohmann/json.hpp"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "securec.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
constexpr int32_t BPP = 4; // bytes per pixel
|
||||
MissionInfoMgr::MissionInfoMgr()
|
||||
{
|
||||
HILOG_INFO("MissionInfoMgr instance is created");
|
||||
@ -432,6 +445,9 @@ bool MissionInfoMgr::UpdateMissionSnapshot(int32_t missionId, const sptr<IRemote
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (missionSnapshot.isPrivate) {
|
||||
CreateWhitePixelMap(snapshot);
|
||||
}
|
||||
missionSnapshot.snapshot = isLowResolution ?
|
||||
MissionDataStorage::GetReducedPixelMap(snapshot.GetPixelMap()) : snapshot.GetPixelMap();
|
||||
#endif
|
||||
@ -499,5 +515,39 @@ bool MissionInfoMgr::GetMissionSnapshot(int32_t missionId, const sptr<IRemoteObj
|
||||
HILOG_INFO("snapshot: storage mission snapshot not exists, create new snapshot");
|
||||
return UpdateMissionSnapshot(missionId, abilityToken, missionSnapshot, isLowResolution);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void MissionInfoMgr::CreateWhitePixelMap(Snapshot &snapshot) const
|
||||
{
|
||||
if (snapshot.GetPixelMap() == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
ssize_t dataLength = snapshot.GetPixelMap()->GetWidth() * snapshot.GetPixelMap()->GetHeight() * BPP;
|
||||
uint8_t* data = (uint8_t*) malloc(dataLength);
|
||||
if (memset_s(data, dataLength, 0xff, dataLength) != EOK) {
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t errCode = 0;
|
||||
Media::SourceOptions sourceOptions;
|
||||
auto imageSource = Media::ImageSource::CreateImageSource(data, dataLength, sourceOptions, errCode);
|
||||
if (errCode != OHOS::Media::SUCCESS) {
|
||||
HILOG_ERROR("snapshot: CreateWhitePixelMap failed, errCode = %{public}d", errCode);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
Media::DecodeOptions decodeOptions;
|
||||
auto pixelMap = imageSource->CreatePixelMap(decodeOptions, errCode);
|
||||
if (errCode != OHOS::Media::SUCCESS) {
|
||||
HILOG_ERROR("snapshot: CreatePixelMap failed, errCode = %{public}d", errCode);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
snapshot.SetPixelMap(std::move(pixelMap));
|
||||
free(data);
|
||||
}
|
||||
#endif
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1535,7 +1535,7 @@ void MissionListManager::UpdateMissionSnapshot(const std::shared_ptr<AbilityReco
|
||||
}
|
||||
int32_t missionId = abilityRecord->GetMissionId();
|
||||
MissionSnapshot snapshot;
|
||||
snapshot.isPrivate = (abilityRecord->GetAppIndex() != 0);
|
||||
snapshot.isPrivate = true;
|
||||
DelayedSingleton<MissionInfoMgr>::GetInstance()->UpdateMissionSnapshot(missionId, abilityRecord->GetToken(),
|
||||
snapshot);
|
||||
if (listenerController_) {
|
||||
@ -2550,6 +2550,7 @@ bool MissionListManager::GetMissionSnapshot(int32_t missionId, const sptr<IRemot
|
||||
auto abilityRecord = GetAbilityRecordByToken(abilityToken);
|
||||
if (abilityRecord && abilityRecord->IsAbilityState(FOREGROUND)) {
|
||||
forceSnapshot = true;
|
||||
missionSnapshot.isPrivate = true;
|
||||
}
|
||||
}
|
||||
return DelayedSingleton<MissionInfoMgr>::GetInstance()->GetMissionSnapshot(
|
||||
|
Loading…
Reference in New Issue
Block a user