예제 #1
0
 public int REST(boolean z) {
   int i = 1;
   ApSingleton instance = ApSingleton.getInstance(this.ctx);
   int doGet = doGet(true);
   if (doGet != 1) {
     instance.getClass();
     return doGet;
   }
   if (this.returnData == null) {
     instance.getClass();
   } else if (z) {
     try {
       this.returnDataJSON = JSONObjectInstrumentation.init(this.returnData);
       try {
         if (this.returnDataJSON
             .getString(NotificationCompatApi21.CATEGORY_STATUS)
             .toLowerCase()
             .equals("ok")) {
           instance.getClass();
         }
       } catch (JSONException e) {
       }
       JSONArray jSONArray = instance.desired;
       JSONArray jSONArray2 = this.returnDataJSON.getJSONArray("desired");
       instance.desired = jSONArray2;
       if (jSONArray2 == null) {
         instance.getClass();
         i = 0;
       } else {
         trackResolve(instance.canonicalKeyspace);
         if (!(jSONArray == null || instance.desired.equals(jSONArray))) {
           instance.getClass();
           ApsalarSQLiteHelper.clearConfigTables();
           Apsalar.loadConfig(this.ctx);
           instance.devicesAlreadyResolved = false;
           instance.already_did_SQL = false;
         }
         instance.getClass();
       }
     } catch (Throwable th) {
       instance.incrExceptionCount();
       instance.getClass();
       i = 0;
     }
     if (!(instance.devicesAlreadyResolved || do_resolve())) {
       i = 0;
     }
   } else {
     instance.getClass();
     i = 0;
   }
   instance.getClass();
   return i;
 }
예제 #2
0
 public int doGet(boolean z) {
   int i;
   ApSingleton instance = ApSingleton.getInstance(this.ctx);
   Apsalar.getDeviceId(instance.canonicalKeyspace);
   instance.getClass();
   if (makeURL(z)) {
     i = 1;
   } else if (alreadyResolved(instance.canonicalKeyspace)) {
     instance.getClass();
     return 1;
   } else {
     instance.getClass();
     i = -1;
   }
   if (i != 1) {
     return i;
   }
   int i2;
   String str = this.url;
   String str2 = Trace.NULL;
   try {
     MessageDigest instance2 = MessageDigest.getInstance("SHA-1");
     instance2.reset();
     instance2.update(this.info.secret.getBytes(HTTP.UTF_8));
     instance2.update(str.getBytes(HTTP.UTF_8));
     str2 = Apsalar.hexDigest(instance2.digest());
     i2 = i;
   } catch (NoSuchAlgorithmException e) {
     instance.incrExceptionCount();
     instance.getClass();
     i2 = -1;
   } catch (UnsupportedEncodingException e2) {
     instance.incrExceptionCount();
     instance.getClass();
     i2 = -1;
   } catch (IndexOutOfBoundsException e3) {
     instance.incrExceptionCount();
     instance.getClass();
     i2 = -1;
   }
   str2 = this.urlbase + str + "&h=" + str2;
   instance.getClass();
   if (i2 != 1) {
     return i2;
   }
   this.returnData = null;
   if (i2 != 1) {
     return i2;
   }
   try {
     this.returnData = ApsalarHttpClient.get(str2);
     try {
       if (this.returnData != null) {
         instance.incrSentEventsCount();
       }
       this.returnDataJSON = JSONObjectInstrumentation.init(this.returnData);
       String string = this.returnDataJSON.getString("k");
       String string2 = this.returnDataJSON.getString("u");
       instance.getClass();
       if (!this.old_k.equals(instance.canonicalKeyspace)
           || !this.old_u.equals(instance.canonicalDeviceId)) {
         return i2;
       }
       changeDeviceKeys(string, string2, this.old_k, this.old_u, false);
       return i2;
     } catch (JSONException e4) {
       instance.incrExceptionCount();
       instance.getClass();
       return i2;
     }
   } catch (ProtocolException e5) {
     instance.incrExceptionCount();
     instance.getClass();
     return -1;
   } catch (SocketTimeoutException e6) {
     instance.incrExceptionCount();
     instance.incrNetworkErrorCount();
     instance.getClass();
     return 0;
   } catch (IOException e7) {
     instance.incrExceptionCount();
     instance.incrNetworkErrorCount();
     instance.getClass();
     return 0;
   }
 }