Rename PackageState getUsesLibraries to getSharedLibraryDependencies

This better communicates what the method returns and prevents it from
being confused with the <uses-library> manifest tag, which is only
one of the 5 types of libraries returned by this method.

Also fixes a null vs empty check calling this method.

API-Coverage-Bug: 262593427

Bug: 265006762

Change-Id: Ia7ab400cfdb4dd9a9ff66cb9c102a21e3f2b95cb
diff --git a/services/api/current.txt b/services/api/current.txt
index 3926b39..e66bf4d 100644
--- a/services/api/current.txt
+++ b/services/api/current.txt
@@ -180,8 +180,8 @@
     method @Nullable public String getPrimaryCpuAbi();
     method @Nullable public String getSeInfo();
     method @Nullable public String getSecondaryCpuAbi();
+    method @NonNull public java.util.List<com.android.server.pm.pkg.SharedLibrary> getSharedLibraryDependencies();
     method @NonNull public com.android.server.pm.pkg.PackageUserState getStateForUser(@NonNull android.os.UserHandle);
-    method @NonNull public java.util.List<com.android.server.pm.pkg.SharedLibrary> getUsesLibraries();
     method public boolean isApex();
     method public boolean isPrivileged();
     method public boolean isSystem();
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java
index 4e5f77f..0668456 100644
--- a/services/core/java/com/android/server/pm/InstallPackageHelper.java
+++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java
@@ -388,7 +388,8 @@
         }
 
         if (reconciledPkg.mCollectedSharedLibraryInfos != null
-                || (oldPkgSetting != null && oldPkgSetting.getUsesLibraries() != null)) {
+                || (oldPkgSetting != null
+                && !oldPkgSetting.getSharedLibraryDependencies().isEmpty())) {
             // Reconcile if the new package or the old package uses shared libraries.
             // It is possible that the old package uses shared libraries but the new one doesn't.
             mSharedLibraries.executeSharedLibrariesUpdate(pkg, pkgSetting, null, null,
diff --git a/services/core/java/com/android/server/pm/PackageSetting.java b/services/core/java/com/android/server/pm/PackageSetting.java
index 53fdfaa..2a1172c 100644
--- a/services/core/java/com/android/server/pm/PackageSetting.java
+++ b/services/core/java/com/android/server/pm/PackageSetting.java
@@ -1219,7 +1219,7 @@
 
     @NonNull
     @Override
-    public List<SharedLibrary> getUsesLibraries() {
+    public List<SharedLibrary> getSharedLibraryDependencies() {
         return (List<SharedLibrary>) (List<?>) pkgState.getUsesLibraryInfos();
     }
 
diff --git a/services/core/java/com/android/server/pm/pkg/PackageState.java b/services/core/java/com/android/server/pm/pkg/PackageState.java
index a12c9d0..106b149 100644
--- a/services/core/java/com/android/server/pm/pkg/PackageState.java
+++ b/services/core/java/com/android/server/pm/pkg/PackageState.java
@@ -158,10 +158,11 @@
     PackageUserState getStateForUser(@NonNull UserHandle user);
 
     /**
-     * @see R.styleable#AndroidManifestUsesLibrary
+     * List of shared libraries that this package declares a dependency on. This includes all
+     * types of libraries, system or app provided and Java or native.
      */
     @NonNull
-    List<SharedLibrary> getUsesLibraries();
+    List<SharedLibrary> getSharedLibraryDependencies();
 
     /** Whether this represents an APEX module. This is different from an APK inside an APEX. */
     boolean isApex();
diff --git a/services/core/java/com/android/server/pm/pkg/PackageStateImpl.java b/services/core/java/com/android/server/pm/pkg/PackageStateImpl.java
index bc6dab4..91a25db3 100644
--- a/services/core/java/com/android/server/pm/pkg/PackageStateImpl.java
+++ b/services/core/java/com/android/server/pm/pkg/PackageStateImpl.java
@@ -190,7 +190,7 @@
         mUsesSdkLibrariesVersionsMajor = pkgState.getUsesSdkLibrariesVersionsMajor();
         mUsesStaticLibraries = pkgState.getUsesStaticLibraries();
         mUsesStaticLibrariesVersions = pkgState.getUsesStaticLibrariesVersions();
-        mUsesLibraries = Collections.unmodifiableList(pkgState.getUsesLibraries());
+        mUsesLibraries = Collections.unmodifiableList(pkgState.getSharedLibraryDependencies());
         mUsesLibraryFiles = Collections.unmodifiableList(pkgState.getUsesLibraryFiles());
         setBoolean(Booleans.FORCE_QUERYABLE_OVERRIDE, pkgState.isForceQueryableOverride());
         setBoolean(Booleans.HIDDEN_UNTIL_INSTALLED, pkgState.isHiddenUntilInstalled());
@@ -693,7 +693,7 @@
     }
 
     @DataClass.Generated.Member
-    public @NonNull List<SharedLibrary> getUsesLibraries() {
+    public @NonNull List<SharedLibrary> getSharedLibraryDependencies() {
         return mUsesLibraries;
     }