• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.microdroid.testservice;
17 
18 import com.android.microdroid.testservice.IAppCallback;
19 
20 /**
21  * This is the service exposed by the test payload, called by the test app.
22  * {@hide}
23  */
24 interface ITestService {
25     const long SERVICE_PORT = 5678;
26 
27     const long ECHO_REVERSE_PORT = 0x80000001L; // Deliberately chosen to be > 2^31, < 2^32
28 
29     /* add two integers. */
addInteger(int a, int b)30     int addInteger(int a, int b);
31 
32     /* read a system property. */
readProperty(String prop)33     String readProperty(String prop);
34 
35     /* get a VM instance secret, this is _only_ done for testing. */
insecurelyExposeVmInstanceSecret()36     byte[] insecurelyExposeVmInstanceSecret();
37 
38     /* get the VM's attestation secret, this is _only_ done for testing. */
insecurelyExposeAttestationCdi()39     byte[] insecurelyExposeAttestationCdi();
40 
41     /* get the VM's boot certificate chain (BCC). */
getBcc()42     byte[] getBcc();
43 
44     /* get the APK contents path. */
getApkContentsPath()45     String getApkContentsPath();
46 
47     /* get the encrypted storage path. */
getEncryptedStoragePath()48     String getEncryptedStoragePath();
49 
50     /* start a simple vsock server on ECHO_REVERSE_PORT that reads a line at a time and echoes
51      * each line reverse.
52      */
runEchoReverseServer()53     void runEchoReverseServer();
54 
55     /** Returns a mask of effective capabilities that the process running the payload binary has. */
getEffectiveCapabilities()56     String[] getEffectiveCapabilities();
57 
58     /* write the content into the specified file. */
writeToFile(String content, String path)59     void writeToFile(String content, String path);
60 
61     /* get the content of the specified file. */
readFromFile(String path)62     String readFromFile(String path);
63 
64     /* get file permissions of the give file by stat'ing it */
getFilePermissions(String path)65     int getFilePermissions(String path);
66 
67     /** Returns flags for the given mountPoint. */
getMountFlags(String mountPoint)68     int getMountFlags(String mountPoint);
69 
70     /** Requests the VM to asynchronously call appCallback.setVmCallback() */
requestCallback(IAppCallback appCallback)71     void requestCallback(IAppCallback appCallback);
72 
73     /**
74      * Request the service to exit, triggering the termination of the VM. This may cause any
75      * requests in flight to fail.
76      */
quit()77     oneway void quit();
78 }
79