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 17 package android.os; 18 19 import android.hidl.manager.V1_2.IServiceManager; 20 import android.util.Log; 21 22 import java.util.ArrayList; 23 24 /** 25 * A fake hwservicemanager that is used locally when HIDL isn't supported on the device. 26 * 27 * @hide 28 */ 29 final class HwNoService extends IServiceManager.Stub implements IHwBinder, IHwInterface { 30 private static final String TAG = "HwNoService"; 31 32 /** @hide */ 33 @Override toString()34 public String toString() { 35 return "[HwNoService]"; 36 } 37 38 @Override get(String fqName, String name)39 public android.hidl.base.V1_0.IBase get(String fqName, String name) 40 throws android.os.RemoteException { 41 Log.i(TAG, "get " + fqName + "/" + name + " with no hwservicemanager"); 42 return null; 43 } 44 45 @Override add(String name, android.hidl.base.V1_0.IBase service)46 public boolean add(String name, android.hidl.base.V1_0.IBase service) 47 throws android.os.RemoteException { 48 Log.i(TAG, "get " + name + " with no hwservicemanager"); 49 return false; 50 } 51 52 @Override getTransport(String fqName, String name)53 public byte getTransport(String fqName, String name) throws android.os.RemoteException { 54 Log.i(TAG, "getTransoport " + fqName + "/" + name + " with no hwservicemanager"); 55 return 0x0; 56 } 57 58 @Override list()59 public java.util.ArrayList<String> list() throws android.os.RemoteException { 60 Log.i(TAG, "list with no hwservicemanager"); 61 return new ArrayList<String>(); 62 } 63 64 @Override listByInterface(String fqName)65 public java.util.ArrayList<String> listByInterface(String fqName) 66 throws android.os.RemoteException { 67 Log.i(TAG, "listByInterface with no hwservicemanager"); 68 return new ArrayList<String>(); 69 } 70 71 @Override registerForNotifications( String fqName, String name, android.hidl.manager.V1_0.IServiceNotification callback)72 public boolean registerForNotifications( 73 String fqName, String name, android.hidl.manager.V1_0.IServiceNotification callback) 74 throws android.os.RemoteException { 75 Log.i(TAG, "registerForNotifications with no hwservicemanager"); 76 return true; 77 } 78 79 @Override debugDump()80 public ArrayList<android.hidl.manager.V1_0.IServiceManager.InstanceDebugInfo> debugDump() 81 throws android.os.RemoteException { 82 Log.i(TAG, "debugDump with no hwservicemanager"); 83 return new ArrayList<android.hidl.manager.V1_0.IServiceManager.InstanceDebugInfo>(); 84 } 85 86 @Override registerPassthroughClient(String fqName, String name)87 public void registerPassthroughClient(String fqName, String name) 88 throws android.os.RemoteException { 89 Log.i(TAG, "registerPassthroughClient with no hwservicemanager"); 90 } 91 92 @Override unregisterForNotifications( String fqName, String name, android.hidl.manager.V1_0.IServiceNotification callback)93 public boolean unregisterForNotifications( 94 String fqName, String name, android.hidl.manager.V1_0.IServiceNotification callback) 95 throws android.os.RemoteException { 96 Log.i(TAG, "unregisterForNotifications with no hwservicemanager"); 97 return true; 98 } 99 100 @Override registerClientCallback( String fqName, String name, android.hidl.base.V1_0.IBase server, android.hidl.manager.V1_2.IClientCallback cb)101 public boolean registerClientCallback( 102 String fqName, 103 String name, 104 android.hidl.base.V1_0.IBase server, 105 android.hidl.manager.V1_2.IClientCallback cb) 106 throws android.os.RemoteException { 107 Log.i( 108 TAG, 109 "registerClientCallback for " + fqName + "/" + name + " with no hwservicemanager"); 110 return true; 111 } 112 113 @Override unregisterClientCallback( android.hidl.base.V1_0.IBase server, android.hidl.manager.V1_2.IClientCallback cb)114 public boolean unregisterClientCallback( 115 android.hidl.base.V1_0.IBase server, android.hidl.manager.V1_2.IClientCallback cb) 116 throws android.os.RemoteException { 117 Log.i(TAG, "unregisterClientCallback with no hwservicemanager"); 118 return true; 119 } 120 121 @Override addWithChain( String name, android.hidl.base.V1_0.IBase service, java.util.ArrayList<String> chain)122 public boolean addWithChain( 123 String name, android.hidl.base.V1_0.IBase service, java.util.ArrayList<String> chain) 124 throws android.os.RemoteException { 125 Log.i(TAG, "addWithChain with no hwservicemanager"); 126 return true; 127 } 128 129 @Override listManifestByInterface(String fqName)130 public java.util.ArrayList<String> listManifestByInterface(String fqName) 131 throws android.os.RemoteException { 132 Log.i(TAG, "listManifestByInterface for " + fqName + " with no hwservicemanager"); 133 return new ArrayList<String>(); 134 } 135 136 @Override tryUnregister(String fqName, String name, android.hidl.base.V1_0.IBase service)137 public boolean tryUnregister(String fqName, String name, android.hidl.base.V1_0.IBase service) 138 throws android.os.RemoteException { 139 Log.i(TAG, "tryUnregister for " + fqName + "/" + name + " with no hwservicemanager"); 140 return true; 141 } 142 } 143