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

Commit 88a879ff authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Whitelist noti listeners on user creation

Test: manual; create new user; verify badges seen in launcher
Change-Id: Ib134b3f5936dfb5dd0081755ce8e8137abce36fb
Fixes: 64073967
parent 7635ab0a
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
import static android.content.pm.PackageManager.FEATURE_TELEVISION;
import static android.content.pm.PackageManager.FEATURE_TELEVISION;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.UserHandle.USER_NULL;
import static android.service.notification.NotificationListenerService
import static android.service.notification.NotificationListenerService
        .NOTIFICATION_CHANNEL_OR_GROUP_ADDED;
        .NOTIFICATION_CHANNEL_OR_GROUP_ADDED;
import static android.service.notification.NotificationListenerService
import static android.service.notification.NotificationListenerService
@@ -405,8 +406,7 @@ public class NotificationManagerService extends SystemService {


    }
    }


    protected void readDefaultApprovedServices() {
    protected void readDefaultApprovedServices(int userId) {
        final int userId = UserHandle.USER_SYSTEM;
        String defaultListenerAccess = getContext().getResources().getString(
        String defaultListenerAccess = getContext().getResources().getString(
                com.android.internal.R.string.config_defaultListenerAccessPackages);
                com.android.internal.R.string.config_defaultListenerAccessPackages);
        if (defaultListenerAccess != null) {
        if (defaultListenerAccess != null) {
@@ -488,7 +488,7 @@ public class NotificationManagerService extends SystemService {
            } catch (FileNotFoundException e) {
            } catch (FileNotFoundException e) {
                // No data yet
                // No data yet
                // Load default managed services approvals
                // Load default managed services approvals
                readDefaultApprovedServices();
                readDefaultApprovedServices(UserHandle.USER_SYSTEM);
            } catch (IOException e) {
            } catch (IOException e) {
                Log.wtf(TAG, "Unable to read notification policy", e);
                Log.wtf(TAG, "Unable to read notification policy", e);
            } catch (NumberFormatException e) {
            } catch (NumberFormatException e) {
@@ -977,7 +977,7 @@ public class NotificationManagerService extends SystemService {
                // turn off LED when user passes through lock screen
                // turn off LED when user passes through lock screen
                mNotificationLight.turnOff();
                mNotificationLight.turnOff();
            } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
            } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
                // reload per-user settings
                // reload per-user settings
                mSettingsObserver.update(null);
                mSettingsObserver.update(null);
                mUserProfiles.updateCache(context);
                mUserProfiles.updateCache(context);
@@ -987,14 +987,18 @@ public class NotificationManagerService extends SystemService {
                mAssistants.onUserSwitched(user);
                mAssistants.onUserSwitched(user);
                mZenModeHelper.onUserSwitched(user);
                mZenModeHelper.onUserSwitched(user);
            } else if (action.equals(Intent.ACTION_USER_ADDED)) {
            } else if (action.equals(Intent.ACTION_USER_ADDED)) {
                final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
                if (userId != USER_NULL) {
                    mUserProfiles.updateCache(context);
                    mUserProfiles.updateCache(context);
                    readDefaultApprovedServices(userId);
                }
            } else if (action.equals(Intent.ACTION_USER_REMOVED)) {
            } else if (action.equals(Intent.ACTION_USER_REMOVED)) {
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
                mZenModeHelper.onUserRemoved(user);
                mZenModeHelper.onUserRemoved(user);
                mRankingHelper.onUserRemoved(user);
                mRankingHelper.onUserRemoved(user);
                savePolicyFile();
                savePolicyFile();
            } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) {
            } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) {
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
                mConditionProviders.onUserUnlocked(user);
                mConditionProviders.onUserUnlocked(user);
                mListeners.onUserUnlocked(user);
                mListeners.onUserUnlocked(user);
                mAssistants.onUserUnlocked(user);
                mAssistants.onUserUnlocked(user);