1 /* 2 * Copyright (C) 2018 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 package com.android.tradefed.build; 17 18 import java.util.HashSet; 19 import java.util.Set; 20 21 /** Class holding enumeration related to build information queries. */ 22 public class BuildInfoKey { 23 24 /** 25 * Enum describing all the known file types that can be queried through {@link 26 * IBuildInfo#getFile(BuildInfoFileKey)}. 27 */ 28 public enum BuildInfoFileKey { 29 DEVICE_IMAGE("device", false), 30 USERDATA_IMAGE("userdata", false), 31 TESTDIR_IMAGE("testsdir", false), 32 BASEBAND_IMAGE("baseband", false), 33 BOOTLOADER_IMAGE("bootloader", false), 34 OTA_IMAGE("ota", false), 35 MKBOOTIMG_IMAGE("mkbootimg", false), 36 RAMDISK_IMAGE("ramdisk", false), 37 38 // Root folder directory 39 ROOT_DIRECTORY("rootdirectory", false), 40 41 // Externally linked files in the testsdir: 42 // ANDROID_HOST_OUT_TESTCASES and ANDROID_TARGET_OUT_TESTCASES are linked in the tests dir 43 // of the build info. 44 TARGET_LINKED_DIR("target_testcases", false), 45 HOST_LINKED_DIR("host_testcases", false), 46 47 // A folder containing the resources from isFake=true devices 48 SHARED_RESOURCE_DIR("resources_dir", false), 49 50 // Keys that can hold lists of files. 51 PACKAGE_FILES("package_files", true); 52 53 private final String mFileKey; 54 private final boolean mCanBeList; 55 BuildInfoFileKey(String fileKey, boolean canBeList)56 private BuildInfoFileKey(String fileKey, boolean canBeList) { 57 mFileKey = fileKey; 58 mCanBeList = canBeList; 59 } 60 getFileKey()61 public String getFileKey() { 62 return mFileKey; 63 } 64 isList()65 public boolean isList() { 66 return mCanBeList; 67 } 68 69 @Override toString()70 public String toString() { 71 return mFileKey; 72 } 73 74 /** 75 * Convert a key name to its {@link BuildInfoFileKey} if any is found. Returns null 76 * otherwise. 77 */ fromString(String keyName)78 public static BuildInfoFileKey fromString(String keyName) { 79 for (BuildInfoFileKey v : BuildInfoFileKey.values()) { 80 if (v.getFileKey().equals(keyName)) { 81 return v; 82 } 83 } 84 return null; 85 } 86 } 87 88 /** 89 * Files key that should be shared from a resources build info to all build infos via the {@link 90 * IDeviceBuildInfo#getResourcesDir()}. 91 */ 92 public static final Set<BuildInfoFileKey> SHARED_KEY = new HashSet<>(); 93 94 static { 95 SHARED_KEY.add(BuildInfoFileKey.PACKAGE_FILES); 96 SHARED_KEY.add(BuildInfoFileKey.TESTDIR_IMAGE); 97 SHARED_KEY.add(BuildInfoFileKey.ROOT_DIRECTORY); 98 } 99 } 100