Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / library / aosp-stubs / src / main / java / android / app / supervision / Policy.java

Policy.java58 lines · 2.2 KiBRaw
1package android.app.supervision;
2
3/**
4 * Stub of the framework's {@code @SystemApi android.app.supervision.Policy}.
5 *
6 * <p>Abstract upstream, and never constructed by us - it arrives through
7 * {@link SupervisionAppService#onPolicyChanged} and is produced by
8 * {@link PackageUsagePolicy.Builder}. The constructors are package-private upstream and are
9 * omitted here for that reason.
10 *
11 * <p>Upstream this implements {@link android.os.Parcelable}. The stub deliberately does not:
12 * nothing in this app ever parcels a policy, and declaring the interface without the required
13 * {@code CREATOR} is exactly the mismatch lint's ParcelCreator check exists to catch. Declaring
14 * only what we touch keeps the stub honest - if a caller ever does need to parcel one, that is
15 * the moment to add the field and check it against upstream, not now.
16 */
17public abstract class Policy {
18
19 /** The only policy identifier that exists upstream. Inlined by javac - value matters. */
20 public static final String PACKAGE_POLICY_IDENTIFIER = "package";
21
22 Policy() {}
23
24 public long getVersion() {
25 throw new UnsupportedOperationException("stub");
26 }
27
28 public String getIdentifier() {
29 throw new UnsupportedOperationException("stub");
30 }
31
32 public PolicyKey getPolicyKey() {
33 throw new UnsupportedOperationException("stub");
34 }
35
36 /**
37 * The generic self-typed builder base.
38 *
39 * <p>Mirrored exactly rather than flattened. {@code build()} erases to
40 * {@code ()Landroid/app/supervision/Policy;} and {@link PackageUsagePolicy.Builder} does not
41 * override it, so a call through the subclass compiles to an invokevirtual on <em>this</em>
42 * method plus a checkcast. A stub that moved {@code build()} down into the subclass would
43 * emit a call to a method the real class does not declare.
44 */
45 public abstract static class Builder<P extends Policy, B extends Builder<P, B>> {
46
47 Builder() {}
48
49 @SuppressWarnings("unchecked")
50 public B setVersion(long version) {
51 throw new UnsupportedOperationException("stub");
52 }
53
54 public P build() {
55 throw new UnsupportedOperationException("stub");
56 }
57 }
58}