Skip to content

Commit

Permalink
[Installer] Ensure package name before making (un)install attempts
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Mar 28, 2024
1 parent f788888 commit 7e63188
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public boolean install(@NonNull ApkFile apkFile, @NonNull List<String> selectedS
ThreadUtils.ensureWorkerThread();
try {
mApkFile = apkFile;
mPackageName = apkFile.getPackageName();
mPackageName = Objects.requireNonNull(apkFile.getPackageName());
initBroadcastReceiver();
int userId = options.getUserId();
int installFlags = getInstallFlags(userId);
Expand Down Expand Up @@ -670,7 +670,7 @@ public boolean install(@NonNull Path[] apkFiles, @NonNull String packageName, @N
ThreadUtils.ensureWorkerThread();
try {
mApkFile = null;
mPackageName = packageName;
mPackageName = Objects.requireNonNull(packageName);
initBroadcastReceiver();
int userId = options.getUserId();
int installFlags = getInstallFlags(userId);
Expand Down Expand Up @@ -847,6 +847,7 @@ private static int getInstallFlags(@UserIdInt int userId) {

public boolean installExisting(@NonNull String packageName, @UserIdInt int userId) {
ThreadUtils.ensureWorkerThread();
mPackageName = Objects.requireNonNull(packageName);
if (mOnInstallListener != null) {
mOnInstallListener.onStartInstall(mSessionId, packageName);
}
Expand Down Expand Up @@ -1033,7 +1034,7 @@ private void installCompleted(int sessionId,
public boolean uninstall(String packageName, @UserIdInt int userId, boolean keepData) {
ThreadUtils.ensureWorkerThread();
boolean hasDeletePackagesPermission = SelfPermissions.checkSelfOrRemotePermission(Manifest.permission.DELETE_PACKAGES);
mPackageName = packageName;
mPackageName = Objects.requireNonNull(packageName);
String callerPackageName = SelfPermissions.getCallingPackage(Users.getSelfOrRemoteUid());
initBroadcastReceiver();
try {
Expand Down

0 comments on commit 7e63188

Please sign in to comment.