Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8a38ef4 authored by Sumedh Sen's avatar Sumedh Sen Committed by Android (Google) Code Review
Browse files

Merge "Remove invalid null check for callingPackage" into tm-dev

parents 59d2ce52 7df6cd01
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.net.Uri;
@@ -65,14 +66,15 @@ public class InstallStart extends Activity {
        // If the activity was started via a PackageInstaller session, we retrieve the calling
        // package from that session
        final int sessionId = (isSessionInstall
                ? intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1)
                : -1);
        if (callingPackage == null && sessionId != -1) {
            PackageInstaller packageInstaller = getPackageManager().getPackageInstaller();
                ? intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, SessionInfo.INVALID_ID)
                : SessionInfo.INVALID_ID);
        if (sessionId != SessionInfo.INVALID_ID) {
            PackageInstaller packageInstaller = mPackageManager.getPackageInstaller();
            PackageInstaller.SessionInfo sessionInfo = packageInstaller.getSessionInfo(sessionId);
            callingPackage = (sessionInfo != null) ? sessionInfo.getInstallerPackageName() : null;
            callingAttributionTag =
                    (sessionInfo != null) ? sessionInfo.getInstallerAttributionTag() : null;
            if (sessionInfo != null) {
                callingPackage = sessionInfo.getInstallerPackageName();
                callingAttributionTag = sessionInfo.getInstallerAttributionTag();
            }
        }

        final ApplicationInfo sourceInfo = getSourceInfo(callingPackage);
@@ -173,7 +175,7 @@ public class InstallStart extends Activity {
    private ApplicationInfo getSourceInfo(@Nullable String callingPackage) {
        if (callingPackage != null) {
            try {
                return getPackageManager().getApplicationInfo(callingPackage, 0);
                return mPackageManager.getApplicationInfo(callingPackage, 0);
            } catch (PackageManager.NameNotFoundException ex) {
                // ignore
            }
@@ -220,7 +222,7 @@ public class InstallStart extends Activity {
    }

    private boolean isSystemDownloadsProvider(int uid) {
        final ProviderInfo downloadProviderPackage = getPackageManager().resolveContentProvider(
        final ProviderInfo downloadProviderPackage = mPackageManager.resolveContentProvider(
                DOWNLOADS_AUTHORITY, 0);
        if (downloadProviderPackage == null) {
            // There seems to be no currently enabled downloads provider on the system.