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 #define MLOG_TAG "RingtoneRestoreFactory" 17 18 #include <memory> 19 20 #include "ringtone_restore_factory.h" 21 22 #include "restore_interface.h" 23 #include "ringtone_dualfwk_restore.h" 24 #include "ringtone_log.h" 25 #include "ringtone_restore.h" 26 27 namespace OHOS { 28 namespace Media { CreateObj(RestoreSceneType type)29std::unique_ptr<RestoreInterface> RingtoneRestoreFactory::CreateObj(RestoreSceneType type) 30 { 31 std::unique_ptr<RestoreInterface> obj = nullptr; 32 33 if (type == RESTORE_SCENE_TYPE_SINGLE_CLONE) { 34 obj = std::make_unique<RingtoneRestore>(); 35 } else if (type == RESTORE_SCENE_TYPE_DUAL_CLONE) { 36 obj = std::make_unique<RingtoneDualFwkRestoreClone>(); 37 } else if (type == RESTORE_SCENE_TYPE_DUAL_UPGRADE) { 38 obj = std::make_unique<RingtoneDualFwkRestore>(); 39 } else { 40 RINGTONE_ERR_LOG("error: invalid argument"); 41 } 42 43 return obj; 44 } 45 } // namespace Media 46 } // namespace OHOS 47