1 /* 2 * Copyright (c) 2021-2022 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 package com.ohos.hapsigntool.profile.model; 17 18 import com.google.gson.annotations.SerializedName; 19 import com.ohos.hapsigntool.error.ERROR; 20 import com.ohos.hapsigntool.utils.ValidateUtils; 21 22 import java.util.List; 23 24 /** 25 * Sub dto of Provision. 26 * 27 * @since 2021/12/28 28 */ 29 public class DebugInfo { 30 /** 31 * Max number of debug device. 32 */ 33 private static final int MAX_DEBUG_DEVICE_NUM = 100; 34 35 /** 36 * Field device-id-type. 37 */ 38 @SerializedName("device-id-type") 39 private String deviceIdType; 40 41 /** 42 * Field device-ids. 43 */ 44 @SerializedName("device-ids") 45 private List<String> deviceIds; 46 47 /** 48 * Sub dto of Provision. 49 */ DebugInfo()50 public DebugInfo() { 51 // Empty constructor of DebugInfo. 52 } 53 getDeviceIdType()54 public String getDeviceIdType() { 55 return deviceIdType; 56 } 57 setDeviceIdType(String deviceIdType)58 public void setDeviceIdType(String deviceIdType) { 59 this.deviceIdType = deviceIdType; 60 } 61 getDeviceIds()62 public List<String> getDeviceIds() { 63 return deviceIds; 64 } 65 setDeviceIds(List<String> deviceIds)66 public void setDeviceIds(List<String> deviceIds) { 67 this.deviceIds = deviceIds; 68 } 69 70 /** 71 * Enforce valid. 72 */ enforceValid()73 public void enforceValid() { 74 if (this.deviceIds != null) { 75 ValidateUtils.throwIfMatches(this.deviceIds.size() > MAX_DEBUG_DEVICE_NUM, ERROR.SIGN_ERROR, 76 "Support at most: 100 devices!"); 77 ValidateUtils.throwIfMatches(!this.isDeviceIdTypeValid(), ERROR.SIGN_ERROR, 78 "Device id type must be sn or udid, current is " + this.deviceIdType); 79 } 80 } 81 isDeviceIdTypeValid()82 private boolean isDeviceIdTypeValid() { 83 return "sn".equals(this.deviceIdType) || "udid".equals(this.deviceIdType); 84 } 85 } 86