private boolean updateMeshKey(@NonNull final MeshKey key) {
        if (key instanceof ApplicationKey) {
            ApplicationKey appKey = null;
            for (int i = 0; i < appKeys.size(); i++) {
                final ApplicationKey tempKey = appKeys.get(i);
                if (tempKey.getKeyIndex() == key.getKeyIndex()) {
                    appKey = (ApplicationKey) key;
                    appKeys.set(i, appKey);
                    break;
                }
            }
            if (appKey != null) {
                notifyAppKeyUpdated(appKey);
                return true;
            }
        } else {
            NetworkKey netKey = null;
            for (int i = 0; i < netKeys.size(); i++) {
                final NetworkKey tempKey = netKeys.get(i);
                if (tempKey.getKeyIndex() == key.getKeyIndex()) {
                    netKey = (NetworkKey) key;
                    netKeys.set(i, netKey);
                    break;
                }
            }
            if (netKey != null) {
                netKey.setTimestamp(System.currentTimeMillis());
                notifyNetKeyUpdated(netKey);
                return true;
            }
        }
        return false;
    }
Distributes/updates the provisioner node's the application key and returns the updated Application Key.

<p>
This will only work if the NetworkKey bound to this ApplicationKey is in Phase 1 of the Key Refresh Procedure. Therefore the NetworkKey
must be updated first before updating it's bound application key. Call {@link #distributeNetKey(NetworkKey, byte[])} to initiate the
Key Refresh Procedure to update a Network Key that's in use by the provisioner or the nodes, if it has not been started already.
To update a key that's not in use call {@link #updateAppKey(ApplicationKey, String)}
<p>
Once the provisioner nodes' AppKey is updated user must distribute the updated AppKey to the nodes. This can be done by sending
{@link ConfigAppKeyUpdate} message with the new key.
</p>

@param applicationKey Network key
@param newAppKey      16-byte key
@throws IllegalArgumentException the key value is already in use.
mesh/src/main/java/no/nordicsemi/android/mesh/BaseMeshNetwork.java