diff --git a/app/build.gradle b/app/build.gradle index a75115c89..a3c57e657 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,12 +23,12 @@ android { assets.srcDirs = ['src/main/assets'] } } - compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } - + productFlavors { + } } dependencies { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e6bfff955..76f205a45 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="20" + android:versionName="0.1.20"> list = mAimsicdService.executeAtCommand(atCommand); - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (list != null) { - mAtResponse.setText(TextUtils.join("\n", list)); - } - } - }); - }catch (Exception e) { - Log.e("AIMSICD", "requestResponse " + e); + //Check busybox is installed + boolean busybox = Helpers.checkBusybox(); + if (!busybox) { + return BUSYBOX_UNAVAILABLE; } + + //Draw Ril Serial Device details from the System Property + String rilDevice = Helpers.getSystemProp(mContext, "rild.libargs", "UNKNOWN"); + mRilDevice = (rilDevice.equals("UNKNOWN") ? rilDevice : rilDevice.substring(3)); + mRilDeviceDisplay.setText(mRilDevice); + + if (mRilDevice.equals("UNKNOWN")) + return RIL_INIT_ERROR; + + return RIL_INIT_OK; } + private void executeAT() { + if (mAtCommand.getText() != null) { + mAtResponse.setText(""); + String cmdSetup = "cat " + mRilDevice + " &"; + new ExecuteAtCommand().execute(cmdSetup); + String atCommand = mAtCommand.getText().toString(); + new ExecuteAtCommand().execute("echo -e " + atCommand +"\r > " + mRilDevice); + } + } - private class RequestOemInfoTask extends AsyncTask { - @Override - protected Void doInBackground(Void... string) { - if (!mBound) return null; - requestResponse(); + private class ExecuteAtCommand extends AsyncTask { - return null; + protected CommandResult doInBackground(String... atCommand) { + return CMDProcessor.runSuCommand(atCommand[0]); } - @Override - protected void onPostExecute(Void aVoid) { - super.onPostExecute(aVoid); + protected void onPostExecute(CommandResult result) { + if (result != null) { + Log.i("AIMSICD_ATCommand", "Stdout: " + result.getStdout() + + " StdErr: " + result.getStderr() + " Exit Value: " + result.getExitValue()); + if (!result.getStdout().isEmpty()) + mAtResponse.append(result.getStdout()); + else if (!result.getStderr().isEmpty()) + mAtResponse.append(result.getStderr()); + else + mAtResponse.append("No response or error detected..."); + } } } + } diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/utils/CommandResult.java b/app/src/main/java/com/SecUpwN/AIMSICD/utils/CommandResult.java index 74622e6f8..8bfc2fc5f 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/utils/CommandResult.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/utils/CommandResult.java @@ -21,6 +21,8 @@ package com.SecUpwN.AIMSICD.utils; +import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; + import android.os.Environment; import android.os.Parcel; import android.os.Parcelable; @@ -106,8 +108,7 @@ private void checkForErrors() { FileWriter errorWriter = null; try { File errorLogFile = new File( - Environment.getExternalStorageDirectory() - + "/aokp/error.txt" + AIMSICDDbAdapter.FOLDER + "error.txt" ); if (!errorLogFile.exists()) { errorLogFile.createNewFile(); @@ -175,7 +176,6 @@ public CommandResult[] newArray(int size) { } }; - @Override public boolean equals(Object o) { if (this == o) { @@ -189,8 +189,8 @@ public boolean equals(Object o) { return (mStartTime == that.mStartTime && mExitValue == that.mExitValue && - mStdout == that.mStdout && - mStderr == that.mStderr && + mStdout.equals(that.mStdout) && + mStderr.equals(that.mStderr) && mEndTime == that.mEndTime); } diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java b/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java index 5c3325ced..314332209 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java @@ -125,7 +125,7 @@ public static Boolean isNetAvailable(Context context) { * @param lat Latitude of current location * @param lng Longitude of current location */ - public static void getOpenCellData(Context context, double lat, double lng, int type) { + public static void getOpenCellData(Context context, double lat, double lng, char type) { if (Helpers.isNetAvailable(context)) { double earthRadius = 6371.01; diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java b/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java index 7f1e789cd..ba04b21e8 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java @@ -22,25 +22,25 @@ import java.net.URL; import java.net.URLConnection; -public class RequestTask extends AsyncTask { +public class RequestTask extends AsyncTask { - public static final int OPEN_CELL_ID_REQUEST = 1; - public static final int OPEN_CELL_ID_REQUEST_FROM_MAP = 2; - public static final int BACKUP_DATABASE = 3; - public static final int RESTORE_DATABASE = 4; + public static final char OPEN_CELL_ID_REQUEST = 1; + public static final char OPEN_CELL_ID_REQUEST_FROM_MAP = 2; + public static final char BACKUP_DATABASE = 3; + public static final char RESTORE_DATABASE = 4; private final AIMSICDDbAdapter mDbAdapter; private final Context mContext; - private final int mType; + private final char mType; - public RequestTask(Context context, int type) { + public RequestTask(Context context, char type) { mType = type; mContext = context; mDbAdapter = new AIMSICDDbAdapter(mContext); } @Override - protected String doInBackground(String... urlString) { + protected String doInBackground(String... commandString) { switch (mType) { case OPEN_CELL_ID_REQUEST: @@ -56,7 +56,7 @@ protected String doInBackground(String... urlString) { } File file = new File(dir, "opencellid.csv"); - URL url = new URL(urlString[0]); + URL url = new URL(commandString[0]); URLConnection connection = url.openConnection(); connection.connect(); @@ -78,7 +78,7 @@ protected String doInBackground(String... urlString) { while ((count = input.read(data)) != -1) { total += count; - AIMSICD.mProgressBar.setProgress((int) ((total * 100) / lengthOfFile)); + publishProgress((int) ((total * 100) / lengthOfFile)); // writing data to file output.write(data, 0, count); @@ -118,6 +118,11 @@ protected String doInBackground(String... urlString) { return null; } + + protected void onProgressUpdate(Integer... values) { + AIMSICD.mProgressBar.setProgress(values[0]); + } + @Override protected void onPostExecute(String result) { super.onPostExecute(result); diff --git a/app/src/main/res/layout/at_command_fragment.xml b/app/src/main/res/layout/at_command_fragment.xml index 831a80b11..4b817f758 100644 --- a/app/src/main/res/layout/at_command_fragment.xml +++ b/app/src/main/res/layout/at_command_fragment.xml @@ -1,7 +1,7 @@ @@ -12,6 +12,29 @@ android:textColor="@color/green_text" android:padding="4dip" android:id="@+id/at_command_title"/> + + + + + android:padding="8dip"/> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4463ffac9..1b57737fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -190,6 +190,7 @@ Enter AT Command: Response: Execute + Ril Serial Device: Silent SMS Intercepted