1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.safetycenter; 18 19 import static android.os.Build.VERSION_CODES.TIRAMISU; 20 21 import android.safetycenter.config.SafetySourcesGroup; 22 23 import androidx.annotation.RequiresApi; 24 25 import com.android.modules.utils.build.SdkLevel; 26 27 /** Static utilities for working with {@link SafetySourcesGroup} objects. */ 28 @RequiresApi(TIRAMISU) 29 final class SafetySourcesGroups { 30 31 /** 32 * Returns a builder with all fields of the original group copied other than {@link 33 * SafetySourcesGroup#getSafetySources()}. 34 */ copyToBuilderWithoutSources(SafetySourcesGroup group)35 static SafetySourcesGroup.Builder copyToBuilderWithoutSources(SafetySourcesGroup group) { 36 SafetySourcesGroup.Builder safetySourcesGroupBuilder = 37 new SafetySourcesGroup.Builder() 38 .setId(group.getId()) 39 .setTitleResId(group.getTitleResId()) 40 .setSummaryResId(group.getSummaryResId()) 41 .setStatelessIconType(group.getStatelessIconType()); 42 if (SdkLevel.isAtLeastU()) { 43 safetySourcesGroupBuilder.setType(group.getType()); 44 } 45 return safetySourcesGroupBuilder; 46 } 47 SafetySourcesGroups()48 private SafetySourcesGroups() {} 49 } 50