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

Commit 1b3972d7 authored by Evan Laird's avatar Evan Laird
Browse files

Create QsInfo and SbInfo boxes for MobileSignalController

Simplify MobileSignalController#notifyListeners() by splitting the QS
and SB portions of the method into their own *Info objects and moving
those calls out to their own methods.

Also adds mNetworkToIconLookup, mProviderModelBehavior, and
mProviderModelSetting to the MobileSignalController logs.

Test: dumpsys
Bug 197851948

Change-Id: Ibdaec230c4a407d23804fb8250809cc877a7f183
Merged-In: Ibdaec230c4a407d23804fb8250809cc877a7f183
parent d145f34c
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -239,6 +239,11 @@ public class SignalIcon {
            return dataConnected && !carrierNetworkChangeMode && activityOut;
            return dataConnected && !carrierNetworkChangeMode && activityOut;
        }
        }


        /** @return true if this state should show a RAT icon in quick settings */
        public boolean showQuickSettingsRatIcon() {
            return dataConnected || isDataDisabledOrNotDefault();
        }

        @Override
        @Override
        protected void toString(StringBuilder builder) {
        protected void toString(StringBuilder builder) {
            super.toString(builder);
            super.toString(builder);
@@ -254,7 +259,8 @@ public class SignalIcon {
            builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
            builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode)
                    .append(',');
                    .append(',');
            builder.append("userSetup=").append(userSetup).append(',');
            builder.append("userSetup=").append(userSetup).append(',');
            builder.append("defaultDataOff=").append(defaultDataOff);
            builder.append("defaultDataOff=").append(defaultDataOff).append(',');
            builder.append("showQuickSettingsRatIcon=").append(showQuickSettingsRatIcon());
        }
        }


        @Override
        @Override
+1 −1
Original line number Original line Diff line number Diff line
@@ -275,7 +275,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
                return;
                return;
            }
            }
            mInfo.dataSubscriptionName = mController.getMobileDataNetworkName();
            mInfo.dataSubscriptionName = mController.getMobileDataNetworkName();
            mInfo.dataContentDescription = indicators.description != null
            mInfo.dataContentDescription = indicators.qsDescription != null
                    ? indicators.typeContentDescriptionHtml : null;
                    ? indicators.typeContentDescriptionHtml : null;
            mInfo.activityIn = indicators.activityIn;
            mInfo.activityIn = indicators.activityIn;
            mInfo.activityOut = indicators.activityOut;
            mInfo.activityOut = indicators.activityOut;
+3 −3
Original line number Original line Diff line number Diff line
@@ -279,9 +279,9 @@ public class InternetTile extends QSTileImpl<SignalState> {
                // Not data sim, don't display.
                // Not data sim, don't display.
                return;
                return;
            }
            }
            mCellularInfo.mDataSubscriptionName = indicators.description == null
            mCellularInfo.mDataSubscriptionName = indicators.qsDescription == null
                    ? mController.getMobileDataNetworkName() : indicators.description;
                    ? mController.getMobileDataNetworkName() : indicators.qsDescription;
            mCellularInfo.mDataContentDescription = indicators.description != null
            mCellularInfo.mDataContentDescription = indicators.qsDescription != null
                    ? indicators.typeContentDescriptionHtml : null;
                    ? indicators.typeContentDescriptionHtml : null;
            mCellularInfo.mMobileSignalIconId = indicators.qsIcon.icon;
            mCellularInfo.mMobileSignalIconId = indicators.qsIcon.icon;
            mCellularInfo.mQsTypeIcon = indicators.qsType;
            mCellularInfo.mQsTypeIcon = indicators.qsType;
