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

Commit 0af22dd7 authored by Sam Mortimer's avatar Sam Mortimer Committed by Danny Baumann
Browse files

Restore ProfileGroup notification override functionality

Also clean up a little.

JIRA: CYAN-3164
Change-Id: I9b71a225996315f517b59d2d6f4074175bbf2d64
parent c688a84a
Loading
Loading
Loading
Loading
+10 −21
Original line number Diff line number Diff line
@@ -187,36 +187,40 @@ public final class ProfileGroup implements Parcelable {
    // TODO : add support for LEDs / screen etc.

    /** @hide */
    public Notification processNotification(Notification notification) {

    public void applyOverridesToNotification(Notification notification) {
        switch (mSoundMode) {
            case OVERRIDE:
                notification.sound = mSoundOverride;
                break;
            case SUPPRESS:
                silenceNotification(notification);
                notification.defaults &= ~Notification.DEFAULT_SOUND;
                notification.sound = null;
                break;
            case DEFAULT:
                break;
        }
        switch (mVibrateMode) {
            case OVERRIDE:
                notification.defaults |= Notification.DEFAULT_VIBRATE;
                break;
            case SUPPRESS:
                suppressVibrate(notification);
                notification.defaults &= ~Notification.DEFAULT_VIBRATE;
                notification.vibrate = null;
                break;
            case DEFAULT:
                break;
        }
        switch (mLightsMode) {
            case OVERRIDE:
                notification.defaults |= Notification.DEFAULT_LIGHTS;
                break;
            case SUPPRESS:
                suppressLights(notification);
                notification.defaults &= ~Notification.DEFAULT_LIGHTS;
                notification.flags &= ~Notification.FLAG_SHOW_LIGHTS;
                break;
            case DEFAULT:
                break;
        }
        return notification;
    }

    private boolean validateOverrideUri(Context context, Uri uri) {
@@ -246,21 +250,6 @@ public final class ProfileGroup implements Parcelable {
        }
    }

    private void silenceNotification(Notification notification) {
        notification.defaults &= (~Notification.DEFAULT_SOUND);
        notification.sound = null;
    }

    private void suppressVibrate(Notification notification) {
        notification.defaults &= (~Notification.DEFAULT_VIBRATE);
        notification.vibrate = null;
    }

    private void suppressLights(Notification notification) {
        notification.defaults &= (~Notification.DEFAULT_LIGHTS);
        notification.flags &= (~Notification.FLAG_SHOW_LIGHTS);
    }

    /** @hide */
    @Override
    public int describeContents() {
+5 −10
Original line number Diff line number Diff line
@@ -1939,17 +1939,12 @@ public class NotificationManagerService extends INotificationManager.Stub
                                + n.getPackageName());
                    }

                    try {
                    final ProfileManager profileManager =
                        (ProfileManager) mContext.getSystemService(Context.PROFILE_SERVICE);

                    ProfileGroup group = profileManager.getActiveProfileGroup(pkg);
                    if (group != null) {
                            // FIXME: local variable notification is accessed from within inner class; needs to be declared final
                            //notification = group.processNotification(notification);
                        }
                    } catch(Throwable th) {
                        Log.e(TAG, "An error occurred profiling the notification.", th);
                        group.applyOverridesToNotification(notification);
                    }

                    final boolean alertsDisabled =