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

Commit ec767cc4 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Channel updates from users lock fields from interference.

Also some apis have changed.

Test: manual, modify settings and check policy xml.

Change-Id: I967cb1fb30d8d400bdc0f3aa92fa07b4c87ddcf5
parent 80d1ec7d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.settings.applications;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.UserHandle;
@@ -92,8 +93,8 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
                return false;
            }
            AppRow row = (AppRow) info.extraInfo;
            return row.appImportance > NotificationListenerService.Ranking.IMPORTANCE_NONE
                    && row.appImportance < NotificationListenerService.Ranking.IMPORTANCE_DEFAULT;
            return row.appImportance > NotificationManager.IMPORTANCE_NONE
                    && row.appImportance < NotificationManager.IMPORTANCE_DEFAULT;
        }
    };

+4 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.LoaderManager.LoaderCallbacks;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.admin.DevicePolicyManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
@@ -1099,15 +1100,15 @@ public class InstalledAppDetails extends AppInfoBase
        List<String> summaryAttributes = new ArrayList<>();
        StringBuffer summary = new StringBuffer();
        if (showSlider) {
            if (appRow.appImportance != Ranking.IMPORTANCE_UNSPECIFIED) {
            if (appRow.appImportance != NotificationManager.IMPORTANCE_UNSPECIFIED) {
                summaryAttributes.add(context.getString(
                        R.string.notification_summary_level, appRow.appImportance));
            }
        } else {
            if (appRow.banned) {
                summaryAttributes.add(context.getString(R.string.notifications_disabled));
            } else if (appRow.appImportance > Ranking.IMPORTANCE_NONE
                    && appRow.appImportance < Ranking.IMPORTANCE_DEFAULT) {
            } else if (appRow.appImportance > NotificationManager.IMPORTANCE_NONE
                    && appRow.appImportance < NotificationManager.IMPORTANCE_DEFAULT) {
                summaryAttributes.add(context.getString(R.string.notifications_silenced));
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
            mChannelList = mBackend.getChannels(mPkg, mUid).getList();

            setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned,
                    NotificationManager.IMPORTANCE_MAX);
                    NotificationManager.IMPORTANCE_HIGH);
            setupPriorityPref(mAppRow.appBypassDnd);
            setupVisOverridePref(mAppRow.appVisOverride);

+8 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.notification;

import android.app.Activity;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.net.Uri;
@@ -24,6 +25,7 @@ import android.os.Bundle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
import android.support.v7.preference.Preference;
import android.view.View;

import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.AppHeader;
@@ -94,7 +96,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
            setupVibrate();
            setupRingtone();
            mMaxImportance = mAppRow.appImportance == NotificationManager.IMPORTANCE_UNSPECIFIED
                    ? NotificationManager.IMPORTANCE_MAX : mAppRow.appImportance;
                    ? NotificationManager.IMPORTANCE_HIGH : mAppRow.appImportance;
            setupImportancePrefs(false, mChannel.getImportance(),
                    mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE,
                    mMaxImportance);
@@ -141,6 +143,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                final boolean lights = (Boolean) newValue;
                mChannel.setLights(lights);
                mChannel.lockFields(NotificationChannel.USER_LOCKED_LIGHTS);
                mBackend.updateChannel(mPkg, mUid, mChannel);
                return true;
            }
@@ -155,6 +158,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                final boolean vibrate = (Boolean) newValue;
                mChannel.setVibration(vibrate);
                mChannel.lockFields(NotificationChannel.USER_LOCKED_VIBRATION);
                mBackend.updateChannel(mPkg, mUid, mChannel);
                return true;
            }
@@ -162,13 +166,14 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
    }

    private void setupRingtone() {
        mRingtone.setRingtone(mChannel.getDefaultRingtone());
        mRingtone.setRingtone(mChannel.getRingtone());
        mRingtone.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                Uri ringtone = Uri.parse((String) newValue);
                mRingtone.setRingtone(ringtone);
                mChannel.setDefaultRingtone(ringtone);
                mChannel.setRingtone(ringtone);
                mChannel.lockFields(NotificationChannel.USER_LOCKED_RINGTONE);
                mBackend.updateChannel(mPkg, mUid, mChannel);
                return false;
            }
+12 −15
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.notification;
import com.android.settings.R;
import com.android.settings.SeekBarPreference;

import android.app.NotificationManager;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
@@ -119,12 +120,10 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
    private void applyAuto(ImageView autoButton) {
        mAutoOn = !mAutoOn;
        if (!mAutoOn) {
            setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT);
            mCallback.onImportanceChanged(
                    NotificationListenerService.Ranking.IMPORTANCE_DEFAULT, true);
            setProgress(NotificationManager.IMPORTANCE_DEFAULT);
            mCallback.onImportanceChanged(NotificationManager.IMPORTANCE_DEFAULT, true);
        } else {
            mCallback.onImportanceChanged(
                    NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED, true);
            mCallback.onImportanceChanged(NotificationManager.IMPORTANCE_UNSPECIFIED, true);
        }
        applyAutoUi(autoButton);
    }
@@ -140,9 +139,8 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
        mSeekBar.setAlpha(alpha);

        if (mAutoOn) {
            setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT);
            mSummary = getProgressSummary(
                    NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED);
            setProgress(NotificationManager.IMPORTANCE_DEFAULT);
            mSummary = getProgressSummary(NotificationManager.IMPORTANCE_UNSPECIFIED);
        }
        mSummaryTextView.setText(mSummary);
    }
@@ -168,18 +166,17 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements

    private String getProgressSummary(int progress) {
        switch (progress) {
            case NotificationListenerService.Ranking.IMPORTANCE_NONE:
            case NotificationManager.IMPORTANCE_NONE:
                return getContext().getString(R.string.notification_importance_blocked);
            case NotificationListenerService.Ranking.IMPORTANCE_MIN:
            case NotificationManager.IMPORTANCE_MIN:
                return getContext().getString(R.string.notification_importance_min);
            case NotificationListenerService.Ranking.IMPORTANCE_LOW:
            case NotificationManager.IMPORTANCE_LOW:
                return getContext().getString(R.string.notification_importance_low);
            case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
            case NotificationManager.IMPORTANCE_DEFAULT:
                return getContext().getString(R.string.notification_importance_default);
            case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
            case NotificationManager.IMPORTANCE_HIGH:
            case NotificationManager.IMPORTANCE_MAX:
                return getContext().getString(R.string.notification_importance_high);
            case NotificationListenerService.Ranking.IMPORTANCE_MAX:
                return getContext().getString(R.string.notification_importance_max);
            default:
                return getContext().getString(R.string.notification_importance_unspecified);
        }
Loading