+97 −77
Original line number Original line Diff line number Diff line
@@ -385,92 +385,82 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
            dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
            dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
        }
        }


        final boolean dataDisabled = mCurrentState.isDataDisabledOrNotDefault();
        final QsInfo qsInfo = getQsInfo(contentDescription, icons.dataType);

        final SbInfo sbInfo = getSbInfo(contentDescription, icons.dataType);
        if (mProviderModelBehavior) {
            // Show icon in QS when we are connected or data is disabled.
            boolean showDataIcon = mCurrentState.dataConnected || dataDisabled;


            int qsTypeIcon = 0;
            IconState qsIcon = null;
            CharSequence description = null;
            // Only send data sim callbacks to QS.
            if (mCurrentState.dataSim && mCurrentState.isDefault) {
                qsTypeIcon =
                        (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
                qsIcon = new IconState(mCurrentState.enabled
                        && !mCurrentState.isEmergency, getQsCurrentIconId(), contentDescription);
                description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
            }

            showDataIcon &= mCurrentState.dataSim && mCurrentState.isDefault;
            boolean showTriangle = showDataIcon && !mCurrentState.airplaneMode;
            int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
            showDataIcon |= mCurrentState.roaming;
            IconState statusIcon = new IconState(showDataIcon && !mCurrentState.airplaneMode,
                    getCurrentIconId(), contentDescription);
        MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
        MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
                    statusIcon,
                sbInfo.icon,
                    qsIcon,
                qsInfo.icon,
                    typeIcon,
                sbInfo.ratTypeIcon,
                    qsTypeIcon,
                qsInfo.ratTypeIcon,
                mCurrentState.hasActivityIn(),
                mCurrentState.hasActivityIn(),
                mCurrentState.hasActivityOut(),
                mCurrentState.hasActivityOut(),
                dataContentDescription,
                dataContentDescription,
                dataContentDescriptionHtml,
                dataContentDescriptionHtml,
                    description,
                qsInfo.description,
                mSubscriptionInfo.getSubscriptionId(),
                mSubscriptionInfo.getSubscriptionId(),
                mCurrentState.roaming,
                mCurrentState.roaming,
                    showTriangle);
                sbInfo.showTriangle);
        callback.setMobileDataIndicators(mobileDataIndicators);
        callback.setMobileDataIndicators(mobileDataIndicators);
        } else {
    }
            boolean showDataIcon = mCurrentState.dataConnected || dataDisabled;
            IconState statusIcon = new IconState(
                    mCurrentState.enabled && !mCurrentState.airplaneMode,
                    getCurrentIconId(), contentDescription);


    private QsInfo getQsInfo(String contentDescription, int dataTypeIcon) {
        int qsTypeIcon = 0;
        int qsTypeIcon = 0;
        IconState qsIcon = null;
        IconState qsIcon = null;
            CharSequence description = null;
        CharSequence qsDescription = null;
            // Only send data sim callbacks to QS.

            if (mProviderModelSetting) {
        boolean pm = mProviderModelSetting || mProviderModelBehavior;
                if (mCurrentState.dataSim && mCurrentState.isDefault) {
                    qsTypeIcon =
                            (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
                    qsIcon = new IconState(
                            mCurrentState.enabled && !mCurrentState.isEmergency,
                            getQsCurrentIconId(), contentDescription);
                    description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
                }
            } else {
        if (mCurrentState.dataSim) {
        if (mCurrentState.dataSim) {
                    qsTypeIcon =
            // If using provider model behavior, only show QS icons if the state is also default
                            (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
            if (pm && !mCurrentState.isDefault) {
                    qsIcon = new IconState(
                  return new QsInfo(qsTypeIcon, qsIcon, qsDescription);
                            mCurrentState.enabled && !mCurrentState.isEmergency,
                            getQsCurrentIconId(), contentDescription);
                    description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
            }
            }

            if (mCurrentState.showQuickSettingsRatIcon() || mConfig.alwaysShowDataRatIcon) {
                qsTypeIcon = dataTypeIcon;
            }
            }


            showDataIcon &= mCurrentState.isDefault || dataDisabled;
            boolean qsIconVisible = mCurrentState.enabled && !mCurrentState.isEmergency;
            int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
            qsIcon = new IconState(qsIconVisible, getQsCurrentIconId(), contentDescription);
            boolean showTriangle = mCurrentState.enabled && !mCurrentState.airplaneMode;

            MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
            if (!mCurrentState.isEmergency) {
                    statusIcon,
                qsDescription = mCurrentState.networkName;
                    qsIcon,
            }
                    typeIcon,
                    qsTypeIcon,
                    mCurrentState.hasActivityIn(),
                    mCurrentState.hasActivityOut(),
                    dataContentDescription,
                    dataContentDescriptionHtml,
                    description,
                    mSubscriptionInfo.getSubscriptionId(),
                    mCurrentState.roaming,
                    showTriangle);
            callback.setMobileDataIndicators(mobileDataIndicators);
        }
        }

        return new QsInfo(qsTypeIcon, qsIcon, qsDescription);
    }

    private SbInfo getSbInfo(String contentDescription, int dataTypeIcon) {
        final boolean dataDisabled = mCurrentState.isDataDisabledOrNotDefault();
        boolean showTriangle = false;
        int typeIcon = 0;
        IconState statusIcon = null;

        if (mProviderModelBehavior) {
            boolean showDataIconStatusBar = (mCurrentState.dataConnected || dataDisabled)
                    && (mCurrentState.dataSim && mCurrentState.isDefault);
            typeIcon =
                    (showDataIconStatusBar || mConfig.alwaysShowDataRatIcon) ? dataTypeIcon : 0;
            showDataIconStatusBar |= mCurrentState.roaming;
            statusIcon = new IconState(
                    showDataIconStatusBar && !mCurrentState.airplaneMode,
                    getCurrentIconId(), contentDescription);

            showTriangle = showDataIconStatusBar && !mCurrentState.airplaneMode;
        } else {
            statusIcon = new IconState(
                    mCurrentState.enabled && !mCurrentState.airplaneMode,
                    getCurrentIconId(), contentDescription);

            boolean showDataIconInStatusBar =
                    (mCurrentState.dataConnected && mCurrentState.isDefault) || dataDisabled;
            typeIcon =
                    (showDataIconInStatusBar || mConfig.alwaysShowDataRatIcon) ? dataTypeIcon : 0;
            showTriangle = mCurrentState.enabled && !mCurrentState.airplaneMode;
        }

        return new SbInfo(showTriangle, typeIcon, statusIcon);
    }
    }


    @Override
    @Override
