1 /* 2 * Copyright (C) 2018 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 android.binder.cts; 18 19 import android.os.IBinder; 20 import android.os.Parcel; 21 22 import androidx.test.InstrumentationRegistry; 23 24 import com.android.gtestrunner.GtestRunner; 25 import com.android.gtestrunner.TargetLibrary; 26 27 import org.junit.runner.RunWith; 28 29 /** 30 * This test runs gtests for testing libbinder_ndk directly and it also runs client tests for native code. 31 */ 32 @RunWith(GtestRunner.class) 33 @TargetLibrary("binder_ndk_test") 34 public class NdkBinderTest { getLocalNativeService()35 static IBinder getLocalNativeService() { 36 return new SyncTestServiceConnection( 37 InstrumentationRegistry.getTargetContext(), NativeService.Local.class) 38 .get().asBinder(); 39 } getLocalJavaService()40 static IBinder getLocalJavaService() { 41 return new SyncTestServiceConnection( 42 InstrumentationRegistry.getTargetContext(), JavaService.Local.class) 43 .get().asBinder(); 44 } getRemoteNativeService()45 static IBinder getRemoteNativeService() { 46 return new SyncTestServiceConnection( 47 InstrumentationRegistry.getTargetContext(), NativeService.Remote.class) 48 .get().asBinder(); 49 } getRemoteJavaService()50 static IBinder getRemoteJavaService() { 51 return new SyncTestServiceConnection( 52 InstrumentationRegistry.getTargetContext(), JavaService.Remote.class) 53 .get().asBinder(); 54 } getRemoteOldNativeService()55 static IBinder getRemoteOldNativeService() { 56 return new SyncTestServiceConnection( 57 InstrumentationRegistry.getTargetContext(), NativeService.RemoteOld.class) 58 .get().asBinder(); 59 } getEmptyParcel()60 static Parcel getEmptyParcel() { 61 return Parcel.obtain(); 62 } 63 } 64