コード例 #1
0
 private void m14500a(String str) {
   CharSequence userId = ((OlaApp) this.f10979j.getApplication()).m12878a().m13209c().getUserId();
   if (TextUtils.isEmpty(userId)) {
     PreferenceManager.getDefaultSharedPreferences(this.f10979j)
         .getString(Constants.PREF_USER_ID, null);
   }
   JSONObject jSONObject = new JSONObject();
   try {
     jSONObject.put(Constants.USER_ID, userId);
     if (this.f10987r != null) {
       jSONObject.put(Constants.ARG_KRN, this.f10987r);
     }
     jSONObject.put("text", str);
     this.f10973d = str;
   } catch (JSONException e) {
     e.printStackTrace();
   }
   try {
     StringEntity stringEntity =
         new StringEntity(
             !(jSONObject instanceof JSONObject)
                 ? jSONObject.toString()
                 : JSONObjectInstrumentation.toString(jSONObject));
   } catch (UnsupportedEncodingException e2) {
     e2.printStackTrace();
   }
   this.f10969D.m13245i(new WeakReference(this.f10974e), this.f10987r, str, f10965a);
 }
コード例 #2
0
ファイル: ApsalarResolve.java プロジェクト: cherakkara/iwms
 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;
 }
コード例 #3
0
ファイル: ApsalarResolve.java プロジェクト: cherakkara/iwms
 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;
   }
 }