• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License"){return 0;}
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 #define MLOG_TAG "MediRefreshControllerService"
17 
18 #include "media_refresh_controller_service.h"
19 
20 #include "album_accurate_refresh.h"
21 #include "asset_accurate_refresh.h"
22 #include "medialibrary_errno.h"
23 #include "media_log.h"
24 #include "user_define_ipc.h"
25 
26 namespace OHOS::Media {
27 
28 const std::unordered_map<uint32_t, std::vector<std::vector<PermissionType>>> mediaRefreshPermissionPolicy = {
29     {static_cast<uint32_t>(MediaLibraryBusinessCode::NOTIFY_FOR_RECHECK), {{SYSTEMAPI_PERM, READ_PERM}}},
30 };
31 
Accept(uint32_t code)32 bool MediaRefreshControllerService::Accept(uint32_t code)
33 {
34     return HANDLERS.find(code) != HANDLERS.end();
35 }
36 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,IPC::IPCContext & context)37 int32_t MediaRefreshControllerService::OnRemoteRequest(uint32_t code, MessageParcel &data,
38     MessageParcel &reply, IPC::IPCContext &context)
39 {
40     auto it = HANDLERS.find(code);
41     if (it == HANDLERS.end()) {
42         return IPC::UserDefineIPC().WriteResponseBody(reply, E_IPC_SEVICE_NOT_FOUND);
43     }
44     return (this->*(it->second))(data, reply);
45 }
46 
NotifyForReCheck(MessageParcel & data,MessageParcel & reply)47 int32_t MediaRefreshControllerService::NotifyForReCheck(MessageParcel &data, MessageParcel &reply)
48 {
49     MEDIA_INFO_LOG("Enter NotifyForReCheck");
50     AccurateRefresh::AlbumAccurateRefresh::NotifyForReCheck();
51     AccurateRefresh::AssetAccurateRefresh::NotifyForReCheck();
52     return E_SUCCESS;
53 }
54 
GetPermissionPolicy(uint32_t code,std::vector<std::vector<PermissionType>> & permissionPolicy,bool & isBypass)55 int32_t MediaRefreshControllerService::GetPermissionPolicy(
56     uint32_t code, std::vector<std::vector<PermissionType>> &permissionPolicy, bool &isBypass)
57 {
58     auto it = mediaRefreshPermissionPolicy.find(code);
59     if (it != mediaRefreshPermissionPolicy.end()) {
60         permissionPolicy = it->second;
61         return E_SUCCESS;
62     }
63     return E_FAIL;
64 }
65 } // namespace OHOS::Media