Skip to content

Commit

Permalink
AT Command Timeout Option
Browse files Browse the repository at this point in the history
Added another spinner to allow selection of a number of timeout values to assist with
receiving the AT Command response, values currently available are: 2, 5, 8, 10 & 15
seconds.
  • Loading branch information
xLaMbChOpSx committed Jul 3, 2014
1 parent 1ff7a3a commit 1cbc244
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SecUpwN.AIMSICD"
android:versionCode="21"
android:versionName="0.1.21">
android:versionCode="22"
android:versionName="0.1.22">

<uses-feature
android:glEsVersion="0x00020000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public class AtCommandFragment extends Fragment {
private final int EXECUTE_AT = 300;
private final int EXECUTE_COMMAND = 301;

//System items
private Context mContext;
private Shell mShell = null;
private String mSerialDevice;
private float mTimeout;
private final List<String> mSerialDevices = new ArrayList<>();

private List<String> mOutput;
Expand All @@ -56,6 +56,7 @@ public class AtCommandFragment extends Fragment {
private EditText mAtCommand;
private Spinner mSerialDeviceSpinner;
private TextView mSerialDeviceSpinnerLabel;
private Spinner mTimoutSpinner;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Expand All @@ -72,11 +73,47 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
mSerialDeviceSpinner = (Spinner) mView.findViewById(R.id.serial_device_spinner);
mSerialDeviceSpinner.setOnItemSelectedListener(new spinnerListener());
mSerialDeviceSpinnerLabel = (TextView) mView.findViewById(R.id.serial_device_spinner_title);
mTimoutSpinner = (Spinner) mView.findViewById(R.id.timeout_spinner);
mTimoutSpinner.setOnItemSelectedListener(new timoutSpinnerListener());
mTimoutSpinner.setSelection(1);
mTimeout = 5.0f;
}

return mView;
}

private class timoutSpinnerListener implements AdapterView.OnItemSelectedListener {

@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView,
int position, long id) {
switch (position) {
case 0: //2 seconds
mTimeout = 2.0f;
break;
case 1: //5 seconds
mTimeout = 5.0f;
break;
case 2: //8 seconds
mTimeout = 8.0f;
break;
case 3: //10 seconds
mTimeout = 10.0f;
break;
case 4: //15 seconds
mTimeout = 15.0f;
break;
default:
mTimeout = 5.0f;
}
}

@Override
public void onNothingSelected(AdapterView<?> parentView) {

}
}

private class spinnerListener implements AdapterView.OnItemSelectedListener {

@Override
Expand Down Expand Up @@ -198,7 +235,7 @@ private int initSerialDevice() {
mSerialDevices.add(mSerialDevice);
}

boolean result = mShell.sendCommandPreserveOut("ls /dev/radio | grep atci*", 5.0f);
boolean result = mShell.sendCommandPreserveOut("ls /dev/radio | grep atci*", mTimeout);
if (result) {
mOutput = new ArrayList<>();
mOutput = mShell.GetStdOut();
Expand All @@ -220,7 +257,7 @@ private int initSerialDevice() {
File xgold = new File("/system/etc/ril_xgold_radio.cfg");
if (xgold.exists() && xgold.isFile()) {
result = mShell.sendCommandPreserveOut("cat /system/etc/ril_xgold_radio.cfg | "
+ "grep -E \"atport*|dataport*\"", 5.0f);
+ "grep -E \"atport*|dataport*\"", mTimeout);
if (result) {
mOutput = new ArrayList<>();
mOutput = mShell.GetStdOut();
Expand Down Expand Up @@ -277,7 +314,7 @@ private boolean executeAT() {
private boolean executeCommand() {
boolean result = false;
if (mAtCommand.getText() != null) {
result = mShell.sendCommandPreserveOut(mAtCommand.getText().toString(), 5.0f);
result = mShell.sendCommandPreserveOut(mAtCommand.getText().toString(), mTimeout);
if (result) {
mOutput = new ArrayList<>();
mOutput = mShell.GetStdOut();
Expand Down
18 changes: 14 additions & 4 deletions app/src/main/res/layout/at_command_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,30 @@
android:layout_below="@+id/serial_device_spinner"
android:id="@+id/atcommandView"
android:visibility="gone">

<TextView
android:id="@+id/enter_at_command_title"
android:id="@+id/timeout_spinner_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/enter_at_command_title"
android:text="@string/timeout_spinner_title"
android:textColor="@color/white"
android:padding="8dip"/>
android:padding="8dip" />

<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/timeout_spinner"
android:entries="@array/timeout_spinner_values"
android:prompt="@string/timeout_spinner_prompt"
android:layout_toRightOf="@id/timeout_spinner_title" />

<EditText
android:id="@+id/at_command"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_below="@+id/enter_at_command_title"
android:hint="@string/command_hint"
android:layout_below="@+id/timeout_spinner_title"
android:layout_toLeftOf="@+id/execute"/>

<Button
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@
<item>"300"</item>
</string-array>

<string-array name="navigation_array">
<item>"Device Information"</item>
<item>"Cell Information"</item>
<item>"AT Command Injector"</item>
<item>"Database Viewer"</item>
<item>"Map Viewer"</item>
<item>"About AIMSICD"</item>
<string-array name="timeout_spinner_values">
<item>"2 sec"</item>
<item>"5 sec"</item>
<item>"8 sec"</item>
<item>"10 sec"</item>
<item>"15 sec"</item>
</string-array>


</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@

<!-- AT Command Injector -->
<string name="at_command_title">AT Command Injector</string>
<string name="enter_at_command_title">Enter AT Command:</string>
<string name="response_label">Response:</string>
<string name="execute_at">Execute</string>
<string name="serial_device_title">Current Serial Device:</string>
<string name="serial_device_prompt">Select Serial Device</string>
<string name="serial_device_spinner_title">Detected Devices:</string>
<string name="timeout_spinner_title">Timeout:</string>
<string name="timeout_spinner_prompt">Select Timeout</string>
<string name="command_hint">Enter Command…</string>

<!-- SILENT SMS FRAGMENT -->
<string name="sms_title">Silent SMS Intercepted</string>
Expand Down

0 comments on commit 1cbc244

Please sign in to comment.