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

Commit 2cbfa1ec authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Catch IllegalArgumentException to avoid SyncManager crash

When SyncManager's scheduling races with an app with a sync
adapter being uninstalled, it can get an IAE from PackageManager.

Catch this exception and skip over the job.

Bug: 36658118
Test: Manual
Change-Id: I0a63a3e0aa19cb5685aa18c7c6c9d6dd6ccfd60a
parent d70f423d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ public abstract class PackageManagerInternal {
     * @param packageName The package name.
     * @param userId The user for which to check.
     * @return Whether was launched.
     * @throws IllegalArgumentException if the package is not found
     */
    public abstract boolean wasPackageEverLaunched(String packageName, int userId);

+6 −1
Original line number Diff line number Diff line
@@ -907,9 +907,14 @@ public class SyncManager {
                    Bundle finalExtras = new Bundle(extras);
                    String packageName = syncAdapterInfo.componentName.getPackageName();
                    // If the app did not run and has no account access, done
                    try {
                        if (!mPackageManagerInternal.wasPackageEverLaunched(packageName, userId)) {
                            continue;
                        }
                    } catch (IllegalArgumentException e) {
                        // Package not found, race with an uninstall
                        continue;
                    }
                    mAccountManagerInternal.requestAccountAccess(account.account,
                            packageName, userId,
                            new RemoteCallback((Bundle result) -> {