Merge "Create Central Version of dataStateToString()" am: 8abad0504e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1436522 Change-Id: Ia3fc57e42b5433f6ccbc3841877d46a0c420ea2c
This commit is contained in:
@@ -89,6 +89,7 @@ import com.android.internal.telephony.IOnSubscriptionsChangedListener;
|
|||||||
import com.android.internal.telephony.IPhoneStateListener;
|
import com.android.internal.telephony.IPhoneStateListener;
|
||||||
import com.android.internal.telephony.ITelephonyRegistry;
|
import com.android.internal.telephony.ITelephonyRegistry;
|
||||||
import com.android.internal.telephony.TelephonyPermissions;
|
import com.android.internal.telephony.TelephonyPermissions;
|
||||||
|
import com.android.internal.telephony.util.TelephonyUtils;
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
import com.android.internal.util.DumpUtils;
|
import com.android.internal.util.DumpUtils;
|
||||||
import com.android.internal.util.FrameworkStatsLog;
|
import com.android.internal.util.FrameworkStatsLog;
|
||||||
@@ -1723,7 +1724,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
&& (mDataConnectionState[phoneId] != state
|
&& (mDataConnectionState[phoneId] != state
|
||||||
|| mDataConnectionNetworkType[phoneId] != networkType)) {
|
|| mDataConnectionNetworkType[phoneId] != networkType)) {
|
||||||
String str = "onDataConnectionStateChanged("
|
String str = "onDataConnectionStateChanged("
|
||||||
+ dataStateToString(state)
|
+ TelephonyUtils.dataStateToString(state)
|
||||||
+ ", " + getNetworkTypeName(networkType)
|
+ ", " + getNetworkTypeName(networkType)
|
||||||
+ ") subId=" + subId + ", phoneId=" + phoneId;
|
+ ") subId=" + subId + ", phoneId=" + phoneId;
|
||||||
log(str);
|
log(str);
|
||||||
@@ -2580,7 +2581,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
// status bar takes care of that after taking into account all of the
|
// status bar takes care of that after taking into account all of the
|
||||||
// required info.
|
// required info.
|
||||||
Intent intent = new Intent(ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
|
Intent intent = new Intent(ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
|
||||||
intent.putExtra(PHONE_CONSTANTS_STATE_KEY, dataStateToString(state));
|
intent.putExtra(PHONE_CONSTANTS_STATE_KEY, TelephonyUtils.dataStateToString(state));
|
||||||
intent.putExtra(PHONE_CONSTANTS_DATA_APN_KEY, apn);
|
intent.putExtra(PHONE_CONSTANTS_DATA_APN_KEY, apn);
|
||||||
intent.putExtra(PHONE_CONSTANTS_DATA_APN_TYPE_KEY,
|
intent.putExtra(PHONE_CONSTANTS_DATA_APN_TYPE_KEY,
|
||||||
ApnSetting.getApnTypesStringFromBitmask(apnType));
|
ApnSetting.getApnTypesStringFromBitmask(apnType));
|
||||||
@@ -2937,21 +2938,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert TelephonyManager.DATA_* to string.
|
|
||||||
*
|
|
||||||
* @return The data state in string format.
|
|
||||||
*/
|
|
||||||
private static String dataStateToString(int state) {
|
|
||||||
switch (state) {
|
|
||||||
case TelephonyManager.DATA_DISCONNECTED: return "DISCONNECTED";
|
|
||||||
case TelephonyManager.DATA_CONNECTING: return "CONNECTING";
|
|
||||||
case TelephonyManager.DATA_CONNECTED: return "CONNECTED";
|
|
||||||
case TelephonyManager.DATA_SUSPENDED: return "SUSPENDED";
|
|
||||||
}
|
|
||||||
return "UNKNOWN(" + state + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of the radio technology (network type)
|
* Returns a string representation of the radio technology (network type)
|
||||||
* currently in use on the device.
|
* currently in use on the device.
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.internal.telephony.util;
|
package com.android.internal.telephony.util;
|
||||||
|
|
||||||
|
import static android.telephony.Annotation.DataState;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -26,6 +28,7 @@ import android.os.Bundle;
|
|||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -154,4 +157,22 @@ public final class TelephonyUtils {
|
|||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert data state to string
|
||||||
|
*
|
||||||
|
* @return The data state in string format.
|
||||||
|
*/
|
||||||
|
public static String dataStateToString(@DataState int state) {
|
||||||
|
switch (state) {
|
||||||
|
case TelephonyManager.DATA_DISCONNECTED: return "DISCONNECTED";
|
||||||
|
case TelephonyManager.DATA_CONNECTING: return "CONNECTING";
|
||||||
|
case TelephonyManager.DATA_CONNECTED: return "CONNECTED";
|
||||||
|
case TelephonyManager.DATA_SUSPENDED: return "SUSPENDED";
|
||||||
|
case TelephonyManager.DATA_DISCONNECTING: return "DISCONNECTING";
|
||||||
|
case TelephonyManager.DATA_UNKNOWN: return "UNKNOWN";
|
||||||
|
}
|
||||||
|
// This is the error case. The well-defined value for UNKNOWN is -1.
|
||||||
|
return "UNKNOWN(" + state + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5499,23 +5499,6 @@ public class TelephonyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert data state to string
|
|
||||||
*
|
|
||||||
* @return The data state in string format.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static String dataStateToString(@DataState int state) {
|
|
||||||
switch (state) {
|
|
||||||
case DATA_DISCONNECTED: return "DISCONNECTED";
|
|
||||||
case DATA_CONNECTING: return "CONNECTING";
|
|
||||||
case DATA_CONNECTED: return "CONNECTED";
|
|
||||||
case DATA_SUSPENDED: return "SUSPENDED";
|
|
||||||
case DATA_DISCONNECTING: return "DISCONNECTING";
|
|
||||||
}
|
|
||||||
return "UNKNOWN(" + state + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user