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

Commit fa1535b1 authored by Pratyush's avatar Pratyush
Browse files

bugfix: notify stopped packages of event account events.

mail app relies on account removed event to remove account from the app, if it stopped it will be in the state where account is removed from account manager but not from mail app (ideally it should be fixed in mail app it self).
parent 8f264fb4
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -1032,7 +1032,7 @@ public class AccountManagerService
                +", sending broadcast of " + AccountManager.ACTION_VISIBLE_ACCOUNTS_CHANGED);
                +", sending broadcast of " + AccountManager.ACTION_VISIBLE_ACCOUNTS_CHANGED);
        Intent intent = new Intent(AccountManager.ACTION_VISIBLE_ACCOUNTS_CHANGED);
        Intent intent = new Intent(AccountManager.ACTION_VISIBLE_ACCOUNTS_CHANGED);
        intent.setPackage(packageName);
        intent.setPackage(packageName);
        intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
        intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        mContext.sendBroadcastAsUser(intent, new UserHandle(accounts.userId));
        mContext.sendBroadcastAsUser(intent, new UserHandle(accounts.userId));
    }
    }


@@ -1059,7 +1059,7 @@ public class AccountManagerService
    // Returns a list of packages listening to ACTION_ACCOUNT_REMOVED able to see the account.
    // Returns a list of packages listening to ACTION_ACCOUNT_REMOVED able to see the account.
    private List<String> getAccountRemovedReceivers(Account account, UserAccounts accounts) {
    private List<String> getAccountRemovedReceivers(Account account, UserAccounts accounts) {
        Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
        Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        List<ResolveInfo> receivers =
        List<ResolveInfo> receivers =
            mPackageManager.queryBroadcastReceiversAsUser(intent, 0, accounts.userId);
            mPackageManager.queryBroadcastReceiversAsUser(intent, 0, accounts.userId);
        List<String> result = new ArrayList<>();
        List<String> result = new ArrayList<>();
@@ -1087,7 +1087,7 @@ public class AccountManagerService
        }
        }


        Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
        Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        intent.setPackage(packageName);
        intent.setPackage(packageName);
        List<ResolveInfo> receivers =
        List<ResolveInfo> receivers =
            mPackageManager.queryBroadcastReceiversAsUser(intent, 0, accounts.userId);
            mPackageManager.queryBroadcastReceiversAsUser(intent, 0, accounts.userId);
@@ -1119,7 +1119,7 @@ public class AccountManagerService
                + useCase + " for userId=" + userId + ", sending broadcast of "
                + useCase + " for userId=" + userId + ", sending broadcast of "
                + AccountManager.ACTION_ACCOUNT_REMOVED);
                + AccountManager.ACTION_ACCOUNT_REMOVED);
        Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
        Intent intent = new Intent(AccountManager.ACTION_ACCOUNT_REMOVED);
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        intent.setPackage(packageName);
        intent.setPackage(packageName);
        intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);
        intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);
        intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);
        intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);