1 /* 2 * Copyright (C) 2024 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.internal; 18 19 /** 20 * StaticBinderInterface provides static methods from {@code android.os.Binder} that are used 21 * internally by car service or car manager. 22 * 23 * This interface allows faking the implementation in unit tests. 24 * 25 * @hide 26 */ 27 public interface StaticBinderInterface { 28 /** 29 * Return the ID of the process that sent you the current transaction 30 * that is being processed. This PID can be used with higher-level 31 * system services to determine its identity and check permissions. 32 * If the current thread is not currently executing an incoming transaction, 33 * then its own PID is returned. 34 * 35 * Warning: oneway transactions do not receive PID. Even if you expect 36 * a transaction to be synchronous, a misbehaving client could send it 37 * as a asynchronous call and result in a 0 PID here. Additionally, if 38 * there is a race and the calling process dies, the PID may still be 39 * 0 for a synchronous call. 40 */ getCallingUid()41 int getCallingUid(); 42 /** 43 * Return the Linux UID assigned to the process that sent you the 44 * current transaction that is being processed. This UID can be used with 45 * higher-level system services to determine its identity and check 46 * permissions. If the current thread is not currently executing an 47 * incoming transaction, then its own UID is returned. 48 */ getCallingPid()49 int getCallingPid(); 50 } 51