// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.oliodevices.assist.app.api; import android.content.Context; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.deser.BeanDeserializer; import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.deser.SettableBeanProperty; import com.olio.communication.messages.MessagePayload; import com.olio.communication.messages.files.TransferStatus; import com.olio.communication.messages.files.TransferStatusBuilder; import com.olio.communication.messages.unit.PairedDeviceProfile; import com.olio.communication.messages.unit.WatchProfile; import com.olio.data.object.analytics.AnalyticsPayload; import com.olio.data.object.user.ActivityTimes; import com.olio.data.object.user.CalendarSettings; import com.olio.data.object.user.FavoriteContacts; import com.olio.data.object.user.Locations; import com.olio.data.object.user.TransportationSettings; import com.olio.state.Unit; import com.olio.util.ALog; import com.oliodevices.assist.app.api.models.AppRequirementsResponse; import com.oliodevices.assist.app.api.models.LoginBody; import com.oliodevices.assist.app.api.models.Me; import com.oliodevices.assist.app.api.models.RegisterBody; import com.oliodevices.assist.app.api.models.RegisterResponse; import com.oliodevices.assist.app.api.models.SettingsEnvelope; import com.oliodevices.assist.app.api.models.TokenResponse; import com.oliodevices.assist.app.api.models.UnitBody; import com.oliodevices.assist.app.api.models.UnitPostSettings; import com.oliodevices.assist.app.api.models.UnitPutSettings; import com.oliodevices.assist.app.api.models.UpdateUserResponse; import com.oliodevices.assist.app.api.models.User; import com.oliodevices.assist.app.api.models.UserBody; import com.oliodevices.assist.app.api.models.UserPutSettings; import com.oliodevices.assist.app.api.models.WebSetting; import com.oliodevices.assist.app.core.Utils; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Map; import org.json.JSONException; import org.json.JSONObject; import retrofit.Callback; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.RetrofitError; import retrofit.client.Response; import retrofit.converter.JacksonConverter; // Referenced classes of package com.oliodevices.assist.app.api: // UserManager, OlioPropertyNamingStrategy, OlioService, ApiResultCallback, // ApiCallback, JsonUtils public class OlioApi { private static final String BASE_URL = "https://api.oliodevices.com"; private static final String PAIRED_DEVICE_PROFILE = "PairedDeviceProfile"; private static final String SETTING_TYPE_DEVICE = "device"; private static final String SETTING_TYPE_USER = "user"; private static final String TRANSFER_STATUS = "TransferStatus"; private static final String WATCH_PROFILE = "WatchProfile"; private static OlioApi sInstance; private final OlioService mService; private final UserManager mUserManager = UserManager.getInstance(); private ObjectMapper mapper; private OlioApi() { Object obj = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); mapper = new ObjectMapper(); mapper.setDateFormat(((java.text.DateFormat) (obj))); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); mapper.setPropertyNamingStrategy(new OlioPropertyNamingStrategy()); mapper.addHandler(new DeserializationProblemHandler() { final OlioApi this$0; public boolean handleUnknownProperty(DeserializationContext deserializationcontext, JsonParser jsonparser, JsonDeserializer jsondeserializer, Object obj1, String s) throws IOException, JsonProcessingException { if (jsondeserializer instanceof BeanDeserializer) { SettableBeanProperty settablebeanproperty = ((BeanDeserializer)jsondeserializer).findProperty(JsonUtils.camelCaseToUnderscore(s)); if (settablebeanproperty != null) { settablebeanproperty.deserializeAndSet(jsonparser, deserializationcontext, obj1); return true; } } return super.handleUnknownProperty(deserializationcontext, jsonparser, jsondeserializer, obj1, s); } { this$0 = OlioApi.this; super(); } }); obj = new JacksonConverter(mapper); RequestInterceptor requestinterceptor = new RequestInterceptor() { final OlioApi this$0; public void intercept(retrofit.RequestInterceptor.RequestFacade requestfacade) { requestfacade.addHeader("Authorization", String.format("Bearer %s", new Object[] { mUserManager.getAccessToken() })); requestfacade.addHeader("Content-Type", "application/json"); } { this$0 = OlioApi.this; super(); } }; mService = (OlioService)(new retrofit.RestAdapter.Builder()).setEndpoint("https://api.oliodevices.com").setRequestInterceptor(requestinterceptor).setConverter(((retrofit.converter.Converter) (obj))).setLogLevel(retrofit.RestAdapter.LogLevel.NONE).build().create(com/oliodevices/assist/app/api/OlioService); } public static OlioApi getInstance() { if (sInstance == null) { sInstance = new OlioApi(); } return sInstance; } public void checkAppServerCompatibility(final ApiResultCallback callback) { mService.getAppRequirements(1, new Callback() { final OlioApi this$0; final ApiResultCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(AppRequirementsResponse apprequirementsresponse, Response response) { callback.callSuccess(apprequirementsresponse); } public volatile void success(Object obj, Response response) { success((AppRequirementsResponse)obj, response); } { this$0 = OlioApi.this; callback = apiresultcallback; super(); } }); } public void claimUnit(final String unitId, final ApiResultCallback callback) { String s = Utils.generateSecretKey(mUserManager.getAccessToken(), unitId); mService.claimUnit(s, unitId, new UnitBody(mUserManager.getUserId()), new Callback() { final OlioApi this$0; final ApiResultCallback val$callback; final String val$unitId; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(Unit unit, Response response) { mUserManager.updateUnitId(unitId); callback.callSuccess(unit); } public volatile void success(Object obj, Response response) { success((Unit)obj, response); } { this$0 = OlioApi.this; unitId = s; callback = apiresultcallback; super(); } }); } public void confirmPassword(String s, final ApiCallback callback) { String s1 = mUserManager.getEmailAddress(); mService.logIn(new LoginBody(s1, s), new Callback() { final OlioApi this$0; final ApiCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(TokenResponse tokenresponse, Response response) { callback.success(); } public volatile void success(Object obj, Response response) { success((TokenResponse)obj, response); } { this$0 = OlioApi.this; callback = apicallback; super(); } }); } public void getAllUserSettings(final Context context, long l, final ApiCallback callback) { mService.getAllUserSettings(l, new Callback() { final OlioApi this$0; final ApiCallback val$callback; final Context val$context; public void failure(RetrofitError retrofiterror) { ALog.d("Failed to load user settings from server", new Object[0]); callback.failure(retrofiterror); } public volatile void success(Object obj, Response response) { success((SettingsEnvelope[])obj, response); } public void success(SettingsEnvelope asettingsenvelope[], Response response) { int i = 0; _L27: if (i >= asettingsenvelope.length) goto _L2; else goto _L1 _L1: if (asettingsenvelope[i].getName() == null) goto _L4; else goto _L3 _L3: byte byte0; response = asettingsenvelope[i].getName(); byte0 = -1; response.hashCode(); JVM INSTR lookupswitch 10: default 124 // -1906117169: 318 // -1197189282: 217 // -979433006: 231 // -767003089: 273 // -538426975: 303 // -247667369: 259 // 393364324: 245 // 457582948: 203 // 806778686: 288 // 807749384: 189; goto _L5 _L6 _L7 _L8 _L9 _L10 _L11 _L12 _L13 _L14 _L15 _L5: byte0; JVM INSTR tableswitch 0 9: default 180 // 0 333 // 1 356 // 2 379 // 3 402 // 4 425 // 5 448 // 6 471 // 7 494 // 8 517 // 9 540; goto _L4 _L16 _L17 _L18 _L19 _L20 _L21 _L22 _L23 _L24 _L25 _L4: i++; continue; /* Loop/switch isn't completed */ _L15: if (response.equals("activity-times")) { byte0 = 0; } goto _L5 _L13: if (response.equals("favorite-contacts")) { byte0 = 1; } goto _L5 _L7: if (response.equals("locations")) { byte0 = 2; } goto _L5 _L8: if (response.equals("calendar-settings")) { byte0 = 3; } goto _L5 _L12: if (response.equals("transportation-settings")) { byte0 = 4; } goto _L5 _L11: if (response.equals("ActivityTimes")) { byte0 = 5; } goto _L5 _L9: if (response.equals("FavoriteContacts")) { byte0 = 6; } goto _L5 _L14: if (response.equals("Locations")) { byte0 = 7; } goto _L5 _L10: if (response.equals("CalendarSettings")) { byte0 = 8; } goto _L5 _L6: if (response.equals("TransportationSettings")) { byte0 = 9; } goto _L5 _L16: ((ActivityTimes)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L17: ((FavoriteContacts)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L18: ((Locations)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L19: ((CalendarSettings)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L20: ((TransportationSettings)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L21: ((ActivityTimes)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L22: ((FavoriteContacts)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L23: ((Locations)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L24: ((CalendarSettings)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L25: ((TransportationSettings)asettingsenvelope[i].getValue()).save(context.getContentResolver()); goto _L4 _L2: callback.success(); return; if (true) goto _L27; else goto _L26 _L26: } { this$0 = OlioApi.this; context = context1; callback = apicallback; super(); } }); } public ObjectMapper getObjectMapper() { return mapper; } public void getOneUserSetting(final Context context, final String thisSettingName, Long long1, final ApiCallback callback) { HashMap hashmap = new HashMap(); hashmap.put("id", thisSettingName); hashmap.put("setting_type", "user"); hashmap.put("object_id", long1); mService.getOneUserSetting(hashmap, thisSettingName, new Callback() { final OlioApi this$0; final ApiCallback val$callback; final Context val$context; final String val$thisSettingName; public void failure(RetrofitError retrofiterror) { ALog.d("Failed to load a specific user setting from server", new Object[0]); callback.failure(retrofiterror); } public void success(SettingsEnvelope settingsenvelope, Response response) { byte byte0; byte0 = 0; ALog.d(settingsenvelope.toString(), new Object[0]); response = thisSettingName; response.hashCode(); JVM INSTR lookupswitch 5: default 72 // -1197189282: 144 // -979433006: 158 // 393364324: 172 // 457582948: 130 // 807749384: 118; goto _L1 _L2 _L3 _L4 _L5 _L6 _L1: byte0 = -1; _L13: byte0; JVM INSTR tableswitch 0 4: default 108 // 0 186 // 1 206 // 2 226 // 3 246 // 4 266; goto _L7 _L8 _L9 _L10 _L11 _L12 _L7: callback.success(); return; _L6: if (!response.equals("activity-times")) goto _L1; else goto _L13 _L5: if (!response.equals("favorite-contacts")) goto _L1; else goto _L14 _L14: byte0 = 1; goto _L13 _L2: if (!response.equals("locations")) goto _L1; else goto _L15 _L15: byte0 = 2; goto _L13 _L3: if (!response.equals("calendar-settings")) goto _L1; else goto _L16 _L16: byte0 = 3; goto _L13 _L4: if (!response.equals("transportation-settings")) goto _L1; else goto _L17 _L17: byte0 = 4; goto _L13 _L8: ((ActivityTimes)settingsenvelope.getValue()).save(context.getContentResolver()); goto _L7 _L9: ((FavoriteContacts)settingsenvelope.getValue()).save(context.getContentResolver()); goto _L7 _L10: ((Locations)settingsenvelope.getValue()).save(context.getContentResolver()); goto _L7 _L11: ((CalendarSettings)settingsenvelope.getValue()).save(context.getContentResolver()); goto _L7 _L12: ((TransportationSettings)settingsenvelope.getValue()).save(context.getContentResolver()); goto _L7 } public volatile void success(Object obj, Response response) { success((SettingsEnvelope)obj, response); } { this$0 = OlioApi.this; thisSettingName = s; context = context1; callback = apicallback; super(); } }); } public void getTestSettings(String s, String s1, ApiCallback apicallback) { mService.getUnitSettings(s, s1, new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.d("Failed to get the settings", new Object[0]); } public void success(WebSetting websetting, Response response) { ALog.d(websetting.toString(), new Object[0]); } public volatile void success(Object obj, Response response) { success((WebSetting)obj, response); } { this$0 = OlioApi.this; super(); } }); } public void getUnit(String s, final ApiResultCallback callback) { mService.getUnit(s, new Callback() { final OlioApi this$0; final ApiResultCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(Unit unit, Response response) { callback.callSuccess(unit); } public volatile void success(Object obj, Response response) { success((Unit)obj, response); } { this$0 = OlioApi.this; callback = apiresultcallback; super(); } }); } public void getUnitDetails(String s, Callback callback) { mService.getUnitDetails(s, callback); } public void logIn(String s, String s1, final ApiCallback callback) { s = new LoginBody(s, s1); mService.logIn(s, new Callback() { final OlioApi this$0; final ApiCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(TokenResponse tokenresponse, Response response) { mUserManager.storeAccessToken(tokenresponse.accessToken); mService.getMe(new Callback() { final _cls3 this$1; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(Me me, Response response) { mUserManager.storeUserDetails(me.id, me.email); callback.success(); } public volatile void success(Object obj, Response response) { success((Me)obj, response); } { this$1 = _cls3.this; super(); } }); } public volatile void success(Object obj, Response response) { success((TokenResponse)obj, response); } { this$0 = OlioApi.this; callback = apicallback; super(); } }); } public void logOut(final ApiCallback callback) { mService.logOut(new Callback() { final OlioApi this$0; final ApiCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public volatile void success(Object obj, Response response) { success((Response)obj, response); } public void success(Response response, Response response1) { mUserManager.clearDetails(); callback.success(); } { this$0 = OlioApi.this; callback = apicallback; super(); } }); } public void postLogs(AnalyticsPayload analyticspayload, Callback callback) { mService.postLogs(analyticspayload, callback); } public void postUnitSettings(UnitPostSettings unitpostsettings, ApiCallback apicallback) { unitpostsettings = new UnitPostSettings("device", "22:22:58:31:47:2C", new SettingsEnvelope("NewSettingsObject", TransferStatusBuilder.aTransferStatus().setStatus(com.olio.communication.messages.files.TransferStatus.TransferStatusActivity.STARTED).setFileIdentifier("FirmwareUpdate").setProgress(10).setVersion("1.0").setType("TransferStatus").build())); mService.postUnitSettings(unitpostsettings, new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.d("Failed to create the settings", new Object[0]); } public void success(WebSetting websetting, Response response) { ALog.d(websetting.toString(), new Object[0]); } public volatile void success(Object obj, Response response) { success((WebSetting)obj, response); } { this$0 = OlioApi.this; super(); } }); } public void putUnitSettings(ApiCallback apicallback) { apicallback = TransferStatusBuilder.aTransferStatus().setStatus(com.olio.communication.messages.files.TransferStatus.TransferStatusActivity.PAUSED).setFileIdentifier("FirmwareUpdate").setProgress(40).setVersion("1.0").setType("TransferStatus").build(); try { new JSONObject(apicallback.jsonEncode()); } catch (JSONException jsonexception) { jsonexception.printStackTrace(); } apicallback = new UnitPutSettings("NewDownloadStatus3", "device", "22:22:58:31:47:2C", new SettingsEnvelope("NewDownloadStatus3", apicallback)); mService.putUnitSettings(apicallback, "NewDownloadStatus3", new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.d("Failed to update the settings", new Object[0]); } public void success(WebSetting websetting, Response response) { ALog.d(websetting.toString(), new Object[0]); } public volatile void success(Object obj, Response response) { success((WebSetting)obj, response); } { this$0 = OlioApi.this; super(); } }); } public void putUserSettings(String s, MessagePayload messagepayload) { messagepayload = new SettingsEnvelope(s, messagepayload); messagepayload = new UserPutSettings(s, "user", mUserManager.getUserId(), messagepayload); mService.putUserSettings(messagepayload, s, new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.e("Failed to update user settings", retrofiterror, new Object[0]); } public volatile void success(Object obj, Response response) { success((Response)obj, response); } public void success(Response response, Response response1) { ALog.d("Updated user settings", new Object[0]); } { this$0 = OlioApi.this; super(); } }); } public void register(String s, String s1, String s2, String s3, final ApiCallback callback) { s = new RegisterBody(s, s1, s2, s3); mService.register(s, new Callback() { final OlioApi this$0; final ApiCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(RegisterResponse registerresponse, Response response) { mUserManager.storeAccessToken(registerresponse.accessToken); mUserManager.storeUserDetails(registerresponse.user.id.longValue(), registerresponse.user.email); callback.success(); } public volatile void success(Object obj, Response response) { success((RegisterResponse)obj, response); } { this$0 = OlioApi.this; callback = apicallback; super(); } }); } public void unregisterUnit(String s, Callback callback) { mService.unregisterUnit(s, callback); } public void updateEmail(String s, final ApiCallback callback) { long l = mUserManager.getUserId(); s = UserBody.userBodyWithEmail(s); mService.updateUser(l, s, new Callback() { final OlioApi this$0; final ApiCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(UpdateUserResponse updateuserresponse, Response response) { mUserManager.updateEmailAddress(updateuserresponse.email); callback.success(); } public volatile void success(Object obj, Response response) { success((UpdateUserResponse)obj, response); } { this$0 = OlioApi.this; callback = apicallback; super(); } }); } public void updatePairedDeviceProfileSetting(PairedDeviceProfile paireddeviceprofile) { ALog.d("Sending paired device profile", new Object[0]); paireddeviceprofile = new SettingsEnvelope("PairedDeviceProfile", paireddeviceprofile); paireddeviceprofile = new UnitPutSettings("PairedDeviceProfile", "device", mUserManager.getUnitId(), paireddeviceprofile); mService.putUnitSettings(paireddeviceprofile, "PairedDeviceProfile", new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.e("Failed to update paired device profile", retrofiterror, new Object[0]); } public void success(WebSetting websetting, Response response) { ALog.d(websetting.toString(), new Object[0]); } public volatile void success(Object obj, Response response) { success((WebSetting)obj, response); } { this$0 = OlioApi.this; super(); } }); } public void updatePassword(String s, String s1, final ApiCallback callback) { long l = mUserManager.getUserId(); s = UserBody.userBodyWithPasswords(s, s1); mService.updateUser(l, s, new Callback() { final OlioApi this$0; final ApiCallback val$callback; public void failure(RetrofitError retrofiterror) { callback.failure(retrofiterror); } public void success(UpdateUserResponse updateuserresponse, Response response) { callback.success(); } public volatile void success(Object obj, Response response) { success((UpdateUserResponse)obj, response); } { this$0 = OlioApi.this; callback = apicallback; super(); } }); } public void updateTransferStatusSetting(TransferStatus transferstatus) { transferstatus = new SettingsEnvelope("TransferStatus", transferstatus); transferstatus = new UnitPutSettings("TransferStatus", "device", mUserManager.getUnitId(), transferstatus); mService.putUnitSettings(transferstatus, "TransferStatus", new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.e("Failed to update transfer status", retrofiterror, new Object[0]); } public void success(WebSetting websetting, Response response) { ALog.d(websetting.toString(), new Object[0]); } public volatile void success(Object obj, Response response) { success((WebSetting)obj, response); } { this$0 = OlioApi.this; super(); } }); } public void updateUserSettings() { } public void updateWatchProfileSetting(WatchProfile watchprofile) { watchprofile = new SettingsEnvelope("WatchProfile", watchprofile); watchprofile = new UnitPutSettings("WatchProfile", "device", mUserManager.getUnitId(), watchprofile); mService.putUnitSettings(watchprofile, "WatchProfile", new Callback() { final OlioApi this$0; public void failure(RetrofitError retrofiterror) { ALog.e("Failed to update watch profile", retrofiterror, new Object[0]); } public void success(WebSetting websetting, Response response) { ALog.d(websetting.toString(), new Object[0]); } public volatile void success(Object obj, Response response) { success((WebSetting)obj, response); } { this$0 = OlioApi.this; super(); } }); } }