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

Commit 1781cf2c authored by Fan Zhang's avatar Fan Zhang
Browse files

Remove wrapper class for NotificationGroup.

It's no longer needed as Robolectric can natively support framework
classes

Bug: 76167422
Test: robotests
Change-Id: If0ac597370240b8efaa8df8783a5c309a2322a3f
parent 234854cb
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
        }
        if (mChannel != null) {
            return isChannelBlockable();
        } else if (mChannelGroup != null && mChannelGroup.getGroup() != null) {
        } else if (mChannelGroup != null) {
            return isChannelGroupBlockable();
        } else {
            return !mAppRow.systemApp || (mAppRow.systemApp && mAppRow.banned);
@@ -80,7 +80,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
            if (mChannel != null) {
                bar.setChecked(!mAppRow.banned
                        && mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
            } else if (mChannelGroup != null && mChannelGroup.getGroup() != null) {
            } else if (mChannelGroup != null) {
                bar.setChecked(!mAppRow.banned && !mChannelGroup.isBlocked());
            } else {
                bar.setChecked(!mAppRow.banned);
@@ -107,9 +107,9 @@ public class BlockPreferenceController extends NotificationPreferenceController
                mAppRow.banned = blocked;
                mBackend.setNotificationsEnabledForPackage(mAppRow.pkg, mAppRow.uid, !blocked);
            }
        } else if (mChannelGroup != null && mChannelGroup.getGroup() != null) {
        } else if (mChannelGroup != null) {
            mChannelGroup.setBlocked(blocked);
            mBackend.updateChannelGroup(mAppRow.pkg, mAppRow.uid, mChannelGroup.getGroup());
            mBackend.updateChannelGroup(mAppRow.pkg, mAppRow.uid, mChannelGroup);
        } else if (mAppRow != null) {
            mAppRow.banned = blocked;
            mBackend.setNotificationsEnabledForPackage(mAppRow.pkg, mAppRow.uid, !blocked);
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class ChannelGroupNotificationSettings extends NotificationSettingsBase {
    @Override
    public void onResume() {
        super.onResume();
        if (mAppRow == null || mChannelGroup == null || mChannelGroup.getGroup() == null) {
        if (mAppRow == null || mChannelGroup == null) {
            Log.w(TAG, "Missing package or uid or packageinfo or group");
            finish();
            return;
@@ -85,7 +85,7 @@ public class ChannelGroupNotificationSettings extends NotificationSettingsBase {
                getPreferenceScreen().removePreference(p);
            }
        }
        if (mChannelGroup.getGroup().getChannels().isEmpty()) {
        if (mChannelGroup.getChannels().isEmpty()) {
            Preference empty = new Preference(getPrefContext());
            empty.setTitle(R.string.no_channels);
            empty.setEnabled(false);
@@ -93,7 +93,7 @@ public class ChannelGroupNotificationSettings extends NotificationSettingsBase {
            mDynamicPreferences.add(empty);

        } else {
            final List<NotificationChannel> channels = mChannelGroup.getGroup().getChannels();
            final List<NotificationChannel> channels = mChannelGroup.getChannels();
            Collections.sort(channels, mChannelComparator);
            for (NotificationChannel channel : channels) {
                mDynamicPreferences.add(populateSingleChannelPrefs(
+15 −15
Original line number Diff line number Diff line
@@ -73,27 +73,27 @@ public class HeaderPreferenceController extends NotificationPreferenceController

    CharSequence getLabel() {
        return mChannel != null ? mChannel.getName()
                : mChannelGroup != null && mChannelGroup.getGroup() != null
                        ? mChannelGroup.getGroup().getName()
                : mChannelGroup != null
                        ? mChannelGroup.getName()
                        : mAppRow.label;
    }

    @Override
    public CharSequence getSummary() {
        if (mChannel != null) {
           if (mChannelGroup != null && mChannelGroup.getGroup() != null
                && !TextUtils.isEmpty(mChannelGroup.getGroup().getName())) {
            if (mChannelGroup != null
                    && !TextUtils.isEmpty(mChannelGroup.getName())) {
                final SpannableStringBuilder summary = new SpannableStringBuilder();
                BidiFormatter bidi = BidiFormatter.getInstance();
                summary.append(bidi.unicodeWrap(mAppRow.label.toString()));
                summary.append(bidi.unicodeWrap(mContext.getText(
                        R.string.notification_header_divider_symbol_with_spaces)));
               summary.append(bidi.unicodeWrap(mChannelGroup.getGroup().getName().toString()));
                summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString()));
                return summary.toString();
            } else {
                return mAppRow.label.toString();
            }
        } else if (mChannelGroup != null && mChannelGroup.getGroup() != null) {
        } else if (mChannelGroup != null) {
            return mAppRow.label.toString();
        } else {
            return "";
+9 −10
Original line number Diff line number Diff line
@@ -25,13 +25,11 @@ import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;

import com.android.settings.wrapper.NotificationChannelGroupWrapper;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.core.AbstractPreferenceController;

@@ -41,11 +39,12 @@ import java.util.Objects;
 * Parent class for preferences appearing on notification setting pages at the app,
 * notification channel group, or notification channel level.
 */
public abstract class NotificationPreferenceController extends AbstractPreferenceController
{
public abstract class NotificationPreferenceController extends AbstractPreferenceController {
    private static final String TAG = "ChannelPrefContr";
    @Nullable protected NotificationChannel mChannel;
    @Nullable protected NotificationChannelGroupWrapper mChannelGroup;
    @Nullable
    protected NotificationChannel mChannel;
    @Nullable
    protected NotificationChannelGroup mChannelGroup;
    protected RestrictedLockUtils.EnforcedAdmin mAdmin;
    protected NotificationBackend.AppRow mAppRow;
    protected final NotificationManager mNm;
@@ -78,7 +77,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
        if (mChannel != null) {
            return mChannel.getImportance() != IMPORTANCE_NONE;
        }
        if (mChannelGroup != null && mChannelGroup.getGroup() == null) {
        if (mChannelGroup != null) {
            return !mChannelGroup.isBlocked();
        }
        return true;
@@ -125,7 +124,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
    }

    protected void onResume(NotificationBackend.AppRow appRow,
            @Nullable NotificationChannel channel, @Nullable NotificationChannelGroupWrapper group,
            @Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
            RestrictedLockUtils.EnforcedAdmin admin) {
        mAppRow = appRow;
        mChannel = channel;
@@ -172,7 +171,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
    }

    protected boolean isChannelGroupBlockable() {
        if (mChannelGroup != null && mChannelGroup.getGroup() != null && mAppRow != null) {
        if (mChannelGroup != null && mAppRow != null) {
            if (!mAppRow.systemApp) {
                return true;
            }
@@ -183,6 +182,6 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
    }

    protected boolean hasValidGroup() {
        return mChannelGroup != null && mChannelGroup.getGroup() != null;
        return mChannelGroup != null;
    }
}
+3 −4
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.MasterCheckBoxPreference;
import com.android.settings.wrapper.NotificationChannelGroupWrapper;
import com.android.settingslib.RestrictedLockUtils;

import java.util.ArrayList;
@@ -70,7 +69,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
    protected String mPkg;
    protected PackageInfo mPkgInfo;
    protected EnforcedAdmin mSuspendedAppsAdmin;
    protected NotificationChannelGroupWrapper mChannelGroup;
    protected NotificationChannelGroup mChannelGroup;
    protected NotificationChannel mChannel;
    protected NotificationBackend.AppRow mAppRow;

@@ -168,7 +167,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
        if (mChannel != null && !TextUtils.isEmpty(mChannel.getGroup())) {
            group = mBackend.getGroup(mPkg, mUid, mChannel.getGroup());
            if (group != null) {
                mChannelGroup = new NotificationChannelGroupWrapper(group);
                mChannelGroup = group;
            }
        }
    }
@@ -209,7 +208,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
            }
            if (mChannelGroup != null) {
                mAppRow.settingsIntent.putExtra(
                        Notification.EXTRA_CHANNEL_GROUP_ID, mChannelGroup.getGroup().getId());
                        Notification.EXTRA_CHANNEL_GROUP_ID, mChannelGroup.getId());
            }
        }
    }
Loading