Loading common/networkstackclient/src/android/net/IpMemoryStoreClient.java +10 −4 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ public abstract class IpMemoryStoreClient { () -> service.storeNetworkAttributes(l2Key, attributes.toParcelable(), OnStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error storing network attributes", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN))); } Loading @@ -116,6 +117,7 @@ public abstract class IpMemoryStoreClient { () -> service.storeBlob(l2Key, clientId, name, data, OnStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error storing blob", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN))); } Loading Loading @@ -143,7 +145,8 @@ public abstract class IpMemoryStoreClient { OnL2KeyResponseListener.toAIDL(listener)))); } catch (ExecutionException m) { ignoringRemoteException("Error finding L2 Key", () -> listener.onL2KeyResponse(new Status(Status.ERROR_UNKNOWN), null)); () -> listener.onL2KeyResponse(new Status(Status.ERROR_UNKNOWN), null /* l2Key */)); } } Loading @@ -164,7 +167,8 @@ public abstract class IpMemoryStoreClient { OnSameL3NetworkResponseListener.toAIDL(listener)))); } catch (ExecutionException m) { ignoringRemoteException("Error checking for network sameness", () -> listener.onSameL3NetworkResponse(new Status(Status.ERROR_UNKNOWN), null)); () -> listener.onSameL3NetworkResponse(new Status(Status.ERROR_UNKNOWN), null /* response */)); } } Loading @@ -186,7 +190,7 @@ public abstract class IpMemoryStoreClient { } catch (ExecutionException m) { ignoringRemoteException("Error retrieving network attributes", () -> listener.onNetworkAttributesRetrieved(new Status(Status.ERROR_UNKNOWN), null, null)); null /* l2Key */, null /* attributes */)); } } Loading @@ -210,7 +214,7 @@ public abstract class IpMemoryStoreClient { } catch (ExecutionException m) { ignoringRemoteException("Error retrieving blob", () -> listener.onBlobRetrieved(new Status(Status.ERROR_UNKNOWN), null, null, null)); null /* l2Key */, null /* name */, null /* blob */)); } } Loading @@ -235,6 +239,7 @@ public abstract class IpMemoryStoreClient { runWhenServiceReady(service -> ignoringRemoteException(() -> service.delete(l2Key, needWipe, OnDeleteStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error deleting from the memory store", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN), 0 /* deletedRecords */)); Loading Loading @@ -266,6 +271,7 @@ public abstract class IpMemoryStoreClient { () -> service.deleteCluster(cluster, needWipe, OnDeleteStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error deleting from the memory store", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN), 0 /* deletedRecords */)); Loading jarjar-rules-shared.txt +3 −0 Original line number Diff line number Diff line # Classes from net-utils-framework-common rule com.android.net.module.util.** com.android.networkstack.util.@1 rule com.android.internal.util.** android.net.networkstack.util.@1 rule android.net.shared.Inet4AddressUtils* android.net.networkstack.shared.Inet4AddressUtils@1 Loading src/android/net/ip/IpClient.java +1 −1 Original line number Diff line number Diff line Loading @@ -1772,7 +1772,7 @@ public class IpClient extends StateMachine { case EVENT_NETLINK_LINKPROPERTIES_CHANGED: handleLinkPropertiesUpdate(NO_CALLBACKS); if (readyToProceed()) { transitionTo(mRunningState); transitionTo(isUsingPreconnection() ? mPreconnectingState : mRunningState); } break; Loading src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java +59 −67 Original line number Diff line number Diff line Loading @@ -335,21 +335,19 @@ public class IpMemoryStoreDatabase { // Returns the expiry date of the specified row, or one of the error codes above if the // row is not found or some other error static long getExpiry(@NonNull final SQLiteDatabase db, @NonNull final String key) { final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, EXPIRY_COLUMN, // columns SELECT_L2KEY, // selection new String[] { key }, // selectionArgs null, // groupBy null, // having null // orderBy ); null)) { // orderBy // L2KEY is the primary key ; it should not be possible to get more than one // result here. 0 results means the key was not found. if (cursor.getCount() != 1) return EXPIRY_ERROR; cursor.moveToFirst(); final long result = cursor.getLong(0); // index in the EXPIRY_COLUMN array cursor.close(); return result; return cursor.getLong(0); // index in the EXPIRY_COLUMN array } } static final int RELEVANCE_ERROR = -1; // Legal values for relevance are positive Loading Loading @@ -399,20 +397,19 @@ public class IpMemoryStoreDatabase { @Nullable static NetworkAttributes retrieveNetworkAttributes(@NonNull final SQLiteDatabase db, @NonNull final String key) { final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, null, // columns, null means everything NetworkAttributesContract.COLNAME_L2KEY + " = ?", // selection new String[] { key }, // selectionArgs null, // groupBy null, // having null); // orderBy null)) { // orderBy // L2KEY is the primary key ; it should not be possible to get more than one // result here. 0 results means the key was not found. if (cursor.getCount() != 1) return null; cursor.moveToFirst(); final NetworkAttributes attributes = readNetworkAttributesLine(cursor); cursor.close(); return attributes; return readNetworkAttributesLine(cursor); } } private static final String[] DATA_COLUMN = new String[] { Loading @@ -422,7 +419,7 @@ public class IpMemoryStoreDatabase { @Nullable static byte[] retrieveBlob(@NonNull final SQLiteDatabase db, @NonNull final String key, @NonNull final String clientId, @NonNull final String name) { final Cursor cursor = db.query(PrivateDataContract.TABLENAME, try (Cursor cursor = db.query(PrivateDataContract.TABLENAME, DATA_COLUMN, // columns PrivateDataContract.COLNAME_L2KEY + " = ? AND " // selection + PrivateDataContract.COLNAME_CLIENT + " = ? AND " Loading @@ -430,14 +427,13 @@ public class IpMemoryStoreDatabase { new String[] { key, clientId, name }, // selectionArgs null, // groupBy null, // having null); // orderBy // The query above is querying by (composite) primary key, so it should not be possible to // get more than one result here. 0 results means the key was not found. null)) { // orderBy // The query above is querying by (composite) primary key, so it should not be possible // to get more than one result here. 0 results means the key was not found. if (cursor.getCount() != 1) return null; cursor.moveToFirst(); final byte[] result = cursor.getBlob(0); // index in the DATA_COLUMN array cursor.close(); return result; return cursor.getBlob(0); // index in the DATA_COLUMN array } } /** Loading @@ -449,7 +445,7 @@ public class IpMemoryStoreDatabase { try { db.delete(NetworkAttributesContract.TABLENAME, null, null); db.delete(PrivateDataContract.TABLENAME, null, null); final Cursor cursorNetworkAttributes = db.query( try (Cursor cursorNetworkAttributes = db.query( // table name NetworkAttributesContract.TABLENAME, // column name Loading @@ -459,13 +455,10 @@ public class IpMemoryStoreDatabase { null, // groupBy null, // having null, // orderBy "1"); // limit if (0 != cursorNetworkAttributes.getCount()) { cursorNetworkAttributes.close(); continue; "1")) { // limit if (0 != cursorNetworkAttributes.getCount()) continue; } cursorNetworkAttributes.close(); final Cursor cursorPrivateData = db.query( try (Cursor cursorPrivateData = db.query( // table name PrivateDataContract.TABLENAME, // column name Loading @@ -475,14 +468,10 @@ public class IpMemoryStoreDatabase { null, // groupBy null, // having null, // orderBy "1"); // limit if (0 != cursorPrivateData.getCount()) { cursorPrivateData.close(); continue; "1")) { // limit if (0 != cursorPrivateData.getCount()) continue; } cursorPrivateData.close(); db.setTransactionSuccessful(); return; } catch (SQLiteException e) { Log.e(TAG, "Could not wipe the data in database", e); } finally { Loading Loading @@ -575,7 +564,7 @@ public class IpMemoryStoreDatabase { final String selection = NetworkAttributesContract.COLNAME_EXPIRYDATE + " > ? AND (" + sj.toString() + ")"; final Cursor cursor = db.queryWithFactory(new CustomCursorFactory(args), try (Cursor cursor = db.queryWithFactory(new CustomCursorFactory(args), false, // distinct NetworkAttributesContract.TABLENAME, null, // columns, null means everything Loading @@ -584,11 +573,12 @@ public class IpMemoryStoreDatabase { null, // groupBy null, // having null, // orderBy null); // limit null)) { // limit if (cursor.getCount() <= 0) return null; cursor.moveToFirst(); String bestKey = null; float bestMatchConfidence = GROUPCLOSE_CONFIDENCE; // Never return a match worse than this. float bestMatchConfidence = GROUPCLOSE_CONFIDENCE; // Never return a match worse than this. while (!cursor.isAfterLast()) { final NetworkAttributes read = readNetworkAttributesLine(cursor); final float confidence = read.getNetworkGroupSamenessConfidence(attr); Loading @@ -598,9 +588,9 @@ public class IpMemoryStoreDatabase { } cursor.moveToNext(); } cursor.close(); return bestKey; } } /** * Delete a single entry by key. Loading Loading @@ -695,20 +685,21 @@ public class IpMemoryStoreDatabase { } // Queries number of NetworkAttributes that start from the lowest expiryDate. final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, final long expiryDate; try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, new String[] {NetworkAttributesContract.COLNAME_EXPIRYDATE}, // columns null, // selection null, // selectionArgs null, // groupBy null, // having NetworkAttributesContract.COLNAME_EXPIRYDATE, // orderBy Integer.toString(number)); // limit Integer.toString(number))) { // limit if (cursor == null || cursor.getCount() <= 0) return Status.ERROR_GENERIC; cursor.moveToLast(); // Get the expiryDate from last record. final long expiryDate = getLong(cursor, NetworkAttributesContract.COLNAME_EXPIRYDATE, 0); cursor.close(); expiryDate = getLong(cursor, NetworkAttributesContract.COLNAME_EXPIRYDATE, 0); } db.beginTransaction(); try { Loading Loading @@ -736,16 +727,17 @@ public class IpMemoryStoreDatabase { static int getTotalRecordNumber(@NonNull final SQLiteDatabase db) { // Query the total number of NetworkAttributes final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, new String[] {"COUNT(*)"}, // columns null, // selection null, // selectionArgs null, // groupBy null, // having null); // orderBy null)) { // orderBy cursor.moveToFirst(); return cursor == null ? 0 : cursor.getInt(0); } } // Helper methods private static String getString(final Cursor cursor, final String columnName) { Loading tests/integration/src/android/net/ip/IpClientIntegrationTest.java +22 −2 Original line number Diff line number Diff line Loading @@ -1658,8 +1658,7 @@ public class IpClientIntegrationTest { HandlerUtilsKt.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS); } @Test public void testIpClientClearingIpAddressState() throws Exception { private void doIPv4OnlyProvisioningAndExitWithLeftAddress() throws Exception { final long currentTime = System.currentTimeMillis(); performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S, true /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */, Loading @@ -1684,6 +1683,11 @@ public class IpClientIntegrationTest { // TODO: once IpClient gets IP addresses directly from netlink instead of from netd, it // may be sufficient to call waitForIdle to see if IpClient has seen the address. addIpAddressAndWaitForIt(mIfaceName); } @Test public void testIpClientClearingIpAddressState() throws Exception { doIPv4OnlyProvisioningAndExitWithLeftAddress(); ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIpReachabilityMonitor() Loading @@ -1702,6 +1706,22 @@ public class IpClientIntegrationTest { assertEquals("0.0.0.0", cfg.ipv4Addr); } @Test public void testIpClientClearingIpAddressState_enablePreconnection() throws Exception { doIPv4OnlyProvisioningAndExitWithLeftAddress(); // Enter ClearingIpAddressesState to clear the remaining IPv4 addresses and transition to // PreconnectionState instead of RunningState. startIpClientProvisioning(false /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */, true /* isDhcpPreConnectionEnabled */, false /* isDhcpIpConflictDetectEnabled */); assertDiscoverPacketOnPreconnectionStart(); // Force to enter RunningState. mIpc.notifyPreconnectionComplete(false /* abort */); HandlerUtilsKt.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS); } @Test public void testDhcpClientPreconnection_success() throws Exception { doIpClientProvisioningWithPreconnectionTest(true /* shouldReplyRapidCommitAck */, Loading Loading
common/networkstackclient/src/android/net/IpMemoryStoreClient.java +10 −4 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ public abstract class IpMemoryStoreClient { () -> service.storeNetworkAttributes(l2Key, attributes.toParcelable(), OnStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error storing network attributes", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN))); } Loading @@ -116,6 +117,7 @@ public abstract class IpMemoryStoreClient { () -> service.storeBlob(l2Key, clientId, name, data, OnStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error storing blob", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN))); } Loading Loading @@ -143,7 +145,8 @@ public abstract class IpMemoryStoreClient { OnL2KeyResponseListener.toAIDL(listener)))); } catch (ExecutionException m) { ignoringRemoteException("Error finding L2 Key", () -> listener.onL2KeyResponse(new Status(Status.ERROR_UNKNOWN), null)); () -> listener.onL2KeyResponse(new Status(Status.ERROR_UNKNOWN), null /* l2Key */)); } } Loading @@ -164,7 +167,8 @@ public abstract class IpMemoryStoreClient { OnSameL3NetworkResponseListener.toAIDL(listener)))); } catch (ExecutionException m) { ignoringRemoteException("Error checking for network sameness", () -> listener.onSameL3NetworkResponse(new Status(Status.ERROR_UNKNOWN), null)); () -> listener.onSameL3NetworkResponse(new Status(Status.ERROR_UNKNOWN), null /* response */)); } } Loading @@ -186,7 +190,7 @@ public abstract class IpMemoryStoreClient { } catch (ExecutionException m) { ignoringRemoteException("Error retrieving network attributes", () -> listener.onNetworkAttributesRetrieved(new Status(Status.ERROR_UNKNOWN), null, null)); null /* l2Key */, null /* attributes */)); } } Loading @@ -210,7 +214,7 @@ public abstract class IpMemoryStoreClient { } catch (ExecutionException m) { ignoringRemoteException("Error retrieving blob", () -> listener.onBlobRetrieved(new Status(Status.ERROR_UNKNOWN), null, null, null)); null /* l2Key */, null /* name */, null /* blob */)); } } Loading @@ -235,6 +239,7 @@ public abstract class IpMemoryStoreClient { runWhenServiceReady(service -> ignoringRemoteException(() -> service.delete(l2Key, needWipe, OnDeleteStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error deleting from the memory store", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN), 0 /* deletedRecords */)); Loading Loading @@ -266,6 +271,7 @@ public abstract class IpMemoryStoreClient { () -> service.deleteCluster(cluster, needWipe, OnDeleteStatusListener.toAIDL(listener)))); } catch (ExecutionException m) { if (null == listener) return; ignoringRemoteException("Error deleting from the memory store", () -> listener.onComplete(new Status(Status.ERROR_UNKNOWN), 0 /* deletedRecords */)); Loading
jarjar-rules-shared.txt +3 −0 Original line number Diff line number Diff line # Classes from net-utils-framework-common rule com.android.net.module.util.** com.android.networkstack.util.@1 rule com.android.internal.util.** android.net.networkstack.util.@1 rule android.net.shared.Inet4AddressUtils* android.net.networkstack.shared.Inet4AddressUtils@1 Loading
src/android/net/ip/IpClient.java +1 −1 Original line number Diff line number Diff line Loading @@ -1772,7 +1772,7 @@ public class IpClient extends StateMachine { case EVENT_NETLINK_LINKPROPERTIES_CHANGED: handleLinkPropertiesUpdate(NO_CALLBACKS); if (readyToProceed()) { transitionTo(mRunningState); transitionTo(isUsingPreconnection() ? mPreconnectingState : mRunningState); } break; Loading
src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreDatabase.java +59 −67 Original line number Diff line number Diff line Loading @@ -335,21 +335,19 @@ public class IpMemoryStoreDatabase { // Returns the expiry date of the specified row, or one of the error codes above if the // row is not found or some other error static long getExpiry(@NonNull final SQLiteDatabase db, @NonNull final String key) { final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, EXPIRY_COLUMN, // columns SELECT_L2KEY, // selection new String[] { key }, // selectionArgs null, // groupBy null, // having null // orderBy ); null)) { // orderBy // L2KEY is the primary key ; it should not be possible to get more than one // result here. 0 results means the key was not found. if (cursor.getCount() != 1) return EXPIRY_ERROR; cursor.moveToFirst(); final long result = cursor.getLong(0); // index in the EXPIRY_COLUMN array cursor.close(); return result; return cursor.getLong(0); // index in the EXPIRY_COLUMN array } } static final int RELEVANCE_ERROR = -1; // Legal values for relevance are positive Loading Loading @@ -399,20 +397,19 @@ public class IpMemoryStoreDatabase { @Nullable static NetworkAttributes retrieveNetworkAttributes(@NonNull final SQLiteDatabase db, @NonNull final String key) { final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, null, // columns, null means everything NetworkAttributesContract.COLNAME_L2KEY + " = ?", // selection new String[] { key }, // selectionArgs null, // groupBy null, // having null); // orderBy null)) { // orderBy // L2KEY is the primary key ; it should not be possible to get more than one // result here. 0 results means the key was not found. if (cursor.getCount() != 1) return null; cursor.moveToFirst(); final NetworkAttributes attributes = readNetworkAttributesLine(cursor); cursor.close(); return attributes; return readNetworkAttributesLine(cursor); } } private static final String[] DATA_COLUMN = new String[] { Loading @@ -422,7 +419,7 @@ public class IpMemoryStoreDatabase { @Nullable static byte[] retrieveBlob(@NonNull final SQLiteDatabase db, @NonNull final String key, @NonNull final String clientId, @NonNull final String name) { final Cursor cursor = db.query(PrivateDataContract.TABLENAME, try (Cursor cursor = db.query(PrivateDataContract.TABLENAME, DATA_COLUMN, // columns PrivateDataContract.COLNAME_L2KEY + " = ? AND " // selection + PrivateDataContract.COLNAME_CLIENT + " = ? AND " Loading @@ -430,14 +427,13 @@ public class IpMemoryStoreDatabase { new String[] { key, clientId, name }, // selectionArgs null, // groupBy null, // having null); // orderBy // The query above is querying by (composite) primary key, so it should not be possible to // get more than one result here. 0 results means the key was not found. null)) { // orderBy // The query above is querying by (composite) primary key, so it should not be possible // to get more than one result here. 0 results means the key was not found. if (cursor.getCount() != 1) return null; cursor.moveToFirst(); final byte[] result = cursor.getBlob(0); // index in the DATA_COLUMN array cursor.close(); return result; return cursor.getBlob(0); // index in the DATA_COLUMN array } } /** Loading @@ -449,7 +445,7 @@ public class IpMemoryStoreDatabase { try { db.delete(NetworkAttributesContract.TABLENAME, null, null); db.delete(PrivateDataContract.TABLENAME, null, null); final Cursor cursorNetworkAttributes = db.query( try (Cursor cursorNetworkAttributes = db.query( // table name NetworkAttributesContract.TABLENAME, // column name Loading @@ -459,13 +455,10 @@ public class IpMemoryStoreDatabase { null, // groupBy null, // having null, // orderBy "1"); // limit if (0 != cursorNetworkAttributes.getCount()) { cursorNetworkAttributes.close(); continue; "1")) { // limit if (0 != cursorNetworkAttributes.getCount()) continue; } cursorNetworkAttributes.close(); final Cursor cursorPrivateData = db.query( try (Cursor cursorPrivateData = db.query( // table name PrivateDataContract.TABLENAME, // column name Loading @@ -475,14 +468,10 @@ public class IpMemoryStoreDatabase { null, // groupBy null, // having null, // orderBy "1"); // limit if (0 != cursorPrivateData.getCount()) { cursorPrivateData.close(); continue; "1")) { // limit if (0 != cursorPrivateData.getCount()) continue; } cursorPrivateData.close(); db.setTransactionSuccessful(); return; } catch (SQLiteException e) { Log.e(TAG, "Could not wipe the data in database", e); } finally { Loading Loading @@ -575,7 +564,7 @@ public class IpMemoryStoreDatabase { final String selection = NetworkAttributesContract.COLNAME_EXPIRYDATE + " > ? AND (" + sj.toString() + ")"; final Cursor cursor = db.queryWithFactory(new CustomCursorFactory(args), try (Cursor cursor = db.queryWithFactory(new CustomCursorFactory(args), false, // distinct NetworkAttributesContract.TABLENAME, null, // columns, null means everything Loading @@ -584,11 +573,12 @@ public class IpMemoryStoreDatabase { null, // groupBy null, // having null, // orderBy null); // limit null)) { // limit if (cursor.getCount() <= 0) return null; cursor.moveToFirst(); String bestKey = null; float bestMatchConfidence = GROUPCLOSE_CONFIDENCE; // Never return a match worse than this. float bestMatchConfidence = GROUPCLOSE_CONFIDENCE; // Never return a match worse than this. while (!cursor.isAfterLast()) { final NetworkAttributes read = readNetworkAttributesLine(cursor); final float confidence = read.getNetworkGroupSamenessConfidence(attr); Loading @@ -598,9 +588,9 @@ public class IpMemoryStoreDatabase { } cursor.moveToNext(); } cursor.close(); return bestKey; } } /** * Delete a single entry by key. Loading Loading @@ -695,20 +685,21 @@ public class IpMemoryStoreDatabase { } // Queries number of NetworkAttributes that start from the lowest expiryDate. final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, final long expiryDate; try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, new String[] {NetworkAttributesContract.COLNAME_EXPIRYDATE}, // columns null, // selection null, // selectionArgs null, // groupBy null, // having NetworkAttributesContract.COLNAME_EXPIRYDATE, // orderBy Integer.toString(number)); // limit Integer.toString(number))) { // limit if (cursor == null || cursor.getCount() <= 0) return Status.ERROR_GENERIC; cursor.moveToLast(); // Get the expiryDate from last record. final long expiryDate = getLong(cursor, NetworkAttributesContract.COLNAME_EXPIRYDATE, 0); cursor.close(); expiryDate = getLong(cursor, NetworkAttributesContract.COLNAME_EXPIRYDATE, 0); } db.beginTransaction(); try { Loading Loading @@ -736,16 +727,17 @@ public class IpMemoryStoreDatabase { static int getTotalRecordNumber(@NonNull final SQLiteDatabase db) { // Query the total number of NetworkAttributes final Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, try (Cursor cursor = db.query(NetworkAttributesContract.TABLENAME, new String[] {"COUNT(*)"}, // columns null, // selection null, // selectionArgs null, // groupBy null, // having null); // orderBy null)) { // orderBy cursor.moveToFirst(); return cursor == null ? 0 : cursor.getInt(0); } } // Helper methods private static String getString(final Cursor cursor, final String columnName) { Loading
tests/integration/src/android/net/ip/IpClientIntegrationTest.java +22 −2 Original line number Diff line number Diff line Loading @@ -1658,8 +1658,7 @@ public class IpClientIntegrationTest { HandlerUtilsKt.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS); } @Test public void testIpClientClearingIpAddressState() throws Exception { private void doIPv4OnlyProvisioningAndExitWithLeftAddress() throws Exception { final long currentTime = System.currentTimeMillis(); performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S, true /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */, Loading @@ -1684,6 +1683,11 @@ public class IpClientIntegrationTest { // TODO: once IpClient gets IP addresses directly from netlink instead of from netd, it // may be sufficient to call waitForIdle to see if IpClient has seen the address. addIpAddressAndWaitForIt(mIfaceName); } @Test public void testIpClientClearingIpAddressState() throws Exception { doIPv4OnlyProvisioningAndExitWithLeftAddress(); ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIpReachabilityMonitor() Loading @@ -1702,6 +1706,22 @@ public class IpClientIntegrationTest { assertEquals("0.0.0.0", cfg.ipv4Addr); } @Test public void testIpClientClearingIpAddressState_enablePreconnection() throws Exception { doIPv4OnlyProvisioningAndExitWithLeftAddress(); // Enter ClearingIpAddressesState to clear the remaining IPv4 addresses and transition to // PreconnectionState instead of RunningState. startIpClientProvisioning(false /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */, true /* isDhcpPreConnectionEnabled */, false /* isDhcpIpConflictDetectEnabled */); assertDiscoverPacketOnPreconnectionStart(); // Force to enter RunningState. mIpc.notifyPreconnectionComplete(false /* abort */); HandlerUtilsKt.waitForIdle(mIpc.getHandler(), TEST_TIMEOUT_MS); } @Test public void testDhcpClientPreconnection_success() throws Exception { doIpClientProvisioningWithPreconnectionTest(true /* shouldReplyRapidCommitAck */, Loading