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

Modern-Apps.git / library / aosp-stubs / src / main / java / android / os / UpdateEngine.java

UpdateEngine.java114 lines · 4.8 KiBRaw
1package android.os;
2
3/**
4 * Compile-only stub. See the module's build.gradle.kts.
5 *
6 * <p>Mirrors the surface of the real {@code @SystemApi android.os.UpdateEngine} that
7 * {@code :updater} calls. Behaviour that is NOT visible from these signatures but that callers
8 * must handle, taken from the AOSP source:
9 *
10 * <ul>
11 * <li>The constructor binds to the {@code android.os.UpdateEngineService} binder. It throws
12 * {@link IllegalStateException} when that service is unavailable, which is the case on
13 * any build where the caller is not privileged.
14 * <li>{@link #applyPayload} is asynchronous. Completion and failure both arrive on
15 * {@link UpdateEngineCallback#onPayloadApplicationComplete}, never as a thrown exception,
16 * so a caller that only tries/catches will silently believe it succeeded.
17 * <li>Only ONE payload may be applied at a time, process-wide and device-wide. Calling
18 * {@link #applyPayload} while an update is in progress throws
19 * {@link ServiceSpecificException}. {@link #cancel()} or {@link #resetStatus()} first.
20 * <li>{@link #resetStatus()} is only valid when an update has been applied but not yet booted
21 * ({@link UpdateStatusConstants#UPDATED_NEED_REBOOT}); it throws otherwise.
22 * <li>The {@code url} passed to {@link #applyPayload} may be an {@code http(s)://} address —
23 * update_engine streams the payload itself — or a {@code file://} path.
24 * </ul>
25 */
26public class UpdateEngine {
27
28 /**
29 * Error codes delivered to
30 * {@link UpdateEngineCallback#onPayloadApplicationComplete(int)}.
31 *
32 * <p>Values are inlined by javac, so they must match AOSP exactly. Note the gap: there is
33 * no 2 or 3, and the tail jumps to 51.
34 */
35 public static final class ErrorCodeConstants {
36 public static final int SUCCESS = 0;
37 public static final int ERROR = 1;
38 public static final int FILESYSTEM_COPIER_ERROR = 4;
39 public static final int POST_INSTALL_RUNNER_ERROR = 5;
40 public static final int PAYLOAD_MISMATCHED_TYPE_ERROR = 6;
41 public static final int INSTALL_DEVICE_OPEN_ERROR = 7;
42 public static final int KERNEL_DEVICE_OPEN_ERROR = 8;
43 public static final int DOWNLOAD_TRANSFER_ERROR = 9;
44 public static final int PAYLOAD_HASH_MISMATCH_ERROR = 10;
45 public static final int PAYLOAD_SIZE_MISMATCH_ERROR = 11;
46 public static final int DOWNLOAD_PAYLOAD_VERIFICATION_ERROR = 12;
47 public static final int PAYLOAD_TIMESTAMP_ERROR = 51;
48 public static final int UPDATED_BUT_NOT_ACTIVE = 52;
49 public static final int NOT_ENOUGH_SPACE = 60;
50 public static final int DEVICE_CORRUPTED = 61;
51 }
52
53 /** Status values delivered to {@link UpdateEngineCallback#onStatusUpdate(int, float)}. */
54 public static final class UpdateStatusConstants {
55 public static final int IDLE = 0;
56 public static final int CHECKING_FOR_UPDATE = 1;
57 public static final int UPDATE_AVAILABLE = 2;
58 public static final int DOWNLOADING = 3;
59 public static final int VERIFYING = 4;
60 public static final int FINALIZING = 5;
61 public static final int UPDATED_NEED_REBOOT = 6;
62 public static final int REPORTING_ERROR_EVENT = 7;
63 public static final int ATTEMPTING_ROLLBACK = 8;
64 public static final int DISABLED = 9;
65 }
66
67 public UpdateEngine() {
68 throw new UnsupportedOperationException("stub");
69 }
70
71 public boolean bind(final UpdateEngineCallback callback, final Handler handler) {
72 throw new UnsupportedOperationException("stub");
73 }
74
75 public boolean bind(final UpdateEngineCallback callback) {
76 throw new UnsupportedOperationException("stub");
77 }
78
79 /**
80 * Unbinds the last bound callback.
81 *
82 * <p>Returns false when the unbind failed. The GrapheneOS updater logs that case rather than
83 * ignoring it, because a callback left registered against the update_engine service outlives
84 * the object that owns it, and a later {@code bind} in the same process then competes with
85 * a stale registration.
86 */
87 public boolean unbind() {
88 throw new UnsupportedOperationException("stub");
89 }
90
91 public void applyPayload(String url, long offset, long size, String[] headerKeyValuePairs) {
92 throw new UnsupportedOperationException("stub");
93 }
94
95 public void cancel() {
96 throw new UnsupportedOperationException("stub");
97 }
98
99 public void suspend() {
100 throw new UnsupportedOperationException("stub");
101 }
102
103 public void resume() {
104 throw new UnsupportedOperationException("stub");
105 }
106
107 public void resetStatus() {
108 throw new UnsupportedOperationException("stub");
109 }
110
111 public void setShouldSwitchSlotOnReboot(String payloadMetadataFilename) {
112 throw new UnsupportedOperationException("stub");
113 }
114}