1 /* 2 * Copyright (C) 2020 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.parsing.component; 18 19 import static android.content.pm.parsing.ParsingPackageImpl.sForInternedString; 20 21 import android.annotation.Nullable; 22 import android.content.ComponentName; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 import android.text.TextUtils; 26 27 import com.android.internal.util.DataClass; 28 import com.android.internal.util.Parcelling.BuiltIn.ForInternedString; 29 30 /** @hide */ 31 public class ParsedInstrumentation extends ParsedComponent { 32 33 @Nullable 34 @DataClass.ParcelWith(ForInternedString.class) 35 private String targetPackage; 36 @Nullable 37 @DataClass.ParcelWith(ForInternedString.class) 38 private String targetProcesses; 39 boolean handleProfiling; 40 boolean functionalTest; 41 ParsedInstrumentation()42 public ParsedInstrumentation() { 43 } 44 setTargetPackage(@ullable String targetPackage)45 public void setTargetPackage(@Nullable String targetPackage) { 46 this.targetPackage = TextUtils.safeIntern(targetPackage); 47 } 48 setTargetProcesses(@ullable String targetProcesses)49 public void setTargetProcesses(@Nullable String targetProcesses) { 50 this.targetProcesses = TextUtils.safeIntern(targetProcesses); 51 } 52 toString()53 public String toString() { 54 StringBuilder sb = new StringBuilder(128); 55 sb.append("Instrumentation{"); 56 sb.append(Integer.toHexString(System.identityHashCode(this))); 57 sb.append(' '); 58 ComponentName.appendShortString(sb, getPackageName(), getName()); 59 sb.append('}'); 60 return sb.toString(); 61 } 62 63 @Override describeContents()64 public int describeContents() { 65 return 0; 66 } 67 68 @Override writeToParcel(Parcel dest, int flags)69 public void writeToParcel(Parcel dest, int flags) { 70 super.writeToParcel(dest, flags); 71 sForInternedString.parcel(this.targetPackage, dest, flags); 72 sForInternedString.parcel(this.targetProcesses, dest, flags); 73 dest.writeBoolean(this.handleProfiling); 74 dest.writeBoolean(this.functionalTest); 75 } 76 ParsedInstrumentation(Parcel in)77 protected ParsedInstrumentation(Parcel in) { 78 super(in); 79 this.targetPackage = sForInternedString.unparcel(in); 80 this.targetProcesses = sForInternedString.unparcel(in); 81 this.handleProfiling = in.readByte() != 0; 82 this.functionalTest = in.readByte() != 0; 83 } 84 85 public static final Parcelable.Creator<ParsedInstrumentation> CREATOR = 86 new Parcelable.Creator<ParsedInstrumentation>() { 87 @Override 88 public ParsedInstrumentation createFromParcel(Parcel source) { 89 return new ParsedInstrumentation(source); 90 } 91 92 @Override 93 public ParsedInstrumentation[] newArray(int size) { 94 return new ParsedInstrumentation[size]; 95 } 96 }; 97 98 @Nullable getTargetPackage()99 public String getTargetPackage() { 100 return targetPackage; 101 } 102 103 @Nullable getTargetProcesses()104 public String getTargetProcesses() { 105 return targetProcesses; 106 } 107 isHandleProfiling()108 public boolean isHandleProfiling() { 109 return handleProfiling; 110 } 111 isFunctionalTest()112 public boolean isFunctionalTest() { 113 return functionalTest; 114 } 115 } 116