Keep same behavior after initiatingPackageName change

InitiatingPackageName was previously set to null for all shell based
installs but has now been changed to "com.android.shell".

Bug: 265203007
Test: atest AppStoreUtilTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:acab1045f3786f775d0c51ffb50f5ff654fc53d8)
Merged-In: I3b8639c5530782375d0b26c9a65c1662eced5493
Change-Id: I3b8639c5530782375d0b26c9a65c1662eced5493
This commit is contained in:
William Loh
2023-02-21 21:57:52 +00:00
committed by Cherrypicker Worker
parent 9848eb9053
commit 5d2420d493

View File

@@ -53,7 +53,8 @@ public class AppStoreUtil {
// so we choose to ignore this when supplied by a non-system app. // so we choose to ignore this when supplied by a non-system app.
String originatingPackageName = source.getOriginatingPackageName(); String originatingPackageName = source.getOriginatingPackageName();
String initiatingPackageName = source.getInitiatingPackageName(); String initiatingPackageName = source.getInitiatingPackageName();
if (originatingPackageName != null && initiatingPackageName != null) { if (originatingPackageName != null && initiatingPackageName != null
&& !initiatingPackageName.equals("com.android.shell")) {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo( ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
initiatingPackageName, 0); initiatingPackageName, 0);
if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {