diff --git a/app/build.gradle b/app/build.gradle index 6748179a5..9ce132c0a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,12 +4,12 @@ android { compileSdkVersion 19 buildToolsVersion '19.0.3' defaultConfig { - minSdkVersion 9 + minSdkVersion 16 targetSdkVersion 19 } buildTypes { release { - runProguard false + runProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } @@ -21,8 +21,8 @@ android { } dependencies { + compile files('libs/opencsv-2.3.jar') compile 'com.android.support:appcompat-v7:19.1.+' compile 'com.google.android.gms:play-services:4.3.23' compile 'com.android.support:support-v4:19.+' - compile files('libs/opencsv-2.3.jar') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 41d392b19..a06d274ad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,84 +1,85 @@ + package="com.SecUpwN.AIMSICD" + android:versionCode="6" + android:versionName="0.1.6" > + android:required="true" /> - - - - - - - - - + + + + + + + + + - + android:theme="@style/AppTheme" > + + - + android:screenOrientation="portrait" > - + - - + + + android:exported="false" > - + - - + + + + android:parentActivityName=".AIMSICD" > + android:value=".AIMSICD" /> - + android:label="@string/preferences" + android:parentActivityName=".AIMSICD" > - + + android:value="AIzaSyDI1lvgpBmNhQS33JfJA4w8GAmrtFeg078" /> - + + diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java b/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java index f0d7c6066..959b8d98c 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java @@ -23,7 +23,6 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; -import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.telephony.TelephonyManager; @@ -43,9 +42,7 @@ public class AIMSICD extends Activity { private final String TAG = "AIMSICD"; private final Context mContext = this; - private Menu mMenu; private boolean mBound; - private boolean mDisplayCurrent; private SharedPreferences prefs; private AIMSICDDbAdapter dbHelper; @@ -92,7 +89,10 @@ protected void onDestroy() { } } - private ServiceConnection mConnection = new ServiceConnection() { + /** + * Service Connection to bind the activity to the service + */ + private final ServiceConnection mConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { // We've bound to LocalService, cast the IBinder and get LocalService instance @@ -111,9 +111,7 @@ public void onServiceDisconnected(ComponentName arg0) { @Override public void onResume() { super.onResume(); - if (!mDisplayCurrent) - updateUI(); - + updateUI(); } private void updateUI() { @@ -121,6 +119,7 @@ private void updateUI() { TableLayout tableLayout; TableRow tr; if (mBound) { + int netID = mAimsicdService.getNetID(true); switch (mAimsicdService.getPhoneID()) { case TelephonyManager.PHONE_TYPE_GSM: { @@ -150,6 +149,16 @@ private void updateUI() { } } + if (mAimsicdService.getNetID(true) == TelephonyManager.NETWORK_TYPE_LTE) { + content = (TextView) findViewById(R.id.network_lte_timing_advance); + content.setText(mAimsicdService.getLteTimingAdvance()); + tr = (TableRow) findViewById(R.id.lte_timing_advance); + tr.setVisibility(View.VISIBLE); + } else { + tr = (TableRow) findViewById(R.id.lte_timing_advance); + tr.setVisibility(View.GONE); + } + content = (TextView) findViewById(R.id.sim_country); content.setText(mAimsicdService.getSimCountry(false)); content = (TextView) findViewById(R.id.sim_operator_id); @@ -161,7 +170,7 @@ private void updateUI() { content = (TextView) findViewById(R.id.sim_serial); content.setText(mAimsicdService.getSimSerial(false)); - int netID = mAimsicdService.getNetID(true); + content = (TextView) findViewById(R.id.device_type); content.setText(mAimsicdService.getPhoneType(false)); content = (TextView) findViewById(R.id.device_imei); @@ -195,22 +204,14 @@ private void updateUI() { Log.i(TAG, "Network code : " + mAimsicdService.getSmmcMcc(false)); Log.i(TAG, "Network name : " + mAimsicdService.getNetworkName(false)); Log.i(TAG, "Roaming : " + mAimsicdService.isRoaming()); - mDisplayCurrent = true; } } - @Override - public void onPause() { - super.onPause(); - mDisplayCurrent = false; - } - @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); - mMenu = menu; return super.onCreateOptionsMenu(menu); } @@ -262,33 +263,25 @@ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.track_cell: trackcell(); - if (Build.VERSION.SDK_INT > 11) { - onPrepareOptionsMenu(mMenu); - } + invalidateOptionsMenu(); return true; case R.id.track_signal: tracksignal(); - if (Build.VERSION.SDK_INT > 11) { - onPrepareOptionsMenu(mMenu); - } + invalidateOptionsMenu(); return true; case R.id.track_location: tracklocation(); - if (Build.VERSION.SDK_INT > 11) { - onPrepareOptionsMenu(mMenu); - } + invalidateOptionsMenu(); return true; case R.id.track_femtocell: trackFemtocell(); - if (Build.VERSION.SDK_INT > 11) { - onPrepareOptionsMenu(mMenu); - } + invalidateOptionsMenu(); return true; case R.id.show_map: showmap(); return true; case R.id.preferences: - Intent intent = new Intent(this, SettingsActivity.class); + Intent intent = new Intent(this, PrefActivity.class); startActivity(intent); return true; case R.id.export_database: @@ -327,7 +320,10 @@ private void showmap() { startActivity(myIntent); } - public void tracksignal() { + /** + * Signal Strength Tracking - Enable/Disable + */ + private void tracksignal() { if (mAimsicdService.TrackingSignal) { mAimsicdService.setSignalTracking(false); } else { @@ -335,7 +331,10 @@ public void tracksignal() { } } - public void trackcell() { + /** + * Cell Information Tracking - Enable/Disable + */ + private void trackcell() { if (mAimsicdService.TrackingCell) { mAimsicdService.setCellTracking(false); } else { @@ -343,7 +342,10 @@ public void trackcell() { } } - public void tracklocation() { + /** + * Location Information Tracking - Enable/Disable + */ + private void tracklocation() { if (mAimsicdService.TrackingLocation) { mAimsicdService.setLocationTracking(false); } else { @@ -351,7 +353,10 @@ public void tracklocation() { } } - public void trackFemtocell() { + /** + * FemtoCell Detection (CDMA Phones ONLY) - Enable/Disable + */ + private void trackFemtocell() { if (mAimsicdService.TrackingFemtocell) { mAimsicdService.stopTrackingFemto(); } else { @@ -359,8 +364,4 @@ public void trackFemtocell() { } } - public AIMSICD getAimsicd() { - return this; - } - } diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICDDbAdapter.java b/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICDDbAdapter.java index 33827095d..d5f47215f 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICDDbAdapter.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICDDbAdapter.java @@ -1,5 +1,6 @@ package com.SecUpwN.AIMSICD; +import android.app.AlertDialog; import android.content.Context; import android.database.Cursor; import android.database.SQLException; @@ -18,16 +19,19 @@ public class AIMSICDDbAdapter { private final String TAG = "AISMICD_DbAdaptor"; - private DbHelper mDbHelper; + private final DbHelper mDbHelper; private SQLiteDatabase mDb; + private Context mContext; private static final int DATABASE_VERSION = 1; - public static final String COLUMN_ID = "_id"; - public String LOCATION_TABLE = "locationinfo"; - public String CELL_TABLE = "cellinfo"; - public String SIGNAL_TABLE = "signalinfo"; - public String DB_NAME = "myCellInfo"; + private static final String COLUMN_ID = "_id"; + private final String LOCATION_TABLE = "locationinfo"; + private final String CELL_TABLE = "cellinfo"; + private final String SIGNAL_TABLE = "signalinfo"; + private final String DB_NAME = "myCellInfo"; + private final String FOLDER = Environment.getExternalStorageDirectory() + "/AIMSICD/"; public AIMSICDDbAdapter(Context context) { + mContext = context; mDbHelper = new DbHelper(context); } @@ -36,11 +40,6 @@ public AIMSICDDbAdapter open() throws SQLException { return this; } - public AIMSICDDbAdapter openRead() throws SQLException { - mDb = mDbHelper.getReadableDatabase(); - return this; - } - public void close() { mDbHelper.close(); } @@ -146,20 +145,27 @@ public boolean cellExists(int cellID) { return cursor.getCount()>0; } + /** + * Exports the database tables to CSV files + */ public void exportDB () { try { export(LOCATION_TABLE); export(CELL_TABLE); export(SIGNAL_TABLE); - } catch (IOException ioe) { + final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); + builder.setTitle(R.string.database_export_successful) + .setMessage("Database tables exported succesfully to:\n" + FOLDER); + builder.create().show(); + } catch (Exception ioe) { Log.e (TAG, "exportDB() " + ioe.getMessage()); } } - public void export(String tableName) throws IOException { + private void export(String tableName) { Log.i(TAG, "exporting database - " + DB_NAME); - File dir = new File(Environment.getExternalStorageDirectory() + "/AIMSICD/"); + File dir = new File(FOLDER); if (!dir.exists()) { dir.mkdirs(); } @@ -185,8 +191,8 @@ public void export(String tableName) throws IOException { csvWrite.close(); c.close(); - } catch (Exception sqlEx) { - Log.e(TAG, "Error exporting table " + tableName + " " + sqlEx.getMessage()); + } catch (Exception e) { + Log.e(TAG, "Error exporting table " + tableName + " " + e); } Log.i(TAG, "exporting database complete"); diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/MapViewer.java b/app/src/main/java/com/SecUpwN/AIMSICD/MapViewer.java index 83ed580c7..7ceffe5fe 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/MapViewer.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/MapViewer.java @@ -17,33 +17,26 @@ package com.SecUpwN.AIMSICD; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.List; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.database.Cursor; import android.location.Location; import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; -import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; import android.telephony.TelephonyManager; import android.text.format.Time; import android.util.Log; @@ -54,10 +47,9 @@ import com.SecUpwN.AIMSICD.cmdprocessor.Helpers; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; -import com.google.android.gms.location.LocationClient; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.SupportMapFragment; +import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.UiSettings; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.CircleOptions; @@ -113,14 +105,16 @@ public void onResume() { setUpMapIfNeeded(); } + /** + * Initialises the Map and sets initial options + * + */ private void setUpMapIfNeeded() { // Do a null check to confirm that we have not already instantiated the // map. if (mMap == null) { - FragmentManager fmanager = getSupportFragmentManager(); - Fragment fragment = fmanager.findFragmentById(R.id.map); - SupportMapFragment supportmapfragment = (SupportMapFragment) fragment; - mMap = supportmapfragment.getMap(); + mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); + // Check if we were successful in obtaining the map. if (mMap != null) { // The Map is verified. It is now safe to manipulate the map. @@ -211,6 +205,11 @@ public void onClick(DialogInterface dialog, int item) { } } + /** + * Loads Signal Strength Database details to plot on the map, + * only entries which have a location (lon, lat) are used. + * + */ private void loadEntries() { int SIGNAL_SIZE_RATIO = 15; double dlat; @@ -312,6 +311,10 @@ private void loadEntries() { } } + /** + * Uses last known location to animateCamera to location + * + */ private void GetCurrentLocation() { double[] d = getlocation(); @@ -320,7 +323,11 @@ private void GetCurrentLocation() { new LatLng(d[0], d[1]), 5)); } - public double[] getlocation() { + /** + * Attempts to retrieve the last known location from the device + * + */ + private double[] getlocation() { LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); List providers = lm.getProviders(true); @@ -339,6 +346,13 @@ public double[] getlocation() { return gps; } + /** + * Requests Cell data from OpenCellID.org, calculating a 100 mile bounding radius + * and requesting all Cell ID information in that area. + * + * @param lat Latitude of current location + * @param lng Longitude of current location + */ private void getOpenCellData(double lat, double lng) { if (isNetAvailable(this)) { double earthRadius = 6371.01; @@ -365,7 +379,11 @@ private void getOpenCellData(double lat, double lng) { } } - public Boolean isNetAvailable(Context context) { + /** + * Checks Network connectivity is available to download OpenCellID data + * + */ + private Boolean isNetAvailable(Context context) { try{ ConnectivityManager connectivityManager = (ConnectivityManager) @@ -383,6 +401,12 @@ public Boolean isNetAvailable(Context context) { return false; } + /** + * Parses the downloaded CSV from OpenCellID and adds Map Marker to identify known + * Cell ID's + * + * @param fileName Name of file downloaded from OpenCellID + */ private void parseOpenCellID (String fileName) { File file = new File(fileName); @@ -408,7 +432,13 @@ private void parseOpenCellID (String fileName) { } - class RequestTask extends AsyncTask { + /** + * Runs the request to download OpenCellID data in an AsyncTask + * preventing the application from becoming unresponsive whilst + * waiting for a response and download from the server + * + */ + private class RequestTask extends AsyncTask { @Override protected String doInBackground(String... uri) { diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/PrefActivity.java b/app/src/main/java/com/SecUpwN/AIMSICD/PrefActivity.java new file mode 100644 index 000000000..6cefb424e --- /dev/null +++ b/app/src/main/java/com/SecUpwN/AIMSICD/PrefActivity.java @@ -0,0 +1,21 @@ +package com.SecUpwN.AIMSICD; + +import android.app.Activity; +import android.app.FragmentManager; +import android.app.FragmentTransaction; +import android.os.Bundle; + + +public class PrefActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + PrefFragment settingsFragment = new PrefFragment(); + FragmentManager fragmentManager = getFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + fragmentTransaction.replace(android.R.id.content, settingsFragment); + fragmentTransaction.commit(); + } + +} diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/SettingsActivity.java b/app/src/main/java/com/SecUpwN/AIMSICD/PrefFragment.java similarity index 69% rename from app/src/main/java/com/SecUpwN/AIMSICD/SettingsActivity.java rename to app/src/main/java/com/SecUpwN/AIMSICD/PrefFragment.java index 0d4e86fc9..295e676dc 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/SettingsActivity.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/PrefFragment.java @@ -1,9 +1,9 @@ package com.SecUpwN.AIMSICD; import android.os.Bundle; -import android.preference.PreferenceActivity; +import android.preference.PreferenceFragment; -public class SettingsActivity extends PreferenceActivity { +public class PrefFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java b/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java index 46d990e80..dde3ac6c9 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java @@ -56,7 +56,14 @@ import android.os.IBinder; import android.support.v4.app.NotificationCompat; +import android.telephony.CellInfo; +import android.telephony.CellInfoCdma; +import android.telephony.CellInfoGsm; +import android.telephony.CellInfoLte; import android.telephony.CellLocation; +import android.telephony.CellSignalStrengthCdma; +import android.telephony.CellSignalStrengthGsm; +import android.telephony.CellSignalStrengthLte; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -79,7 +86,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL * System and helper declarations */ private final AimscidBinder mBinder = new AimscidBinder(); - public final AIMSICDDbAdapter dbHelper = new AIMSICDDbAdapter(this); + private final AIMSICDDbAdapter dbHelper = new AIMSICDDbAdapter(this); private int mUpdateInterval; private TelephonyManager tm; private LocationManager lm; @@ -90,19 +97,32 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL /* * Device Declarations */ - public int mPhoneID = -1; - public int mSignalInfo = -1; - public int mNetID = -1; - public int mLacID = -1; - public int mCellID = -1; - public int mSID = -1; - public double mLongitude = 0.0; - public double mLatitude = 0.0; - public String mNetType = ""; - public String mPhoneNum = "", mCellType = "", mLac = "", mCellInfo = "", mDataState = ""; - public String mNetName = "", mMmcmcc = "", mSimCountry = "", mPhoneType = ""; - public String mIMEI = "", mIMEIV = "", mSimOperator = "", mSimOperatorName = ""; - public String mSimSerial = "", mSimSubs = "", mDataActivityType = ""; + private int mPhoneID = -1; + private int mSignalInfo = -1; + private int mNetID = -1; + private int mLacID = -1; + private int mCellID = -1; + private int mSID = -1; + private int mTimingAdvance = -1; + private double mLongitude = 0.0; + private double mLatitude = 0.0; + private String mNetType = ""; + private String mPhoneNum = ""; + private String mCellType = ""; + private String mLac = ""; + private String mCellInfo = ""; + private String mDataState = ""; + private String mNetName = ""; + private String mMmcmcc = ""; + private String mSimCountry = ""; + private String mPhoneType = ""; + private String mIMEI = ""; + private String mIMEIV = ""; + private String mSimOperator = ""; + private String mSimOperatorName = ""; + private String mSimSerial = ""; + private String mSimSubs = ""; + private String mDataActivityType = ""; /* * Tracking and Alert Declarations @@ -142,7 +162,7 @@ public void onCreate() { @Override public int onStartCommand(Intent intent, int flags, int startId) { tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); - return super.onStartCommand(intent, flags, startId); + return START_STICKY; } @Override @@ -150,17 +170,24 @@ public void onDestroy() { super.onDestroy(); prefs.unregisterOnSharedPreferenceChangeListener(this); cancelNotification(); - + dbHelper.close(); Log.i(TAG, "Service destroyed"); } - public void refreshDeviceInfo() { + /** + * Refreshes all device specific details + */ + private void refreshDeviceInfo() { //Phone type and associated details mIMEI = tm.getDeviceId(); mIMEIV = tm.getDeviceSoftwareVersion(); mPhoneNum = tm.getLine1Number(); mPhoneID = tm.getPhoneType(); mRoaming = tm.isNetworkRoaming(); + //Network type + mNetID = getNetID(true); + mNetType = getNetworkTypeName(mNetID, true); + switch (mPhoneID) { case TelephonyManager.PHONE_TYPE_GSM: mPhoneType = "GSM"; @@ -189,6 +216,36 @@ public void refreshDeviceInfo() { break; } + //SDK 17 allows access to signal strength outside of the listener and also + //provide access to the LTE timing advance data + /* + if (Build.VERSION.SDK_INT > 16) { + try { + final TelephonyManager tm = (TelephonyManager) this + .getSystemService(Context.TELEPHONY_SERVICE); + for (final CellInfo info : tm.getAllCellInfo()) { + if (info instanceof CellInfoGsm) { + final CellSignalStrengthGsm gsm = ((CellInfoGsm) info) + .getCellSignalStrength(); + mSignalInfo = gsm.getDbm(); + } else if (info instanceof CellInfoCdma) { + final CellSignalStrengthCdma cdma = ((CellInfoCdma) info) + .getCellSignalStrength(); + mSignalInfo = cdma.getDbm(); + } else if (info instanceof CellInfoLte) { + final CellSignalStrengthLte lte = ((CellInfoLte) info) + .getCellSignalStrength(); + mSignalInfo = lte.getDbm(); + mTimingAdvance = lte.getTimingAdvance(); + } else { + throw new Exception("Unknown type of cell signal!"); + } + } + } catch (Exception e) { + Log.e(TAG, "Unable to obtain cell signal information", e); + } + }*/ + //SIM Information mSimCountry = tm.getSimCountryIso(); mSimOperator = tm.getSimOperator(); @@ -196,10 +253,6 @@ public void refreshDeviceInfo() { mSimSerial = tm.getSimSerialNumber(); mSimSubs = tm.getSubscriberId(); - //Network type - mNetID = getNetID(true); - mNetType = getNetworkTypeName(mNetID, true); - int mDataActivity = tm.getDataActivity(); mDataActivityType = getActivityDesc(mDataActivity); @@ -207,12 +260,31 @@ public void refreshDeviceInfo() { mDataState = getStateDesc(mDataActivity); } + /** + * LTE Timing Advance + * + * @return Timing Advance figure or -1 if not available + */ + public int getLteTimingAdvance() { + return mTimingAdvance; + } + + /** + * Mobile Roaming + * + * @return string representing Roaming status (True/False) + */ public String isRoaming() { mRoaming = tm.isNetworkRoaming(); return String.valueOf(mRoaming); } + /** + * CDMA System ID + * + * @return System ID or -1 if not supported + */ public int getSID() { CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) tm.getCellLocation(); if (cdmaCellLocation != null) { @@ -224,12 +296,22 @@ public int getSID() { return mSID; } + /** + * Phone Type ID + * + * @return integer representation of Phone Type + */ public int getPhoneID() { mPhoneID = tm.getPhoneType(); return mPhoneID; } + /** + * SIM Country + * + * @return string of SIM Country data + */ public String getSimCountry(boolean force) { if (mSimCountry.isEmpty() || force) { mSimCountry = tm.getSimCountryIso(); @@ -238,6 +320,11 @@ public String getSimCountry(boolean force) { return mSimCountry; } + /** + * SIM Operator + * + * @return string of SIM Operator data + */ public String getSimOperator(boolean force) { if (mSimOperator.isEmpty() || force) { mSimOperator = tm.getSimOperator(); @@ -246,6 +333,11 @@ public String getSimOperator(boolean force) { return mSimOperator; } + /** + * SIM Operator Name + * + * @return string of SIM Operator Name + */ public String getSimOperatorName(boolean force) { if (mSimOperatorName.isEmpty() || force) { mSimOperatorName = tm.getSimOperatorName(); @@ -254,6 +346,11 @@ public String getSimOperatorName(boolean force) { return mSimOperatorName; } + /** + * SIM Subscriber ID + * + * @return string of SIM Subscriber ID data + */ public String getSimSubs(boolean force) { if (mSimSubs.isEmpty() || force) { mSimSubs = tm.getSubscriberId(); @@ -262,6 +359,11 @@ public String getSimSubs(boolean force) { return mSimSubs; } + /** + * SIM Serial Number + * + * @return string of SIM Serial Number data + */ public String getSimSerial(boolean force) { if (mSimSerial.isEmpty() || force) { mSimSerial = tm.getSimSerialNumber(); @@ -270,6 +372,11 @@ public String getSimSerial(boolean force) { return mSimSerial; } + /** + * Phone Type + * + * @return string representing Phone Type + */ public String getPhoneType(boolean force) { if (mPhoneType.isEmpty() || force) { switch (getPhoneID()) { @@ -294,6 +401,11 @@ public String getPhoneType(boolean force) { return mPhoneType; } + /** + * IMEI + * + * @return string representing device IMEI + */ public String getIMEI(boolean force) { if (mIMEI.isEmpty() || force) { mIMEI = tm.getDeviceId(); @@ -302,6 +414,11 @@ public String getIMEI(boolean force) { return mIMEI; } + /** + * IMEI Version / Device Software Version + * + * @return string representing device IMEI Version + */ public String getIMEIv(boolean force) { if (mIMEIV.isEmpty() || force) { mIMEIV = tm.getDeviceSoftwareVersion(); @@ -310,6 +427,11 @@ public String getIMEIv(boolean force) { return mIMEIV; } + /** + * Device Line Number + * + * @return string representing device line number + */ public String getPhoneNumber(boolean force) { if (mPhoneNum.isEmpty() || force) { mPhoneNum = tm.getLine1Number(); @@ -318,6 +440,11 @@ public String getPhoneNumber(boolean force) { return mPhoneNum; } + /** + * Network Operator Name + * + * @return string representing device Network Operator Name + */ public String getNetworkName(boolean force) { if (mNetName.isEmpty() || force) { mNetName = tm.getNetworkOperatorName(); @@ -326,6 +453,11 @@ public String getNetworkName(boolean force) { return mNetName; } + /** + * Network Operator + * + * @return string representing the Network Operator + */ public String getSmmcMcc(boolean force) { if (mMmcmcc.isEmpty() || force) { mMmcmcc = tm.getNetworkOperator(); @@ -334,6 +466,11 @@ public String getSmmcMcc(boolean force) { return mMmcmcc; } + /** + * Network Type + * + * @return string representing device Network Type + */ public String getNetworkTypeName(int netID, boolean force) { if (mNetType.isEmpty() || force) { switch (netID) { @@ -373,6 +510,9 @@ public String getNetworkTypeName(int netID, boolean force) { case TelephonyManager.NETWORK_TYPE_1xRTT: mNetType = "1xRTT"; break; + case TelephonyManager.NETWORK_TYPE_LTE: + mNetType = "LTE"; + break; default: mNetType = "Unknown"; break; @@ -382,6 +522,11 @@ public String getNetworkTypeName(int netID, boolean force) { return mNetType; } + /** + * Network Type + * + * @return integer representing device Network Type + */ public int getNetID(boolean force) { if (mNetID == -1 || force) { mNetID = tm.getNetworkType(); @@ -390,6 +535,12 @@ public int getNetID(boolean force) { return mNetID; } + /** + * Local Area Code (LAC) for either GSM or CDMA devices, returns string representation + * but also updates the integer member as well + * + * @return string representing the Local Area Code (LAC) from GSM or CDMA devices + */ public String getLAC(boolean force) { if (mLac.isEmpty() || force) { switch (getPhoneID()) { @@ -415,6 +566,12 @@ public String getLAC(boolean force) { return mLac; } + /** + * Cell ID for either GSM or CDMA devices, returns string representation + * but also updates the integer member as well + * + * @return string representing the Cell ID from GSM or CDMA devices + */ public String getCellId() { switch (getPhoneID()) @@ -444,6 +601,11 @@ public String getCellId() { return mCellType; } + /** + * Mobile data activity description + * + * @return string representing the current Mobile Data Activity + */ public String getActivityDesc(int dataID) { mDataActivityType = "undef"; switch (dataID) { @@ -466,6 +628,11 @@ public String getActivityDesc(int dataID) { return mDataActivityType; } + /** + * Mobile data state description + * + * @return string representing the current Mobile Data State + */ public String getStateDesc(int dataID) { mDataState = "undef"; switch (dataID) { @@ -486,7 +653,11 @@ public String getStateDesc(int dataID) { return mDataState; } - public void updateCdmaLocation() { + /** + * Updates location from CDMA base station longitude and latitude + * + */ + private void updateCdmaLocation() { CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) tm.getCellLocation(); int Long = cdmaCellLocation.getBaseStationLongitude(); int Lat = cdmaCellLocation.getBaseStationLatitude(); @@ -504,7 +675,7 @@ public void updateCdmaLocation() { * Set or update the Notification * */ - public void setNotification() { + private void setNotification() { Intent notificationIntent = new Intent(this, AIMSICD.class); PendingIntent contentIntent = PendingIntent.getActivity( @@ -589,6 +760,10 @@ public void setNotification() { mNotificationManager.notify(0x1212, mBuilder); } + /** + * Cancel and remove the persistent notification + * + */ private void cancelNotification() { NotificationManager notificationManager = (NotificationManager) this.getSystemService( NOTIFICATION_SERVICE); @@ -597,6 +772,11 @@ private void cancelNotification() { } } + /** + * Cell Information Tracking and database logging + * + * @param track Enable/Disable tracking + */ public void setCellTracking(boolean track) { if (track) { tm.listen(mCellSignalListener, PhoneStateListener.LISTEN_CELL_LOCATION); @@ -613,6 +793,11 @@ public void setCellTracking(boolean track) { setNotification(); } + /** + * Signal Strength Tracking and database logging + * + * @param track Enable/Disable tracking + */ public void setSignalTracking(boolean track) { if (track) { tm.listen(mSignalListenerStrength, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); @@ -627,7 +812,7 @@ public void setSignalTracking(boolean track) { setNotification(); } - private PhoneStateListener mSignalListenerStrength = new PhoneStateListener() { + private final PhoneStateListener mSignalListenerStrength = new PhoneStateListener() { public void onSignalStrengthsChanged(SignalStrength signalStrength) { switch (mPhoneID) { case TelephonyManager.PHONE_TYPE_GSM: @@ -651,7 +836,7 @@ public void onSignalStrengthsChanged(SignalStrength signalStrength) { } }; - private PhoneStateListener mCellSignalListener = new PhoneStateListener() { + private final PhoneStateListener mCellSignalListener = new PhoneStateListener() { public void onCellLocationChanged(CellLocation location) { mNetID = getNetID(true); mNetType = getNetworkTypeName(mNetID, true); @@ -732,6 +917,11 @@ public void onCellLocationChanged(CellLocation location) { } }; + /** + * Location Information Tracking and database logging + * + * @param track Enable/Disable tracking + */ public void setLocationTracking(boolean track) { if (track) { if (lm != null) { @@ -754,6 +944,7 @@ public void setLocationTracking(boolean track) { builder.setMessage(R.string.location_error_message) .setTitle(R.string.location_error_title); builder.create().show(); + TrackingLocation = false; } } } @@ -811,12 +1002,18 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin } -/* - * The below code section was copied and modified from - * Femtocatcher https://github.com/iSECPartners/femtocatcher - * - * Copyright (C) 2013 iSEC Partners - */ + /* + * The below code section was copied and modified from + * Femtocatcher https://github.com/iSECPartners/femtocatcher + * + * Copyright (C) 2013 iSEC Partners + */ + + /** + * Start FemtoCell detection tracking + * CDMA Devices ONLY + * + */ public void startTrackingFemto() { /* Check if it is a CDMA phone */ @@ -837,6 +1034,11 @@ public void onServiceStateChanged(ServiceState s) { setNotification(); } + /** + * Stop FemtoCell detection tracking + * CDMA Devices ONLY + * + */ public void stopTrackingFemto() { if (mPhoneStateListener != null) { tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); @@ -846,7 +1048,7 @@ public void stopTrackingFemto() { } } - public void getServiceStateInfo(ServiceState s) { + private void getServiceStateInfo(ServiceState s) { if (s != null) { if (IsConnectedToCdmaFemto(s)) { Helpers.sendMsg(this, "ALERT!! Femtocell Connection Detected!!"); @@ -924,28 +1126,22 @@ private boolean IsConnectedToCdmaFemto(ServiceState s) { } + /** + * Confirmation of connection to an EVDO Network + * + * @return EVDO network connection returns TRUE + */ private boolean isEvDoNetwork(int networkType) { - if (Build.VERSION.SDK_INT > 11) { - if ((networkType == TelephonyManager.NETWORK_TYPE_EVDO_0) || - (networkType == TelephonyManager.NETWORK_TYPE_EVDO_A) || - (networkType == TelephonyManager.NETWORK_TYPE_EVDO_B) || - (networkType == TelephonyManager.NETWORK_TYPE_EHRPD)) { - return true; - } - } else { - if ((networkType == TelephonyManager.NETWORK_TYPE_EVDO_0) || - (networkType == TelephonyManager.NETWORK_TYPE_EVDO_A) || - (networkType == TelephonyManager.NETWORK_TYPE_EVDO_B)) { - return true; - } - } - return false; + return (networkType == TelephonyManager.NETWORK_TYPE_EVDO_0) || + (networkType == TelephonyManager.NETWORK_TYPE_EVDO_A) || + (networkType == TelephonyManager.NETWORK_TYPE_EVDO_B) || + (networkType == TelephonyManager.NETWORK_TYPE_EHRPD); } -/* - * The above code section was copied and modified from - * Femtocatcher https://github.com/iSECPartners/femtocatcher - * - * Copyright (C) 2013 iSEC Partners - */ + /* + * The above code section was copied and modified from + * Femtocatcher https://github.com/iSECPartners/femtocatcher + * + * Copyright (C) 2013 iSEC Partners + */ } diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index d85a39355..ca73cd249 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -385,6 +385,28 @@ android:padding="2dip" android:gravity="left"/> + + + + + + + + android:name="com.google.android.gms.maps.MapFragment" /> diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 000000000..63fc81644 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bbb22a8ed..d9e7701a9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,6 +64,7 @@ Data Activity: Data Status: Roaming: + Timing Advance: Network ID: @@ -96,5 +97,10 @@ pref_ui_icons Icon Theme Selection Hello blank fragment + SettingActivity + Hello world! + Settings + + Export Successful diff --git a/proguard-rules.txt b/proguard-rules.txt new file mode 100644 index 000000000..e3040e8d5 --- /dev/null +++ b/proguard-rules.txt @@ -0,0 +1,119 @@ +-optimizationpasses 5 + +#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use: +-dontusemixedcaseclassnames + +#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting +-dontskipnonpubliclibraryclasses + +#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option. +-dontpreverify + +#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message. +-verbose + +#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields). +#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +#To repackage classes on a single package +#-repackageclasses '' + +#Uncomment if using annotations to keep them. +#-keepattributes *Annotation* + +#Keep classes that are referenced on the AndroidManifest +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class com.android.vending.licensing.ILicensingService + + +#To remove debug logs: +-assumenosideeffects class android.util.Log { + public static *** d(...); + public static *** v(...); +} + +#To avoid changing names of methods invoked on layout's onClick. +# Uncomment and add specific method names if using onClick on layouts +#-keepclassmembers class * { +# public void onClickButton(android.view.View); +#} + +#Maintain java native methods +-keepclasseswithmembernames class * { + native ; +} + +#To maintain custom components names that are used on layouts XML. +#Uncomment if having any problem with the approach below +#-keep public class custom.components.package.and.name.** + +#To maintain custom components names that are used on layouts XML: +-keep public class * extends android.view.View { + public (android.content.Context); + public (android.content.Context, android.util.AttributeSet); + public (android.content.Context, android.util.AttributeSet, int); + public void set*(...); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +#Maintain enums +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +#To keep parcelable classes (to serialize - deserialize objects to sent through Intents) +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +#Keep the R +-keepclassmembers class **.R$* { + public static ; +} + +-keep class * extends java.util.ListResourceBundle { + protected Object[][] getContents(); +} + +-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { + public static final *** NULL; +} + +-keepnames @com.google.android.gms.common.annotation.KeepName class * +-keepclassmembernames class * { + @com.google.android.gms.common.annotation.KeepName *; +} + +-keepnames class * implements android.os.Parcelable { + public static final ** CREATOR; +} + +###### ADDITIONAL OPTIONS NOT USED NORMALLY + +#To keep callback calls. Uncomment if using any +#http://proguard.sourceforge.net/index.html#/manual/examples.html#callback +#-keep class mypackage.MyCallbackClass { +# void myCallbackMethod(java.lang.String); +#} + +#Uncomment if using Serializable +#-keepclassmembers class * implements java.io.Serializable { +# private static final java.io.ObjectStreamField[] serialPersistentFields; +# private void writeObject(java.io.ObjectOutputStream); +# private void readObject(java.io.ObjectInputStream); +# java.lang.Object writeReplace(); +# java.lang.Object readResolve(); +#} \ No newline at end of file