| 1 |
/* |
| 2 |
* Copyright (C) 2022 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 com.android.server.art.model; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
|
| 22 |
import com.android.internal.annotations.Immutable; |
| 23 |
|
| 24 |
import com.google.auto.value.AutoValue; |
| 25 |
|
| 26 |
import java.util.ArrayList; |
| 27 |
import java.util.Collections; |
| 28 |
import java.util.List; |
| 29 |
|
| 30 |
/** @hide */ |
| 31 |
@SystemApi(client = SystemApi.Client.SYSTEM_SERVER) |
| 32 |
@Immutable |
| 33 |
@AutoValue |
| 34 |
public abstract class BatchDexoptParams { |
| 35 |
/** @hide */ |
| 36 |
@SystemApi(client = SystemApi.Client.SYSTEM_SERVER) |
| 37 |
public static final class Builder { |
| 38 |
private @NonNull List<String> mPackageNames; // This is assumed immutable. |
| 39 |
private @NonNull DexoptParams mDexoptParams; |
| 40 |
|
| 41 |
/** @hide */ |
| 42 |
public Builder( |
| 43 |
@NonNull List<String> defaultPackages, @NonNull DexoptParams defaultDexoptParams) { |
| 44 |
mPackageNames = defaultPackages; // The argument is assumed immutable. |
| 45 |
mDexoptParams = defaultDexoptParams; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Sets the list of packages to dexopt. The dexopt will be scheduled in the given |
| 50 |
* order. |
| 51 |
* |
| 52 |
* If not called, the default list will be used. |
| 53 |
*/ |
| 54 |
@NonNull |
| 55 |
public Builder setPackages(@NonNull List<String> packageNames) { |
| 56 |
mPackageNames = Collections.unmodifiableList(new ArrayList<>(packageNames)); |
| 57 |
return this; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Sets the params for dexopting each package. |
| 62 |
* |
| 63 |
* If not called, the default params built from {@link DexoptParams#Builder(String)} will |
| 64 |
* be used. |
| 65 |
*/ |
| 66 |
@NonNull |
| 67 |
public Builder setDexoptParams(@NonNull DexoptParams dexoptParams) { |
| 68 |
mDexoptParams = dexoptParams; |
| 69 |
return this; |
| 70 |
} |
| 71 |
|
| 72 |
/** Returns the built object. */ |
| 73 |
@NonNull |
| 74 |
public BatchDexoptParams build() { |
| 75 |
return new AutoValue_BatchDexoptParams(mPackageNames, mDexoptParams); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
/** @hide */ |
| 80 |
protected BatchDexoptParams() {} |
| 81 |
|
| 82 |
/** The ordered list of packages to dexopt. */ |
| 83 |
public abstract @NonNull List<String> getPackages(); |
| 84 |
|
| 85 |
/** The params for dexopting each package. */ |
| 86 |
public abstract @NonNull DexoptParams getDexoptParams(); |
| 87 |
} |