1 /*
2 * Copyright (c) 2024-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
17 #include "smart_reminder_center.h"
18
19 #include "ans_log_wrapper.h"
20 #include "ipc_skeleton.h"
21 #include "notification_bundle_option.h"
22 #include "notification_config_parse.h"
23 #include "notification_local_live_view_content.h"
24 #include "notification_preferences.h"
25 #include "os_account_manager.h"
26 #include "screenlock_manager.h"
27 #include "string_utils.h"
28
29 namespace OHOS {
30 namespace Notification {
31 using namespace std;
32 constexpr int32_t CONTROL_BY_SMART_REMINDER = 1 << 15;
33 namespace {
34 const std::string ANS_VOIP = "ANS_VOIP";
35 }
SmartReminderCenter()36 SmartReminderCenter::SmartReminderCenter()
37 {
38 DelayedSingleton<NotificationConfigParse>::GetInstance()->GetCollaborationFilter();
39 if (!DelayedSingleton<NotificationConfigParse>::GetInstance()->GetCurrentSlotReminder(currentReminderMethods_)) {
40 return;
41 }
42 GetMultiDeviceReminder();
43 }
44
GetMultiDeviceReminder()45 void SmartReminderCenter::GetMultiDeviceReminder()
46 {
47 nlohmann::json root;
48 string multiJsonPoint = "/";
49 multiJsonPoint.append(NotificationConfigParse::CFG_KEY_NOTIFICATION_SERVICE);
50 multiJsonPoint.append("/");
51 multiJsonPoint.append(MULTI_DEVICE_REMINDER);
52 if (!DelayedSingleton<NotificationConfigParse>::GetInstance()->GetConfigJson(multiJsonPoint, root)) {
53 ANS_LOGW("Failed to get multiDeviceReminder CCM config file.");
54 return;
55 }
56
57 if (root.find(NotificationConfigParse::CFG_KEY_NOTIFICATION_SERVICE) == root.end()) {
58 ANS_LOGW("GetMultiDeviceReminder failed as can not find notificationService.");
59 return;
60 }
61
62 nlohmann::json multiDeviceRemindJson =
63 root[NotificationConfigParse::CFG_KEY_NOTIFICATION_SERVICE][MULTI_DEVICE_REMINDER];
64 if (multiDeviceRemindJson.is_null() || !multiDeviceRemindJson.is_array() || multiDeviceRemindJson.empty()) {
65 ANS_LOGW("GetMultiDeviceReminder failed as invalid multiDeviceReminder json.");
66 return;
67 }
68
69 reminderMethods_.clear();
70 for (auto &singleDeviceRemindJson : multiDeviceRemindJson) {
71 if (singleDeviceRemindJson.is_null() || !singleDeviceRemindJson.is_object()) {
72 continue;
73 }
74
75 if (singleDeviceRemindJson.find(ReminderAffected::DEVICE_TYPE) == singleDeviceRemindJson.end() ||
76 singleDeviceRemindJson[ReminderAffected::DEVICE_TYPE].is_null() ||
77 !singleDeviceRemindJson[ReminderAffected::DEVICE_TYPE].is_string()) {
78 continue;
79 }
80
81 if (singleDeviceRemindJson.find(REMINDER_FILTER_DEVICE) == singleDeviceRemindJson.end() ||
82 singleDeviceRemindJson[REMINDER_FILTER_DEVICE].is_null() ||
83 !singleDeviceRemindJson[REMINDER_FILTER_DEVICE].is_array() ||
84 singleDeviceRemindJson[REMINDER_FILTER_DEVICE].empty()) {
85 continue;
86 }
87 ParseReminderFilterDevice(singleDeviceRemindJson[REMINDER_FILTER_DEVICE],
88 singleDeviceRemindJson[ReminderAffected::DEVICE_TYPE].get<string>());
89 }
90
91 if (reminderMethods_.size() <= 0) {
92 ANS_LOGW("GetMultiDeviceReminder failed as Invalid reminderMethods size.");
93 }
94 }
95
ParseReminderFilterDevice(const nlohmann::json & root,const string & deviceType)96 void SmartReminderCenter::ParseReminderFilterDevice(const nlohmann::json &root, const string &deviceType)
97 {
98 map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice;
99 for (auto &reminderFilterDeviceJson : root) {
100 NotificationConstant::SlotType slotType;
101 if (reminderFilterDeviceJson.find(SLOT_TYPE) == reminderFilterDeviceJson.end() ||
102 reminderFilterDeviceJson[SLOT_TYPE].is_null() ||
103 !reminderFilterDeviceJson[SLOT_TYPE].is_string()) {
104 continue;
105 }
106
107 if (reminderFilterDeviceJson.find(REMINDER_FILTER_SLOT) == reminderFilterDeviceJson.end() ||
108 reminderFilterDeviceJson[REMINDER_FILTER_SLOT].is_null() ||
109 !reminderFilterDeviceJson[REMINDER_FILTER_SLOT].is_array() ||
110 reminderFilterDeviceJson[REMINDER_FILTER_SLOT].empty()) {
111 continue;
112 }
113
114 std::string slotTypes = reminderFilterDeviceJson[SLOT_TYPE].get<std::string>();
115 std::vector<std::string> slotTypeVector;
116 StringUtils::Split(slotTypes, SPLIT_FLAG, slotTypeVector);
117
118 for (std::string slotTypeStr : slotTypeVector) {
119 if (!NotificationSlot::GetSlotTypeByString(slotTypeStr, slotType)) {
120 continue;
121 }
122 ParseReminderFilterSlot(reminderFilterDeviceJson[REMINDER_FILTER_SLOT],
123 to_string(static_cast<int32_t>(slotType)), reminderFilterDevice);
124 }
125 }
126 if (reminderFilterDevice.size() > 0) {
127 reminderMethods_[deviceType] = move(reminderFilterDevice);
128 } else {
129 ANS_LOGI("ParseReminderFilterDevice failed as Invalid reminderFilterDevice size. deviceType = %{public}s.",
130 deviceType.c_str());
131 }
132 }
133
ParseReminderFilterSlot(const nlohmann::json & root,const string & notificationType,map<string,vector<shared_ptr<ReminderAffected>>> & reminderFilterDevice) const134 void SmartReminderCenter::ParseReminderFilterSlot(
135 const nlohmann::json &root,
136 const string ¬ificationType,
137 map<string, vector<shared_ptr<ReminderAffected>>> &reminderFilterDevice) const
138 {
139 vector<shared_ptr<ReminderAffected>> reminderFilterSlot;
140 for (auto &reminderFilterSlotJson : root) {
141 NotificationContent::Type contentType;
142 bool validContentType = true;
143
144 if (reminderFilterSlotJson.find(CONTENT_TYPE) == reminderFilterSlotJson.end() ||
145 reminderFilterSlotJson[CONTENT_TYPE].is_null() ||
146 !reminderFilterSlotJson[CONTENT_TYPE].is_string() ||
147 !NotificationContent::GetContentTypeByString(
148 reminderFilterSlotJson[CONTENT_TYPE].get<std::string>(), contentType)) {
149 validContentType = false;
150 }
151
152 if (reminderFilterSlotJson.find(REMINDER_FILTER_CONTENT) == reminderFilterSlotJson.end() ||
153 reminderFilterSlotJson[REMINDER_FILTER_CONTENT].is_null() ||
154 !reminderFilterSlotJson[REMINDER_FILTER_CONTENT].is_array() ||
155 reminderFilterSlotJson[REMINDER_FILTER_CONTENT].empty()) {
156 validContentType = false;
157 }
158
159 if (validContentType) {
160 string localNotificationType = notificationType;
161 localNotificationType.append("#");
162 localNotificationType.append(to_string(static_cast<int32_t>(contentType)));
163 ParseReminderFilterContent(
164 reminderFilterSlotJson[REMINDER_FILTER_CONTENT], localNotificationType, reminderFilterDevice);
165 continue;
166 }
167 shared_ptr<ReminderAffected> reminderAffected = make_shared<ReminderAffected>();
168 if (reminderAffected->FromJson(reminderFilterSlotJson)) {
169 reminderFilterSlot.push_back(reminderAffected);
170 }
171 }
172 if (reminderFilterSlot.size() > 0) {
173 reminderFilterDevice[notificationType] = move(reminderFilterSlot);
174 }
175 }
176
ParseReminderFilterContent(const nlohmann::json & root,const string & notificationType,map<string,vector<shared_ptr<ReminderAffected>>> & reminderFilterDevice) const177 void SmartReminderCenter::ParseReminderFilterContent(
178 const nlohmann::json &root,
179 const string ¬ificationType,
180 map<string, vector<shared_ptr<ReminderAffected>>> &reminderFilterDevice) const
181 {
182 vector<shared_ptr<ReminderAffected>> reminderFilterContent;
183 for (auto &reminderFilterContentJson : root) {
184 bool validTypeCode = true;
185 if (reminderFilterContentJson.find(TYPE_CODE) == reminderFilterContentJson.end() ||
186 reminderFilterContentJson[TYPE_CODE].is_null() ||
187 !reminderFilterContentJson[TYPE_CODE].is_number()) {
188 validTypeCode = false;
189 }
190
191 if (reminderFilterContentJson.find(REMINDER_FILTER_CODE) == reminderFilterContentJson.end() ||
192 reminderFilterContentJson[REMINDER_FILTER_CODE].is_null() ||
193 !reminderFilterContentJson[REMINDER_FILTER_CODE].is_array() ||
194 reminderFilterContentJson[REMINDER_FILTER_CODE].empty()) {
195 validTypeCode = false;
196 }
197
198 if (validTypeCode) {
199 int32_t typeCode = reminderFilterContentJson[TYPE_CODE].get<int32_t>();
200 string localNotificationType = notificationType;
201 localNotificationType.append("#");
202 localNotificationType.append(to_string(typeCode));
203 ParseReminderFilterCode(
204 reminderFilterContentJson[REMINDER_FILTER_CODE], localNotificationType, reminderFilterDevice);
205 continue;
206 }
207 shared_ptr<ReminderAffected> reminderAffected = make_shared<ReminderAffected>();
208 if (reminderAffected->FromJson(reminderFilterContentJson)) {
209 reminderFilterContent.push_back(reminderAffected);
210 }
211 }
212 if (reminderFilterContent.size() > 0) {
213 reminderFilterDevice[notificationType] = move(reminderFilterContent);
214 }
215 }
216
ParseReminderFilterCode(const nlohmann::json & root,const string & notificationType,map<string,vector<shared_ptr<ReminderAffected>>> & reminderFilterDevice) const217 void SmartReminderCenter::ParseReminderFilterCode(
218 const nlohmann::json &root,
219 const string ¬ificationType,
220 map<string, vector<shared_ptr<ReminderAffected>>> &reminderFilterDevice) const
221 {
222 vector<shared_ptr<ReminderAffected>> reminderFilterCode;
223 for (auto &reminderFilterCodeJson : root) {
224 shared_ptr<ReminderAffected> reminderAffected = make_shared<ReminderAffected>();
225 if (reminderAffected->FromJson(reminderFilterCodeJson)) {
226 reminderFilterCode.push_back(reminderAffected);
227 }
228 }
229 if (reminderFilterCode.size() > 0) {
230 reminderFilterDevice[notificationType] = move(reminderFilterCode);
231 }
232 }
233
IsCollaborationAllowed(const sptr<NotificationRequest> & request) const234 bool SmartReminderCenter::IsCollaborationAllowed(const sptr<NotificationRequest>& request) const
235 {
236 if (!request->IsSystemApp()) {
237 ANS_LOGI("IsSystemApp <%{public}d> allowed to collaborate.", request->IsSystemApp());
238 return true;
239 }
240 if (request->IsNotDistributed()) {
241 ANS_LOGI("IsNotDistributed <%{public}d> not allowed to collaborate", request->IsNotDistributed());
242 return false;
243 }
244 if (request->IsForceDistributed()) {
245 ANS_LOGI("IsForceDistributed <%{public}d> allowed to collaborate", request->IsForceDistributed());
246 return true;
247 }
248 return !DelayedSingleton<NotificationConfigParse>::GetInstance()->IsInCollaborationFilter(
249 request->GetOwnerBundleName(), request->GetCreatorUid());
250 }
251
ReminderDecisionProcess(const sptr<NotificationRequest> & request) const252 void SmartReminderCenter::ReminderDecisionProcess(const sptr<NotificationRequest> &request) const
253 {
254 shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
255 make_shared<map<string, shared_ptr<NotificationFlags>>>();
256 NotificationConstant::SlotType slotType = request->GetSlotType();
257 auto iter = currentReminderMethods_.find(slotType);
258 if (iter != currentReminderMethods_.end()) {
259 // Only config file can set reminder open now. Otherwise, change iter->second to 11111
260 (*notificationFlagsOfDevices)[NotificationConstant::CURRENT_DEVICE_TYPE] = iter->second;
261 }
262 if (!IsCollaborationAllowed(request)) {
263 request->SetDeviceFlags(notificationFlagsOfDevices);
264 return;
265 }
266
267 set<string> validDevices;
268 InitValidDevices(validDevices, request);
269 for (auto &reminderMethod : reminderMethods_) {
270 if (validDevices.size() <= 1 && reminderMethod.first.compare(NotificationConstant::CURRENT_DEVICE_TYPE) == 0) {
271 continue;
272 }
273 HandleReminderMethods(
274 reminderMethod.first, reminderMethod.second, request, validDevices, notificationFlagsOfDevices);
275 }
276 request->SetDeviceFlags(notificationFlagsOfDevices);
277 }
278
InitValidDevices(set<string> & validDevices,const sptr<NotificationRequest> & request) const279 void SmartReminderCenter::InitValidDevices(
280 set<string> &validDevices,
281 const sptr<NotificationRequest> &request) const
282 {
283 auto notificationControlFlags = request->GetNotificationControlFlags();
284 validDevices.insert(NotificationConstant::CURRENT_DEVICE_TYPE);
285 for (std::string deviceType : NotificationConstant::DEVICESTYPES) {
286 if (!NotificationSubscriberManager::GetInstance()->IsDeviceTypeSubscriberd(deviceType)) {
287 continue;
288 }
289 if (NotificationConstant::SlotType::LIVE_VIEW == request->GetSlotType()) {
290 bool isEnable = false;
291 NotificationPreferences::GetInstance()->IsDistributedEnabledBySlot(
292 request->GetSlotType(), deviceType, isEnable);
293 if (!isEnable) {
294 ANS_LOGI("switch-status, slot switch closed. device = %{public}s", deviceType.c_str());
295 continue;
296 } else {
297 validDevices.insert(deviceType);
298 request->SetNotificationControlFlags(notificationControlFlags | CONTROL_BY_SMART_REMINDER);
299 ANS_LOGI("InitValidDevices- %{public}s", deviceType.c_str());
300 }
301 } else {
302 if (IsNeedSynergy(request->GetSlotType(), deviceType,
303 request->GetOwnerBundleName(), request->GetOwnerUid())) {
304 validDevices.insert(deviceType);
305 request->SetNotificationControlFlags(notificationControlFlags | CONTROL_BY_SMART_REMINDER);
306 ANS_LOGI("InitValidDevices- %{public}s", deviceType.c_str());
307 }
308 }
309 }
310 return;
311 }
312
HandleReminderMethods(const string & deviceType,const map<string,vector<shared_ptr<ReminderAffected>>> & reminderFilterDevice,const sptr<NotificationRequest> & request,set<string> & validDevices,shared_ptr<map<string,shared_ptr<NotificationFlags>>> notificationFlagsOfDevices) const313 void SmartReminderCenter::HandleReminderMethods(
314 const string &deviceType,
315 const map<string, vector<shared_ptr<ReminderAffected>>> &reminderFilterDevice,
316 const sptr<NotificationRequest> &request,
317 set<string> &validDevices,
318 shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices) const
319 {
320 std::string classfication = request->GetClassification();
321 if (deviceType.compare(NotificationConstant::CURRENT_DEVICE_TYPE) == 0 &&
322 classfication == ANS_VOIP) {
323 ANS_LOGI("VOIP or CALL is not affected with SmartReminder");
324 return;
325 }
326 vector<shared_ptr<ReminderAffected>> reminderAffecteds;
327 GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds);
328 if (reminderAffecteds.size() <= 0) {
329 return;
330 }
331 bitset<DistributedDeviceStatus::STATUS_SIZE> bitStatus;
332 GetDeviceStatusByType(deviceType, bitStatus);
333 request->AdddeviceStatu(deviceType, bitStatus.bitset<DistributedDeviceStatus::STATUS_SIZE>::to_string());
334
335 if (NotificationConstant::SlotType::LIVE_VIEW == request->GetSlotType() &&
336 validDevices.find(deviceType) == validDevices.end()
337 ) {
338 ANS_LOGI("live view slot switch is close, not notify");
339 return;
340 }
341
342 bool enabledAffectedBy = true;
343
344 if (validDevices.find(deviceType) == validDevices.end()) {
345 enabledAffectedBy = false;
346 }
347
348 for (auto &reminderAffected : reminderAffecteds) {
349 if (!CompareStatus(reminderAffected->status_, bitStatus)) {
350 continue;
351 }
352 if (reminderAffected->affectedBy_.size() <= 0) {
353 (*notificationFlagsOfDevices)[deviceType] = reminderAffected->reminderFlags_;
354 ANS_LOGI("unaffect match deviceType = %{public}s , remindFlags = %{public}d",
355 deviceType.c_str(), reminderAffected->reminderFlags_->GetReminderFlags());
356 continue;
357 }
358 if (enabledAffectedBy &&
359 HandleAffectedReminder(deviceType, reminderAffected, validDevices, notificationFlagsOfDevices)) {
360 break;
361 }
362 }
363 }
364
IsNeedSynergy(const NotificationConstant::SlotType & slotType,const string & deviceType,const string & ownerBundleName,int32_t ownerUid) const365 bool SmartReminderCenter::IsNeedSynergy(const NotificationConstant::SlotType &slotType,
366 const string &deviceType, const string &ownerBundleName, int32_t ownerUid) const
367 {
368 std::string device = deviceType;
369 if (deviceType.compare(NotificationConstant::WEARABLE_DEVICE_TYPE) == 0) {
370 device = NotificationConstant::LITEWEARABLE_DEVICE_TYPE;
371 }
372
373 bool isEnable = true;
374 if (NotificationPreferences::GetInstance()->IsSmartReminderEnabled(device, isEnable) != ERR_OK || !isEnable) {
375 ANS_LOGI("switch-status, smartReminderEnable closed. device = %{public}s", device.c_str());
376 return false;
377 }
378
379 sptr<NotificationBundleOption> bundleOption =
380 new (std::nothrow) NotificationBundleOption(ownerBundleName, ownerUid);
381 if (NotificationPreferences::GetInstance()->IsDistributedEnabledByBundle(
382 bundleOption, device, isEnable) != ERR_OK || !isEnable) {
383 ANS_LOGI("switch-status, app switch closed. device = %{public}s", device.c_str());
384 return false;
385 }
386 return true;
387 }
388
HandleAffectedReminder(const string & deviceType,const shared_ptr<ReminderAffected> & reminderAffected,const set<string> & validDevices,shared_ptr<map<string,shared_ptr<NotificationFlags>>> notificationFlagsOfDevices) const389 bool SmartReminderCenter::HandleAffectedReminder(
390 const string &deviceType,
391 const shared_ptr<ReminderAffected> &reminderAffected,
392 const set<string> &validDevices,
393 shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices) const
394 {
395 bool ret = true;
396 for (auto &affectedBy : reminderAffected->affectedBy_) {
397 if (validDevices.find(affectedBy.first) == validDevices.end()) {
398 ret = false;
399 break;
400 }
401 bitset<DistributedDeviceStatus::STATUS_SIZE> bitStatus;
402 GetDeviceStatusByType(affectedBy.first, bitStatus);
403 if (!CompareStatus(affectedBy.second, bitStatus)) {
404 ret = false;
405 break;
406 }
407 }
408 if (ret) {
409 (*notificationFlagsOfDevices)[deviceType] = reminderAffected->reminderFlags_;
410 ANS_LOGI("affect match deviceType = %{public}s , remindFlags = %{public}d",
411 deviceType.c_str(), reminderAffected->reminderFlags_->GetReminderFlags());
412 }
413 return ret;
414 }
415
CompareStatus(const string & status,const bitset<DistributedDeviceStatus::STATUS_SIZE> & bitStatus) const416 bool SmartReminderCenter::CompareStatus(
417 const string &status, const bitset<DistributedDeviceStatus::STATUS_SIZE> &bitStatus) const
418 {
419 if (status.size() <= 0) {
420 return true;
421 }
422 std::vector<std::string> statusVector;
423 StringUtils::Split(status, StringUtils::SPLIT_CHAR, statusVector);
424 for (std::string strStatus : statusVector) {
425 // bitset.to_string() and config is reverse, bit[0] is behind
426 string localStatus = strStatus;
427 reverse(localStatus.begin(), localStatus.end());
428 for (int32_t seq = 0; seq < DistributedDeviceStatus::STATUS_SIZE; seq++) {
429 if (localStatus[seq] != ReminderAffected::STATUS_DEFAULT && bitStatus[seq] != localStatus[seq] - '0') {
430 break;
431 }
432 if (seq == DistributedDeviceStatus::STATUS_SIZE -1) {
433 return true;
434 }
435 }
436 }
437 return false;
438 }
439
GetReminderAffecteds(const map<string,vector<shared_ptr<ReminderAffected>>> & reminderFilterDevice,const sptr<NotificationRequest> & request,vector<shared_ptr<ReminderAffected>> & reminderAffecteds) const440 __attribute__((no_sanitize("cfi"))) void SmartReminderCenter::GetReminderAffecteds(
441 const map<string, vector<shared_ptr<ReminderAffected>>> &reminderFilterDevice,
442 const sptr<NotificationRequest> &request,
443 vector<shared_ptr<ReminderAffected>> &reminderAffecteds) const
444 {
445 string strSlotType = to_string(static_cast<int32_t>(request->GetSlotType()));
446 string contentTypeCombination = strSlotType;
447 contentTypeCombination.append("#");
448 if (request->GetContent() != nullptr) {
449 contentTypeCombination.append(to_string(static_cast<int32_t>(request->GetContent()->GetContentType())));
450 }
451 string typeCodeCombination = contentTypeCombination;
452 typeCodeCombination.append("#");
453 if (request->GetContent() != nullptr && request->GetContent()->GetNotificationContent() != nullptr) {
454 NotificationLocalLiveViewContent *localLiveView =
455 static_cast<NotificationLocalLiveViewContent *>(&(*(request->GetContent()->GetNotificationContent())));
456 typeCodeCombination.append(to_string(localLiveView->GetType()));
457 }
458 auto iter = reminderFilterDevice.find(typeCodeCombination);
459 if (iter != reminderFilterDevice.end()) {
460 reminderAffecteds = iter->second;
461 return;
462 }
463 iter = reminderFilterDevice.find(contentTypeCombination);
464 if (iter != reminderFilterDevice.end()) {
465 reminderAffecteds = iter->second;
466 return;
467 }
468 iter = reminderFilterDevice.find(strSlotType);
469 if (iter != reminderFilterDevice.end()) {
470 reminderAffecteds = iter->second;
471 return;
472 }
473 ANS_LOGD("GetReminderAffecteds fail as wrong notification_config.json possibly. TypeCombination = %{public}s.",
474 typeCodeCombination.c_str());
475 }
476
GetDeviceStatusByType(const string & deviceType,bitset<DistributedDeviceStatus::STATUS_SIZE> & bitStatus) const477 void SmartReminderCenter::GetDeviceStatusByType(
478 const string &deviceType, bitset<DistributedDeviceStatus::STATUS_SIZE> &bitStatus) const
479 {
480 u_int32_t status = DelayedSingleton<DistributedDeviceStatus>::GetInstance()->GetDeviceStatus(deviceType);
481 bitStatus = bitset<DistributedDeviceStatus::STATUS_SIZE>(status);
482 if (deviceType.compare(NotificationConstant::CURRENT_DEVICE_TYPE) == 0) {
483 bool screenLocked = true;
484 screenLocked = ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked();
485 bitStatus.set(DistributedDeviceStatus::LOCK_FLAG, !screenLocked);
486 }
487 ANS_LOGI("GetDeviceStatusByType deviceType: %{public}s, bitStatus: %{public}s.",
488 deviceType.c_str(), bitStatus.to_string().c_str());
489 }
490 } // namespace Notification
491 } // namespace OHOS
492 #endif
493