Skip to content

Commit

Permalink
Service Persistence Preference & Minor cleanup
Browse files Browse the repository at this point in the history
Corrected the behaviour of the Persistent Service preference and the application will
now correctly shutdown the server when destroyed if this preference is disabled.

Other minor changes.
  • Loading branch information
xLaMbChOpSx committed Jun 14, 2014
1 parent 7f22147 commit f410aac
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ private void loadEntries() {
}

} while (c.moveToNext());
c.close();
} else {
Helpers.msgShort(this, "No tracked locations found to overlay on map.");
}
Expand Down Expand Up @@ -434,6 +433,8 @@ private void loadEntries() {

} while (c.moveToNext());
}

mDbHelper.close();
}

public class MarkerData {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.SecUpwN.AIMSICD.fragments;

import com.SecUpwN.AIMSICD.R;
import com.SecUpwN.AIMSICD.rilexecutor.DetectResult;
import com.SecUpwN.AIMSICD.service.AimsicdService;
import com.SecUpwN.AIMSICD.utils.Helpers;

Expand Down Expand Up @@ -91,7 +92,7 @@ public void onClick(View v) {
}

private void executeAT() {
/*if (mBound && !mView.findViewById(R.id.at_command).toString().isEmpty()) {
/* if (mBound && !mView.findViewById(R.id.at_command).toString().isEmpty()) {
//Try SamSung MultiRil Implementation
DetectResult rilStatus = mAimsicdService.getRilExecutorStatus();
if (rilStatus.available) {
Expand Down
59 changes: 55 additions & 4 deletions app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL

private final String TAG = "AIMSICD_Service";
public static final String SHARED_PREFERENCES_BASENAME = "com.SecUpwN.AIMSICD_preferences";
public static final String SILENT_SMS = "SILENT_SMS_INTERCEPTED";

/*
* System and helper declarations
Expand Down Expand Up @@ -187,6 +188,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
private boolean TrackingFemtocell;
private boolean mFemtoDetected;
private boolean mLocationPrompted;
private boolean mClassZeroSmsDetected;

/*
* Samsung MultiRil Implementation
Expand Down Expand Up @@ -593,7 +595,7 @@ private void refreshDeviceInfo() {
mCellID = cdmaCellLocation.getBaseStationId();
mLac = cdmaCellLocation.getNetworkId();
mSID = getSID();
updateCdmaLocation();
//updateCdmaLocation();
}
break;
}
Expand Down Expand Up @@ -733,6 +735,9 @@ public String getSimCountry(boolean force) {
}
}

if (mSimCountry.isEmpty())
mSimCountry = "N/A";

return mSimCountry;
}

Expand All @@ -756,6 +761,9 @@ public String getSimOperator(boolean force) {
}
}

if (mSimOperator.isEmpty())
mSimOperator = "N/A";

return mSimOperator;
}

Expand All @@ -778,6 +786,9 @@ public String getSimOperatorName(boolean force) {
}
}

if (mSimOperatorName.isEmpty())
mSimOperatorName = "N/A";

return mSimOperatorName;
}

Expand All @@ -801,6 +812,9 @@ public String getSimSubs(boolean force) {
}
}

if (mSimSubs.isEmpty())
mSimSubs= "N/A";

return mSimSubs;
}

Expand All @@ -824,6 +838,9 @@ public String getSimSerial(boolean force) {
}
}

if (mSimSerial.isEmpty())
mSimSerial = "N/A";

return mSimSerial;
}

Expand Down Expand Up @@ -1155,11 +1172,18 @@ public void updateCdmaLocation() {

if(!(Double.isNaN(Long) || Long < -2592000 || Long > 2592000)) {
mLongitude = ((double) Long) / (3600 * 4);
} else {
mLongitude = 0.0f;
}

if(!(Double.isNaN(Lat) || Lat < -2592000 || Lat > 2592000)) {
mLatitude = ((double) Lat) / (3600 * 4);
} else {
mLatitude = 0.0f;
}

mLastLocation.setLongitude(mLongitude);
mLastLocation.setLatitude(mLatitude);
}

/**
Expand Down Expand Up @@ -1234,7 +1258,12 @@ private void setNotification() {
}
tickerText = getResources().getString(R.string.app_name_short)
+ " - ALERT!! Threat Detected";
contentText = "ALERT!! Threat Detected";
if (mFemtoDetected) {
contentText = "ALERT!! FemtoCell Connection Threat Detected";
} else if (mClassZeroSmsDetected) {
contentText = "ALERT!! Class Zero Hidden SMS Intercepted";
}

break;
default:
icon = R.drawable.sense_idle;
Expand Down Expand Up @@ -1271,7 +1300,7 @@ private void cancelNotification() {
NotificationManager notificationManager = (NotificationManager) this.getSystemService(
NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.cancel(0x1212);
notificationManager.cancel(NOTIFICATION_ID);
}
}

Expand Down Expand Up @@ -1488,7 +1517,11 @@ public void onDataConnectionStateChanged(int state) {
* @return double array [0] - Latitude [1] - Longitude
*/
public double[] getLastLocation() {
return new double[] {mLastLocation.getLatitude(), mLastLocation.getLongitude()};
if (mLastLocation != null) {
return new double[]{mLastLocation.getLatitude(), mLastLocation.getLongitude()};
} else {
return new double[]{0.0f,0.0f};
}
}

public Location lastKnownLocation() {
Expand All @@ -1499,6 +1532,24 @@ public Location lastKnownLocation() {

if (location != null)
location = (isBetterLocation(location, mLastLocation) ? location : mLastLocation);
else {
CellLocation cellLocation = tm.getCellLocation();
if (cellLocation != null) {
switch (mPhoneID) {
case TelephonyManager.PHONE_TYPE_GSM:
GsmCellLocation gsmCellLocation
= (GsmCellLocation) cellLocation;
mCellID = gsmCellLocation.getCid();
mLac = gsmCellLocation.getLac();
break;
case TelephonyManager.PHONE_TYPE_CDMA:
CdmaCellLocation cdmaCellLocation
= (CdmaCellLocation) cellLocation;
mCellID = cdmaCellLocation.getBaseStationId();
mLac = cdmaCellLocation.getNetworkId();
}
}
}

return location;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/cell_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@
android:layout_span="2" android:visibility="gone"/>
</TableRow>
</TableLayout>

</RelativeLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,5 @@
</TableRow>

</TableLayout>

</ScrollView>

0 comments on commit f410aac

Please sign in to comment.