Merge "Update package of DataConnectionStats"

This commit is contained in:
Treehugger Robot
2021-03-08 01:36:37 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 11 deletions

View File

@@ -74,7 +74,6 @@ import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.ParseUtils; import com.android.internal.util.ParseUtils;
import com.android.net.module.util.NetworkCapabilitiesUtils; import com.android.net.module.util.NetworkCapabilitiesUtils;
import com.android.server.LocalServices; import com.android.server.LocalServices;
import com.android.server.connectivity.DataConnectionStats;
import com.android.server.net.BaseNetworkObserver; import com.android.server.net.BaseNetworkObserver;
import java.io.File; import java.io.File;

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.server.connectivity; package com.android.server.am;
import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN; import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS; import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS;
@@ -34,11 +34,11 @@ import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import com.android.internal.app.IBatteryStats; import com.android.internal.app.IBatteryStats;
import com.android.server.am.BatteryStatsService;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
/** Class for receiving data connection state to report to {@link BatteryStatsService}. */
public class DataConnectionStats extends BroadcastReceiver { public class DataConnectionStats extends BroadcastReceiver {
private static final String TAG = "DataConnectionStats"; private static final String TAG = "DataConnectionStats";
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
@@ -62,14 +62,14 @@ public class DataConnectionStats extends BroadcastReceiver {
new PhoneStateListenerImpl(new PhoneStateListenerExecutor(listenerHandler)); new PhoneStateListenerImpl(new PhoneStateListenerExecutor(listenerHandler));
} }
/** Start data connection state monitoring. */
public void startMonitoring() { public void startMonitoring() {
TelephonyManager phone = TelephonyManager phone = mContext.getSystemService(TelephonyManager.class);
(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
phone.listen(mPhoneStateListener, phone.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
| PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
| PhoneStateListener.LISTEN_DATA_ACTIVITY); | PhoneStateListener.LISTEN_DATA_ACTIVITY);
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SIM_STATE_CHANGED); filter.addAction(Intent.ACTION_SIM_STATE_CHANGED);
@@ -103,8 +103,10 @@ public class DataConnectionStats extends BroadcastReceiver {
if (mNrState == NetworkRegistrationInfo.NR_STATE_CONNECTED) { if (mNrState == NetworkRegistrationInfo.NR_STATE_CONNECTED) {
networkType = TelephonyManager.NETWORK_TYPE_NR; networkType = TelephonyManager.NETWORK_TYPE_NR;
} }
if (DEBUG) Log.d(TAG, String.format("Noting data connection for network type %s: %svisible", if (DEBUG) {
networkType, visible ? "" : "not ")); Log.d(TAG, String.format("Noting data connection for network type %s: %svisible",
networkType, visible ? "" : "not "));
}
try { try {
mBatteryStats.notePhoneDataConnectionState(networkType, visible, mBatteryStats.notePhoneDataConnectionState(networkType, visible,
mServiceState.getState()); mServiceState.getState());
@@ -113,7 +115,7 @@ public class DataConnectionStats extends BroadcastReceiver {
} }
} }
private final void updateSimState(Intent intent) { private void updateSimState(Intent intent) {
String stateExtra = intent.getStringExtra(Intent.EXTRA_SIM_STATE); String stateExtra = intent.getStringExtra(Intent.EXTRA_SIM_STATE);
if (Intent.SIM_STATE_ABSENT.equals(stateExtra)) { if (Intent.SIM_STATE_ABSENT.equals(stateExtra)) {
mSimState = TelephonyManager.SIM_STATE_ABSENT; mSimState = TelephonyManager.SIM_STATE_ABSENT;