@@ -844,12 +834,15 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
    public void dump(PrintWriter pw) {
    public void dump(PrintWriter pw) {
        super.dump(pw);
        super.dump(pw);
        pw.println("  mSubscription=" + mSubscriptionInfo + ",");
        pw.println("  mSubscription=" + mSubscriptionInfo + ",");
        pw.println("  mProviderModelSetting=" + mProviderModelSetting + ",");
        pw.println("  mProviderModelBehavior=" + mProviderModelBehavior + ",");
        pw.println("  mServiceState=" + mServiceState + ",");
        pw.println("  mServiceState=" + mServiceState + ",");
        pw.println("  mSignalStrength=" + mSignalStrength + ",");
        pw.println("  mSignalStrength=" + mSignalStrength + ",");
        pw.println("  mTelephonyDisplayInfo=" + mTelephonyDisplayInfo + ",");
        pw.println("  mTelephonyDisplayInfo=" + mTelephonyDisplayInfo + ",");
        pw.println("  mDataState=" + mDataState + ",");
        pw.println("  mDataState=" + mDataState + ",");
        pw.println("  mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
        pw.println("  mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
        pw.println("  isDataDisabled=" + isDataDisabled() + ",");
        pw.println("  isDataDisabled=" + isDataDisabled() + ",");
        pw.println("  mNetworkToIconLookup=" + mNetworkToIconLookup + ",");
        pw.println("  MobileStatusHistory");
        pw.println("  MobileStatusHistory");
        int size = 0;
        int size = 0;
        for (int i = 0; i < STATUS_HISTORY_SIZE; i++) {
        for (int i = 0; i < STATUS_HISTORY_SIZE; i++) {
@@ -865,4 +858,31 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
                    + mMobileStatusHistory[i & (STATUS_HISTORY_SIZE - 1)]);
                    + mMobileStatusHistory[i & (STATUS_HISTORY_SIZE - 1)]);
        }
        }
    }
    }

    /** Box for QS icon info */
    private static final class QsInfo {
        final int ratTypeIcon;
        final IconState icon;
        final CharSequence description;

        QsInfo(int typeIcon, IconState iconState, CharSequence desc) {
            ratTypeIcon = typeIcon;
            icon = iconState;
            description = desc;
        }
    }

    /** Box for StatusBar icon info */
    private static final class SbInfo {
        final boolean showTriangle;
        final int ratTypeIcon;
        final IconState icon;

        SbInfo(boolean show, int typeIcon, IconState iconState) {
            showTriangle = show;
            ratTypeIcon = typeIcon;
            icon = iconState;
        }
    }

}
}
+11 −9
Original line number Original line Diff line number Diff line
@@ -81,7 +81,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
                .append(",qsIcon=").append(qsIcon == null ? "" : qsIcon.toString())
                .append(",qsIcon=").append(qsIcon == null ? "" : qsIcon.toString())
                .append(",activityIn=").append(activityIn)
                .append(",activityIn=").append(activityIn)
                .append(",activityOut=").append(activityOut)
                .append(",activityOut=").append(activityOut)
                .append(",description=").append(description)
                .append(",qsDescription=").append(description)
                .append(",isTransient=").append(isTransient)
                .append(",isTransient=").append(isTransient)
                .append(",statusLabel=").append(statusLabel)
                .append(",statusLabel=").append(statusLabel)
                .append(']').toString();
                .append(']').toString();
