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

Commit fdc42429 authored by Shuo Qian's avatar Shuo Qian
Browse files

Integrate the mechanism that always enable or disable signal strength

 reporting in Telephony framework, such as DeviceStateMonitor.

Test: WIP (Have this CL out to try to catch up the API deadline)
Bug: 147322848

Change-Id: I12e2015dbea1da6afe9c4ec62342424b111d4b0b
parent 99a910bc
Loading
Loading
Loading
Loading
+25 −3
Original line number Original line Diff line number Diff line
@@ -36,7 +36,6 @@ import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import com.android.telephony.Rlog;
import android.telephony.SignalThresholdInfo;
import android.telephony.SignalThresholdInfo;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.util.LocalLog;
import android.util.LocalLog;
@@ -45,6 +44,7 @@ import android.view.Display;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.IndentingPrintWriter;
import com.android.telephony.Rlog;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -76,6 +76,7 @@ public class DeviceStateMonitor extends Handler {
    static final int EVENT_RADIO_AVAILABLE              = 6;
    static final int EVENT_RADIO_AVAILABLE              = 6;
    @VisibleForTesting
    @VisibleForTesting
    static final int EVENT_WIFI_CONNECTION_CHANGED      = 7;
    static final int EVENT_WIFI_CONNECTION_CHANGED      = 7;
    static final int EVENT_UPDATE_ALWAYS_REPORT_SIGNAL_STRENGTH = 8;


    // TODO(b/74006656) load hysteresis values from a property when DeviceStateMonitor starts
    // TODO(b/74006656) load hysteresis values from a property when DeviceStateMonitor starts
    private static final int HYSTERESIS_KBPS = 50;
    private static final int HYSTERESIS_KBPS = 50;
@@ -163,6 +164,11 @@ public class DeviceStateMonitor extends Handler {
     */
     */
    private boolean mIsWifiConnected;
    private boolean mIsWifiConnected;


    /**
     * True indicates we should always enable the signal strength reporting from radio.
     */
    private boolean mIsAlwaysSignalStrengthReportingEnabled;

    @VisibleForTesting
    @VisibleForTesting
    static final int CELL_INFO_INTERVAL_SHORT_MS = 2000;
    static final int CELL_INFO_INTERVAL_SHORT_MS = 2000;
    @VisibleForTesting
    @VisibleForTesting
@@ -313,7 +319,8 @@ public class DeviceStateMonitor extends Handler {
        // 3. When the update mode is IGNORE_SCREEN_OFF. This mode is used in some corner cases like
        // 3. When the update mode is IGNORE_SCREEN_OFF. This mode is used in some corner cases like
        //    when Bluetooth carkit is connected, we still want to update signal strength even
        //    when Bluetooth carkit is connected, we still want to update signal strength even
        //    when screen is off.
        //    when screen is off.
        if (mIsCharging || mIsScreenOn
        // 4. Any of system services is registrating to always listen to signal strength changes
        if (mIsAlwaysSignalStrengthReportingEnabled || mIsCharging || mIsScreenOn
                || mUpdateModes.get(TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH)
                || mUpdateModes.get(TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH)
                == TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF) {
                == TelephonyManager.INDICATION_UPDATE_MODE_IGNORE_SCREEN_OFF) {
            return false;
            return false;
@@ -410,6 +417,15 @@ public class DeviceStateMonitor extends Handler {
        sendMessage(obtainMessage(EVENT_UPDATE_MODE_CHANGED, filters, mode));
        sendMessage(obtainMessage(EVENT_UPDATE_MODE_CHANGED, filters, mode));
    }
    }


    /**
     * Set if Telephony need always report signal strength.
     *
     * @param isEnable
     */
    public void setAlwaysReportSignalStrength(boolean isEnable) {
        sendMessage(obtainMessage(EVENT_UPDATE_ALWAYS_REPORT_SIGNAL_STRENGTH, isEnable ? 1 : 0));
    }

    private void onSetIndicationUpdateMode(int filters, int mode) {
    private void onSetIndicationUpdateMode(int filters, int mode) {
        if ((filters & TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH) != 0) {
        if ((filters & TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH) != 0) {
            mUpdateModes.put(TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, mode);
            mUpdateModes.put(TelephonyManager.INDICATION_FILTER_SIGNAL_STRENGTH, mode);
@@ -453,6 +469,9 @@ public class DeviceStateMonitor extends Handler {
            case EVENT_WIFI_CONNECTION_CHANGED:
            case EVENT_WIFI_CONNECTION_CHANGED:
                onUpdateDeviceState(msg.what, msg.arg1 != WIFI_UNAVAILABLE);
                onUpdateDeviceState(msg.what, msg.arg1 != WIFI_UNAVAILABLE);
                break;
                break;
            case EVENT_UPDATE_ALWAYS_REPORT_SIGNAL_STRENGTH:
                onUpdateDeviceState(msg.what, msg.arg1 != 0);
                break;
            default:
            default:
                throw new IllegalStateException("Unexpected message arrives. msg = " + msg.what);
                throw new IllegalStateException("Unexpected message arrives. msg = " + msg.what);
        }
        }
@@ -487,7 +506,10 @@ public class DeviceStateMonitor extends Handler {
            case EVENT_WIFI_CONNECTION_CHANGED:
            case EVENT_WIFI_CONNECTION_CHANGED:
                if (mIsWifiConnected == state) return;
                if (mIsWifiConnected == state) return;
                mIsWifiConnected = state;
                mIsWifiConnected = state;

                break;
            case EVENT_UPDATE_ALWAYS_REPORT_SIGNAL_STRENGTH:
                if (mIsAlwaysSignalStrengthReportingEnabled == state) return;
                mIsAlwaysSignalStrengthReportingEnabled = state;
                break;
                break;
            default:
            default:
                return;
                return;
+12 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,6 @@ import android.telephony.PhoneStateListener;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
import android.telephony.PreciseDataConnectionState;
import android.telephony.RadioAccessFamily;
import android.telephony.RadioAccessFamily;
import com.android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
@@ -87,6 +86,7 @@ import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UiccController;
import com.android.internal.telephony.uicc.UsimServiceTable;
import com.android.internal.telephony.uicc.UsimServiceTable;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.telephony.Rlog;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -3264,6 +3264,17 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
        }
    }
    }


    /**
     * Enable or disable always reporting signal strength changes from radio.
     *
     * @param isEnable {@code true} for enabling; {@code false} for disabling.
     */
    public void setAlwaysReportSignalStrength(boolean isEnable) {
        if (mDeviceStateMonitor != null) {
            mDeviceStateMonitor.setAlwaysReportSignalStrength(isEnable);
        }
    }

    /**
    /**
     * TODO: Adding a function for each property is not good.
     * TODO: Adding a function for each property is not good.
     * A fucntion of type getPhoneProp(propType) where propType is an
     * A fucntion of type getPhoneProp(propType) where propType is an