1 /* 2 * Copyright (C) 2007 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 android.content.pm; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 import android.util.SparseArray; 22 23 /** 24 * Information you can retrieve about a particular piece of test 25 * instrumentation. This corresponds to information collected 26 * from the AndroidManifest.xml's <instrumentation> tag. 27 */ 28 public class InstrumentationInfo extends PackageItemInfo implements Parcelable { 29 /** 30 * The name of the application package being instrumented. From the 31 * "package" attribute. 32 */ 33 public String targetPackage; 34 35 /** 36 * Names of the process(es) this instrumentation will run in. If not specified, only 37 * runs in the main process of the targetPackage. Can either be a comma-separated list 38 * of process names or '*' for any process that launches to run targetPackage code. 39 */ 40 public String targetProcesses; 41 42 /** 43 * Full path to the base APK for this application. 44 */ 45 public String sourceDir; 46 47 /** 48 * Full path to the publicly available parts of {@link #sourceDir}, 49 * including resources and manifest. This may be different from 50 * {@link #sourceDir} if an application is forward locked. 51 */ 52 public String publicSourceDir; 53 54 /** 55 * The names of all installed split APKs, ordered lexicographically. 56 */ 57 public String[] splitNames; 58 59 /** 60 * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}. 61 */ 62 public String[] splitSourceDirs; 63 64 /** 65 * Full path to the publicly available parts of {@link #splitSourceDirs}, 66 * including resources and manifest. This may be different from 67 * {@link #splitSourceDirs} if an application is forward locked. 68 * 69 * @see #splitSourceDirs 70 */ 71 public String[] splitPublicSourceDirs; 72 73 /** 74 * Maps the dependencies between split APKs. All splits implicitly depend on the base APK. 75 * 76 * Available since platform version O. 77 * 78 * Only populated if the application opts in to isolated split loading via the 79 * {@link android.R.attr.isolatedSplits} attribute in the <manifest> tag of the app's 80 * AndroidManifest.xml. 81 * 82 * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs}, 83 * and {@link #splitPublicSourceDirs} arrays. 84 * Each key represents a split and its value is an array of splits. The first element of this 85 * array is the parent split, and the rest are configuration splits. These configuration splits 86 * have no dependencies themselves. 87 * Cycles do not exist because they are illegal and screened for during installation. 88 * 89 * May be null if no splits are installed, or if no dependencies exist between them. 90 * @hide 91 */ 92 public SparseArray<int[]> splitDependencies; 93 94 /** 95 * Full path to a directory assigned to the package for its persistent data. 96 */ 97 public String dataDir; 98 99 /** {@hide} */ 100 public String deviceProtectedDataDir; 101 /** {@hide} */ 102 public String credentialProtectedDataDir; 103 104 /** {@hide} Full path to the directory containing primary ABI native libraries. */ 105 public String nativeLibraryDir; 106 107 /** {@hide} Full path to the directory containing secondary ABI native libraries. */ 108 public String secondaryNativeLibraryDir; 109 110 /** 111 * Specifies whether or not this instrumentation will handle profiling. 112 */ 113 public boolean handleProfiling; 114 115 /** Specifies whether or not to run this instrumentation as a functional test */ 116 public boolean functionalTest; 117 InstrumentationInfo()118 public InstrumentationInfo() { 119 } 120 InstrumentationInfo(InstrumentationInfo orig)121 public InstrumentationInfo(InstrumentationInfo orig) { 122 super(orig); 123 targetPackage = orig.targetPackage; 124 targetProcesses = orig.targetProcesses; 125 sourceDir = orig.sourceDir; 126 publicSourceDir = orig.publicSourceDir; 127 splitNames = orig.splitNames; 128 splitSourceDirs = orig.splitSourceDirs; 129 splitPublicSourceDirs = orig.splitPublicSourceDirs; 130 splitDependencies = orig.splitDependencies; 131 dataDir = orig.dataDir; 132 deviceProtectedDataDir = orig.deviceProtectedDataDir; 133 credentialProtectedDataDir = orig.credentialProtectedDataDir; 134 nativeLibraryDir = orig.nativeLibraryDir; 135 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir; 136 handleProfiling = orig.handleProfiling; 137 functionalTest = orig.functionalTest; 138 } 139 toString()140 public String toString() { 141 return "InstrumentationInfo{" 142 + Integer.toHexString(System.identityHashCode(this)) 143 + " " + packageName + "}"; 144 } 145 describeContents()146 public int describeContents() { 147 return 0; 148 } 149 writeToParcel(Parcel dest, int parcelableFlags)150 public void writeToParcel(Parcel dest, int parcelableFlags) { 151 super.writeToParcel(dest, parcelableFlags); 152 dest.writeString(targetPackage); 153 dest.writeString(targetProcesses); 154 dest.writeString(sourceDir); 155 dest.writeString(publicSourceDir); 156 dest.writeStringArray(splitNames); 157 dest.writeStringArray(splitSourceDirs); 158 dest.writeStringArray(splitPublicSourceDirs); 159 dest.writeSparseArray((SparseArray) splitDependencies); 160 dest.writeString(dataDir); 161 dest.writeString(deviceProtectedDataDir); 162 dest.writeString(credentialProtectedDataDir); 163 dest.writeString(nativeLibraryDir); 164 dest.writeString(secondaryNativeLibraryDir); 165 dest.writeInt((handleProfiling == false) ? 0 : 1); 166 dest.writeInt((functionalTest == false) ? 0 : 1); 167 } 168 169 public static final Parcelable.Creator<InstrumentationInfo> CREATOR 170 = new Parcelable.Creator<InstrumentationInfo>() { 171 public InstrumentationInfo createFromParcel(Parcel source) { 172 return new InstrumentationInfo(source); 173 } 174 public InstrumentationInfo[] newArray(int size) { 175 return new InstrumentationInfo[size]; 176 } 177 }; 178 179 @SuppressWarnings("unchecked") InstrumentationInfo(Parcel source)180 private InstrumentationInfo(Parcel source) { 181 super(source); 182 targetPackage = source.readString(); 183 targetProcesses = source.readString(); 184 sourceDir = source.readString(); 185 publicSourceDir = source.readString(); 186 splitNames = source.readStringArray(); 187 splitSourceDirs = source.readStringArray(); 188 splitPublicSourceDirs = source.readStringArray(); 189 splitDependencies = source.readSparseArray(null); 190 dataDir = source.readString(); 191 deviceProtectedDataDir = source.readString(); 192 credentialProtectedDataDir = source.readString(); 193 nativeLibraryDir = source.readString(); 194 secondaryNativeLibraryDir = source.readString(); 195 handleProfiling = source.readInt() != 0; 196 functionalTest = source.readInt() != 0; 197 } 198 199 /** {@hide} */ copyTo(ApplicationInfo ai)200 public void copyTo(ApplicationInfo ai) { 201 ai.packageName = packageName; 202 ai.sourceDir = sourceDir; 203 ai.publicSourceDir = publicSourceDir; 204 ai.splitNames = splitNames; 205 ai.splitSourceDirs = splitSourceDirs; 206 ai.splitPublicSourceDirs = splitPublicSourceDirs; 207 ai.splitDependencies = splitDependencies; 208 ai.dataDir = dataDir; 209 ai.deviceProtectedDataDir = deviceProtectedDataDir; 210 ai.credentialProtectedDataDir = credentialProtectedDataDir; 211 ai.nativeLibraryDir = nativeLibraryDir; 212 ai.secondaryNativeLibraryDir = secondaryNativeLibraryDir; 213 } 214 } 215