wultra / ssl-pinning-android

Android SDK for our dynamic SSL pinning
Apache License 2.0
60 stars 8 forks source link

Change update API and add observers #12

Closed TomasKypta closed 5 years ago

TomasKypta commented 5 years ago

Add observers for updates and global observers for validation failures. Change update method to be asynchronous with observer. Add method for checking if update is necessary (without invoking the update).

petrdvorak commented 5 years ago

... or we should have first talked about the observer callback naming - the correct one is onYouCanContinueFriendlyDeveloper(). This would emphasize that from our consumer developer perspective, the network activity and updates are irrelevant and should be hidden...

petrdvorak commented 5 years ago

On the other hand, if we just add UpdateType to the onUpdateFinished method, it will work and in a way, the API will give our developer more control. We can also then implement class alongside these lines:

public class DefaultUpdateObserver implements UpdateObserver {

   public void onUpdateStarted(UpdateType type) {
        if (type == UpdateType.SILENT || type == UpdateType.NO_UPDATE) {
            runTask(); // run the task now...
        }
    }

    public void onUpdateFinished(UpdateType type, UpdateResult result) {
        if (result == UpdateResult.OK) {
            if (UpdateType == UpdateType.DIRECT) {
                runTask(); // run the task later
            }
        }
    }

   public abstract void runTask();

}
TomasKypta commented 5 years ago

OK, I can we can extend onUpdateFinished. It's not necessary, you can easily work around it, but it simplifies things for the devs. And the default is some a nice to have.