Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
Minor tweaks to a number of items including moving some packages to local, declaring
some variables as final etc.
  • Loading branch information
xLaMbChOpSx committed Jun 14, 2014
1 parent d651a66 commit 3219b85
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 76 deletions.
20 changes: 9 additions & 11 deletions app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
Expand All @@ -45,7 +44,6 @@
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
Expand Down Expand Up @@ -74,7 +72,7 @@ public class MapViewer extends FragmentActivity implements OnSharedPreferenceCha
private AimsicdService mAimsicdService;
private boolean mBound;

private Map<Marker, MarkerData> mMarkerMap = new HashMap<>();
private final Map<Marker, MarkerData> mMarkerMap = new HashMap<>();

/**
* Called when the activity is first created.
Expand Down Expand Up @@ -438,14 +436,14 @@ private void loadEntries() {
}

public class MarkerData {
public String cellID;
public String lat;
public String lng;
public String lac;
public String mcc;
public String mnc;
public String samples;
public boolean openCellID;
public final String cellID;
public final String lat;
public final String lng;
public final String lac;
public final String mcc;
public final String mnc;
public final String samples;
public final boolean openCellID;

MarkerData(String cell_id, String latitude, String longitude,
String local_area_code, String mobile_country_code, String mobile_network_code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class CardItemData
private String mSignal;
private String mAvgSigStr;
private String mSamples;
private String mLat;
private String mLng;
private final String mLat;
private final String mLng;
private String mCountry;
private String mRecordId;
private final String mRecordId;

public CardItemData(String cellID, String lac, String mcc, String mnc, String lat, String lng,
String avgSigStr, String samples, String recordId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,43 +111,28 @@ public void setUserVisibleHint(boolean isVisibleToUser) {
private void updateUI() {
if (mBound) {
mAimsicdService.updateNeighbouringCells();
Map neighborMapUMTS = mAimsicdService.getUMTSNeighbouringCells();
Map neighborMapGSM = mAimsicdService.getGSMNeighbouringCells();
Map neighborMap = mAimsicdService.getNeighbouringCells();

mNeighbouringTotal
.setText(String.valueOf(mAimsicdService.getNeighbouringCellSize()) + "/"
+ String.valueOf(neighborMapUMTS.size() + neighborMapGSM.size()));
.setText(String.valueOf(mAimsicdService.getNeighbouringCellSize()));

StringBuilder sb = new StringBuilder();
int i = 1;
if (!neighborMapUMTS.isEmpty())
for (Object key : neighborMapUMTS.keySet()) {
sb.append(i)
.append(") PSC: ")
.append(key)
.append(" RSCP: ")
.append(neighborMapUMTS.get(key)) //TS25.133 section 9.1.1.3
.append(" dBm");
if (i < neighborMapUMTS.size() + neighborMapGSM.size())
sb.append("\n");
i++;
}
if (!neighborMapGSM.isEmpty())
for (Object key : neighborMapGSM.keySet()) {
if (!neighborMap.isEmpty())
for (Object key : neighborMap.keySet()) {
sb.append(i)
.append(") LAC-CID: ")
.append(key)
.append(" RSSI: ")
.append(neighborMapGSM.get(key)) //TS27.007 section 8.5
.append(" dBm");
if (i < neighborMapUMTS.size() + neighborMapGSM.size())
.append(neighborMap.get(key)); //TS27.007 section 8.5
if (i < neighborMap.size())
sb.append("\n");
i++;
}
mNeighbouringCells.setText(sb);

//Try SamSung MultiRil Implementation
if (neighborMapGSM.isEmpty() && neighborMapUMTS.isEmpty()) {
if (neighborMap.isEmpty()) {
DetectResult rilStatus = mAimsicdService.getRilExecutorStatus();
if (rilStatus.available) {
//new RequestOemInfoTask().execute();
Expand Down
99 changes: 59 additions & 40 deletions app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.location.Location;
Expand Down Expand Up @@ -119,7 +121,6 @@
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Timer;

public class AimsicdService extends Service implements OnSharedPreferenceChangeListener {

Expand All @@ -132,6 +133,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
*/
private final AimscidBinder mBinder = new AimscidBinder();
private final AIMSICDDbAdapter dbHelper = new AIMSICDDbAdapter(this);
private Context mContext;
private final int NOTIFICATION_ID = 1;
private long mDbResult;
private TelephonyManager tm;
Expand All @@ -142,7 +144,6 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
private static final long GPS_MIN_UPDATE_TIME = 1000;
private static final float GPS_MIN_UPDATE_DISTANCE = 10;
public boolean mMultiRilCompatible;
private Timer timer = new Timer();

