Skip to content

Commit

Permalink
[Installer] Fix opening the installed app from the notification
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Jun 3, 2024
1 parent f3a1281 commit ccc371f
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public PackageInstallerService() {

@Nullable
private OnInstallFinished mOnInstallFinished;
private int mSessionId;
private String mPackageName;
private QueuedProgressHandler mProgressHandler;
private NotificationInfo mNotificationInfo;
private PowerManager.WakeLock mWakeLock;
Expand Down Expand Up @@ -123,8 +121,6 @@ protected void onHandleIntent(@Nullable Intent intent) {
installer.setOnInstallListener(new PackageInstallerCompat.OnInstallListener() {
@Override
public void onStartInstall(int sessionId, String packageName) {
mSessionId = sessionId;
mPackageName = packageName;
}

// MIUI-begin: MIUI 12.5+ workaround
Expand Down Expand Up @@ -156,7 +152,9 @@ public void onFinishedInstall(int sessionId, String packageName, int result,
mOnInstallFinished.onFinished(packageName, result, blockingPackage, statusMessage);
}
});
} else sendNotification(result, apkQueueItem.getAppLabel(), blockingPackage, statusMessage);
} else {
sendNotification(packageName, result, apkQueueItem.getAppLabel(), blockingPackage, statusMessage);
}
}
});
// Two possibilities: 1. Install-existing, 2. ApkFile/Uri
Expand Down Expand Up @@ -241,19 +239,12 @@ public void setOnInstallFinished(@Nullable OnInstallFinished onInstallFinished)
this.mOnInstallFinished = onInstallFinished;
}

public int getCurrentSessionId() {
return mSessionId;
}

public String getCurrentPackageName() {
return mPackageName;
}

private void sendNotification(@PackageInstallerCompat.Status int status,
private void sendNotification(@NonNull String packageName,
@PackageInstallerCompat.Status int status,
@Nullable String appLabel,
@Nullable String blockingPackage,
@Nullable String statusMessage) {
Intent intent = PackageManagerCompat.getLaunchIntentForPackage(mPackageName, UserHandleHidden.myUserId());
Intent intent = PackageManagerCompat.getLaunchIntentForPackage(packageName, UserHandleHidden.myUserId());
PendingIntent defaultAction = intent != null ? PendingIntentCompat.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT, false) : null;
String subject = getStringFromStatus(this, status, appLabel, blockingPackage);
Expand Down

0 comments on commit ccc371f

Please sign in to comment.