-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVirtualMachineCallback.java
More file actions
165 lines (133 loc) · 6.09 KB
/
Copy pathVirtualMachineCallback.java
File metadata and controls
165 lines (133 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.system.virtualmachine;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Callback interface to get notified with the events from the virtual machine. The methods are
* executed on a binder thread. Implementations can make blocking calls in the methods.
*
* @hide
*/
@SystemApi
@SuppressLint("CallbackInterface") // Guidance has changed, lint is out of date (b/245552641)
public interface VirtualMachineCallback {
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(
prefix = "ERROR_",
value = {
ERROR_UNKNOWN,
ERROR_PAYLOAD_VERIFICATION_FAILED,
ERROR_PAYLOAD_CHANGED,
ERROR_PAYLOAD_INVALID_CONFIG
})
@interface ErrorCode {}
/** Error code for all other errors not listed below. */
int ERROR_UNKNOWN = 0;
/**
* Error code indicating that the payload can't be verified due to various reasons (e.g invalid
* merkle tree, invalid formats, etc).
*/
int ERROR_PAYLOAD_VERIFICATION_FAILED = 1;
/**
* Error code indicating that the payload is verified, but has changed to be incompatible with
* the previous payload. This payload has not been allowed to boot to protect the VM's data.
*/
int ERROR_PAYLOAD_CHANGED = 2;
/** Error code indicating that the payload config is invalid. */
int ERROR_PAYLOAD_INVALID_CONFIG = 3;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(
prefix = "STOP_REASON_",
value = {
STOP_REASON_VIRTUALIZATION_SERVICE_DIED,
STOP_REASON_INFRASTRUCTURE_ERROR,
STOP_REASON_KILLED,
STOP_REASON_UNKNOWN,
STOP_REASON_SHUTDOWN,
STOP_REASON_START_FAILED,
STOP_REASON_REBOOT,
STOP_REASON_CRASH,
STOP_REASON_PVM_FIRMWARE_PUBLIC_KEY_MISMATCH,
STOP_REASON_PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED,
STOP_REASON_BOOTLOADER_PUBLIC_KEY_MISMATCH,
STOP_REASON_BOOTLOADER_INSTANCE_IMAGE_CHANGED,
STOP_REASON_MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE,
STOP_REASON_MICRODROID_PAYLOAD_HAS_CHANGED,
STOP_REASON_MICRODROID_PAYLOAD_VERIFICATION_FAILED,
STOP_REASON_MICRODROID_INVALID_PAYLOAD_CONFIG,
STOP_REASON_MICRODROID_UNKNOWN_RUNTIME_ERROR,
STOP_REASON_HANGUP,
})
@interface StopReason {}
/** The virtualization service itself died, taking the VM down with it. */
// This is a negative number to avoid conflicting with the other death reasons which match
// the ones in the AIDL interface.
int STOP_REASON_VIRTUALIZATION_SERVICE_DIED = -1;
/** There was an error waiting for the VM. */
int STOP_REASON_INFRASTRUCTURE_ERROR = 0;
/** The VM was killed. */
int STOP_REASON_KILLED = 1;
/** The VM died for an unknown reason. */
int STOP_REASON_UNKNOWN = 2;
/** The VM requested to shut down. */
int STOP_REASON_SHUTDOWN = 3;
/** crosvm had an error starting the VM. */
int STOP_REASON_START_FAILED = 4;
/** The VM requested to reboot, possibly as the result of a kernel panic. */
int STOP_REASON_REBOOT = 5;
/** The VM or crosvm crashed. */
int STOP_REASON_CRASH = 6;
/** The pVM firmware failed to verify the VM because the public key doesn't match. */
int STOP_REASON_PVM_FIRMWARE_PUBLIC_KEY_MISMATCH = 7;
/** The pVM firmware failed to verify the VM because the instance image changed. */
int STOP_REASON_PVM_FIRMWARE_INSTANCE_IMAGE_CHANGED = 8;
/** The bootloader failed to verify the VM because the public key doesn't match. */
int STOP_REASON_BOOTLOADER_PUBLIC_KEY_MISMATCH = 9;
/** The bootloader failed to verify the VM because the instance image changed. */
int STOP_REASON_BOOTLOADER_INSTANCE_IMAGE_CHANGED = 10;
/** The microdroid failed to connect to VirtualizationService's RPC server. */
int STOP_REASON_MICRODROID_FAILED_TO_CONNECT_TO_VIRTUALIZATION_SERVICE = 11;
/** The payload for microdroid is changed. */
int STOP_REASON_MICRODROID_PAYLOAD_HAS_CHANGED = 12;
/** The microdroid failed to verify given payload APK. */
int STOP_REASON_MICRODROID_PAYLOAD_VERIFICATION_FAILED = 13;
/** The VM config for microdroid is invalid (e.g. missing tasks). */
int STOP_REASON_MICRODROID_INVALID_PAYLOAD_CONFIG = 14;
/** There was a runtime error while running microdroid manager. */
int STOP_REASON_MICRODROID_UNKNOWN_RUNTIME_ERROR = 15;
/** The VM killed due to hangup */
int STOP_REASON_HANGUP = 16;
/** Called when the payload starts in the VM. */
void onPayloadStarted(@NonNull VirtualMachine vm);
/**
* Called when the payload in the VM is ready to serve. See {@link
* VirtualMachine#connectToVsockServer}.
*/
void onPayloadReady(@NonNull VirtualMachine vm);
/** Called when the payload has finished in the VM. */
void onPayloadFinished(@NonNull VirtualMachine vm, int exitCode);
/** Called when an error occurs in the VM. */
void onError(@NonNull VirtualMachine vm, @ErrorCode int errorCode, @NonNull String message);
/** Called when the VM has stopped. */
void onStopped(@NonNull VirtualMachine vm, @StopReason int reason);
}