| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.app.search; |
| 17 |
|
| 18 |
import android.annotation.NonNull; |
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
import android.os.Bundle; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
import java.util.Objects; |
| 26 |
import java.util.concurrent.Executor; |
| 27 |
import java.util.function.Consumer; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
@SystemApi |
| 37 |
public final class SearchContext implements Parcelable { |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
private final int mResultTypes; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
private final int mTimeoutMillis; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
@Nullable |
| 53 |
private final Bundle mExtras; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
@Nullable |
| 59 |
private String mPackageName; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public SearchContext(@SearchTarget.SearchResultType int resultTypes, int timeoutMillis) { |
| 66 |
this(resultTypes, timeoutMillis, new Bundle()); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public SearchContext(int resultTypes, |
| 75 |
int timeoutMillis, |
| 76 |
@NonNull Bundle extras) { |
| 77 |
mResultTypes = resultTypes; |
| 78 |
mTimeoutMillis = timeoutMillis; |
| 79 |
mExtras = Objects.requireNonNull(extras); |
| 80 |
} |
| 81 |
|
| 82 |
private SearchContext(Parcel parcel) { |
| 83 |
mResultTypes = parcel.readInt(); |
| 84 |
mTimeoutMillis = parcel.readInt(); |
| 85 |
mPackageName = parcel.readString(); |
| 86 |
mExtras = parcel.readBundle(); |
| 87 |
} |
| 88 |
|
| 89 |
@Nullable |
| 90 |
public String getPackageName() { |
| 91 |
return mPackageName; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
void setPackageName(@Nullable String packageName) { |
| 98 |
mPackageName = packageName; |
| 99 |
} |
| 100 |
|
| 101 |
@NonNull |
| 102 |
public int getTimeoutMillis() { |
| 103 |
return mTimeoutMillis; |
| 104 |
} |
| 105 |
|
| 106 |
@NonNull |
| 107 |
public Bundle getExtras() { |
| 108 |
return mExtras; |
| 109 |
} |
| 110 |
|
| 111 |
@NonNull |
| 112 |
public int getResultTypes() { |
| 113 |
return mResultTypes; |
| 114 |
} |
| 115 |
|
| 116 |
@Override |
| 117 |
public int describeContents() { |
| 118 |
return 0; |
| 119 |
} |
| 120 |
|
| 121 |
@Override |
| 122 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 123 |
dest.writeInt(mResultTypes); |
| 124 |
dest.writeInt(mTimeoutMillis); |
| 125 |
dest.writeString(mPackageName); |
| 126 |
dest.writeBundle(mExtras); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
@NonNull |
| 133 |
public static final Parcelable.Creator<SearchContext> CREATOR = |
| 134 |
new Parcelable.Creator<SearchContext>() { |
| 135 |
public SearchContext createFromParcel(Parcel parcel) { |
| 136 |
return new SearchContext(parcel); |
| 137 |
} |
| 138 |
|
| 139 |
public SearchContext[] newArray(int size) { |
| 140 |
return new SearchContext[size]; |
| 141 |
} |
| 142 |
}; |
| 143 |
} |