/*
* Device Declarations
Expand Down Expand Up @@ -177,8 +178,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
private String mSimSubs = "";
private String mDataActivityType = "";
private String mDataActivityTypeShort = "";
private final Map<Integer,Integer> mNeighborMapUMTS = new HashMap<>();
private final Map<String,Integer> mNeighborMapGSM = new HashMap<>();
private final Map<String, String> mNeighborMap = new HashMap<>();

/*
* Tracking and Alert Declarations
Expand Down Expand Up @@ -237,6 +237,7 @@ public void onCreate() {
//TelephonyManager provides system details
tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
mContext = getApplicationContext();

prefs = this.getSharedPreferences(
AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
Expand Down Expand Up @@ -265,6 +266,9 @@ public void onCreate() {
}
}

//Register receiver for Silent SMS Interception Notification
mContext.registerReceiver(mMessageReceiver, new IntentFilter(SILENT_SMS));

Log.i(TAG, "Service launched successfully");
}

Expand All @@ -280,6 +284,7 @@ public void onDestroy() {
prefs.unregisterOnSharedPreferenceChangeListener(this);
cancelNotification();
dbHelper.close();
mContext.unregisterReceiver(mMessageReceiver);

//Samsung MultiRil Cleanup
if (mRequestExecutor != null) {
Expand All @@ -289,9 +294,23 @@ public void onDestroy() {
mHandler = null;
mHandlerThread.quit();
mHandlerThread = null;

Log.i(TAG, "Service destroyed");
}

private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final Bundle bundle = intent.getExtras();
if (bundle != null) {
dbHelper.open();
dbHelper.insertSilentSms(bundle);
dbHelper.close();
setSilentSmsStatus(true);
}
}
};

/**
* Check the status of the Rill Executor
*
Expand Down Expand Up @@ -411,7 +430,7 @@ private synchronized List<String> executeAtServiceModeCommand(int type, int subt

private static class KeyStep {
public final char keychar;
public boolean captureResponse;
public final boolean captureResponse;

public KeyStep(char keychar, boolean captureResponse) {
this.keychar = keychar;
Expand Down Expand Up @@ -1015,7 +1034,7 @@ public String getNetworkTypeName() {
return mNetType;
}

public void getDataActivity() {
void getDataActivity() {
int direction = tm.getDataActivity();
mDataActivityTypeShort = "un";
mDataActivityType = "undef";
Expand Down Expand Up @@ -1043,7 +1062,7 @@ public void getDataActivity() {
}
}

public void getDataState() {
void getDataState() {
int state = tm.getDataState();
mDataState = "undef";
mDataStateShort = "un";
Expand Down Expand Up @@ -1186,8 +1205,17 @@ public void updateCdmaLocation() {
mLastLocation.setLatitude(mLatitude);
}

public void setSilentSmsStatus(boolean state) {
void setSilentSmsStatus(boolean state) {
mClassZeroSmsDetected = state;
setNotification();
if (state) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.sms_message)
.setTitle(R.string.location_error_title);
AlertDialog alert = builder.create();
alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
alert.show();
}
}

/**
Expand Down Expand Up @@ -1275,11 +1303,11 @@ private void setNotification() {
break;
}

Context context = getApplicationContext();
Intent notificationIntent = new Intent(context, AIMSICD.class);
Intent notificationIntent = new Intent(mContext, AIMSICD.class);
notificationIntent.putExtra("silent_sms", mClassZeroSmsDetected);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_FROM_BACKGROUND);
PendingIntent contentIntent = PendingIntent.getActivity(
context, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
mContext, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(icon)
Expand Down Expand Up @@ -1313,24 +1341,25 @@ private void cancelNotification() {
*
*/
public void updateNeighbouringCells() {
//Update Neighbouring Cell Map
for (String key: mNeighborMapGSM.keySet())
mNeighborMapGSM.put(key,-113);
for (int key: mNeighborMapUMTS.keySet())
mNeighborMapUMTS.put(key,-115);

List<NeighboringCellInfo> neighboringCellInfo;
neighboringCellInfo = tm.getNeighboringCellInfo();
mNeighbouringCellSize = neighboringCellInfo.size();
for (NeighboringCellInfo i : neighboringCellInfo) {
int networktype = i.getNetworkType();
if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSDPA) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSUPA) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSPA))
mNeighborMapUMTS.put(i.getPsc(), i.getRssi()-115);
else
mNeighborMapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi())));
if (neighboringCellInfo != null) {
mNeighbouringCellSize = neighboringCellInfo.size();
for (int i = 0; i > neighboringCellInfo.size(); i++) {
if (neighboringCellInfo.get(i) != null) {
String dBm;
int rssi = neighboringCellInfo.get(i).getRssi();

if (rssi == NeighboringCellInfo.UNKNOWN_RSSI) {
dBm = "Unknown RSSI";
} else {
dBm = String.valueOf(-113 + 2 * rssi) + " dBm";
}

mNeighborMap.put(neighboringCellInfo.get(i).getLac() +
":" + neighboringCellInfo.get(i).getCid(), dBm);
}
}
}
}

Expand All @@ -1339,19 +1368,9 @@ public void updateNeighbouringCells() {
*
* @return Map of GSM Neighbouring Cell Information
*/
public Map getGSMNeighbouringCells() {
return mNeighborMapGSM;
public Map getNeighbouringCells() {
return mNeighborMap;
}

/**
* Neighbouring UMTS Cell Map
*
* @return Map of UMTS Neighbouring Cell Information
*/
public Map getUMTSNeighbouringCells() {
return mNeighborMapUMTS;
}

/**
* Neighbouring Cell Size
*
Expand Down Expand Up @@ -1665,7 +1684,7 @@ public void onStatusChanged(String provider, int status,
* @param location The new Location that you want to evaluate
* @param currentBestLocation The current Location fix, to which you want to compare the new one
*/
protected boolean isBetterLocation(Location location, Location currentBestLocation) {
boolean isBetterLocation(Location location, Location currentBestLocation) {
if (currentBestLocation == null) {
// A new location is always better than no location
return true;
Expand Down

0 comments on commit 3219b85

Please sign in to comment.