1 /* 2 * Copyright (C) 2023 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 package com.android.hoststubgen.test.tinyframework; 17 18 import android.hosttest.annotation.HostSideTestStub; 19 import android.hosttest.annotation.HostSideTestSubstitute; 20 import android.hosttest.annotation.HostSideTestWholeClassStub; 21 22 @HostSideTestWholeClassStub 23 public class TinyFrameworkClassClassWideAnnotations { TinyFrameworkClassClassWideAnnotations()24 public TinyFrameworkClassClassWideAnnotations() { 25 } 26 27 public int stub = 1; 28 29 public int keep = 2; 30 31 // Cannot have an initial value, because otherwise .ctor will fail to set it at runtime. 32 public int remove; 33 34 // @Stub addOne(int value)35 public int addOne(int value) { 36 return addOneInner(value); 37 } 38 39 // @Keep addOneInner(int value)40 public int addOneInner(int value) { 41 return value + 1; 42 } 43 44 // @Remove toBeRemoved(String foo)45 public void toBeRemoved(String foo) { 46 throw new RuntimeException(); 47 } 48 49 @HostSideTestStub 50 @HostSideTestSubstitute(suffix = "_host") addTwo(int value)51 public int addTwo(int value) { 52 throw new RuntimeException("not supported on host side"); 53 } 54 addTwo_host(int value)55 public int addTwo_host(int value) { 56 return value + 2; 57 } 58 59 @HostSideTestStub 60 @HostSideTestSubstitute(suffix = "_host") nativeAddThree(int value)61 public static native int nativeAddThree(int value); 62 nativeAddThree_host(int value)63 public static int nativeAddThree_host(int value) { 64 return value + 3; 65 } 66 unsupportedMethod()67 public String unsupportedMethod() { 68 return "This value shouldn't be seen on the host side."; 69 } 70 visibleButUsesUnsupportedMethod()71 public String visibleButUsesUnsupportedMethod() { 72 return unsupportedMethod(); 73 } 74 } 75