1/* 2 * Copyright (c) 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#include "quick_fix_manager_stub.h" 17 18namespace OHOS { 19namespace AAFwk { 20 21int32_t QuickFixManagerStub::OnRemoteRequest( 22 uint32_t code, 23 MessageParcel& data, 24 MessageParcel& reply, 25 MessageOption& option) 26{ 27 std::u16string localDescriptor = GetDescriptor(); 28 std::u16string remoteDescriptor = data.ReadInterfaceToken(); 29 if (localDescriptor != remoteDescriptor) { 30 return ERR_TRANSACTION_FAILED; 31 } 32 switch (static_cast<IQuickFixManagerIpcCode>(code)) { 33 case IQuickFixManagerIpcCode::COMMAND_APPLY_QUICK_FIX: { 34 std::vector<std::string> quickFixFiles; 35 int32_t quickFixFilesSize = data.ReadInt32(); 36 if (quickFixFilesSize > static_cast<int32_t>(VECTOR_MAX_SIZE)) { 37 return ERR_INVALID_DATA; 38 } 39 for (int32_t i1 = 0; i1 < quickFixFilesSize; ++i1) { 40 std::string value1 = Str16ToStr8(data.ReadString16()); 41 quickFixFiles.push_back(value1); 42 } 43 bool isDebug = data.ReadInt32() == 1 ? true : false; 44 ErrCode errCode = ApplyQuickFix(quickFixFiles, isDebug); 45 if (!reply.WriteInt32(errCode)) { 46 return ERR_INVALID_VALUE; 47 } 48 return ERR_NONE; 49 } 50 case IQuickFixManagerIpcCode::COMMAND_GET_APPLYED_QUICK_FIX_INFO: { 51 std::string bundleName = Str16ToStr8(data.ReadString16()); 52 ApplicationQuickFixInfo quickFixInfo; 53 ErrCode errCode = GetApplyedQuickFixInfo(bundleName, quickFixInfo); 54 if (!reply.WriteInt32(errCode)) { 55 return ERR_INVALID_VALUE; 56 } 57 if (SUCCEEDED(errCode)) { 58 if (!reply.WriteParcelable(&quickFixInfo)) { 59 return ERR_INVALID_DATA; 60 } 61 } 62 return ERR_NONE; 63 } 64 case IQuickFixManagerIpcCode::COMMAND_REVOKE_QUICK_FIX: { 65 std::string bundleName = Str16ToStr8(data.ReadString16()); 66 ErrCode errCode = RevokeQuickFix(bundleName); 67 if (!reply.WriteInt32(errCode)) { 68 return ERR_INVALID_VALUE; 69 } 70 return ERR_NONE; 71 } 72 default: 73 return IPCObjectStub::OnRemoteRequest(code, data, reply, option); 74 } 75 76 return ERR_TRANSACTION_FAILED; 77} 78} // namespace AAFwk 79} // namespace OHOS 80