Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
Add a flag to be used for an optimization to queue callbacks while apps are frozen, instead of filling the binder buffer. Bug: 327038794 Bug: 279392981 Test: atest Change-Id: I6cc2507de88fae3d0866f9831e1e9026200297e4
This commit is contained in:
parent
c3621e6012
commit
48d2527e43
4 changed files with 21 additions and 1 deletions
|
|
@ -145,6 +145,7 @@ import static com.android.net.module.util.PermissionUtils.enforceNetworkStackPer
|
|||
import static com.android.net.module.util.PermissionUtils.hasAnyPermissionOf;
|
||||
import static com.android.server.ConnectivityStatsLog.CONNECTIVITY_STATE_SAMPLE;
|
||||
import static com.android.server.connectivity.ConnectivityFlags.DELAY_DESTROY_SOCKETS;
|
||||
import static com.android.server.connectivity.ConnectivityFlags.QUEUE_CALLBACKS_FOR_FROZEN_APPS;
|
||||
import static com.android.server.connectivity.ConnectivityFlags.REQUEST_RESTRICTED_WIFI;
|
||||
import static com.android.server.connectivity.ConnectivityFlags.INGRESS_TO_VPN_ADDRESS_FILTERING;
|
||||
|
||||
|
|
@ -510,6 +511,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
|
||||
private final boolean mUseDeclaredMethodsForCallbacksEnabled;
|
||||
|
||||
// Flag to delay callbacks for frozen apps, suppressing duplicate and stale callbacks.
|
||||
private final boolean mQueueCallbacksForFrozenApps;
|
||||
|
||||
/**
|
||||
* Uids ConnectivityService tracks blocked status of to send blocked status callbacks.
|
||||
* Key is uid based on mAsUid of registered networkRequestInfo
|
||||
|
|
@ -1873,6 +1877,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
context, ConnectivityFlags.BACKGROUND_FIREWALL_CHAIN);
|
||||
mUseDeclaredMethodsForCallbacksEnabled = mDeps.isFeatureEnabled(context,
|
||||
ConnectivityFlags.USE_DECLARED_METHODS_FOR_CALLBACKS);
|
||||
// registerUidFrozenStateChangedCallback is only available on U+
|
||||
mQueueCallbacksForFrozenApps = mDeps.isAtLeastU()
|
||||
&& mDeps.isFeatureEnabled(context, QUEUE_CALLBACKS_FOR_FROZEN_APPS);
|
||||
mCarrierPrivilegeAuthenticator = mDeps.makeCarrierPrivilegeAuthenticator(
|
||||
mContext, mTelephonyManager, mRequestRestrictedWifiEnabled,
|
||||
this::handleUidCarrierPrivilegesLost, mHandler);
|
||||
|
|
@ -2028,7 +2035,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
mDelayDestroySockets = mDeps.isFeatureNotChickenedOut(context, DELAY_DESTROY_SOCKETS);
|
||||
mAllowSysUiConnectivityReports = mDeps.isFeatureNotChickenedOut(
|
||||
mContext, ALLOW_SYSUI_CONNECTIVITY_REPORTS);
|
||||
if (mDestroyFrozenSockets) {
|
||||
if (mDestroyFrozenSockets || mQueueCallbacksForFrozenApps) {
|
||||
final UidFrozenStateChangedCallback frozenStateChangedCallback =
|
||||
new UidFrozenStateChangedCallback() {
|
||||
@Override
|
||||
|
|
@ -3464,6 +3471,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
|
||||
private void handleFrozenUids(int[] uids, int[] frozenStates) {
|
||||
ensureRunningOnConnectivityServiceThread();
|
||||
handleDestroyFrozenSockets(uids, frozenStates);
|
||||
// TODO: handle freezing NetworkCallbacks
|
||||
}
|
||||
|
||||
private void handleDestroyFrozenSockets(int[] uids, int[] frozenStates) {
|
||||
if (!mDestroyFrozenSockets) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < uids.length; i++) {
|
||||
final int uid = uids[i];
|
||||
final boolean addReason = frozenStates[i] == UID_FROZEN_STATE_FROZEN;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ public final class ConnectivityFlags {
|
|||
public static final String USE_DECLARED_METHODS_FOR_CALLBACKS =
|
||||
"use_declared_methods_for_callbacks";
|
||||
|
||||
public static final String QUEUE_CALLBACKS_FOR_FROZEN_APPS =
|
||||
"queue_callbacks_for_frozen_apps";
|
||||
|
||||
private boolean mNoRematchAllRequestsOnRegister;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2180,6 +2180,7 @@ public class ConnectivityServiceTest {
|
|||
case ConnectivityFlags.CARRIER_SERVICE_CHANGED_USE_CALLBACK:
|
||||
case ConnectivityFlags.REQUEST_RESTRICTED_WIFI:
|
||||
case ConnectivityFlags.USE_DECLARED_METHODS_FOR_CALLBACKS:
|
||||
case ConnectivityFlags.QUEUE_CALLBACKS_FOR_FROZEN_APPS:
|
||||
case KEY_DESTROY_FROZEN_SOCKETS_VERSION:
|
||||
return true;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ open class CSTest {
|
|||
it[ConnectivityFlags.BACKGROUND_FIREWALL_CHAIN] = true
|
||||
it[ConnectivityFlags.DELAY_DESTROY_SOCKETS] = true
|
||||
it[ConnectivityFlags.USE_DECLARED_METHODS_FOR_CALLBACKS] = true
|
||||
it[ConnectivityFlags.QUEUE_CALLBACKS_FOR_FROZEN_APPS] = true
|
||||
}
|
||||
fun setFeatureEnabled(flag: String, enabled: Boolean) = enabledFeatures.set(flag, enabled)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue