1 /* 2 * Copyright 2019 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 #pragma once 18 19 #include <binder/IInterface.h> 20 #include <cutils/compiler.h> 21 #include <graphicsenv/GpuStatsInfo.h> 22 23 #include <vector> 24 25 namespace android { 26 27 /* 28 * This class defines the Binder IPC interface for GPU-related queries and 29 * control. 30 */ 31 class IGpuService : public IInterface { 32 public: 33 DECLARE_META_INTERFACE(GpuService) 34 35 // set GPU stats from GraphicsEnvironment. 36 virtual void setGpuStats(const std::string& driverPackageName, 37 const std::string& driverVersionName, uint64_t driverVersionCode, 38 int64_t driverBuildTime, const std::string& appPackageName, 39 const int32_t vulkanVersion, GpuStatsInfo::Driver driver, 40 bool isDriverLoaded, int64_t driverLoadingTime) = 0; 41 42 // set target stats. 43 virtual void setTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode, 44 const GpuStatsInfo::Stats stats, const uint64_t value = 0) = 0; 45 virtual void setTargetStatsArray(const std::string& appPackageName, 46 const uint64_t driverVersionCode, 47 const GpuStatsInfo::Stats stats, const uint64_t* values, 48 const uint32_t valueCount) = 0; 49 50 // setter and getter for updatable driver path. 51 virtual void setUpdatableDriverPath(const std::string& driverPath) = 0; 52 virtual std::string getUpdatableDriverPath() = 0; 53 54 // sets ANGLE as system GLES driver if enabled==true by setting persist.graphics.egl to true. 55 virtual void toggleAngleAsSystemDriver(bool enabled) = 0; 56 }; 57 58 class BnGpuService : public BnInterface<IGpuService> { 59 public: 60 enum IGpuServiceTag { 61 SET_GPU_STATS = IBinder::FIRST_CALL_TRANSACTION, 62 SET_TARGET_STATS, 63 SET_UPDATABLE_DRIVER_PATH, 64 GET_UPDATABLE_DRIVER_PATH, 65 TOGGLE_ANGLE_AS_SYSTEM_DRIVER, 66 // Always append new enum to the end. 67 }; 68 69 status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, 70 uint32_t flags = 0) override; 71 72 protected: 73 virtual status_t shellCommand(int in, int out, int err, std::vector<String16>& args) = 0; 74 }; 75 76 } // namespace android 77