1// Copyright (C) 2018 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Note that if you add/remove methods in this file you must update 16// the metrics sql as well by running ./android/scripts/gen-grpc-sql.py 17// 18// Please group deleted methods in a block including the date (MM/DD/YY) 19// it was removed. This enables us to easily keep metrics around after removal 20// 21// List of deleted methods 22// rpc iWasDeleted (03/12/12) 23// ... 24syntax = "proto3"; 25 26package android.emulation.control; 27 28import "google/protobuf/wrappers.proto"; 29import "snapshot.proto"; 30 31option java_multiple_files = true; 32option java_package = "com.android.emulator.control"; 33option objc_class_prefix = "AEC"; 34 35// The SnapshotService enables you to list, insert, store, and retrieve 36// snapshots. 37// 38// Currently there are two types of snapshots: 39// 40// - Local (default): These are snapshots that are created locally. They are 41// stored internally inside qcow2 files and are very efficient. These are 42// the snapshots usually created by interacting with the UI. 43// 44// - Remote: These are snapshots that have been exported at a certain point. 45// an exported snapshot is normalized (completely self contained) and 46// can be imported into an emulator with a similar hardware configuration. 47// 48// Currently the emulator has limited support for importing snapshots: 49// - Once an imported snapshot has been loaded into an emulator it is no longer 50// possible to create new snapshots. 51// - The hardware configuration of the emulator your are pushing a snapshot to 52// must match (or be very similar) to the one you pulled the snapshot from. 53// 54// For example do not expect to be able to restore a snapshot on created on an 55// Intel cpu on an AMD cpu. 56service SnapshotService { 57 // Lists all the snapshots, filtered by the given query, that are stored 58 // locally for the currently running avd. This includes all the snapshots 59 // that were imported (pushed) into this emulator. 60 // 61 // Returns a list of snapshot_id's and associated details that describes 62 // the hardware configuration, logical name, etc of the snapshot. 63 rpc ListSnapshots(SnapshotFilter) returns (SnapshotList) {} 64 65 // Pulls down the snapshot stored inside the AVD as a tar.gz/tar stream 66 // This will normalize the snapshot, all relevant data to push a snapshot 67 // into a similar emulator will be placed inside the tar file. 68 // 69 // Pulling down a snapshot will pause the emulator until the snapshots 70 // are rebased and ready for exporting. Once the snapshot is rebased 71 // the emulator will continue and downloading should commence. 72 // 73 // Note that pulling .gz stream is slow. 74 // 75 // You must provide the snapshot_id and (desired) format. 76 // 77 // If SnapshotPackage.path is set, the gRPC service will directly write the 78 // exported snapshot to SnapshotPackage.path without streaming, which is 79 // usually significantly faster. It would require emulator to have direct 80 // access to SnapshotPackage.path, which usually means it can only be used 81 // when pulling from a local emulator. 82 rpc PullSnapshot(SnapshotPackage) returns (stream SnapshotPackage) {} 83 84 // Push a tar.gz stream contain the snapshot. The tar file should 85 // be a snapshot that was exported through the PullSnapshot in the past. 86 // The emulator will try to import the snapshot. The hardware configuration 87 // of the current emulator should match the one used for pulling. 88 // 89 // A detailed description of the snapshot (emulator_snapshot.Snapshot) 90 // is stored in the snapshot.pb file inside the tar. 91 // 92 // You must provide the snapshot_id and format in the first message. 93 // Will return success and a possible error message when a failure occurs. 94 // 95 // If SnapshotPackage.path is set, the gRPC service will directly unzip the 96 // exported snapshot from SnapshotPackage.path without streaming, which is 97 // usually significantly faster. It would require emulator to have direct 98 // access to SnapshotPackage.path, which usually means it can only be used 99 // when pushing to a local emulator. 100 rpc PushSnapshot(stream SnapshotPackage) returns (SnapshotPackage) {} 101 102 // Loads the given snapshot inside the emulator and activates it. 103 // The device will be in the state as it was when the snapshot was created. 104 // 105 // You will no longer be able to call Save if this was an imported 106 // snapshot that was pushed into this emulator. 107 // 108 // You must provide the snapshot_id to indicate which snapshot to load 109 // Will return success and a possible error message when a failure occurs. 110 rpc LoadSnapshot(SnapshotPackage) returns (SnapshotPackage) {} 111 112 // Creates as a snapshot of the current state of the emulator. 113 // You can only save a snapshot if you never activated (Load) an imported 114 // snapshot (Push). 115 // 116 // For example: 117 // - PushSnapshot("some_snap.tar.gz"); 118 // - LoadSnapshot("some_snap"); 119 // - SaveSnapshot("same_newer_snap"); // <--- Will currently fail. 120 // 121 // You can provide the snapshot_id to indicate the name used for storing. 122 // Will return success and a possible error message when a failure occurs. 123 rpc SaveSnapshot(SnapshotPackage) returns (SnapshotPackage) {} 124 125 // Deletes the snapshot with the given snapshot_id from the avd. 126 // 127 // You must provide the snapshot_id to indicate which snapshot to delete. 128 // Will return success and a possible error message when a failure occurs. 129 rpc DeleteSnapshot(SnapshotPackage) returns (SnapshotPackage) {} 130 131 // Tracks the given process for automated snapshot creation in case of 132 // assert failures. 133 // 134 // Will return success and a possible error message when a failure occurs. 135 // The snapshot_id field will contain the name of the snapshot that 136 // will be created. The pid field will contain the process id that is 137 // being tracked. 138 rpc TrackProcess(IceboxTarget) returns (IceboxTarget) {} 139 140 // Updates the snapshot details. 141 // 142 // This allows you to update the description, logical name 143 // of the given snapshot. 144 // 145 // You must provide all the details, even if you are not changing them. 146 // 147 // The following gRPC error codes can be returned: 148 // NOT_FOUND (code 5): The given snapshot id does not exist 149 // INVALID_ARGUMENT (code 3): Neither description, nor logical_name were present. 150 // INTERNAL (code 13): An internal failure occured while accessing the 151 // data. 152 rpc UpdateSnapshot(SnapshotUpdateDescription) returns (SnapshotDetails) {} 153 154 // Get the screenshot of the given snapshot 155 // 156 // Returns the emlator display at time of screenshot. 157 // 158 // The following gRPC error codes can be returned: 159 // NOT_FOUND (code 5): The given snapshot id does not exist 160 // INTERNAL (code 13): An internal failure occured while accessing the 161 // data. 162 rpc GetScreenshot(SnapshotId) returns (SnapshotScreenshotFile) {} 163} 164 165// The SnapshotId message represents the ID of a snapshot. 166message SnapshotId { 167 // The identifier to the snapshot 168 string snapshot_id = 1; 169} 170 171message SnapshotUpdateDescription { 172 // The identifier to the snapshot 173 string snapshot_id = 1; 174 175 // Optional logical name of the snapshot. This is usually a name 176 // a user has provided. 177 google.protobuf.StringValue logical_name = 2; 178 179 // Optional description of the snapshot. This description is usually 180 // provided by the user. 181 google.protobuf.StringValue description = 3; 182}; 183 184// The screenshot associated with the snapshot. A screenshot 185// contains the visual display of the emulator at the time 186// of the screenshot. 187message SnapshotScreenshotFile { 188 enum Format { 189 FORMAT_UNSPECIFIED = 0; 190 191 // Portable Network Graphics format 192 // (https://en.wikipedia.org/wiki/Portable_Network_Graphics) 193 FORMAT_PNG = 1; 194 } 195 196 // Format of the image. 197 Format format = 1; 198 199 // The actual bytes of the image. 200 bytes data = 2; 201}; 202 203// Sets options for SnapshotService. Used for both request and response 204// messages. 205message SnapshotPackage { 206 enum Format { 207 TARGZ = 0; // Transport as tar.gz 208 TAR = 1; // Transport as tar (not zipped) 209 DIRECTORY = 2; // Write to disk directly 210 PNG = 3; // Export a screenshot in png (if available) 211 } 212 // The identifier to the snapshot, only required for request messages. For 213 // streaming service, only used in the first stream message of a gRPC call 214 // (would be ignored in consequent stream messages of the same call). 215 string snapshot_id = 1; 216 217 // A stream of bytes. Encoded as a tar (possibly gzipped) file pending on 218 // the value of format. 219 bytes payload = 2; 220 221 // [response only] status fields, usually indicates end of transmission. 222 bool success = 3; 223 bytes err = 4; 224 225 // [request only] Format of the payload. Only used in request messages. For 226 // streaming service, only used in the first stream message of a gRPC call 227 // (would be ignored in consequent stream messages of the same call). 228 Format format = 5; 229 230 // [request only] Path to the snapshot package file. Only used in request 231 // messages. 232 // 233 // When set in a request, the PullSnapshot/PushSnapshot operation will 234 // directly write/read the exported snapshot in path without streaming, 235 // which is usually significantly faster. It would require emulator to have 236 // direct access to path, which usually means it can only be used with a 237 // local emulator. 238 string path = 6; 239} 240 241// A snapshot filter can be used to filter the results produced by ListSnapshots 242message SnapshotFilter { 243 enum LoadStatus { 244 // Only return compatible snapshots 245 CompatibleOnly = 0; 246 247 // Return all snapshots. 248 All = 1; 249 } 250 251 // Filter snapshots by load status. 252 LoadStatus statusFilter = 1; 253} 254 255// Provides detailed information regarding the snapshot. 256message SnapshotDetails { 257 enum LoadStatus { 258 // The emulator believes that the snapshot is compatible with the 259 // emulator that provided this information. The emulator will attempt 260 // to load this snapshot when requested. 261 // 262 // A snapshot is usually compatible when the following statements are 263 // true: 264 // - The snapshot was taken by the current emulator version. i.e. 265 // emulator_build_id in the details field matches the build_id of the 266 // emulator that provided this information. 267 // 268 // - The snapshot was taken on the current running machine, and no 269 // hardware 270 // changes have taken place between taking and loading the snapshot. 271 // 272 // - The avd configuration has not changed between when this snapshot 273 // was 274 // taken and when the snapshot was loaded. 275 // 276 // - The system images on which the avd is based have not changed. 277 Compatible = 0; 278 279 // The emulator will not allow loading of the snapshot, as it deems the 280 // snapshot to be incompatible. Loading of snapshots can be forced by 281 // launching the emulator with the feature "AllowSnapshotMigration" 282 // enabled. 283 Incompatible = 1; 284 285 // This snapshot was successfully loaded in the emulator, and was used 286 // at the starting point of the current running emulator. The following 287 // holds: 288 // 289 // A loaded snapshot is a compatible snapshot 290 // There is at most one snapshot_id that is in the "Loaded" state 291 Loaded = 2; 292 } 293 294 // The id of this snapshot. Use this id to load/delete/pull/update the 295 // snapshot. 296 string snapshot_id = 1; 297 298 // Detailed information about this snapshot. This contains a detailed 299 // hardware description of the snapshot. These details are the same 300 // as the "snapshot.pb" file found in an exported snapshot. 301 // Look at the import file for a detailed description of the available 302 // fields. 303 // 304 // Note that some of these fields can be modified with the update 305 // method. 306 emulator_snapshot.Snapshot details = 2; 307 308 // Provides information about the ability to restore this snapshot. 309 LoadStatus status = 3; 310 311 // The size of the folder that stores required information to load a 312 // snapshot. 313 uint64 size = 4; 314} 315 316// A List of on snapshot details. 317message SnapshotList { 318 repeated SnapshotDetails snapshots = 1; 319} 320 321message IceboxTarget { 322 // This is the process id to attach to, if this value is not set (0) 323 // The process name will be used instead. 324 int64 pid = 1; 325 326 // The process name to attach to if any, if this is not set the pid will 327 // be used. This is usually the application name of your application under 328 // test, that is passed in to the am instrument command. It is likely 329 // what you will find in your AndroidManifest.xml 330 string package_name = 2; 331 332 // The name of the snapshot that icebox will create if a snapshot is 333 // generated. 334 string snapshot_id = 3; 335 336 // [Output Only] True if icebox failed to track the given target. 337 bool failed = 4; 338 339 // [Output Only] Detailed error message that might provide more information. 340 string err = 5; 341 342 // Maximum number of snapshots the emulator can take during one Icebox run. 343 // Set to -1 for unlimited number of snapshots. 344 int32 max_snapshot_number = 6; 345} 346 347// List of deleted methods: 348// 349