@@ -100,7 +100,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
        public boolean activityOut;
        public boolean activityOut;
        public CharSequence typeContentDescription;
        public CharSequence typeContentDescription;
        public CharSequence typeContentDescriptionHtml;
        public CharSequence typeContentDescriptionHtml;
        public CharSequence description;
        public CharSequence qsDescription;
        public int subId;
        public int subId;
        public boolean roaming;
        public boolean roaming;
        public boolean showTriangle;
        public boolean showTriangle;
@@ -108,7 +108,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
        public MobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
        public MobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
                int qsType, boolean activityIn, boolean activityOut,
                int qsType, boolean activityIn, boolean activityOut,
                CharSequence typeContentDescription, CharSequence typeContentDescriptionHtml,
                CharSequence typeContentDescription, CharSequence typeContentDescriptionHtml,
                CharSequence description, int subId, boolean roaming,
                CharSequence qsDescription, int subId, boolean roaming,
                boolean showTriangle) {
                boolean showTriangle) {
            this.statusIcon = statusIcon;
            this.statusIcon = statusIcon;
            this.qsIcon = qsIcon;
            this.qsIcon = qsIcon;
@@ -118,7 +118,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
            this.activityOut = activityOut;
            this.activityOut = activityOut;
            this.typeContentDescription = typeContentDescription;
            this.typeContentDescription = typeContentDescription;
            this.typeContentDescriptionHtml = typeContentDescriptionHtml;
            this.typeContentDescriptionHtml = typeContentDescriptionHtml;
            this.description = description;
            this.qsDescription = qsDescription;
            this.subId = subId;
            this.subId = subId;
            this.roaming = roaming;
            this.roaming = roaming;
            this.showTriangle = showTriangle;
            this.showTriangle = showTriangle;
@@ -135,7 +135,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
                .append(",activityOut=").append(activityOut)
                .append(",activityOut=").append(activityOut)
                .append(",typeContentDescription=").append(typeContentDescription)
                .append(",typeContentDescription=").append(typeContentDescription)
                .append(",typeContentDescriptionHtml=").append(typeContentDescriptionHtml)
                .append(",typeContentDescriptionHtml=").append(typeContentDescriptionHtml)
                .append(",description=").append(description)
                .append(",description=").append(qsDescription)
                .append(",subId=").append(subId)
                .append(",subId=").append(subId)
                .append(",roaming=").append(roaming)
                .append(",roaming=").append(roaming)
                .append(",showTriangle=").append(showTriangle)
                .append(",showTriangle=").append(showTriangle)
@@ -183,11 +183,13 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
        default void setCallIndicator(IconState statusIcon, int subId) {}
        default void setCallIndicator(IconState statusIcon, int subId) {}
    }
    }


    public interface EmergencyListener {
    /** */
    interface EmergencyListener {
        void setEmergencyCallsOnly(boolean emergencyOnly);
        void setEmergencyCallsOnly(boolean emergencyOnly);
    }
    }


    public static class IconState {
    /** */
    class IconState {
        public final boolean visible;
        public final boolean visible;
        public final int icon;
        public final int icon;
        public final String contentDescription;
        public final String contentDescription;
@@ -217,7 +219,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
     * Tracks changes in access points.  Allows listening for changes, scanning for new APs,
     * Tracks changes in access points.  Allows listening for changes, scanning for new APs,
     * and connecting to new ones.
     * and connecting to new ones.
     */
     */
    public interface AccessPointController {
    interface AccessPointController {
        void addAccessPointCallback(AccessPointCallback callback);
        void addAccessPointCallback(AccessPointCallback callback);
        void removeAccessPointCallback(AccessPointCallback callback);
        void removeAccessPointCallback(AccessPointCallback callback);
        void scanForAccessPoints();
        void scanForAccessPoints();
@@ -227,7 +229,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
        boolean canConfigWifi();
        boolean canConfigWifi();
        boolean canConfigMobileData();
        boolean canConfigMobileData();


        public interface AccessPointCallback {
        interface AccessPointCallback {
            void onAccessPointsChanged(List<WifiEntry> accessPoints);
            void onAccessPointsChanged(List<WifiEntry> accessPoints);
            void onSettingsActivityTriggered(Intent settingsIntent);
            void onSettingsActivityTriggered(Intent settingsIntent);
        }
        }
Loading