Commit e037e21c authored by Security: Pwned.'s avatar Security: Pwned.
Browse files

Merge pull request #530 from SecUpwN/development

Unchaining WIP-Release v0.1.31-alpha-build-00
Showing with 313 additions and 140 deletions
+313 -140
......@@ -77,3 +77,4 @@ addons:
build_command_prepend: "./gradlew clean"
build_command: "./gradlew build"
branch_pattern: development
build_script_url: https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/travisci_build_coverity_scan.sh
# CHANGELOG of 'AIMSICD'
----------------------
#### [05.07.2015 - WIP-Release v0.1.31-alpha-build-00](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases/tag/v0.1.31-alpha-b00)
* Removed: Commented out unused imports and re-ordered variable declarations
* Updated: Shortened badge of `Development Status` in `README` for better display
* Added: More clarifying code co´mments in `CellTracker.java`
#### 05.07.2015 - WIP-Internal v0.1.30-alpha-build-16
* Fixed: Cleanup of timestamp code in `MiscUtils.java`
* Fixed: AIMSICD Status-Icons are now shown correctly in colored style on Android 5+
---
#### 04.07.2015 - WIP-Internal v0.1.30-alpha-build-14
* Added: New Log items for MCC and MNC parameters when downloading OCID for debugging
* Fixed: Reformatted 23 char limitation of Log TAG with our standard TAG, mTAG + "text"
* Fixed: Corrected MiscUtils TAGs and nulls in CellTracker and improved some formatting
* Fixed: Silenced even more XPrivacy logcat spam in DebugLogs
---
#### 03.07.2015 - WIP-Internal v0.1.30-alpha-build-13
* Fixed: Comments in `RequestTask.java` have been fixed to reflect code changes
* Fixed: Silenced some spammy XPrivacy items using: `XPrivacy/XRuntime:S Xposed:S`
---
#### 03.07.2015 - WIP-Internal v0.1.30-alpha-build-12
* Added: Weblate translations badge added to our `README` for people to see progress
* Fixed: AIMSICD should now start again properly on previously complaining devices
---
#### 03.07.2015 - WIP-Internal v0.1.30-alpha-build-11
* Updated: `CREDITS` now reflect the latest awesome additions by our new developers
* Fixed: Small string fixes and translation improvements to move our new [Weblate](https://hosted.weblate.org/projects/aimsicd/strings/).
---
#### 03.07.2015 - WIP-Internal v0.1.30-alpha-build-10
* Fixed: Now truncating measured and used Lat/Lon GPS coordinates in `LocationTracker`
---
#### 27.06.2015 - WIP-Internal v0.1.30-alpha-build-09
* Changed: Timeout value in `RequestTask.java` has been increased to 80 seconds
* Fixed: Repaired OCIDCSV parsing which obviously temporarily broke during development
---
#### 27.06.2015 - WIP-Internal v0.1.30-alpha-build-08
* Added: Buildozer Buildnumber to has been added to About View for development builds
---
#### 26.06.2015 - WIP-Internal v0.1.30-alpha-build-07
* Changed: mTAG has been changed as requested to `SamsungMulticlientRilExecutor`
* Added: Small warning within code to not remove commented out stuff without prior asking
---
#### 25.06.2015 - WIP-Internal v0.1.30-alpha-build-06
* Updated: Log calls updated to common TAGs, added doublepoints and removed whitespaces
---
#### 25.06.2015 - WIP-Internal v0.1.30-alpha-build-05
* Changed: Customized build script in `.travis.yml` to override CoverityScan limits
* Changed: Made toast property static and non-final, splitting toast creation for `msgShort`
* Removed: Commented out `LeakCanary` until this libray has reived some code improvemens
* Fixed: Toasts are now displayed in the ccorrect position and duration to really read them
---
#### 24.06.2015 - WIP-Internal v0.1.30-alpha-build-04
* Added: Toasts are now being cancelled on new toast to prevent overapping of toasts
---
#### 24.06.2015 - WIP-Internal v0.1.30-alpha-build-03
* Fixed: Info box toasts are now shown longer by adding a new singleton toaster
---
#### 23.06.2015 - WIP-Internal v0.1.30-alpha-build-02
* Changed: Context property changed to `appContext` in `DrawerMenuAdapter.java`
* Removed: Purged `this` prefix of `appContext` as it is not needed anymore
---
#### 23.06.2015 - WIP-Internal v0.1.30-alpha-build-01
* Changed: Help toast has been changed to long toast in `DrawerMenuAdapter.java`
---
#### [21.06.2015 - WIP-Release v0.1.30-alpha-build-00](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases/tag/v0.1.30-alpha-b00)
* Updated: Refactored OpenCellId activity for better code quality and error handling
......
......@@ -23,11 +23,9 @@ Feel invited to develop with us using these steps:
Let our app start up in your native language!
* Copy file [translatable_strings.xml](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/raw/development/app/src/main/res/values/translatable_strings.xml) into your values-[code](https://en.wikipedia.org/wiki/ISO_639-1) folder.
* Example: `app/src/main/res/values-de/translatable_strings.xml`
* Translate the xml-file with an Editor, Android Studio or IntelliJ IDEA.
6. Increase the build number `*-alpha-bXX` in `android:versionName`.
7. Test your changes and submit a [pull request](https://help.github.com/articles/using-pull-requests/) when we shall add it.
* See [our translations](https://hosted.weblate.org/projects/aimsicd/strings/) and login via [GitHub](https://hosted.weblate.org/accounts/login/github/?next=/projects/aimsicd/strings/) or [others](https://hosted.weblate.org/accounts/login/?next=/projects/aimsicd/strings/) to add yours.
* When translating, keep small device screens in mind. Shorten it.
* Translations will be pulled into our GitHub automatically. Enjoy!
---
......
### Android IMSI-Catcher Detector
[![BuildStatus](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector.svg)](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector) [![DevelopmentStatus](http://img.shields.io/badge/Development_Status-ALPHA-brightgreen.svg)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Development-Status) [![CoverityScan](https://scan.coverity.com/projects/3346/badge.svg)](https://scan.coverity.com/projects/3346)
[![BuildStatus](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector.svg)](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector) [![DevelopmentStatus](http://img.shields.io/badge/Development-ALPHA-brightgreen.svg)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Development-Status) [![CoverityScan](https://scan.coverity.com/projects/3346/badge.svg)](https://scan.coverity.com/projects/3346) [![Translations](https://hosted.weblate.org/widgets/aimsicd/-/shields-badge.svg)](https://hosted.weblate.org/projects/aimsicd/strings/)
[![Bountysource](https://www.bountysource.com/badge/team?team_id=40338&style=bounties_received)](https://www.bountysource.com/teams/android-imsi-catcher-detector/issues?utm_source=Android%20IMSI-Catcher%20Detector&utm_medium=shield&utm_campaign=bounties_received)
--
......
......@@ -56,9 +56,15 @@ android {
} catch (MissingPropertyException e) {
buildConfigField 'String', 'OPEN_CELLID_API_KEY', '"NA"'
}
try {
buildConfigField 'String', 'BUILDOZER_BUILDNUMBER', '\"' + System.getenv("BUILDOZER_BUILDNUMBER") + '\"'
} catch (MissingPropertyException e) {
buildConfigField 'String', 'BUILDOZER_BUILDNUMBER', '"NA"'
}
}
release {
buildConfigField 'String', 'OPEN_CELLID_API_KEY', '"NA"'
buildConfigField 'String', 'BUILDOZER_BUILDNUMBER', '"NA"'
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
......@@ -125,6 +131,7 @@ android {
}
dependencies {
// DO NOT REMOVE BELOW COMMENTED-OUT CODE BEFORE ASKING!
//compile 'com.github.amlcurran.showcaseview:library:5.0.0'
//compile 'com.android.support:appcompat-v7:22.1.1'
//https://github.com/lp0/slf4j-android
......@@ -140,6 +147,6 @@ dependencies {
compile 'com.nineoldandroids:library:2.4.0'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'com.google.code.gson:gson:2.2.4'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
//debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
//releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SecUpwN.AIMSICD"
android:versionCode="30"
android:versionName="0.1.30-alpha-b00">
android:versionCode="31"
android:versionName="0.1.31-alpha-b00">
<!-- If we ever wanna make this a system app, we can add the following 2 lines above:
coreApp="true"
......@@ -204,4 +204,4 @@
</activity>
</application>
</manifest>
</manifest>
\ No newline at end of file
......@@ -221,4 +221,10 @@ for OCID improvements and code fixes.\n
\n
Willem van Engen\n
https://github.com/wvengen\n
for improving database imports.
\ No newline at end of file
for improving database imports.\n
\n
Daniel Jäger\n
https://github.com/DJaeger\n
for your unbelievable endurance\n
and all the lovely coding. THANK YOU!\n
\n
\ No newline at end of file
......@@ -14,13 +14,15 @@ import android.util.SparseArray;
import com.SecUpwN.AIMSICD.constants.TinyDbKeys;
import com.SecUpwN.AIMSICD.utils.BaseAsyncTask;
import com.SecUpwN.AIMSICD.utils.TinyDB;
import com.squareup.leakcanary.LeakCanary;
// DO NOT REMOVE BELOW COMMENTED-OUT CODE BEFORE ASKING!
//import com.squareup.leakcanary.LeakCanary;
import java.util.ArrayList;
import java.util.List;
public class AppAIMSICD extends Application {
final static String TAG = "AppAIMSICD";
final static String TAG = "AIMSICD";
final static String mTAG = "AppAIMSICD";
/**
* Maps between an activity class name and the list of currently running
......@@ -35,7 +37,8 @@ public class AppAIMSICD extends Application {
@Override
public void onCreate() {
super.onCreate();
LeakCanary.install(this);
// DO NOT REMOVE BELOW COMMENTED-OUT CODE BEFORE ASKING!
//LeakCanary.install(this);
TinyDB.getInstance().init(getApplicationContext());
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, true);
}
......@@ -49,7 +52,7 @@ public class AppAIMSICD extends Application {
if (lTask.equals(pTask)) {
tasks.remove(lTask);
if (BuildConfig.DEBUG) {
Log.v(TAG, "BaseTask removed:" + pTask.toString());
Log.v(TAG, mTAG + ": BaseTask removed:" + pTask.toString());
}
break;
}
......@@ -66,7 +69,7 @@ public class AppAIMSICD extends Application {
return;
}
if (BuildConfig.DEBUG) {
Log.d(TAG, "BaseTask addTask activity:" + activity.getClass().getCanonicalName());
Log.d(TAG, mTAG + ": BaseTask addTask activity:" + activity.getClass().getCanonicalName());
}
int key = activity.getClass().getCanonicalName().hashCode();
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(key);
......@@ -75,7 +78,7 @@ public class AppAIMSICD extends Application {
mActivityTaskMap.put(key, tasks);
}
if (BuildConfig.DEBUG) {
Log.v(TAG, "BaseTask added:" + pTask.toString());
Log.v(TAG, mTAG + ": BaseTask added:" + pTask.toString());
}
tasks.add(pTask);
}
......@@ -85,7 +88,7 @@ public class AppAIMSICD extends Application {
return;
}
if (BuildConfig.DEBUG) {
Log.d(TAG, "BaseTask detach:" + activity.getClass().getCanonicalName());
Log.d(TAG, mTAG + ": BaseTask detach:" + activity.getClass().getCanonicalName());
}
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(activity.getClass().getCanonicalName().hashCode());
......@@ -101,7 +104,7 @@ public class AppAIMSICD extends Application {
return;
}
if (BuildConfig.DEBUG) {
Log.d(TAG, "BaseTask attach:" + activity.getClass().getCanonicalName());
Log.d(TAG, mTAG + ": BaseTask attach:" + activity.getClass().getCanonicalName());
}
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(activity.getClass().getCanonicalName().hashCode());
if (tasks != null) {
......@@ -110,5 +113,4 @@ public class AppAIMSICD extends Application {
}
}
}
}
}
\ No newline at end of file
......@@ -25,7 +25,9 @@ import com.SecUpwN.AIMSICD.utils.Status;
* @author Tor Henning Ueland
*/
public class BaseActivity extends FragmentActivity {
private static String TAG = "BaseActivity";
private static final String TAG = "AIMSICD";
private static final String mTAG = "BaseActivity";
/**
* Triggered when GUI is opened
......@@ -33,7 +35,7 @@ public class BaseActivity extends FragmentActivity {
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "StatusWatcher starting watching");
Log.d(TAG, mTAG + ": StatusWatcher starting watching");
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter("StatusChange"));
updateIcon(this);
......@@ -45,7 +47,7 @@ public class BaseActivity extends FragmentActivity {
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "StatusWatcher received status change to " + Status.getStatus().name()+", updating icon");
Log.d(TAG, mTAG + ": StatusWatcher received status change to " + Status.getStatus().name()+", updating icon");
updateIcon(context);
}
};
......@@ -69,7 +71,7 @@ public class BaseActivity extends FragmentActivity {
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "StatusWatcher stopped watching");
Log.d(TAG, mTAG + ": StatusWatcher stopped watching");
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
}
}
......@@ -46,6 +46,8 @@ import java.io.InputStreamReader;
* but never implemented here. We need to add the buffer selector button
* to the top bar, next to email icon button. **
*
* TODO: [ ] We should add an XPrivacy button (or automatic) to add XPrivacy filters when used.
*
* ChangeLog:
*
* 2015-01-27 E:V:A Added "getprop|sort" info to log.
......@@ -53,11 +55,16 @@ import java.io.InputStreamReader;
* 2015-02-11 E:V:A Increased to 500 lines and removed "-d" and
* incl. radio log, but not working. Permission problem?
* 2015-02-24 E:V:A Silent some spam logs on HTC devices.
* 2015-07-03 E:V:A Silent some spam logs from the XPosed framework
*
*/
public class DebugLogs extends BaseActivity {
private static final String TAG = "AIMSICD";
private static final String mTAG = "DebugLogs";
private LogUpdaterThread logUpdater = null;
private boolean updateLogs = true;
private boolean isRadioLogs = true; // Including this, should be a toggle.
......@@ -95,7 +102,7 @@ public class DebugLogs extends BaseActivity {
clearLogs();
//Log.d("DebugLogs", "Logcat clearing disabled!");
} catch (Exception e) {
Log.e("AIMSICD", "DebugLogs: Error clearing logs", e);
Log.e(TAG, mTAG + ": Error clearing logs", e);
}
}
});
......@@ -158,7 +165,7 @@ public class DebugLogs extends BaseActivity {
logUpdater = new LogUpdaterThread();
logUpdater.start();
} catch (Exception e) {
Log.e("AIMSICD", "DebugLogs: Error starting log updater thread", e);
Log.e(TAG, mTAG + ": Error starting log updater thread", e);
}
btnStop.setText(getString(R.string.btn_stop_logs));
}
......@@ -211,7 +218,7 @@ public class DebugLogs extends BaseActivity {
intent.putExtra(Intent.EXTRA_TEXT, log);
startActivity(Intent.createChooser(intent, "Send Error Log"));
} catch (IOException e) {
Log.e("AIMSICD", "DebugLogs: Error reading logs", e);
Log.e(TAG, mTAG + ": Error reading logs", e);
}
}
}.start();
......@@ -241,6 +248,8 @@ public class DebugLogs extends BaseActivity {
* 4) Need to silent some Qualcomm GPS: " LocSvc_eng:S LocSvc_adapter:S LocSvc_afw:S"
* 5) "-d" is not necessary when using "-t".
* 6) Need to silent some spammy HTC's: "QC-QMI:S AudioPolicyManager:S"
* 7) Need to silent some spammy XPrivacy items: "XPrivacy/XRuntime:S Xposed:S"
* 8) Need to silent even more XPrivacy items: "XPrivacy/XTelephonyManager:S XPrivacy/XLocationManager:S XPrivacy/XPackageManager:S"
*
*/
private String getLogs() throws IOException {
......@@ -249,7 +258,9 @@ public class DebugLogs extends BaseActivity {
(isRadioLogs ? " -b radio RILQ:S" : "") +
" AbsListView:S PackageInfo:S" +
" LocSvc_eng:S LocSvc_adapter:S LocSvc_afw:S" +
" QC-QMI:S AudioPolicyManager:S" + " *:D"
" QC-QMI:S AudioPolicyManager:S" +
" XPrivacy/XRuntime:S Xposed:S" +
" XPrivacy/XTelephonyManager:S XPrivacy/XLocationManager:S XPrivacy/XPackageManager:S" + " *:D"
);
}
......@@ -296,7 +307,7 @@ public class DebugLogs extends BaseActivity {
try {
Runtime.getRuntime().exec("logcat -c -b main -b system -b radio -b events");
} catch (Exception e) {
Log.e("AIMSICD", "DebugLogs: Error clearing logs", e);
Log.e(TAG, mTAG + ": Error clearing logs", e);
}
runOnUiThread(new Runnable() {
......@@ -335,7 +346,7 @@ public class DebugLogs extends BaseActivity {
});
}
} catch (Exception e) {
Log.e("AIMSICD", "DebugLogs: Error updating logs", e);
Log.e(TAG, mTAG + ": Error updating logs", e);
}
try { Thread.sleep(1000); } catch (Exception e) {}
}
......
......@@ -33,4 +33,4 @@ public class PrefActivity extends BaseActivity {
fragmentTransaction.replace(android.R.id.content, settingsFragment);
fragmentTransaction.commit();
}
}
}
\ No newline at end of file
......@@ -1417,7 +1417,7 @@ public class AIMSICDDbAdapter {
// Make sure it has a location index. Separate connection to avoid locking issues.
// TODO this can take a while the first time, provide UI feedback
SQLiteDatabase ladb = SQLiteDatabase.openDatabase(LACELLS_DB_NAME, null, 0);
String LACELLS_TABLE_CREATE = "CREATE TABLE " +
String LACELLS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
LACELLS_TABLE + " (" + COLUMN_ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
"Lac INTEGER, CellID INTEGER, " +
......
......@@ -15,13 +15,13 @@ import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.SecUpwN.AIMSICD.R;
import com.SecUpwN.AIMSICD.constants.DrawerMenu;
import com.SecUpwN.AIMSICD.drawer.DrawerMenuItem;
import com.SecUpwN.AIMSICD.drawer.DrawerMenuSection;
import com.SecUpwN.AIMSICD.drawer.NavDrawerItem;
import com.SecUpwN.AIMSICD.utils.Helpers;
import java.util.List;
......@@ -29,16 +29,16 @@ public class DrawerMenuAdapter extends ArrayAdapter<NavDrawerItem> {
private final LayoutInflater inflater;
private final View.OnClickListener mInfoButtonListener;
private final Toast mToast;
private final Animation mBounceHelpButtonAnimation;
private static Context appContext;
@SuppressLint("ShowToast")
public DrawerMenuAdapter(Context context, int textViewResourceId, List<NavDrawerItem> objects ) {
super(context, textViewResourceId, objects);
inflater = LayoutInflater.from(context);
appContext = context.getApplicationContext();
mToast = Toast.makeText(context.getApplicationContext(), "", Toast.LENGTH_LONG);
mInfoButtonListener = new View.OnClickListener() {
@Override
public void onClick(View pView) {
......@@ -47,12 +47,11 @@ public class DrawerMenuAdapter extends ArrayAdapter<NavDrawerItem> {
showHelpToast((Integer) pView.getTag());
}
};
mBounceHelpButtonAnimation = AnimationUtils.loadAnimation(context.getApplicationContext(), R.anim.action_button_help);
mBounceHelpButtonAnimation = AnimationUtils.loadAnimation(appContext, R.anim.action_button_help);
}
private void showHelpToast(Integer pToastValueId) {
mToast.setText(getContext().getString(pToastValueId));
mToast.show();
Helpers.msgLong(appContext, appContext.getString(pToastValueId));
}
@Override
......
......@@ -20,6 +20,7 @@ import android.widget.Button;
import android.widget.TextView;
import com.SecUpwN.AIMSICD.R;
import com.SecUpwN.AIMSICD.BuildConfig;
import com.SecUpwN.AIMSICD.activities.CreditsRollActivity;
import com.SecUpwN.AIMSICD.utils.MiscUtils;
......@@ -33,6 +34,7 @@ public class AboutFragment extends Fragment {
View v = inflater.inflate(R.layout.about_fragment, container, false);
String version;
String BUILDOZER_BUILDNUMBER;
btncredits = (Button) v.findViewById(R.id.aimsicd_credits_link);
PackageManager manager = mContext.getPackageManager();
......@@ -44,12 +46,24 @@ public class AboutFragment extends Fragment {
//Woops something went wrong??
version = "";
}
BUILDOZER_BUILDNUMBER = BuildConfig.BUILDOZER_BUILDNUMBER;
if (BUILDOZER_BUILDNUMBER == null) {
BUILDOZER_BUILDNUMBER = "NA"; // avoid null buildnumber
}
TextView versionNumber;
TextView BuildozerView;
if (v != null) {
versionNumber = (TextView) v.findViewById(R.id.aimsicd_version);
versionNumber.setText(getString(R.string.app_version) + version);
if(BUILDOZER_BUILDNUMBER != "NA") {
BuildozerView = (TextView) v.findViewById(R.id.buildozer_buildnumber);
BuildozerView.setText(getString(R.string.buildozer_buildnumber) + BUILDOZER_BUILDNUMBER);
BuildozerView.setVisibility(View.VISIBLE);
}
//Status icons link
View tv = v.findViewById(R.id.aimsicd_status_icons);
//setLink(tv, R.string.status_icons_link);
......@@ -183,4 +197,4 @@ public class AboutFragment extends Fragment {
}
}
}
\ No newline at end of file
......@@ -18,4 +18,4 @@ public class PrefFragment extends PreferenceFragment {
addPreferencesFromResource(R.xml.preferences);
}
}
}
\ No newline at end of file
......@@ -27,7 +27,9 @@ import java.util.Queue;
* Class to handle Ril and Samsung MultiRil implementation. Used by the Aimsicd Service.
*/
public class RilExecutor {
public static final String TAG = "MultiRil";
protected static final String TAG = "AIMSICD";
protected static final String mTAG = "RilExecutor";
public boolean mMultiRilCompatible;
/*
......@@ -76,7 +78,7 @@ public class RilExecutor {
mRilExecutorDetectResult = mRequestExecutor.detect();
if (!mRilExecutorDetectResult.available) {
mMultiRilCompatible = false;
Log.e(TAG, "Samsung Multiclient RIL not available: " + mRilExecutorDetectResult.error);
Log.e(TAG, mTAG + ": Samsung Multiclient RIL not available: " + mRilExecutorDetectResult.error);
mRequestExecutor = null;
} else {
mRequestExecutor.start();
......@@ -142,7 +144,7 @@ public class RilExecutor {
subtype,
keySeqence).sendToTarget();
if (!mRequestCondvar.block(timeout)) {
Log.e(TAG, "request timeout");
Log.e(TAG, mTAG + ": request timeout");
return Collections.emptyList();
} else {
synchronized (mLastResponseLock) {
......@@ -248,15 +250,15 @@ public class RilExecutor {
try {
RawResult result = (RawResult) msg.obj;
if (result == null) {
Log.e(TAG, "result is null");
Log.e(TAG, mTAG + ": result is null");
break;
}
if (result.exception != null) {
Log.e(TAG, "", result.exception);
Log.e(TAG, mTAG + ": ", result.exception);
break;
}
if (result.result == null) {
Log.v(TAG, "No need to refresh.");
Log.v(TAG, mTAG + ": No need to refresh.");
break;
}
if (lastKeyStep.captureResponse) {
......@@ -286,4 +288,4 @@ public class RilExecutor {
return true;
}
}
}
}
\ No newline at end of file
......@@ -57,8 +57,9 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
// private static final boolean DBG = BuildConfig.DEBUG;
private static final boolean DBG = false;
// TODO: EVA: We should add AIMSICD to this TAG
private static final String TAG = SamsungMulticlientRilExecutor.class.getSimpleName();
private static final String TAG = "AIMSICD";
private static final String mTAG = "SamsungMulticlientRilExecutor";
private volatile LocalSocketThread mThread;
public SamsungMulticlientRilExecutor() {
......@@ -104,7 +105,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
@Override
public synchronized void start() {
if (mThread != null) {
Log.e(TAG, "OEM raw request executor thread is running");
Log.e(TAG, mTAG + ": OEM raw request executor thread is running");
return;
}
mThread = new LocalSocketThread(MULTICLIENT_SOCKET);
......@@ -114,7 +115,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
@Override
public synchronized void stop() {
if (mThread == null) {
Log.e(TAG, "OEM raw request executor thread is not running");
Log.e(TAG, mTAG + ": OEM raw request executor thread is not running");
return;
}
mThread.cancel();
......@@ -124,26 +125,26 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
@Override
public synchronized void invokeOemRilRequestRaw(byte[] data, Message response) {
if (mThread == null) {
Log.e(TAG, "OEM raw request executor thread is not running");
Log.e(TAG, mTAG + ": OEM raw request executor thread is not running");
return;
}
try {
mThread.invokeOemRilRequestRaw(data, response);
} catch (IOException ioe) {
Log.e(TAG, "invokeOemRilRequestRaw() error", ioe);
Log.e(TAG, mTAG + ": invokeOemRilRequestRaw() error", ioe);
}
}
@Override
public synchronized void invokeOemRilRequestStrings(String[] strings, Message response) {
if (mThread == null) {
Log.e(TAG, "OEM raw request executor thread is not running");
Log.e(TAG, mTAG + ": OEM raw request executor thread is not running");
return;
}
try {
mThread.invokeOemRilRequestStrings(strings, response);
} catch (IOException ioe) {
Log.e(TAG, "invokeOemRilRequestStrings() error", ioe);
Log.e(TAG, mTAG + ": invokeOemRilRequestStrings() error", ioe);
}
}
......@@ -168,7 +169,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
public void cancel() {
if (DBG) {
Log.v(TAG, "SamsungMulticlientRil cancel()");
Log.v(TAG, mTAG + ": SamsungMulticlientRil cancel()");
}
synchronized (this) {
mCancelRequested.set(true);
......@@ -181,12 +182,12 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
throws IOException {
int token;
if (mMessages.size() > MAX_MESSAGES) {
Log.e(TAG, "message queue is full");
Log.e(TAG, mTAG + ": message queue is full");
return;
}
if (mOutputStream == null) {
Log.e(TAG, "Local write() error: not connected");
Log.e(TAG, mTAG + ": Local write() error: not connected");
return;
}
......@@ -213,12 +214,12 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
throws IOException {
int token;
if (mMessages.size() > MAX_MESSAGES) {
Log.e(TAG, "message queue is full");
Log.e(TAG, mTAG + ": message queue is full");
return;
}
if (mOutputStream == null) {
Log.e(TAG, "Local write() error: not connected");
Log.e(TAG, mTAG + ": Local write() error: not connected");
return;
}
......@@ -272,7 +273,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
public synchronized void disconnect() {
if (DBG) {
Log.v(TAG, "Local disconnect()");
Log.v(TAG, mTAG + ": Local disconnect()");
}
if (mSocket == null) {
......@@ -282,31 +283,31 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
try {
mSocket.shutdownInput();
} catch (IOException e) {
Log.e(TAG, "Local shutdownInput() of mSocket failed", e);
Log.e(TAG, mTAG + ": Local shutdownInput() of mSocket failed", e);
}
try {
mSocket.shutdownOutput();
} catch (IOException e) {
Log.e(TAG, "Local shutdownOutput() of mSocket failed", e);
Log.e(TAG, mTAG + ": Local shutdownOutput() of mSocket failed", e);
}
try {
mInputStream.close();
} catch (IOException e) {
Log.e(TAG, "Local close() of mInputStream failed", e);
Log.e(TAG, mTAG + ": Local close() of mInputStream failed", e);
}
try {
mOutputStream.close();
} catch (IOException e) {
Log.e(TAG, "Local close() of mOutputStream failed", e);
Log.e(TAG, mTAG + ": Local close() of mOutputStream failed", e);
}
try {
mSocket.close();
} catch (IOException e) {
Log.e(TAG, "Local close() of mSocket failed", e);
Log.e(TAG, mTAG + ": Local close() of mSocket failed", e);
}
mSocket = null;
......@@ -320,7 +321,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
int endpos = 0;
final byte buf[] = new byte[4096];
Log.i(TAG, "BEGIN LocalSocketThread-Socket");
Log.i(TAG, mTAG + ": BEGIN LocalSocketThread-Socket");
setName("MultiClientThread");
mSocket = new LocalSocket();
......@@ -329,7 +330,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
mInputStream = mSocket.getInputStream();
mOutputStream = mSocket.getOutputStream();
} catch (IOException e) {
Log.e(TAG, "Connect error", e);
Log.e(TAG, mTAG + ": Connect error", e);
return;
}
......@@ -338,7 +339,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
rcvd = mInputStream.read(buf, endpos, buf.length - endpos);
if (rcvd < 0) {
if (DBG) {
Log.v(TAG, "EOF reached");
Log.v(TAG, mTAG + ": EOF reached");
}
break;
}
......@@ -349,7 +350,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
int msgLen = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3] & 0xff);
if (msgLen + 4 > buf.length) {
Log.e(TAG, "message to big. Length: " + msgLen);
Log.e(TAG, mTAG + ": message to big. Length: " + msgLen);
endpos = 0;
continue;
}
......@@ -390,13 +391,13 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
responseType = p.readInt();
switch (responseType) {
case RESPONSE_UNSOLICITED:
Log.v(TAG, "Unsolicited response ");
Log.v(TAG, mTAG + ": Unsolicited response ");
break;
case RESPONSE_SOLICITED:
processSolicited(p);
break;
default:
Log.v(TAG, "Invalid response type: " + responseType);
Log.v(TAG, mTAG + ": Invalid response type: " + responseType);
break;
}
} finally {
......@@ -430,7 +431,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
}
if (token == null) {
Log.e(TAG, "token is null", errorEx);
Log.e(TAG, mTAG + ": token is null", errorEx);
} else {
synchronized (this) {
Message m = mMessages.remove(token);
......@@ -448,7 +449,7 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
m.sendToTarget();
}
} else {
Log.i(TAG, "Message with token " + token + " not found");
Log.i(TAG, mTAG + ": Message with token " + token + " not found");
}
}
}
......@@ -466,4 +467,4 @@ public class SamsungMulticlientRilExecutor implements OemRilExecutor {
}
}
}
}
\ No newline at end of file
......@@ -14,10 +14,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
import android.telephony.CellInfo;
......@@ -45,13 +46,9 @@ import com.SecUpwN.AIMSICD.utils.OCIDResponse;
import com.SecUpwN.AIMSICD.utils.Status;
import com.SecUpwN.AIMSICD.utils.TinyDB;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -95,7 +92,14 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
private final String mTAG = "CellTracker";
public static String OCID_API_KEY = null; // see getOcidKey()
public static int PHONE_TYPE; //
public static long REFRESH_RATE; // [s] The DeviceInfo refresh rate (arrays.xml)
public static int LAST_DB_BACKUP_VERSION; //
public static final String SILENT_SMS = "SILENT_SMS_DETECTED";
private boolean CELL_TABLE_CLEANSED; //
private final int NOTIFICATION_ID = 1; // ?
private final Device mDevice = new Device();
private static TelephonyManager tm;
private final SignalStrengthTracker signalStrengthTracker;
......@@ -105,12 +109,6 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
//TinyDB tinydb = new TinyDB(context);
private TinyDB tinydb;
public static int PHONE_TYPE; //
public static long REFRESH_RATE; // [s] The DeviceInfo refresh rate (arrays.xml)
public static int LAST_DB_BACKUP_VERSION; //
public static final String SILENT_SMS = "SILENT_SMS_DETECTED";
private boolean CELL_TABLE_CLEANSED;
private final Device mDevice = new Device();
/*
* Tracking and Alert Declarations
......@@ -253,13 +251,13 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
public void setCellTracking(boolean track) {
if (track) {
tm.listen(mCellSignalListener,
PhoneStateListener.LISTEN_CELL_LOCATION | // gpsd_lat/lon ?
PhoneStateListener.LISTEN_CELL_LOCATION | // gpsd_lat/lon ?
PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | // rx_signal
PhoneStateListener.LISTEN_DATA_ACTIVITY | // No,In,Ou,IO,Do
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | // Di,Ct,Cd,Su
PhoneStateListener.LISTEN_CELL_INFO
// PhoneStateListener.LISTEN_CALL_STATE ?
// PhoneStateListener.LISTEN_SERVICE_STATE ?
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | // Di,Ct,Cd,Su
PhoneStateListener.LISTEN_CELL_INFO // !? (Need API 17)
// PhoneStateListener.LISTEN_CALL_STATE // idle,ringing,offhook
// PhoneStateListener.LISTEN_SERVICE_STATE // emergency_only,in_service,out_of_service,power_off
);
mTrackingCell = true;
Helpers.msgShort(context, context.getString(R.string.tracking_cell_information));
......@@ -372,7 +370,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
// a new API key within 24 hours of the last request. (See GH issue #267)
// Make toast message: "Only one new API key request per 24 hours. Please try again later."
Helpers.msgLong(context, context.getString(R.string.only_one_api_per_day));
Helpers.msgLong(context, context.getString(R.string.only_one_key_per_day));
String responseFromServer = result.getResponseFromServer();
Log.d("AIMSICD", "CellTracker: OCID Reached 24hr API key limit: " + responseFromServer);
return responseFromServer;
......@@ -380,12 +378,16 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
// TODO add code here or elsewhere to check for NO network exceptions...
// See: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/293
httpclient = null;
httpGet = null;
result = null;
// TODO: Remove commented out stuff if app works without these NULLs
// See: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/pull/526
// PR: 4a68d00
//httpclient = null;
//httpGet = null;
//result = null;
Log.d("AIMSICD", "CellTracker: OCID Returned " + result.getStatusCode() + " " + result.getReasonPhrase());
// throw new Exception("OCID Returned " + status.getStatusCode() + " " + status.getReasonPhrase());
//throw new Exception("OCID Returned " + status.getStatusCode() + " " + status.getReasonPhrase());
return null;
}
}
......@@ -447,6 +449,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
neighboringCellInfo = cellInfoList;
} catch (InterruptedException e) {
// Maybe a more valuable message here?
//Log.d(TAG, mTAG + ": unknown NC info exception: " + e); // How about this???
// normal
}
}
......@@ -463,8 +466,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
// Add NC list to ?? cellinfo ?? ---> DBi_measure:nc_list
for (NeighboringCellInfo neighbourCell : neighboringCellInfo) {
Log.i(TAG,
mTAG + ": neighbouringCellInfo -" +
Log.i(TAG, mTAG + ": neighbouringCellInfo -" +
" LAC:" + neighbourCell.getLac() +
" CID:" + neighbourCell.getCid() +
" PSC:" + neighbourCell.getPsc() +
......@@ -488,7 +490,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
*/
public void checkForNeighbourCount(CellLocation location){
Log.i(mTAG,"in checkForNeighbourCount");
Log.i(TAG, mTAG + ": checkForNeighbourCount()");
/**
* Description: This snippet sets a global variable (SharedPreference) to indicate
......@@ -549,7 +551,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
}
/** Update: from banjaxbanjo
/**
* I removed the timer that activated this code and now the code will be run when
* the cell changes so it will detect faster rather than using a timer that might
* miss an imsi catcher, also says cpu rather than refreshing every x seconds.
......@@ -597,7 +599,8 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
* Are there any reasons why not using a listener?
*
* ChangeLog:
* 2015-03-03 E:V:A Changed getProp() to use TinyDB (SharedPreferences)
* 2015-03-03 E:V:A Changed getProp() to use TinyDB (SharedPreferences)
* 2015-0x-xx banjaxbanjo Update: ??? (hey dude what did you do?)
*
*/
public void compareLac(CellLocation location){
......@@ -622,7 +625,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
// Check if CellID (CID) is in DBe_import (OpenCell) database (issue #91)
if ( tinydb.getBoolean("ocid_downloaded") ) {
if (!dbHelper.openCellExists(mMonitorCell.getCID())) {
Log.i(mTAG, "ALERT: Connected to unknown CID not in DBe_import: " + mMonitorCell.getCID());
Log.i(TAG, "ALERT: Connected to unknown CID not in DBe_import: " + mMonitorCell.getCID());
// Code Place-holder: TODO: Add to EventLog table!!
......@@ -684,16 +687,16 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
*
*/
private void loadPreferences() {
boolean trackFemtoPref = prefs.getBoolean( context.getString(R.string.pref_femto_detection_key), false);
boolean trackCellPref = prefs.getBoolean( context.getString(R.string.pref_enable_cell_key), true);
boolean monitorCellPref = prefs.getBoolean( context.getString(R.string.pref_enable_cell_monitoring_key), true);
boolean trackFemtoPref = prefs.getBoolean(context.getString(R.string.pref_femto_detection_key), false);
boolean trackCellPref = prefs.getBoolean(context.getString(R.string.pref_enable_cell_key), true);
boolean monitorCellPref = prefs.getBoolean(context.getString(R.string.pref_enable_cell_monitoring_key), true);
LAST_DB_BACKUP_VERSION = prefs.getInt( context.getString(R.string.pref_last_database_backup_version), 1);
CELL_TABLE_CLEANSED = prefs.getBoolean( context.getString(R.string.pref_cell_table_cleansed), false);
LAST_DB_BACKUP_VERSION = prefs.getInt(context.getString(R.string.pref_last_database_backup_version), 1);
CELL_TABLE_CLEANSED = prefs.getBoolean(context.getString(R.string.pref_cell_table_cleansed), false);
String refreshRate = prefs.getString( context.getString(R.string.pref_refresh_key), "1");
String refreshRate = prefs.getString(context.getString(R.string.pref_refresh_key), "1");
// Default to Automatic ("1")
if (refreshRate.isEmpty()) { refreshRate = "1"; }
if (refreshRate.isEmpty()) { refreshRate = "1"; } // Set default to: 1 second
int rate = Integer.parseInt(refreshRate);
long t;
......@@ -702,7 +705,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
t = 15L; // Automatic refresh rate is 15 seconds
break;
default:
t = (rate * 1L);
t = ((long) rate); // Default is 1 sec (from above)
break;
}
......@@ -749,22 +752,22 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
public void onCellLocationChanged(CellLocation location) {
checkForNeighbourCount(location);
compareLac(location);
refreshDevice();//refresh data on cell change
refreshDevice(); //refresh data on cell change
mDevice.setNetID(tm); // ??
mDevice.getNetworkTypeName(); // RAT??
switch (mDevice.getPhoneID()) {
case TelephonyManager.PHONE_TYPE_NONE: // Maybe bad!
case TelephonyManager.PHONE_TYPE_SIP: // Maybe bad!
case TelephonyManager.PHONE_TYPE_NONE:
case TelephonyManager.PHONE_TYPE_SIP:
case TelephonyManager.PHONE_TYPE_GSM:
GsmCellLocation gsmCellLocation = (GsmCellLocation) location;
if (gsmCellLocation != null) {
mDevice.setCellInfo(
gsmCellLocation.toString() + // ??
gsmCellLocation.toString() + // ??
mDevice.getDataActivityTypeShort() + "|" + // No,In,Ou,IO,Do
mDevice.getDataStateShort() + "|" + // Di,Ct,Cd,Su
mDevice.getNetworkTypeName() + "|" // TODO: Is "|" a typo?
mDevice.getNetworkTypeName() + "|" // HSPA,LTE etc
);
mDevice.mCell.setLAC(gsmCellLocation.getLac()); // LAC
mDevice.mCell.setCID(gsmCellLocation.getCid()); // CID
......@@ -778,7 +781,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) location;
if (cdmaCellLocation != null) {
mDevice.setCellInfo(
cdmaCellLocation.toString() + // ??
cdmaCellLocation.toString() + // ??
mDevice.getDataActivityTypeShort() + "|" + // No,In,Ou,IO,Do
mDevice.getDataStateShort() + "|" + // Di,Ct,Cd,Su
mDevice.getNetworkTypeName() + "|" // TODO: Is "|" a typo?
......@@ -930,8 +933,8 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
if (cellLocation != null) {
switch (mDevice.getPhoneID()) {
case TelephonyManager.PHONE_TYPE_NONE: // Maybe bad!
case TelephonyManager.PHONE_TYPE_SIP: // Maybe bad!
case TelephonyManager.PHONE_TYPE_NONE:
case TelephonyManager.PHONE_TYPE_SIP:
case TelephonyManager.PHONE_TYPE_GSM:
GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
mDevice.mCell.setCID(gsmCellLocation.getCid()); // CID
......@@ -944,7 +947,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
mDevice.mCell.setCID(cdmaCellLocation.getBaseStationId()); // BSID ??
mDevice.mCell.setLAC(cdmaCellLocation.getNetworkId()); // NID
mDevice.mCell.setSID(cdmaCellLocation.getSystemId()); // SID
mDevice.mCell.setMNC(cdmaCellLocation.getSystemId()); // <== BUG!?? // MNC
mDevice.mCell.setMNC(cdmaCellLocation.getSystemId()); // MNC <== BUG!??
}
}
}
......@@ -1109,7 +1112,7 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
case ALARM: // ORANGE, RED or BLACK ?
tickerText = context.getResources().getString(R.string.app_name_short) + " - " + context.getString(R.string.alert_threat_detected); // Hmm, this is vague!
if (mFemtoDetected) {
contentText = context.getString(R.string.aletr_femtocell_connection_detected);
contentText = context.getString(R.string.alert_femtocell_connection_detected);
} else if (mTypeZeroSmsDetected) {
contentText = context.getString(R.string.alert_silent_sms_detected);
}
......@@ -1127,9 +1130,13 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
PendingIntent contentIntent = PendingIntent.getActivity(
context, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
String iconType = prefs.getString(context.getString(R.string.pref_ui_icons_key), "SENSE").toUpperCase();
int iconResId = Icon.getIcon(Icon.Type.valueOf(iconType));
Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), iconResId);
Notification mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(Icon.getIcon(Icon.Type.valueOf(iconType)))
//.setSmallIcon(Icon.getIcon(Icon.Type.valueOf(iconType)))
.setSmallIcon(iconResId)
.setLargeIcon(largeIcon)
.setTicker(tickerText)
.setContentTitle(context.getResources().getString(R.string.main_app_name))
.setContentText(contentText)
......@@ -1309,13 +1316,13 @@ public class CellTracker implements SharedPreferences.OnSharedPreferenceChangeLi
@Override
public void onCellInfoChanged(List<CellInfo> cellInfo) {
handle();
Log.i(mTAG,"Cell info change");
Log.i(TAG, mTAG + ": Cell info change");
}
@Override
public void onCellLocationChanged(CellLocation location) {
handle();
Log.i(mTAG,"Cell info change");
Log.i(TAG, mTAG +": Cell info change");
}
};
......
......@@ -19,6 +19,7 @@ import com.SecUpwN.AIMSICD.R;
import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter;
import com.SecUpwN.AIMSICD.utils.Cell;
import com.SecUpwN.AIMSICD.utils.GeoLocation;
import com.SecUpwN.AIMSICD.utils.TruncatedLocation;
/**
* Class to handle GPS location tracking
......@@ -100,12 +101,14 @@ public class LocationTracker {
GeoLocation loc = null;
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null && (location.getLatitude() != 0.0 && location.getLongitude() != 0.0)) {
loc = GeoLocation.fromDegrees(location.getLatitude(), location.getLongitude());
TruncatedLocation TruncatedLocation = new TruncatedLocation(location);
loc = GeoLocation.fromDegrees(TruncatedLocation.getLatitude(), TruncatedLocation.getLongitude());
} else {
location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null && (location.getLatitude() != 0.0
&& location.getLongitude() != 0.0)) {
loc = GeoLocation.fromDegrees(location.getLatitude(), location.getLongitude());
TruncatedLocation TruncatedLocation = new TruncatedLocation(location);
loc = GeoLocation.fromDegrees(TruncatedLocation.getLatitude(), TruncatedLocation.getLongitude());
} else {
String coords = prefs.getString(context.getString(R.string.data_last_lat_lon), null);
if (coords != null) {
......
......@@ -26,16 +26,26 @@ import java.util.HashMap;
*
* https://cloud.githubusercontent.com/assets/2507905/4428863/c85c8366-45d4-11e4-89da-c650cdb56caf.jpg
*
* Issues:
*
* [ ]
*
* ChangeLog
*
* 20150703 E:V:A Changed log TAG to use only TAG for Log.i() and mTAG for Log.d/e/v()
*
* @author Tor Henning Ueland
*/
public class SignalStrengthTracker {
//FIXME The logging tag can be at most 23 characters, was 29 (AIMSICD_SignalStrengthTracker)
public static final String TAG = "AIMSICD_SignalStrength";
private static final String TAG = "AIMSICD";
private static final String mTAG = "SignalStrengthTracker";
private static int sleepTimeBetweenSignalRegistration = 60; // [seconds]
private static int minimumIdleTime = 30; // [seconds]
private static int maximumNumberOfDaysSaved = 60; // [days] = 2 months
private static int mysteriousSignalDifference = 10; // [dBm] or [ASU]?
private static int sleepTimeBetweenCleanup = 3600; // Once per hour
private static int minimumIdleTime = 30; // [seconds]
private static int maximumNumberOfDaysSaved = 60; // [days] = 2 months
private static int mysteriousSignalDifference = 10; // [dBm] or [ASU]?
private static int sleepTimeBetweenCleanup = 3600; // Once per hour
private Long lastRegistrationTime; //Timestamp for last registration to DB
private Long lastCleanupTime; //Timestamp for last cleanup of DB
private HashMap<Integer, Integer> averageSignalCache = new HashMap<>();
......@@ -62,8 +72,8 @@ public class SignalStrengthTracker {
long now = System.currentTimeMillis();
if(deviceIsMoving()) {
Log.i(TAG, "Ignored signal strength sample for CID: " + cellID +
" as the device is currently moving around, will not accept anything for another " +
Log.i(TAG, "Ignoring signal strength for CID: " + cellID +
" since device is moving around, waiting for " +
((minimumIdleTime*1000) - (now - lastMovementDetected)) + " ms.");
return;
}
......@@ -113,7 +123,7 @@ public class SignalStrengthTracker {
//If moving, return false
if(deviceIsMoving()) {
Log.i(TAG, "Cannot check signal strength for CID: " + cellID +
" as the device is currently moving around.");
" since device is moving around.");
return false;
}
......@@ -122,13 +132,13 @@ public class SignalStrengthTracker {
//Cached?
if(averageSignalCache.get(cellID) != null) {
storedAvg = averageSignalCache.get(cellID);
Log.d(TAG, "Cached average SS for CID: " + cellID + " is: " + storedAvg);
Log.d(TAG, mTAG + ": Cached average SS for CID: " + cellID + " is: " + storedAvg);
} else {
//Not cached, check DB
mDbHelper.open();
storedAvg = mDbHelper.getAverageSignalStrength(cellID);
averageSignalCache.put(cellID, storedAvg);
Log.d(TAG, "Average SS in DB for CID: " + cellID + " is: " + storedAvg);
Log.d(TAG, mTAG + ": Average SS in DB for CID: " + cellID + " is: " + storedAvg);
mDbHelper.close();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment