[pm] fix potential NPE in system server

getSourceInstallerPackageName is NPE prone and can be replaced by a safe
method (getInstallerPackageName).

BUG: 284423191
Test: presubmit
Change-Id: I404bd7544eb059597982ca9c3bc6d6f0ba297887
This commit is contained in:
Songchun Fan
2023-06-02 10:09:07 -07:00
parent f429d98cfb
commit 169fbe9ed3
2 changed files with 1 additions and 7 deletions

View File

@@ -2145,7 +2145,7 @@ final class InstallPackageHelper {
final String pkgName = pkg.getPackageName();
final int[] installedForUsers = installRequest.getOriginUsers();
final int installReason = installRequest.getInstallReason();
final String installerPackageName = installRequest.getSourceInstallerPackageName();
final String installerPackageName = installRequest.getInstallerPackageName();
if (DEBUG_INSTALL) Slog.d(TAG, "New package installed in " + pkg.getPath());
synchronized (mPm.mLock) {

View File

@@ -366,12 +366,6 @@ final class InstallRequest {
public String getApexModuleName() {
return mApexModuleName;
}
@Nullable
public String getSourceInstallerPackageName() {
return mInstallArgs.mInstallSource.mInstallerPackageName;
}
public boolean isRollback() {
return mInstallArgs != null
&& mInstallArgs.mInstallReason == PackageManager.INSTALL_REASON_ROLLBACK;