-
Notifications
You must be signed in to change notification settings - Fork 970
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #426 from SecUpwN/development
Unchaining WIP-Release v0.1.27-alpha-build-00
- Loading branch information
Showing
50 changed files
with
1,132 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* Android IMSI-Catcher Detector | (c) AIMSICD Privacy Project | ||
* ----------------------------------------------------------- | ||
* LICENSE: http://git.io/vJaf6 | TERMS: http://git.io/vJMf5 | ||
* ----------------------------------------------------------- | ||
*/ | ||
package com.SecUpwN.AIMSICD; | ||
|
||
|
||
import android.app.Activity; | ||
import android.app.Application; | ||
import android.util.Log; | ||
import android.util.SparseArray; | ||
|
||
import com.SecUpwN.AIMSICD.constants.TinyDbKeys; | ||
import com.SecUpwN.AIMSICD.utils.BaseAsyncTask; | ||
import com.SecUpwN.AIMSICD.utils.TinyDB; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AppAIMSICD extends Application { | ||
final static String TAG = "AppAIMSICD"; | ||
|
||
/** | ||
* Maps between an activity class name and the list of currently running | ||
* AsyncTasks that were spawned while it was active. | ||
*/ | ||
private SparseArray<List<BaseAsyncTask<?, ?, ?>>> mActivityTaskMap; | ||
|
||
public AppAIMSICD() { | ||
mActivityTaskMap = new SparseArray<>(); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
TinyDB.getInstance().init(getApplicationContext()); | ||
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, true); | ||
} | ||
|
||
public void removeTask(BaseAsyncTask<?, ?, ?> pTask) { | ||
int key; | ||
for (int i = 0; i < mActivityTaskMap.size(); i++) { | ||
key = mActivityTaskMap.keyAt(i); | ||
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(key); | ||
for (BaseAsyncTask<?, ?, ?> lTask : tasks) { | ||
if (lTask.equals(pTask)) { | ||
tasks.remove(lTask); | ||
if (BuildConfig.DEBUG) { | ||
Log.v(TAG, "BaseTask removed:" + pTask.toString()); | ||
} | ||
break; | ||
} | ||
} | ||
if (tasks.size() == 0) { | ||
mActivityTaskMap.remove(key); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
public void addTask(Activity activity, BaseAsyncTask<?, ?, ?> pTask) { | ||
if (activity == null) { | ||
return; | ||
} | ||
if (BuildConfig.DEBUG) { | ||
Log.d(TAG, "BaseTask addTask activity:" + activity.getClass().getCanonicalName()); | ||
} | ||
int key = activity.getClass().getCanonicalName().hashCode(); | ||
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(key); | ||
if (tasks == null) { | ||
tasks = new ArrayList<>(); | ||
mActivityTaskMap.put(key, tasks); | ||
} | ||
if (BuildConfig.DEBUG) { | ||
Log.v(TAG, "BaseTask added:" + pTask.toString()); | ||
} | ||
tasks.add(pTask); | ||
} | ||
|
||
public void detach(Activity activity) { | ||
if (activity == null) { | ||
return; | ||
} | ||
if (BuildConfig.DEBUG) { | ||
Log.d(TAG, "BaseTask detach:" + activity.getClass().getCanonicalName()); | ||
} | ||
|
||
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(activity.getClass().getCanonicalName().hashCode()); | ||
if (tasks != null) { | ||
for (BaseAsyncTask<?, ?, ?> task : tasks) { | ||
task.setActivity(null); | ||
} | ||
} | ||
} | ||
|
||
public void attach(Activity activity) { | ||
if (activity == null) { | ||
return; | ||
} | ||
if (BuildConfig.DEBUG) { | ||
Log.d(TAG, "BaseTask attach:" + activity.getClass().getCanonicalName()); | ||
} | ||
List<BaseAsyncTask<?, ?, ?>> tasks = mActivityTaskMap.get(activity.getClass().getCanonicalName().hashCode()); | ||
if (tasks != null) { | ||
for (BaseAsyncTask<?, ?, ?> task : tasks) { | ||
task.setActivity(activity); | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.