Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #254 from denzilferreira/bundle
Browse files Browse the repository at this point in the history
Bundled client
  • Loading branch information
denzilferreira authored Feb 2, 2019
2 parents 2df2d90 + b850eee commit 4bb88ef
Show file tree
Hide file tree
Showing 26 changed files with 254 additions and 27 deletions.
33 changes: 33 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[submodule "com.aware.plugin.device_usage"]
path = com.aware.plugin.device_usage
url = https://github.com/denzilferreira/com.aware.plugin.device_usage.git
[submodule "com.aware.plugin.ambient_noise"]
path = com.aware.plugin.ambient_noise
url = https://github.com/denzilferreira/com.aware.plugin.ambient_noise.git
[submodule "com.aware.plugin.contacts_list"]
path = com.aware.plugin.contacts_list
url = https://github.com/denzilferreira/com.aware.plugin.contacts_list.git
[submodule "com.aware.plugin.studentlife.audio"]
path = com.aware.plugin.studentlife.audio
url = https://github.com/denzilferreira/com.aware.plugin.studentlife.audio
[submodule "com.aware.plugin.fitbit"]
path = com.aware.plugin.fitbit
url = https://github.com/denzilferreira/com.aware.plugin.fitbit
[submodule "com.aware.plugin.google.activity_recognition"]
path = com.aware.plugin.google.activity_recognition
url = https://github.com/denzilferreira/com.aware.plugin.google.activity_recognition
[submodule "com.aware.plugin.google.auth"]
path = com.aware.plugin.google.auth
url = https://github.com/denzilferreira/com.aware.plugin.google.auth
[submodule "com.aware.plugin.google.fused_location"]
path = com.aware.plugin.google.fused_location
url = https://github.com/denzilferreira/com.aware.plugin.google.fused_location
[submodule "com.aware.plugin.openweather"]
path = com.aware.plugin.openweather
url = https://github.com/denzilferreira/com.aware.plugin.openweather
[submodule "com.aware.plugin.esm.scheduler"]
path = com.aware.plugin.esm.scheduler
url = https://github.com/denzilferreira/com.aware.plugin.esm.scheduler
[submodule "com.aware.plugin.sensortag"]
path = com.aware.plugin.sensortag
url = https://github.com/denzilferreira/com.aware.plugin.sensortag
4 changes: 2 additions & 2 deletions aware-core/aware.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ ext {
ion_libs = "2.+"
support_libs = "28.0.0"
google_libs = "16.0.0"
version_code = 711
version_readable = "4.0." + version_code + "." + "legacy"
version_code = 803
version_readable = "4.0." + version_code + "." + "selfie"
compile_sdk = 28
target_sdk = 26
minimum_sdk = 19
Expand Down
5 changes: 5 additions & 0 deletions aware-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ if (System.getenv("storeFile") != null && System.getenv("storePassword") != null
android.buildTypes.release.signingConfig = null
}

repositories {
maven { url "https://jitpack.io" } //MPAndroidChart, AWARE
}

dependencies {
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:$mqtt_libs"
implementation "com.koushikdutta.ion:ion:$ion_libs"
implementation "com.android.support:gridlayout-v7:$support_libs"
implementation "com.android.support:appcompat-v7:$support_libs"
implementation "com.android.support:design:$support_libs"
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
}

6 changes: 5 additions & 1 deletion aware-core/src/main/java/com/aware/Traffic.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ public void onDataActivity(int direction) {
public void onDestroy() {
super.onDestroy();

telephonyManager.listen(networkTrafficObserver, PhoneStateListener.LISTEN_NONE);
try {
telephonyManager.listen(networkTrafficObserver, PhoneStateListener.LISTEN_NONE);
} catch (NullPointerException e) {
e.printStackTrace();
}

ContentResolver.setSyncAutomatically(Aware.getAWAREAccount(this), Traffic_Provider.getAuthority(this), false);
ContentResolver.removePeriodicSync(
Expand Down
3 changes: 1 addition & 2 deletions aware-core/src/main/java/com/aware/utils/Aware_Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class Aware_Plugin extends Service {
public void onCreate() {
super.onCreate();


//Register Context Broadcaster
IntentFilter filter = new IntentFilter();
filter.addAction(Aware.ACTION_AWARE_CURRENT_CONTEXT);
Expand Down Expand Up @@ -125,7 +124,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
startService(aware);
}

Aware.startAWARE(getApplicationContext());
//Aware.startAWARE(getApplicationContext());

//Aware.debug(this, "active: " + getClass().getName() + " package: " + getPackageName());
}
Expand Down
20 changes: 18 additions & 2 deletions aware-core/src/main/java/com/aware/utils/DatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.text.TextUtils;
import android.util.Log;

import com.aware.Aware;
import com.aware.R;

import org.json.JSONArray;
Expand Down Expand Up @@ -235,8 +236,12 @@ private synchronized SQLiteDatabase getDatabaseFile() {
// sdcard/AWARE/ (shareable, does not delete when uninstalling)
aware_folder = new File(Environment.getExternalStoragePublicDirectory("AWARE").toString());
} else {
// sdcard/Android/<app_package_name>/AWARE/ (not shareable, deletes when uninstalling package)
aware_folder = new File(ContextCompat.getExternalFilesDirs(mContext, null)[0] + "/AWARE");
if (isEmulator()) {
aware_folder = mContext.getFilesDir();
} else {
// sdcard/Android/<app_package_name>/AWARE/ (not shareable, deletes when uninstalling package)
aware_folder = new File(ContextCompat.getExternalFilesDirs(mContext, null)[0] + "/AWARE");
}
}

if (!aware_folder.exists()) {
Expand All @@ -249,4 +254,15 @@ private synchronized SQLiteDatabase getDatabaseFile() {
return null;
}
}

public static boolean isEmulator() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| "google_sdk".equals(Build.PRODUCT);
}
}
67 changes: 67 additions & 0 deletions aware-phone/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ android {
resValue "string", "provider_timezones", android.defaultConfig.applicationId + ".provider.timezone"
resValue "string", "provider_traffic", android.defaultConfig.applicationId + ".provider.traffic"
resValue "string", "provider_wifi", android.defaultConfig.applicationId + ".provider.wifi"

//plugins
resValue "string", "provider_device_usage", android.defaultConfig.applicationId + ".provider.device_usage"
resValue "string", "provider_ambient_noise", android.defaultConfig.applicationId + ".provider.ambient_noise"
resValue "string", "provider_contacts_list", android.defaultConfig.applicationId + ".provider.contacts_list"
resValue "string", "provider_conversations", android.defaultConfig.applicationId + ".provider.audio_final"
resValue "string", "provider_fitbit", android.defaultConfig.applicationId + ".provider.fitbit"
resValue "string", "provider_google_activity_recognition", android.defaultConfig.applicationId + ".provider.gar"
resValue "string", "provider_google_login", android.defaultConfig.applicationId + ".provider.google_login"
resValue "string", "provider_google_fused", android.defaultConfig.applicationId + ".provider.geofences"
resValue "string", "provider_openweather", android.defaultConfig.applicationId + ".provider.openweather"
resValue "string", "provider_sensortag", android.defaultConfig.applicationId + ".provider.sensortag"
}

splits {
abi {
enable true
reset()
include 'armeabi', 'x86'
}
}

signingConfigs {
Expand All @@ -56,6 +76,18 @@ android {
lintOptions {
abortOnError false
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}

if (System.getenv("storeFile") != null && System.getenv("storePassword") != null && System.getenv("keyAlias") != null && System.getenv("keyPassword") != null) {
Expand All @@ -75,9 +107,44 @@ repositories {
dependencies {
implementation "com.android.support:cardview-v7:$support_libs"
implementation "com.android.support:design:$support_libs"

implementation('me.dm7.barcodescanner:zbar:1.8.4') {
exclude group: 'com.android.support', module: "support-v4"
}
api project(':aware-core')

api (project(":com.aware.plugin.device_usage")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.ambient_noise")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.contacts_list")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.studentlife.audio")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.fitbit")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.google.activity_recognition")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.google.auth")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.google.fused_location")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.openweather")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.esm.scheduler")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
api (project(":com.aware.plugin.sensortag")) {
exclude group:'com.github.denzilferreira',module:'aware-client'
}
}

1 change: 1 addition & 0 deletions aware-phone/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"installed":{"client_id":"209043386748-2f9a0ar2g597hs9731md76v1sqv33i1t.apps.googleusercontent.com","project_id":"aware-client-leg-1545138814121","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://www.googleapis.com/oauth2/v3/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
12 changes: 3 additions & 9 deletions aware-phone/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<application
android:icon="@drawable/ic_launcher_aware"
Expand All @@ -83,7 +84,6 @@
<activity
android:name="com.aware.phone.ui.Stream_UI"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:icon="@mipmap/ic_launcher_stream"
android:label="@string/aware_stream"
android:launchMode="singleTop"
Expand All @@ -102,7 +102,6 @@
<activity
android:name="com.aware.phone.ui.Plugins_Manager"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:icon="@drawable/ic_launcher_settings"
android:label="@string/aware_plugins"
android:launchMode="singleTop"
Expand All @@ -114,7 +113,6 @@
<activity
android:name="com.aware.phone.ui.About"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:label="@string/aware_team"
android:launchMode="singleTop"
android:theme="@style/Theme.Aware">
Expand All @@ -125,7 +123,6 @@
<activity
android:name="com.aware.phone.ui.Aware_Join_Study"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:label="Join study"
android:launchMode="singleTop"
android:theme="@style/Theme.Aware">
Expand All @@ -142,8 +139,7 @@
</activity>

<receiver
android:name="com.aware.Aware$AndroidPackageMonitor"
android:exported="true">
android:name="com.aware.Aware$AndroidPackageMonitor" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
Expand All @@ -153,9 +149,7 @@
</receiver>

<receiver
android:name="com.aware.Aware$AwareBoot"
android:enabled="true"
android:exported="true">
android:name="com.aware.Aware$AwareBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
11 changes: 10 additions & 1 deletion aware-phone/src/main/java/com/aware/phone/Aware_Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -28,6 +29,7 @@
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.PermissionChecker;
import android.support.v7.widget.Toolbar;
Expand Down Expand Up @@ -119,6 +121,7 @@ protected void onCreate(Bundle savedInstanceState) {
REQUIRED_PERMISSIONS.add(Manifest.permission.WRITE_SYNC_SETTINGS);
REQUIRED_PERMISSIONS.add(Manifest.permission.READ_SYNC_SETTINGS);
REQUIRED_PERMISSIONS.add(Manifest.permission.READ_SYNC_STATS);
REQUIRED_PERMISSIONS.add(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) REQUIRED_PERMISSIONS.add(Manifest.permission.FOREGROUND_SERVICE);

Expand All @@ -141,6 +144,12 @@ protected void onCreate(Bundle savedInstanceState) {
awarePackages.addAction(Intent.ACTION_PACKAGE_REMOVED);
awarePackages.addDataScheme("package");
registerReceiver(packageMonitor, awarePackages);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent whitelisting = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
whitelisting.setData(Uri.parse("package:" + getPackageName()));
startActivity(whitelisting);
}
}

@Override
Expand Down Expand Up @@ -371,7 +380,7 @@ protected void onResume() {
}

//Check if AWARE is allowed to run on Doze
Aware.isBatteryOptimizationIgnored(this, getPackageName());
//Aware.isBatteryOptimizationIgnored(this, getPackageName());

prefs.registerOnSharedPreferenceChangeListener(this);

Expand Down
24 changes: 19 additions & 5 deletions aware-phone/src/main/java/com/aware/phone/ui/Aware_Join_Study.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.*;

import com.aware.Aware;
import com.aware.Aware_Preferences;
Expand Down Expand Up @@ -81,6 +79,22 @@ protected void onCreate(Bundle savedInstanceState) {
btnAction = (Button) findViewById(R.id.btn_sign_up);
btnQuit = (Button) findViewById(R.id.btn_quit_study);

EditText participant_label = findViewById(R.id.participant_label);
participant_label.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_LABEL));
participant_label.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_LABEL, s.toString());
}

@Override
public void afterTextChanged(Editable s) {
}
});

pluginsRecyclerView = (RecyclerView) findViewById(R.id.rv_plugins);
mLayoutManager = new LinearLayoutManager(this);
pluginsRecyclerView.setLayoutManager(mLayoutManager);
Expand Down
Loading

0 comments on commit 4bb88ef

Please sign in to comment.