• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 public interface StaticBinderInterface {
26     /**
27      * Return the ID of the process that sent you the current transaction
28      * that is being processed. This PID can be used with higher-level
29      * system services to determine its identity and check permissions.
30      * If the current thread is not currently executing an incoming transaction,
31      * then its own PID is returned.
32      *
33      * Warning: oneway transactions do not receive PID. Even if you expect
34      * a transaction to be synchronous, a misbehaving client could send it
35      * as a asynchronous call and result in a 0 PID here. Additionally, if
36      * there is a race and the calling process dies, the PID may still be
37      * 0 for a synchronous call.
38      */
getCallingUid()39     int getCallingUid();
40     /**
41      * Return the Linux UID assigned to the process that sent you the
42      * current transaction that is being processed. This UID can be used with
43      * higher-level system services to determine its identity and check
44      * permissions. If the current thread is not currently executing an
45      * incoming transaction, then its own UID is returned.
46      */
getCallingPid()47     int getCallingPid();
48 }
49