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

Commit a43f144d authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Listen to USER_STARTED instead of USER_ADDED from WebViewUpdateService.

When adding a restricted user, 'hidden' applications are uninstalled for
the user after creation of the user, but before the user is 'started'.

Because WebViewUpdateService only listens to USER_ADDED and USER_REMOVED
intents it wouldn't realize that Chrome had been uninstalled for a new
restricted user (at the time of user-creation Chrome would be
installed). Instead listen to user-started/stopped intents to ensure the
restricted-user case is handled correctly.

Bug: 35813523
Test: Add a restricted user (on a Pixel C), with Chrome disabled. Start
an app using WebView (and ensure WebView doesn't crash).

Change-Id: I0c5d0a543b4bc80d269e586444b80cd3baffa11c
parent a622b24d
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -92,7 +92,7 @@ public class WebViewUpdateService extends SystemService {
                                    (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)
                                    (intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)
                                     ? PACKAGE_ADDED_REPLACED : PACKAGE_ADDED), userId);
                                     ? PACKAGE_ADDED_REPLACED : PACKAGE_ADDED), userId);
                            break;
                            break;
                        case Intent.ACTION_USER_ADDED:
                        case Intent.ACTION_USER_STARTED:
                            mImpl.handleNewUser(userId);
                            mImpl.handleNewUser(userId);
                            break;
                            break;
                        case Intent.ACTION_USER_REMOVED:
                        case Intent.ACTION_USER_REMOVED:
@@ -115,7 +115,7 @@ public class WebViewUpdateService extends SystemService {
                null /* broadcast permission */, null /* handler */);
                null /* broadcast permission */, null /* handler */);


        IntentFilter userAddedFilter = new IntentFilter();
        IntentFilter userAddedFilter = new IntentFilter();
        userAddedFilter.addAction(Intent.ACTION_USER_ADDED);
        userAddedFilter.addAction(Intent.ACTION_USER_STARTED);
        userAddedFilter.addAction(Intent.ACTION_USER_REMOVED);
        userAddedFilter.addAction(Intent.ACTION_USER_REMOVED);
        getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL,
        getContext().registerReceiverAsUser(mWebViewUpdatedReceiver, UserHandle.ALL,
                userAddedFilter, null /* broadcast permission */, null /* handler */);
                userAddedFilter, null /* broadcast permission */, null /* handler */);
+4 −0
Original line number Original line Diff line number Diff line
@@ -112,6 +112,10 @@ public class WebViewUpdateServiceImpl {
    }
    }


    void handleNewUser(int userId) {
    void handleNewUser(int userId) {
        // The system user is always started at boot, and by that point we have already run one
        // round of the package-changing logic (through prepareWebViewInSystemServer()), so early
        // out here.
        if (userId == UserHandle.USER_SYSTEM) return;
        handleUserChange();
        handleUserChange();
    }
    }