Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
General code clean up including removal of unnecessary initializations, unused methods
or methods which were no longer required, declaration access tweaked where
appropriate.
  • Loading branch information
xLaMbChOpSx committed Jul 8, 2014
1 parent dc7c337 commit 3c3bf3e
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 80 deletions.
12 changes: 4 additions & 8 deletions app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public class AIMSICD extends Activity implements AsyncResponse {
private CharSequence mTitle;
public static ProgressBar mProgressBar;

private LocationServices.LocationAsync mLocationAsync;

//Back press to exit timer
private long mLastPress = 0;

Expand Down Expand Up @@ -228,7 +226,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
}

/** Swaps fragments in the main content view */
public void selectItem(int position) {
void selectItem(int position) {
NavDrawerItem selectedItem = mNavConf.getNavItems().get(position);

// Create a new fragment
Expand Down Expand Up @@ -269,19 +267,17 @@ public void selectItem(int position) {
} else if (selectedItem.getId() == 204) {
new RequestTask(mContext, RequestTask.RESTORE_DATABASE).execute();
} else if (selectedItem.getId() == 301) {
boolean foundLocation = false;
Location loc = mAimsicdService.lastKnownLocation();
if (loc != null && loc.hasAccuracy()) {
Helpers.msgShort(mContext, "Contacting OpenCellID.org for data...");
Helpers.getOpenCellData(mContext, loc.getLatitude(), loc.getLongitude(),
RequestTask.OPEN_CELL_ID_REQUEST);
foundLocation = true;
} else {
//Attempt to find location through CID
//CID Location Async Output Delegate Interface Implementation
mLocationAsync = new LocationServices.LocationAsync();
mLocationAsync.delegate = this;
mLocationAsync.execute(
LocationServices.LocationAsync locationAsync = new LocationServices.LocationAsync();
locationAsync.delegate = this;
locationAsync.execute(
mAimsicdService.mDevice.getCellId(),
mAimsicdService.mDevice.getLac(),
mAimsicdService.mDevice.getMnc(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
public class MapViewer extends FragmentActivity implements OnSharedPreferenceChangeListener {

private final String TAG = "AIMSICD_MapViewer";
public static String updateOpenCellIDMarkers = "update_opencell_markers";
public static final String updateOpenCellIDMarkers = "update_opencell_markers";

private GoogleMap mMap;
private AIMSICDDbAdapter mDbHelper;
Expand Down Expand Up @@ -145,7 +145,7 @@ protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
}

private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
loadOpenCellIDMarkers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public long insertCell(int lac, int cellID,
*
* @return row id or -1 if error
*/
public long insertOpenCell(double latitude, double longitude,
long insertOpenCell(double latitude, double longitude,
int mcc, int mnc, int lac, int cellID, int avgSigStr,
int samples) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.util.List;

public class DrawerMenuAdapter extends ArrayAdapter<NavDrawerItem> {
Context mContext;
List<NavDrawerItem> drawerItemList;
private LayoutInflater inflater;
private final Context mContext;
final List<NavDrawerItem> drawerItemList;
private final LayoutInflater inflater;


public DrawerMenuAdapter(Context context, int textViewResourceId, List<NavDrawerItem> objects ) {
Expand All @@ -30,7 +30,7 @@ public DrawerMenuAdapter(Context context, int textViewResourceId, List<NavDrawer

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null ;
View view;
NavDrawerItem menuItem = this.getItem(position);
if ( menuItem.getType() == DrawerMenuItem.ITEM_TYPE ) {
view = getItemView(convertView, parent, menuItem );
Expand All @@ -41,7 +41,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
return view ;
}

public View getItemView( View convertView, ViewGroup parentView, NavDrawerItem navDrawerItem ) {
View getItemView(View convertView, ViewGroup parentView, NavDrawerItem navDrawerItem) {

DrawerMenuItem menuItem = (DrawerMenuItem) navDrawerItem ;
NavMenuItemHolder navMenuItemHolder = null;
Expand Down Expand Up @@ -70,7 +70,7 @@ public View getItemView( View convertView, ViewGroup parentView, NavDrawerItem n
return convertView ;
}

public View getSectionView(View convertView, ViewGroup parentView,
View getSectionView(View convertView, ViewGroup parentView,
NavDrawerItem navDrawerItem) {

DrawerMenuSection menuSection = (DrawerMenuSection) navDrawerItem ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
version = "";
}

TextView versionNumber = null;
TextView versionNumber;
if (v != null) {
versionNumber = (TextView) v.findViewById(R.id.aimsicd_version);

Expand Down Expand Up @@ -85,11 +85,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
return v;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ public void onNothingSelected(AdapterView<?> parentView) {
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CellInfoFragment extends Fragment {
private boolean mBound;
private Context mContext;
private Activity mActivity;
Handler timerHandler = new Handler();
private final Handler timerHandler = new Handler();

//Layout items
private ListView lv;
Expand All @@ -47,7 +47,7 @@ public class CellInfoFragment extends Fragment {
private TextView mCipheringIndicatorLabel;
private TextView mCipheringIndicator;

Runnable timerRunnable = new Runnable() {
private final Runnable timerRunnable = new Runnable() {

@Override
public void run() {
Expand Down Expand Up @@ -123,11 +123,6 @@ public void onDestroy() {
timerHandler.removeCallbacks(timerRunnable);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

/**
* Service Connection to bind the activity to the service
*/
Expand Down Expand Up @@ -181,7 +176,7 @@ private void updateUI() {
"Country Code (MCC): " + cell.getMCC(),
"Network Code (MNC): " + cell.getMNC(),
"Signal Strength (dBM): " + cell.getDBM(),
"" + i + " / " + total);
"" + i++ + " / " + total);
adapter.addItem(data, false);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ public class DbViewerFragment extends Fragment {
//Layout items
private Spinner tblSpinner;
private ListView lv;
private View mView;

public DbViewerFragment() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Expand All @@ -56,21 +50,21 @@ public void onAttach(Activity activity) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

mView = inflater.inflate(R.layout.db_view,
View view = inflater.inflate(R.layout.db_view,
container, false);

if (mView != null) {
lv = (ListView) mView.findViewById(R.id.list_view);
if (view != null) {
lv = (ListView) view.findViewById(R.id.list_view);

tblSpinner = (Spinner) mView.findViewById(R.id.table_spinner);
tblSpinner = (Spinner) view.findViewById(R.id.table_spinner);
tblSpinner.setOnItemSelectedListener(new spinnerListener());

Button loadTable = (Button) mView.findViewById(R.id.load_table_data);
Button loadTable = (Button) view.findViewById(R.id.load_table_data);

loadTable.setOnClickListener(new btnClick());
}

return mView;
return view;
}

private class spinnerListener implements AdapterView.OnItemSelectedListener {
Expand Down Expand Up @@ -140,7 +134,6 @@ private void BuildTable(Cursor tableData) {
BaseInflaterAdapter<SilentSmsCardData> adapter
= new BaseInflaterAdapter<>(
new SilentSmsCardInflater());
int count = tableData.getCount();
while (tableData.moveToNext()) {
SilentSmsCardData data = new SilentSmsCardData(tableData.getString(0),
tableData.getString(1), tableData.getString(2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public class DeviceFragment extends Fragment {
public DeviceFragment() {
}

@Override
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Expand Down
14 changes: 3 additions & 11 deletions app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
private Context mContext;
private final int NOTIFICATION_ID = 1;
private long mDbResult;
public TelephonyManager tm;
private TelephonyManager tm;
private LocationManager lm;
private SharedPreferences prefs;
private PhoneStateListener mPhoneStateListener;
Expand Down Expand Up @@ -340,7 +340,8 @@ public List<Cell> updateNeighbouringCells() {
}
}
}
} else {
}
if (Build.VERSION.SDK_INT < 16 || neighboringCells.isEmpty()) {
List<NeighboringCellInfo> neighboringCellInfo;
neighboringCellInfo = tm.getNeighboringCellInfo();
if (neighboringCellInfo != null) {
Expand Down Expand Up @@ -709,15 +710,6 @@ public Location lastKnownLocation() {
return location;
}

/**
* Neighbouring Cell List
*
* @return List of (Cell) Neighbouring Cell Information
*/
public List<Cell> getNeighbouringCells() {
return mDevice.getNeighboringCells();
}

/**
* Cell Information Tracking and database logging
*
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/SecUpwN/AIMSICD/utils/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public class Cell {
private int dbm;
private long timestamp;

public Cell() {
}

public Cell(int cid, int lac, int mcc, int mnc, int dbm, long timestamp) {
this.cid = cid;
this.lac = lac;
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/SecUpwN/AIMSICD/utils/ChildProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class ChildProcess {

private class ChildReader extends Thread {

InputStream mStream;
final InputStream mStream;

StringBuffer mBuffer;
final StringBuffer mBuffer;

ChildReader(InputStream is, StringBuffer buf) {
mStream = is;
Expand Down Expand Up @@ -65,9 +65,9 @@ public void run() {

private class ChildWriter extends Thread {

OutputStream mStream;
final OutputStream mStream;

String mBuffer;
final String mBuffer;

ChildWriter(OutputStream os, String buf) {
mStream = os;
Expand All @@ -94,7 +94,7 @@ public void run() {
}
}

private long mStartTime;
private final long mStartTime;
private Process mChildProc;
private ChildWriter mChildStdinWriter;
private ChildReader mChildStdoutReader;
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/com/SecUpwN/AIMSICD/utils/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class Device {

public final String TAG = "AIMSICD";
private final String TAG = "AIMSICD";

/*
* Device Declarations
Expand Down Expand Up @@ -356,7 +356,7 @@ public String getSimOperatorName() {
*
* @return string of SIM Subscriber ID data
*/
public String getSimSubs(TelephonyManager tm) {
String getSimSubs(TelephonyManager tm) {
try {
if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
mSimSubs = (tm.getSubscriberId() != null) ? tm.getSubscriberId() : "N/A";
Expand Down Expand Up @@ -385,7 +385,7 @@ public String getSimSubs() {
*
* @return string of SIM Serial Number data
*/
public String getSimSerial(TelephonyManager tm) {
String getSimSerial(TelephonyManager tm) {
try {
if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
mSimSerial = (tm.getSimSerialNumber() != null) ? tm.getSimSerialNumber()
Expand Down Expand Up @@ -433,9 +433,8 @@ public String getIMEIv() {
}

/**
* Network Operator Name
* Sets Network Operator Name
*
* @return string representing device Network Operator Name
*/
public void setNetworkName(String networkName) {
mNetName = networkName;
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/SecUpwN/AIMSICD/utils/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ public boolean sendCommandPreserveOut(String command, float maxWaitSeconds) {
clearStdOutAndErr();
try {
int oldCount;
boolean returned = false;
try {
oldCount = mShellStdOut.available() + mShellStdErr.available();
} catch (IOException ioe) {
Expand All @@ -369,7 +368,6 @@ public boolean sendCommandPreserveOut(String command, float maxWaitSeconds) {
+ ", curr = " + currCount);
if (currCount != oldCount) {
Log.i(TAG, "Command returned");
returned = true;
break;
}
SystemClock.sleep(100);
Expand Down

0 comments on commit 3c3bf3e

Please sign in to comment.