Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / library / aosp-stubs / src / main / java / android / app / supervision / PackageUsagePolicy.java
PackageUsagePolicy.java65 lines · 2.3 KiBRaw
| 1 | package android.app.supervision; |
| 2 | |
| 3 | import java.time.Duration; |
| 4 | |
| 5 | /** |
| 6 | * Stub of the framework's {@code @SystemApi android.app.supervision.PackageUsagePolicy} - the |
| 7 | * only concrete {@link Policy} the platform accepts. |
| 8 | * |
| 9 | * <p>The three TYPE_ values are inlined by javac, so they must match upstream exactly. |
| 10 | * |
| 11 | * <p>{@code TYPE_TIME_LIMIT} is gated upstream on the |
| 12 | * {@code enable_supervision_package_usage_apis} aconfig flag, which AOSP ships enabled only in |
| 13 | * {@code trunk_staging} - not an active value set for this build. MAOS turns it on via a value |
| 14 | * file under {@code build/release/aconfig/cp2a/}, carried by |
| 15 | * {@code vendor/modern-apps/patches/build_release.patch}. Without that, building a policy of |
| 16 | * this type throws {@code IllegalStateException} from {@code performBuild}. |
| 17 | */ |
| 18 | public final class PackageUsagePolicy extends Policy { |
| 19 | |
| 20 | public static final int TYPE_ALLOWED = 0; |
| 21 | public static final int TYPE_BLOCKED = 1; |
| 22 | public static final int TYPE_TIME_LIMIT = 2; |
| 23 | |
| 24 | private PackageUsagePolicy() {} |
| 25 | |
| 26 | public int getType() { |
| 27 | throw new UnsupportedOperationException("stub"); |
| 28 | } |
| 29 | |
| 30 | public String getPackageName() { |
| 31 | throw new UnsupportedOperationException("stub"); |
| 32 | } |
| 33 | |
| 34 | public Duration getTimeLimit() { |
| 35 | throw new UnsupportedOperationException("stub"); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Note this deliberately does NOT declare {@code build()} - it is inherited from |
| 40 | * {@link Policy.Builder}, exactly as upstream. See the note there. |
| 41 | */ |
| 42 | public static final class Builder extends Policy.Builder<PackageUsagePolicy, Builder> { |
| 43 | |
| 44 | public Builder(String packageName, int type) { |
| 45 | throw new UnsupportedOperationException("stub"); |
| 46 | } |
| 47 | |
| 48 | public Builder(PackageUsagePolicy policy) { |
| 49 | throw new UnsupportedOperationException("stub"); |
| 50 | } |
| 51 | |
| 52 | public Builder setPackageName(String packageName) { |
| 53 | throw new UnsupportedOperationException("stub"); |
| 54 | } |
| 55 | |
| 56 | public Builder setType(int type) { |
| 57 | throw new UnsupportedOperationException("stub"); |
| 58 | } |
| 59 | |
| 60 | /** Rejected upstream unless the type is {@link #TYPE_TIME_LIMIT}, and capped at 24 h. */ |
| 61 | public Builder setTimeLimit(Duration timeLimit) { |
| 62 | throw new UnsupportedOperationException("stub"); |
| 63 | } |
| 64 | } |
| 65 | } |