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

Commit e6a18f81 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "remove_wrappers" into pi-dev

* changes:
  Remove wrapper class for NotificationGroup.
  Remove more wrappers in favor of new Robolectric support
parents 8608f6b0 1781cf2c
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.net.ConnectivityManager;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;

import com.android.settings.wrapper.UsbManagerWrapper;
import com.android.settings.wrapper.UserManagerWrapper;

/**
@@ -44,7 +43,6 @@ public class UsbBackend {
    private final boolean mTetheringSupported;

    private UsbManager mUsbManager;
    private UsbManagerWrapper mUsbManagerWrapper;

    @Nullable
    private UsbPort mPort;
@@ -52,19 +50,13 @@ public class UsbBackend {
    private UsbPortStatus mPortStatus;

    public UsbBackend(Context context) {
        this(context, new UserManagerWrapper(UserManager.get(context)), null);
        this(context, new UserManagerWrapper(UserManager.get(context)));
    }

    @VisibleForTesting
    public UsbBackend(Context context, UserManagerWrapper userManagerWrapper,
            UsbManagerWrapper usbManagerWrapper) {
    public UsbBackend(Context context, UserManagerWrapper userManagerWrapper) {
        mUsbManager = context.getSystemService(UsbManager.class);

        mUsbManagerWrapper = usbManagerWrapper;
        if (mUsbManagerWrapper == null) {
            mUsbManagerWrapper = new UsbManagerWrapper(mUsbManager);
        }

        mFileTransferRestricted = userManagerWrapper.isUsbFileTransferRestricted();
        mFileTransferRestrictedBySystem = userManagerWrapper.isUsbFileTransferRestrictedBySystem();
        mTetheringRestricted = userManagerWrapper.isUsbTetheringRestricted();
@@ -79,7 +71,7 @@ public class UsbBackend {
    }

    public long getCurrentFunctions() {
        return mUsbManagerWrapper.getCurrentFunctions();
        return mUsbManager.getCurrentFunctions();
    }

    public void setCurrentFunctions(long functions) {
+5 −12
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.support.v7.preference.PreferenceScreen;
import android.util.Log;

import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.wrapper.PowerManagerWrapper;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -72,21 +71,15 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
        };

    public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle) {
        this(context, lifecycle, new PowerManagerWrapper(
                (PowerManager) context.getSystemService(Context.POWER_SERVICE)));
    }

    @VisibleForTesting
    public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle,
            PowerManagerWrapper powerManagerWrapper) {
        super(context);
        if (lifecycle != null) {
            lifecycle.addObserver(this);
        }
        mMinBrightness = powerManagerWrapper.getMinimumScreenBrightnessSetting();
        mMaxBrightness = powerManagerWrapper.getMaximumScreenBrightnessSetting();
        mMinVrBrightness = powerManagerWrapper.getMinimumScreenBrightnessForVrSetting();
        mMaxVrBrightness = powerManagerWrapper.getMaximumScreenBrightnessForVrSetting();
        PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mMinBrightness = powerManager.getMinimumScreenBrightnessSetting();
        mMaxBrightness = powerManager.getMaximumScreenBrightnessSetting();
        mMinVrBrightness = powerManager.getMinimumScreenBrightnessForVrSetting();
        mMaxVrBrightness = powerManager.getMaximumScreenBrightnessForVrSetting();
        mContentResolver = mContext.getContentResolver();
    }

+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 "";
Loading