1 /* 2 * Copyright (C) 2021 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.server.pm; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.pm.SharedLibraryInfo; 22 import android.util.proto.ProtoOutputStream; 23 24 import com.android.server.utils.WatchedArrayMap; 25 import com.android.server.utils.WatchedLongSparseArray; 26 27 import java.io.PrintWriter; 28 29 /** 30 * An interface implemented by {@link SharedLibrariesImpl} for {@link Computer} to get current 31 * shared libraries on the device. 32 */ 33 public interface SharedLibrariesRead { 34 35 /** 36 * Returns all shared libraries on the device. 37 * 38 * @return A map of library name to a list of {@link SharedLibraryInfo}s with 39 * different versions. 40 */ 41 @NonNull getAll()42 WatchedArrayMap<String, WatchedLongSparseArray<SharedLibraryInfo>> getAll(); 43 44 /** 45 * Given the library name, returns a list of shared libraries on all versions. 46 * 47 * @param libName The library name. 48 * @return A list of shared library info. 49 */ 50 @Nullable getSharedLibraryInfos(@onNull String libName)51 WatchedLongSparseArray<SharedLibraryInfo> getSharedLibraryInfos(@NonNull String libName); 52 53 /** 54 * Returns the shared library with given library name and version number. 55 * 56 * @param libName The library name. 57 * @param version The library version number. 58 * @return The shared library info. 59 */ 60 @Nullable getSharedLibraryInfo(@onNull String libName, long version)61 SharedLibraryInfo getSharedLibraryInfo(@NonNull String libName, long version); 62 63 /** 64 * Given the declaring package name, returns a list of static shared libraries on all versions. 65 * 66 * @param declaringPackageName The declaring name of the package. 67 * @return A list of shared library info. 68 */ 69 @Nullable getStaticLibraryInfos( @onNull String declaringPackageName)70 WatchedLongSparseArray<SharedLibraryInfo> getStaticLibraryInfos( 71 @NonNull String declaringPackageName); 72 73 /** 74 * Dump all shared libraries. 75 * 76 * @param pw A PrintWriter to dump to. 77 * @param dumpState Including options and states for writing. 78 */ dump(@onNull PrintWriter pw, @NonNull DumpState dumpState)79 void dump(@NonNull PrintWriter pw, @NonNull DumpState dumpState); 80 81 /** 82 * Dump all shared libraries to given proto output stream. 83 * @param proto A proto output stream to dump to. 84 */ dumpProto(@onNull ProtoOutputStream proto)85 void dumpProto(@NonNull ProtoOutputStream proto); 86 } 87