What is sync in Android?
Today, I’m pleased to inform you that Wi-Fi Sync is originating to 1Password for Android os! Indeed, it's already for sale in the most recent beta, in order to join our beta family members and try it out right now. In this edition of our DevBits series, i will talk about how we implemented Wi-Fi Sync in 1Password for Android.
Wi-Fi Sync in 1Password for Android os makes use of just standard Android os APIs. We don’t utilize any 3rd party libraries. All of the needed interaction reasoning ended up being written in-house (although inspirational tips for WebSocket execution had been taken from elsewhere). Making use of Android APIs keeps the .apk register small and removes variation incompatibility, licensing issues, or any other trouble that may arise whenever incorporating third-party signal to the app.
Wi-Fi Sync in 1Password for Android is comprised of three components: system provider Discovery (NSD), system provider Resolution, as well as the real sync it self. Both the system provider Discovery and system provider Resolution depend on the NSD framework built in to Android. The sync is implemented making use of synchronous Websocket interaction with a site provided by 1Password for Mac or 1Password for Microsoft windows.
Network Provider Discovery
Whenever you elect to sync using Wi-Fi in 1Password for Android os, Network Service Discovery is established asynchronously and continues to run in the background until you stop it. The solution actively seeks all system services matching the sort used by 1Password (within our instance “_1password4._tcp.”).
This system solution kind fits the nature utilized by the newest versions of 1Password on both Mac and Microsoft windows whenever Wi-Fi Sync is enabled. Any found Wi-Fi solutions tend to be displayed in a list for you really to pick from to be able to setup the first sync. You will need to observe that the service information found by NSD includes no information aside from the service name and type.
System Provider Resolution
After you have determined which service you intend to utilize, the Network Service Resolution procedure is launched asynchronously for the chosen solution. 1Password for Android is given the solution qualifications, such as the IP address and interface, in order for interaction using the server can be established. The service name's stored in 1Password choices and utilized for subsequent communication sessions. This enables service finding during progressive sync to automatically stop whenever a service matching the only kept in choices is located.
Next, 1Password proceeds with solution resolution. In the event that link is successful, the sync procedure is established with the provided service IP address and interface. If solution finding is not able to uncover the service in 2 seconds, or if perhaps the resolution is invalid, you will end up asked to ensure 1Password is running on the computer you may be attempting to sync with, and sync attempt is aborted.
The actual sync
The specific sync process is taken care of by a subclass of Android’s AsyncTask that establishes synchronous communication utilizing the server with the WebSocket protocol. Being establish a link, this first calls for good solution credentials (address and slot) and a reference on database manager. When associated with the service, interaction continues according to a proprietary JSON-based command protocol that is it self based on the WebSocket protocol.