1 /* 2 * Copyright (c) 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 17 package com.android.car.telemetry.scriptexecutorinterface; 18 19 import android.os.ParcelFileDescriptor; 20 import android.os.PersistableBundle; 21 import com.android.car.telemetry.scriptexecutorinterface.BundleList; 22 import com.android.car.telemetry.scriptexecutorinterface.IScriptExecutorListener; 23 24 /** 25 * An internal API provided by isolated Script Executor process 26 * for executing Lua scripts in a sandboxed environment 27 */ 28 oneway interface IScriptExecutor { 29 /** 30 * Executes a specified function in a provided Lua script with given input arguments. 31 * 32 * @param scriptBody complete body of Lua script that also contains the function to be invoked 33 * @param functionName the name of the function to execute 34 * @param publishedData input data provided by the source which the function handles 35 * @param savedState key-value pairs preserved from the previous invocation of the function 36 * @param listener callback for the sandboxed environment to report back script execution results, 37 * errors, and logs 38 */ invokeScript(String scriptBody, String functionName, in PersistableBundle publishedData, in @nullable PersistableBundle savedState, in IScriptExecutorListener listener)39 void invokeScript(String scriptBody, 40 String functionName, 41 in PersistableBundle publishedData, 42 in @nullable PersistableBundle savedState, 43 in IScriptExecutorListener listener); 44 45 /** 46 * Executes a specified function in a provided Lua script with given input arguments. 47 * This is a specialized version of invokeScript API above for a case when publishedData input 48 * could be potentially large and overflow Binder's buffer. 49 * 50 * @param scriptBody complete body of Lua script that also contains the function to be invoked 51 * @param functionName the name of the function to execute 52 * @param publishedDataFileDescriptor file descriptor which is be used to open a pipe to read 53 * large amount of input data. The input data is then handled by the provided Lua function. 54 * @param savedState key-value pairs preserved from the previous invocation of the function 55 * @param listener callback for the sandboxed environment to report back script execution results, 56 * errors, and logs 57 */ invokeScriptForLargeInput(String scriptBody, String functionName, in ParcelFileDescriptor publishedDataFileDescriptor, in @nullable PersistableBundle savedState, in IScriptExecutorListener listener)58 void invokeScriptForLargeInput(String scriptBody, 59 String functionName, 60 in ParcelFileDescriptor publishedDataFileDescriptor, 61 in @nullable PersistableBundle savedState, 62 in IScriptExecutorListener listener); 63 64 /** 65 * Executes a specified function in a provided Lua script with given input arguments. 66 * This is a specialized version of invokeScript API above for sending a list of bundles. The 67 * data is delivered use LargeParcelable so it can handle large data sizes automatically. 68 * 69 * @param scriptBody complete body of Lua script that also contains the function to be invoked 70 * @param functionName the name of the function to execute 71 * @param bundleList the list of bundles as input data which the scripts will handle 72 * @param savedState key-value pairs preserved from the previous invocation of the function 73 * @param listener callback for the sandboxed environment to report back script execution results, 74 * errors, and logs 75 */ invokeScriptForBundleList(String scriptBody, String functionName, in BundleList bundleList, in @nullable PersistableBundle savedState, in IScriptExecutorListener listener)76 void invokeScriptForBundleList(String scriptBody, 77 String functionName, 78 in BundleList bundleList, 79 in @nullable PersistableBundle savedState, 80 in IScriptExecutorListener listener); 81 } 82