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

Commit 728ac98e authored by Sumedh Sen's avatar Sumedh Sen
Browse files

Silently exit if Pia cant post notification

If appInfo for installed or installer package cant be found, catch the
exception thrown instead of crashing Pia

Bug: 289660748
Test: None
Change-Id: I61f25eb14265d21729dd84e2e4ab34d182b68132
parent 8a77a846
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.packageinstaller;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.InstallSourceInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.util.Log;

@@ -61,11 +63,19 @@ public class PackageInstalledReceiver extends BroadcastReceiver {
                return;
            }

            // TODO: Make sure the installer information here is accurate
            String installer =
                    context.getPackageManager().getInstallerPackageName(packageName);
            try {
                InstallSourceInfo installerInfo =
                        context.getPackageManager().getInstallSourceInfo(packageName);
                String installer = installerInfo.getInstallingPackageName();
                if (installer == null) {
                    Log.e(TAG, "No installer package name for: " + packageName);
                    return;
                }
                new PackageInstalledNotificationUtils(context, installer,
                        packageName).postAppInstalledNotification();
            } catch (PackageManager.NameNotFoundException e) {
                Log.e(TAG, "Cannot get source info for: " + packageName);
            }
        }
    }
}