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

Commit 75910654 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Resolve ANR in AppUninstallBroadcastReceiver

Move the onReceive code into another thread so that the main thread
isn't blocked which would cause an ANR. The broadcast is kept alive
after returning from the function without blocking the main thread.

Bug: 324036454
Test: Manual
Change-Id: I6cf17cdaaef12617169d9500a575c64ec65aa0e8
parent 967b8f86
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -61,9 +61,14 @@ public class AppUninstallBroadcastReceiver extends BroadcastReceiver {
                return;
            }

            final PendingResult result = goAsync();
            // Move computation off into a separate thread to prevent ANR.
            new Thread(() -> {
                String packageName = uri.getSchemeSpecificPart();
                handlePackageRemoved(context, packageName);
                handleUninstallOfCallScreeningService(context, packageName);
                result.finish();
            }).start();
        }
    }