Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:audaciouscode/PassiveDataKit-Android
  • Loading branch information
audaciouscode committed May 5, 2017
2 parents 530744e + 4503b2f commit 3577db9
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 152 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -3,11 +3,11 @@ language: android
jdk: oraclejdk8

before_install:
- wget http://services.gradle.org/distributions/gradle-2.14.1-bin.zip
- unzip gradle-2.14.1-bin.zip
- export GRADLE_HOME=$PWD/gradle-2.14.1
- wget http://services.gradle.org/distributions/gradle-3.3-bin.zip
- unzip gradle-3.3-bin.zip
- export GRADLE_HOME=$PWD/gradle-3.3
- export PATH=$GRADLE_HOME/bin:$PATH
- ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk -a --no-ui --filter tool,platform-tool,build-tools-25.0.0
- ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk -a --no-ui --filter tool,platform-tool,build-tools-25.0.2

script:
- gradle assembleDebug
Expand Down
20 changes: 10 additions & 10 deletions build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}

Expand Down Expand Up @@ -45,21 +45,21 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-nearby:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.android.gms:play-services-awareness:10.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-location:10.2.4'
compile 'com.google.android.gms:play-services-maps:10.2.4'
compile 'com.google.android.gms:play-services-nearby:10.2.4'
compile 'com.google.android.gms:play-services-places:10.2.4'
compile 'com.google.android.gms:play-services-awareness:10.2.4'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.10'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.github.philjay:mpandroidchart:v3.0.0'
compile 'com.github.philjay:mpandroidchart:v3.0.1'
}

buildTypes {
Expand Down
4 changes: 4 additions & 0 deletions res/values/databases.xml
Expand Up @@ -12,4 +12,8 @@

<!-- Phone Calls Generator -->
<string name="pdk_generator_text_messages_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, direction TEXT, length INTEGER, body TEXT, number_name TEXT, number TEXT);</string>

<!-- App Events Generator -->
<string name="pdk_generator_app_events_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, event_name TEXT, event_details TEXT);</string>

</resources>
11 changes: 9 additions & 2 deletions src/com/audacious_software/passive_data_kit/Logger.java
Expand Up @@ -2,16 +2,23 @@

import android.content.Context;

import com.audacious_software.passive_data_kit.generators.diagnostics.AppEvent;

import java.util.HashMap;
import java.util.Map;

/**
* Created by cjkarr on 4/3/2016.
*/
public class Logger {
private Context mContext = null;

public void log(String event, HashMap<String, Object> details) {
// TODO
public void log(String event, Map<String, ? extends Object> details) {
if (details == null) {
details = new HashMap<>();
}

AppEvent.getInstance(this.mContext).logEvent(event, details);
}

private static class LoggerHolder {
Expand Down
Expand Up @@ -58,7 +58,7 @@ protected void onPause() {
}

@Override
public void onGeneratorUpdated(String identifier, Bundle data) {
public void onGeneratorUpdated(String identifier, long timestamp, Bundle data) {
final DataStreamActivity me = this;

this.runOnUiThread(new Runnable() {
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -120,6 +121,12 @@ public static String formatTimestamp(Context context, double timestamp) {

public abstract List<Bundle> fetchPayloads();

public Cursor queryHistory(String[] cols, String where, String[] args, String orderBy) {
Cursor c = new MatrixCursor(cols);

return c;
}

protected int getDatabaseVersion(SQLiteDatabase db) {
String where = "type = ? AND name = ?";
String[] args = { "table", Generator.TABLE_METADATA };
Expand Down
Expand Up @@ -11,6 +11,7 @@

import com.audacious_software.passive_data_kit.Logger;
import com.audacious_software.passive_data_kit.diagnostics.DiagnosticAction;
import com.audacious_software.passive_data_kit.generators.diagnostics.AppEvent;
import com.audacious_software.pdk.passivedatakit.R;

import java.lang.reflect.InvocationTargetException;
Expand All @@ -37,6 +38,8 @@ public void start() {
{
this.mGenerators.clear();

this.mGenerators.add(AppEvent.class.getCanonicalName());

for (String className : this.mContext.getResources().getStringArray(R.array.pdk_available_generators))
{
this.mGenerators.add(className);
Expand Down Expand Up @@ -238,9 +241,19 @@ public List<Class<? extends Generator>> activeGenerators() {
return active;
}

public void notifyGeneratorUpdated(String identifier, Bundle bundle) {
public void notifyGeneratorUpdated(String identifier, long timestamp, Bundle bundle) {
for (GeneratorUpdatedListener listener : this.mGeneratorUpdatedListeners) {
listener.onGeneratorUpdated(identifier, bundle);
listener.onGeneratorUpdated(identifier, timestamp, bundle);
}
}

public void notifyGeneratorUpdated(String identifier, Bundle bundle) {
long timestamp = System.currentTimeMillis();

synchronized(this.mGeneratorUpdatedListeners) {
for (GeneratorUpdatedListener listener : this.mGeneratorUpdatedListeners) {
listener.onGeneratorUpdated(identifier, timestamp, bundle);
}
}
}

Expand All @@ -262,14 +275,18 @@ private void setContext(Context context) {
}

public void addNewGeneratorUpdatedListener(Generators.GeneratorUpdatedListener listener) {
this.mGeneratorUpdatedListeners.add(listener);
synchronized(this.mGeneratorUpdatedListeners) {
this.mGeneratorUpdatedListeners.add(listener);
}
}

public void removeGeneratorUpdatedListener(Generators.GeneratorUpdatedListener listener) {
this.mGeneratorUpdatedListeners.remove(listener);
synchronized(this.mGeneratorUpdatedListeners) {
this.mGeneratorUpdatedListeners.remove(listener);
}
}

public interface GeneratorUpdatedListener {
void onGeneratorUpdated(String identifier, Bundle data);
void onGeneratorUpdated(String identifier, long timestamp, Bundle data);
}
}

0 comments on commit 3577db9

Please sign in to comment.