public boolean updateNetKey(@NonNull final NetworkKey networkKey) throws IllegalArgumentException {
        final int keyIndex = networkKey.getKeyIndex();
        final NetworkKey key = getNetKey(keyIndex);
        //We check if the contents of the key are the same
        //This will return true only if the key index and the key are the same
        if (key.equals(networkKey)) {
            // The name might be updated so we must update the key.
            return updateMeshKey(networkKey);
        } else {
            //If the keys are not the same we check if its in use before updating the key
            if (!isKeyInUse(key)) {
                //We check if the contents of the key are the same
                //This will return true only if the key index and the key are the same
                return updateMeshKey(networkKey);
            } else {
                throw new IllegalArgumentException("Unable to update a network key that's already in use.");
            }
        }
    }
Update a network key in the mesh network.

<p>
Updating a NetworkKey's key value requires initiating a Key Refresh Procedure. A NetworkKey that's in use
would require a Key Refresh Procedure to update it's key contents. However a NetworkKey that's not in could
be updated without this procedure. If the key is in use, call {@link #distributeNetKey(NetworkKey, byte[])}
to initiate the Key Refresh Procedure.
</p>

@param networkKey Network key
@throws IllegalArgumentException if the key is already in use
mesh/src/main/java/no/nordicsemi/android/mesh/BaseMeshNetwork.java