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
This commit is contained in:
@@ -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);
|
||||
new PackageInstalledNotificationUtils(context, installer,
|
||||
packageName).postAppInstalledNotification();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user