diff options
6 files changed, 40 insertions, 28 deletions
diff --git a/services/core/Android.bp b/services/core/Android.bp index 89bac5123084..3532b0a59f3d 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -235,6 +235,7 @@ java_library_static { "dreams_flags_lib", "aconfig_new_storage_flags_lib", "powerstats_flags_lib", + "locksettings_flags_lib", ], javac_shard_size: 50, javacflags: [ diff --git a/services/core/java/com/android/server/locksettings/Android.bp b/services/core/java/com/android/server/locksettings/Android.bp new file mode 100644 index 000000000000..53f1ac668e49 --- /dev/null +++ b/services/core/java/com/android/server/locksettings/Android.bp @@ -0,0 +1,11 @@ +aconfig_declarations { + name: "locksettings_flags", + package: "com.android.server.locksettings", + container: "system", + srcs: ["*.aconfig"], +} + +java_aconfig_library { + name: "locksettings_flags_lib", + aconfig_declarations: "locksettings_flags", +} diff --git a/services/core/java/com/android/server/locksettings/RebootEscrowManager.java b/services/core/java/com/android/server/locksettings/RebootEscrowManager.java index f44b85273af6..820c0efcc1cf 100644 --- a/services/core/java/com/android/server/locksettings/RebootEscrowManager.java +++ b/services/core/java/com/android/server/locksettings/RebootEscrowManager.java @@ -273,11 +273,6 @@ class RebootEscrowManager { "server_based_ror_enabled", false); } - public boolean waitForInternet() { - return DeviceConfig.getBoolean( - DeviceConfig.NAMESPACE_OTA, "wait_for_internet_ror", false); - } - public boolean isNetworkConnected() { final ConnectivityManager connectivityManager = mContext.getSystemService(ConnectivityManager.class); @@ -433,7 +428,7 @@ class RebootEscrowManager { /** Wrapper function to set error code serialized through handler, */ private void setLoadEscrowDataErrorCode(@RebootEscrowErrorCode int value, Handler handler) { - if (mInjector.waitForInternet()) { + if (Flags.waitForInternetRor()) { mInjector.post( handler, () -> { @@ -516,7 +511,7 @@ class RebootEscrowManager { mWakeLock.acquire(mInjector.getWakeLockTimeoutMillis()); } - if (mInjector.waitForInternet()) { + if (Flags.waitForInternetRor()) { // Timeout to stop retrying same as the wake lock timeout. mInjector.postDelayed( retryHandler, @@ -553,7 +548,7 @@ class RebootEscrowManager { return; } - if (mInjector.waitForInternet()) { + if (Flags.waitForInternetRor()) { if (mRebootEscrowTimedOut) { Slog.w(TAG, "Failed to load reboot escrow data within timeout"); compareAndSetLoadEscrowDataErrorCode( diff --git a/services/core/java/com/android/server/locksettings/flags.aconfig b/services/core/java/com/android/server/locksettings/flags.aconfig new file mode 100644 index 000000000000..6818de91c98e --- /dev/null +++ b/services/core/java/com/android/server/locksettings/flags.aconfig @@ -0,0 +1,9 @@ +package: "com.android.server.locksettings" +container: "system" + +flag { + name: "wait_for_internet_ror" + namespace: "sudo" + description: "Feature flag to wait for internet connectivity before calling resume on reboot server." + bug: "231660348" +}
\ No newline at end of file diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp index dce6c359e6fd..c2afba82f7c2 100644 --- a/services/tests/servicestests/Android.bp +++ b/services/tests/servicestests/Android.bp @@ -88,6 +88,7 @@ android_test { "net_flags_lib", "CtsVirtualDeviceCommonLib", "com_android_server_accessibility_flags_lib", + "locksettings_flags_lib", ], libs: [ diff --git a/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java b/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java index d6f7e21a2069..d071c159d6f5 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/RebootEscrowManagerTests.java @@ -60,6 +60,9 @@ import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.UserManager; import android.platform.test.annotations.Presubmit; +import android.platform.test.annotations.RequiresFlagsEnabled; +import android.platform.test.flag.junit.CheckFlagsRule; +import android.platform.test.flag.junit.DeviceFlagsValueProvider; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; @@ -70,6 +73,7 @@ import com.android.server.locksettings.ResumeOnRebootServiceProvider.ResumeOnReb import com.android.server.pm.UserManagerInternal; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -108,6 +112,9 @@ public class RebootEscrowManagerTests { 0x26, 0x52, 0x72, 0x63, 0x63, 0x61, 0x78, 0x23, }; + @Rule + public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); + private Context mContext; private UserManager mUserManager; private UserManagerInternal mUserManagerInternal; @@ -145,7 +152,6 @@ public class RebootEscrowManagerTests { private RebootEscrowProviderInterface mRebootEscrowProviderInUse; private ConnectivityManager.NetworkCallback mNetworkCallback; private Consumer<ConnectivityManager.NetworkCallback> mNetworkConsumer; - private boolean mWaitForInternet; MockInjector( Context context, @@ -159,7 +165,6 @@ public class RebootEscrowManagerTests { super(context, storage, userManagerInternal); mRebootEscrow = rebootEscrow; mServerBased = false; - mWaitForInternet = false; RebootEscrowProviderHalImpl.Injector halInjector = new RebootEscrowProviderHalImpl.Injector() { @Override @@ -185,7 +190,6 @@ public class RebootEscrowManagerTests { super(context, storage, userManagerInternal); mRebootEscrow = null; mServerBased = true; - mWaitForInternet = false; RebootEscrowProviderServerBasedImpl.Injector injector = new RebootEscrowProviderServerBasedImpl.Injector(serviceConnection) { @Override @@ -227,15 +231,6 @@ public class RebootEscrowManagerTests { } @Override - public boolean waitForInternet() { - return mWaitForInternet; - } - - public void setWaitForNetwork(boolean waitForNetworkEnabled) { - mWaitForInternet = waitForNetworkEnabled; - } - - @Override public boolean isNetworkConnected() { return false; } @@ -934,10 +929,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_serverBasedWaitForInternet_success() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -987,10 +982,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_serverBasedWaitForInternetRemoteException_Failure() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -1042,10 +1037,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_waitForInternet_networkUnavailable() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -1090,9 +1085,9 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_waitForInternet_networkLost() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -1145,10 +1140,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_waitForInternet_networkAvailableWithDelay() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -1204,10 +1199,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_waitForInternet_timeoutExhausted() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -1264,10 +1259,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_serverBasedWaitForNetwork_retryCountExhausted() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); @@ -1320,10 +1315,10 @@ public class RebootEscrowManagerTests { } @Test + @RequiresFlagsEnabled(Flags.FLAG_WAIT_FOR_INTERNET_ROR) public void loadRebootEscrowDataIfAvailable_ServerBasedWaitForInternet_RetrySuccess() throws Exception { setServerBasedRebootEscrowProvider(); - mMockInjector.setWaitForNetwork(true); when(mInjected.getBootCount()).thenReturn(0); RebootEscrowListener mockListener = mock(RebootEscrowListener.class); |