Merge "[DK5]Add debugging information for automaticOnOff keepalive" am: 2f003081b0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2379729 Change-Id: Ic2d3b8731ed62c7d30ba6edc08ef60704691ae0c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
414a8504ac
3 changed files with 66 additions and 3 deletions
|
|
@ -1315,6 +1315,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
return new MultinetworkPolicyTracker(c, h, r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AutomaticOnOffKeepaliveTracker
|
||||
*/
|
||||
public AutomaticOnOffKeepaliveTracker makeAutomaticOnOffKeepaliveTracker(
|
||||
@NonNull Context c, @NonNull Handler h) {
|
||||
return new AutomaticOnOffKeepaliveTracker(c, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see BatteryStatsManager
|
||||
*/
|
||||
|
|
@ -1578,7 +1586,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
mSettingsObserver = new SettingsObserver(mContext, mHandler);
|
||||
registerSettingsCallbacks();
|
||||
|
||||
mKeepaliveTracker = new AutomaticOnOffKeepaliveTracker(mContext, mHandler);
|
||||
mKeepaliveTracker = mDeps.makeAutomaticOnOffKeepaliveTracker(mContext, mHandler);
|
||||
mNotifier = new NetworkNotificationManager(mContext, mTelephonyManager);
|
||||
mQosCallbackTracker = new QosCallbackTracker(mHandler, mNetworkRequestCounter);
|
||||
|
||||
|
|
|
|||
|
|
@ -254,6 +254,28 @@ public class AutomaticOnOffKeepaliveTracker {
|
|||
// not duplicated this is a no-op.
|
||||
FileUtils.closeQuietly(mFd);
|
||||
}
|
||||
|
||||
private String getAutomaticOnOffStateName(int state) {
|
||||
switch (state) {
|
||||
case STATE_ENABLED:
|
||||
return "STATE_ENABLED";
|
||||
case STATE_SUSPENDED:
|
||||
return "STATE_SUSPENDED";
|
||||
case STATE_ALWAYS_ON:
|
||||
return "STATE_ALWAYS_ON";
|
||||
default:
|
||||
Log.e(TAG, "Get unexpected state:" + state);
|
||||
return Integer.toString(state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutomaticOnOffKeepalive [ "
|
||||
+ mKi
|
||||
+ ", state=" + getAutomaticOnOffStateName(mAutomaticOnOffState)
|
||||
+ " ]";
|
||||
}
|
||||
}
|
||||
|
||||
public AutomaticOnOffKeepaliveTracker(@NonNull Context context, @NonNull Handler handler) {
|
||||
|
|
@ -529,8 +551,18 @@ public class AutomaticOnOffKeepaliveTracker {
|
|||
* Dump AutomaticOnOffKeepaliveTracker state.
|
||||
*/
|
||||
public void dump(IndentingPrintWriter pw) {
|
||||
// TODO: Dump the necessary information for automatic on/off keepalive.
|
||||
mKeepaliveTracker.dump(pw);
|
||||
// Reading DeviceConfig will check if the calling uid and calling package name are the same.
|
||||
// Clear calling identity to align the calling uid and package so that it won't fail if cts
|
||||
// would like to do the dump()
|
||||
final boolean featureEnabled = BinderUtils.withCleanCallingIdentity(
|
||||
() -> mDependencies.isFeatureEnabled(AUTOMATIC_ON_OFF_KEEPALIVE_VERSION));
|
||||
pw.println("AutomaticOnOff enabled: " + featureEnabled);
|
||||
pw.increaseIndent();
|
||||
for (AutomaticOnOffKeepalive autoKi : mAutomaticOnOffKeepalives) {
|
||||
pw.println(autoKi.toString());
|
||||
}
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -378,6 +378,7 @@ import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
|
|||
import com.android.server.ConnectivityService.ConnectivityDiagnosticsCallbackInfo;
|
||||
import com.android.server.ConnectivityService.NetworkRequestInfo;
|
||||
import com.android.server.ConnectivityServiceTest.ConnectivityServiceDependencies.ReportedInterfaces;
|
||||
import com.android.server.connectivity.AutomaticOnOffKeepaliveTracker;
|
||||
import com.android.server.connectivity.CarrierPrivilegeAuthenticator;
|
||||
import com.android.server.connectivity.ClatCoordinator;
|
||||
import com.android.server.connectivity.ConnectivityFlags;
|
||||
|
|
@ -539,6 +540,7 @@ public class ConnectivityServiceTest {
|
|||
private MockContext mServiceContext;
|
||||
private HandlerThread mCsHandlerThread;
|
||||
private ConnectivityServiceDependencies mDeps;
|
||||
private AutomaticOnOffKeepaliveTrackerDependencies mAutoOnOffKeepaliveDependencies;
|
||||
private ConnectivityService mService;
|
||||
private WrappedConnectivityManager mCm;
|
||||
private TestNetworkAgentWrapper mWiFiAgent;
|
||||
|
|
@ -1839,7 +1841,8 @@ public class ConnectivityServiceTest {
|
|||
doReturn(mResources).when(mockResContext).getResources();
|
||||
ConnectivityResources.setResourcesContextForTest(mockResContext);
|
||||
mDeps = new ConnectivityServiceDependencies(mockResContext);
|
||||
|
||||
mAutoOnOffKeepaliveDependencies =
|
||||
new AutomaticOnOffKeepaliveTrackerDependencies(mServiceContext);
|
||||
mService = new ConnectivityService(mServiceContext,
|
||||
mMockDnsResolver,
|
||||
mock(IpConnectivityLog.class),
|
||||
|
|
@ -1939,6 +1942,12 @@ public class ConnectivityServiceTest {
|
|||
return mPolicyTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutomaticOnOffKeepaliveTracker makeAutomaticOnOffKeepaliveTracker(final Context c,
|
||||
final Handler h) {
|
||||
return new AutomaticOnOffKeepaliveTracker(c, h, mAutoOnOffKeepaliveDependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectivityResources getResources(final Context ctx) {
|
||||
return mConnRes;
|
||||
|
|
@ -2097,6 +2106,20 @@ public class ConnectivityServiceTest {
|
|||
}
|
||||
}
|
||||
|
||||
private class AutomaticOnOffKeepaliveTrackerDependencies
|
||||
extends AutomaticOnOffKeepaliveTracker.Dependencies {
|
||||
AutomaticOnOffKeepaliveTrackerDependencies(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureEnabled(@NonNull final String name) {
|
||||
// Tests for enabling the feature are verified in AutomaticOnOffKeepaliveTrackerTest.
|
||||
// Assuming enabled here to focus on ConnectivityService tests.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void initAlarmManager(final AlarmManager am, final Handler alarmHandler) {
|
||||
doAnswer(inv -> {
|
||||
final long when = inv.getArgument(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue