Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2c98815ff | ||
|
|
99abe5e86e | ||
|
|
55a8c55aba | ||
|
|
16c31df0bf | ||
|
|
10feb5d6aa | ||
|
|
f8371a4b0a | ||
|
|
f8ed7dfac4 | ||
|
|
5b0f0bef32 | ||
|
|
c207f5470a | ||
|
|
1002351f2d | ||
|
|
dd4cc41740 | ||
|
|
3f43df52e9 | ||
|
|
de8ad98f8d | ||
|
|
0fc0605a85 |
Vendored
+2
-1
@@ -49,8 +49,9 @@ node {
|
||||
if (env.BRANCH_NAME == "master" && release) {
|
||||
echo "Deploying to production server ..."
|
||||
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "KEYFILE")]) {
|
||||
// sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-21-mowesta/standalone/deployments/mowesta.ear'
|
||||
// sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-21-mowesta/standalone/deployments/mowesta.ear'
|
||||
sh 'scp -i $KEYFILE android-app/build/outputs/apk/prod/release/*.apk wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
|
||||
sh 'scp -i $KEYFILE android-app/build/outputs/bundle/prodRelease/*.aab wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
|
||||
}
|
||||
} else if (env.BRANCH_NAME == "master" || env.BRANCH_NAME == "feat/auth") {
|
||||
echo "Deploying to beta server ..."
|
||||
|
||||
@@ -14,15 +14,15 @@ ext {
|
||||
versionAndroidXPaging = '2.1.2'
|
||||
versionAndroidXCard = '1.0.0'
|
||||
versionAndroidXCoordinator = '1.1.0'
|
||||
versionAndroidXConstraint = '2.1.0'
|
||||
versionAndroidXConstraint = '2.1.2'
|
||||
versionAndroidXNavigation = '2.3.5'
|
||||
versionAndroidXLifecycle = '2.3.1'
|
||||
versionAndroidXSecurity = '1.1.0-alpha03'
|
||||
versionAndroidXLifecycle = '2.4.0'
|
||||
versionAndroidXSecurity = '1.0.0'
|
||||
versionAndroidXViewpager = '1.0.0'
|
||||
versionGoogleMaterial = '1.4.0'
|
||||
versionAndroidXSwipeRefresh = '1.1.0'
|
||||
versionAndroidXWebkit = '1.4.0'
|
||||
versionExoPlayer = '2.14.2'
|
||||
versionExoPlayer = '2.16.1'
|
||||
versionApp = project.version
|
||||
}
|
||||
|
||||
@@ -95,12 +95,12 @@ configurations {
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
defaultConfig {
|
||||
applicationId "com.mowesta.android.app"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
versionCode 20
|
||||
versionCode 23
|
||||
versionName "${versionApp}"
|
||||
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -200,4 +200,7 @@ eclipse {
|
||||
}
|
||||
}
|
||||
|
||||
if (System.properties['android.keystore.password'] != null) {
|
||||
build.dependsOn "bundle"
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+4
-2
@@ -20,6 +20,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
@@ -56,10 +57,11 @@ public class AdvertiseDialogFragment extends BottomSheetDialogFragment {
|
||||
binding.setModel(model);
|
||||
binding.setLifecycleOwner(getViewLifecycleOwner());
|
||||
binding.videoView.setPlayer(model.getExoPlayer());
|
||||
binding.videoView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
|
||||
model.getClose().observe(getViewLifecycleOwner(), (v) -> { if (v) this.dismiss(); } );
|
||||
model.getOpen().observe(getViewLifecycleOwner(), (v) -> {
|
||||
if (v) {
|
||||
String url = "https://www.mowesta.com/2021/08/21/fair-experiment-bei-den-schlosslichtspielen-in-karlsruhe/";
|
||||
String url = "https://www.mowesta.com/2021/12/01/fair-experiment-bei-der-eiszeit-in-karlsruhe/";
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(url));
|
||||
try {
|
||||
@@ -76,7 +78,7 @@ public class AdvertiseDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public boolean shouldShow(Context context) {
|
||||
long time = System.currentTimeMillis();
|
||||
if (time > 1633298400000l) return false;
|
||||
if (time > 1643500800000l) return false;
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
long last = prefs.getLong(KEY_ADVERTISEMENT, 0);
|
||||
return (time - last > 7 * 24* 60 * 60 * 1000);
|
||||
|
||||
@@ -40,14 +40,16 @@ import java.util.List;
|
||||
*/
|
||||
public class FavoritesFragment extends Fragment {
|
||||
|
||||
private static final String TAG_ADVERTISEMENT = "ad";
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
// possibly show the ad for schlosslichtspiele
|
||||
// possibly show the ad for eiszeit
|
||||
AdvertiseDialogFragment adf = new AdvertiseDialogFragment();
|
||||
if (adf.shouldShow(getContext())) {
|
||||
adf.show(getChildFragmentManager(), "ad");
|
||||
if (adf.shouldShow(getContext()) && getChildFragmentManager().findFragmentByTag(TAG_ADVERTISEMENT) == null) {
|
||||
adf.show(getChildFragmentManager(), TAG_ADVERTISEMENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AdvertiseViewModel extends AndroidViewModel {
|
||||
}
|
||||
};
|
||||
MediaSource videoSource = new ProgressiveMediaSource.Factory(df)
|
||||
.createMediaSource(MediaItem.fromUri("android_assets:///schlosslichtspiele.mp4"));
|
||||
.createMediaSource(MediaItem.fromUri("android_assets:///eiszeit.mp4"));
|
||||
exoPlayer.setRepeatMode(ExoPlayer.REPEAT_MODE_ALL);
|
||||
exoPlayer.setMediaSource(videoSource);
|
||||
exoPlayer.prepare();
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.security.crypto.EncryptedFile;
|
||||
import androidx.security.crypto.MasterKey;
|
||||
import androidx.security.crypto.MasterKeys;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -281,9 +281,8 @@ public class FileStoreObserver<T> implements Observer<T> {
|
||||
* be setup.
|
||||
*/
|
||||
@NonNull EncryptedFile getEncryptedFile() throws IOException, GeneralSecurityException {
|
||||
MasterKey.Builder b = new MasterKey.Builder(context);
|
||||
b.setKeyScheme(MasterKey.KeyScheme.AES256_GCM);
|
||||
return new EncryptedFile.Builder(context, getFile(), b.build(),
|
||||
String keySpec = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
|
||||
return new EncryptedFile.Builder(getFile(), context, keySpec,
|
||||
EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ public class MeasureWidgetProvider extends AbstractWidgetProvider {
|
||||
Measurement measurement = widget.getContent(Measurement.class);
|
||||
if (measurement != null) {
|
||||
List<RemoteViews> items = new ArrayList<>();
|
||||
Date dateTime = new Date(measurement.getTime());
|
||||
String date = android.text.format.DateFormat.getDateFormat(context).format(dateTime);
|
||||
createItemView(items, context, R.drawable.ic_calendar_today_normal_24, R.string.widget_measure_date, UnitUtils.toSpanned(date), widget.getColor());
|
||||
String time = android.text.format.DateFormat.getTimeFormat(context).format(dateTime);
|
||||
createItemView(items, context, R.drawable.ic_alarm_normal_24, R.string.widget_measure_time , UnitUtils.toSpanned(time), widget.getColor());
|
||||
if (measurement.getTemperature() != null) {
|
||||
createItemView(items, context, R.drawable.ic_thermometer_normal_24, R.string.label_temperature, UnitUtils.toSpanned(UnitUtils.getTemperature(context, measurement.getTemperature(), unit)), widget.getColor());
|
||||
}
|
||||
@@ -114,6 +109,11 @@ public class MeasureWidgetProvider extends AbstractWidgetProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
Date dateTime = new Date(measurement.getTime());
|
||||
String date = android.text.format.DateFormat.getDateFormat(context).format(dateTime);
|
||||
createItemView(items, context, R.drawable.ic_calendar_today_normal_24, R.string.widget_measure_date, UnitUtils.toSpanned(date), widget.getColor());
|
||||
String time = android.text.format.DateFormat.getTimeFormat(context).format(dateTime);
|
||||
createItemView(items, context, R.drawable.ic_alarm_normal_24, R.string.widget_measure_time , UnitUtils.toSpanned(time), widget.getColor());
|
||||
int max = Math.min(items.size(), (int)((height - (HEIGHT_DEVICE * scale)) / (HEIGHT_ITEM * scale)));
|
||||
for (int i = 0; i < max; i++) {
|
||||
views.addView(R.id.widget_container_item, items.get(i));
|
||||
|
||||
@@ -70,12 +70,12 @@
|
||||
<TextView
|
||||
android:text="@string/advertise_title"
|
||||
android:id="@+id/ad_title"
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:textAppearance="?attr/textAppearanceHeadline3"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:padding="8dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
@@ -83,7 +83,10 @@
|
||||
android:text="@string/advertise_more"
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingTop="50dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/accent"
|
||||
@@ -96,9 +99,10 @@
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textAppearance="?attr/textAppearanceBody2"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -321,9 +321,9 @@
|
||||
<string name="color_dialog_green">Grün</string>
|
||||
|
||||
<string name="advertise_header">Veranstaltungshinweis</string>
|
||||
<string name="advertise_description">Mach mit beim FAIR Experiment vom 19. August bis zum 3. Oktober in Karlsruhe</string>
|
||||
<string name="advertise_description">Mach mit beim FAIR Experiment vom 25. November bis zum 30. Januar in Karlsruhe</string>
|
||||
<string name="advertise_more">Mehr erfahren…</string>
|
||||
<string name="advertise_title">Schlosslichtspiele 2021</string>
|
||||
<string name="advertise_title">EISZEIT</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -326,7 +326,7 @@
|
||||
<string name="color_dialog_green">Green</string>
|
||||
|
||||
<string name="advertise_header">Event note</string>
|
||||
<string name="advertise_description">Join the FAIR Experiment from August 19th to October 3rd in Karlsruhe</string>
|
||||
<string name="advertise_description">Join the FAIR Experiment from November 25th to January 30th in Karlsruhe</string>
|
||||
<string name="advertise_more">Read more…</string>
|
||||
<string name="advertise_title">Schlosslichtspiele 2021</string>
|
||||
<string name="advertise_title">EISZEIT</string>
|
||||
</resources>
|
||||
|
||||
@@ -10,7 +10,7 @@ description = "Mowesta Android SDK"
|
||||
project.version = "unspecified"
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.mowesta.android.sdk;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -87,6 +92,7 @@ public abstract class SdkService extends Service {
|
||||
private BroadcastReceiver timeTickReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
debugLog("Time tick received");
|
||||
onStartCommand(null, 0, 0);
|
||||
}
|
||||
};
|
||||
@@ -98,7 +104,9 @@ public abstract class SdkService extends Service {
|
||||
private LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
debugLog("Location changed");
|
||||
if (isLocationAccurate(location)) {
|
||||
debugLog("Location is accurate enough");
|
||||
setLocation(location);
|
||||
}
|
||||
}
|
||||
@@ -137,6 +145,7 @@ public abstract class SdkService extends Service {
|
||||
private boolean initialized = false;
|
||||
@Override
|
||||
public void onChanged(Boolean uploading) {
|
||||
debugLog("Uploading is " + uploading);
|
||||
if (currentState == State.IDLE) {
|
||||
if (uploading) {
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_upload);
|
||||
@@ -220,6 +229,7 @@ public abstract class SdkService extends Service {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onCreate() {
|
||||
debugLog("Creating service");
|
||||
Log.d(TAG, "Creating sdk service.");
|
||||
super.onCreate();
|
||||
channelManager = new ChannelManager(getApplication());
|
||||
@@ -238,6 +248,10 @@ public abstract class SdkService extends Service {
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
debugLog("Destroying service in state: " + currentState);
|
||||
if (currentState != State.IDLE) {
|
||||
scheduleExecution(this, measurementTime);
|
||||
}
|
||||
Log.d(TAG, "Destroying sdk service.");
|
||||
switch (currentState) {
|
||||
case MEASURE:
|
||||
@@ -260,9 +274,9 @@ public abstract class SdkService extends Service {
|
||||
}
|
||||
repository.getUploading().removeObserver(uploadListener);
|
||||
unregisterReceiver(timeTickReceiver);
|
||||
stopForeground(true);
|
||||
Log.d(TAG, "Releasing wake lock.");
|
||||
if (wakeLock != null && wakeLock.isHeld()) wakeLock.release();
|
||||
stopForeground(true);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -295,6 +309,7 @@ public abstract class SdkService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (!isEnabled()) {
|
||||
debugLog("Service not enabled, stopping");
|
||||
Log.d(TAG, "Stopping since the service is not enabled.");
|
||||
cancelExecution(this);
|
||||
stopSelf();
|
||||
@@ -305,12 +320,15 @@ public abstract class SdkService extends Service {
|
||||
if (currentState == State.IDLE) {
|
||||
if (now - measurementTime > repository.getConstants().TIMEOUT_MEASUREMENT) {
|
||||
Log.d(TAG, "Starting state machine since timeout has expired.");
|
||||
debugLog("Starting state machine since timeout has expired.");
|
||||
changeState();
|
||||
} else {
|
||||
Log.d(TAG, "Ignoring start request while timeout has not expired.");
|
||||
debugLog("Ignoring start request while timeout has not expired.");
|
||||
scheduleExecution(this, measurementTime);
|
||||
}
|
||||
} else {
|
||||
debugLog("Ignoring start request while service is " + currentState + ".");
|
||||
Log.d(TAG, "Ignoring start request while service is " + currentState + ".");
|
||||
}
|
||||
return START_STICKY;
|
||||
@@ -321,6 +339,7 @@ public abstract class SdkService extends Service {
|
||||
*/
|
||||
private void changeState() {
|
||||
Log.d(TAG, "Changing state from " + currentState);
|
||||
debugLog("Changing state from " + currentState);
|
||||
switch (currentState) {
|
||||
case IDLE: {
|
||||
// acquire a wake lock to keep the cpu running
|
||||
@@ -404,6 +423,7 @@ public abstract class SdkService extends Service {
|
||||
* an unrecoverable failure.
|
||||
*/
|
||||
private void resetState(boolean success) {
|
||||
debugLog("Reset state with succes: " + success);
|
||||
currentState = State.IDLE;
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_idle);
|
||||
currentNetworks = null;
|
||||
@@ -435,6 +455,7 @@ public abstract class SdkService extends Service {
|
||||
* Starts the measurement.
|
||||
*/
|
||||
private void startMeasure() {
|
||||
debugLog("Starting measurement.");
|
||||
Log.d(TAG, "Starting measurement.");
|
||||
currentState = State.MEASURE;
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_measure);
|
||||
@@ -457,6 +478,8 @@ public abstract class SdkService extends Service {
|
||||
*/
|
||||
private void startGps() {
|
||||
Log.d(TAG, "Starting gps localization.");
|
||||
debugLog("Starting gps localization.");
|
||||
|
||||
currentState = State.GPS;
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_gps);
|
||||
if (capabilityManager.hasLocationPermissions()) {
|
||||
@@ -466,6 +489,7 @@ public abstract class SdkService extends Service {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "Aborting gps localization.");
|
||||
debugLog("Aborting gps localization (timeout).");
|
||||
changeState();
|
||||
}
|
||||
};
|
||||
@@ -473,9 +497,11 @@ public abstract class SdkService extends Service {
|
||||
return;
|
||||
} catch (SecurityException e) {
|
||||
Log.d(TAG, "Security exception while accessing location.", e);
|
||||
debugLog("Security exception while accessing location.");
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "Location permissions missing, changing state.");
|
||||
debugLog("Location permissions missing, changing state.");
|
||||
changeState();
|
||||
}
|
||||
|
||||
@@ -484,6 +510,7 @@ public abstract class SdkService extends Service {
|
||||
*/
|
||||
private void startNet() {
|
||||
Log.d(TAG, "Starting network localization.");
|
||||
debugLog("Starting network localization.");
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_net);
|
||||
currentState = State.NET;
|
||||
if (capabilityManager.hasLocationPermissions()) {
|
||||
@@ -493,6 +520,8 @@ public abstract class SdkService extends Service {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "Aborting network localization.");
|
||||
debugLog("Aborting network localization (timeout).");
|
||||
|
||||
changeState();
|
||||
}
|
||||
};
|
||||
@@ -500,9 +529,12 @@ public abstract class SdkService extends Service {
|
||||
return;
|
||||
} catch (SecurityException e) {
|
||||
Log.d(TAG, "Security exception while accessing location.", e);
|
||||
debugLog("Security exception while accessing location.");
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "Location permissions missing, changing state.");
|
||||
debugLog("Location permissions missing, changing state.");
|
||||
|
||||
changeState();
|
||||
}
|
||||
|
||||
@@ -512,8 +544,10 @@ public abstract class SdkService extends Service {
|
||||
@SuppressWarnings("deprecation")
|
||||
private void startWifi() {
|
||||
Log.d(TAG, "Acquiring wifi lock.");
|
||||
debugLog("Acquiring wifi lock");
|
||||
wifiLock.acquire();
|
||||
Log.d(TAG, "Starting wifi scan.");
|
||||
debugLog("Starting wifi scan.");
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_wifi);
|
||||
currentState = State.WIFI;
|
||||
registerReceiver(wifiListener, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
|
||||
@@ -521,6 +555,7 @@ public abstract class SdkService extends Service {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "Aborting wifi scan.");
|
||||
debugLog("Aborting wifi scan (timeout).");
|
||||
changeState();
|
||||
}
|
||||
};
|
||||
@@ -533,19 +568,22 @@ public abstract class SdkService extends Service {
|
||||
*/
|
||||
private void startCache() {
|
||||
Log.d(TAG, "Starting cache lookup.");
|
||||
debugLog("Starting cache lookup.");
|
||||
currentState = State.CACHE;
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_cache);
|
||||
lookupTask = new LookupTask(repository, currentNetworks, new LookupTask.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(@Nullable LocationEntity entity) {
|
||||
Log.d(TAG, "Cache lookup complete.");
|
||||
Log.d(TAG, "Cache lookup complete with cached result.");
|
||||
if (entity != null) {
|
||||
debugLog("Cache lockup success");
|
||||
Coordinate c = new Coordinate();
|
||||
c.setLatitude(entity.getLatitude());
|
||||
c.setLongitude(entity.getLongitude());
|
||||
measurement.setCoordinate(c);
|
||||
resetState(true);
|
||||
} else {
|
||||
debugLog("Cache lockup without cached result.");
|
||||
changeState();
|
||||
}
|
||||
}
|
||||
@@ -625,6 +663,7 @@ public abstract class SdkService extends Service {
|
||||
}
|
||||
this.currentNetworks = networks;
|
||||
Log.d(TAG, "Found " + this.currentNetworks.size() + " wifi networks.");
|
||||
debugLog("Found " + this.currentNetworks.size() + " wifi networks.");
|
||||
changeState();
|
||||
}
|
||||
|
||||
@@ -634,6 +673,7 @@ public abstract class SdkService extends Service {
|
||||
* @param location The location.
|
||||
*/
|
||||
private void setLocation(Location location) {
|
||||
debugLog("Set location");
|
||||
// cleanup based on type
|
||||
if (currentState == State.GPS) cleanupGps();
|
||||
if (currentState == State.NET) cleanupNet();
|
||||
@@ -647,6 +687,7 @@ public abstract class SdkService extends Service {
|
||||
measurement.setCoordinate(c);
|
||||
// store location in cache
|
||||
if (hasMinimumNetworks()) {
|
||||
debugLog("Store in cache");
|
||||
LocationEntity entity = new LocationEntity();
|
||||
entity.setAccuracy((double)location.getAccuracy());
|
||||
entity.setLatitude(location.getLatitude());
|
||||
@@ -694,6 +735,7 @@ public abstract class SdkService extends Service {
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
long next = Math.max(5000, (lastTime + service.repository.getConstants().TIMEOUT_MEASUREMENT) - now);
|
||||
Log.d(TAG, "Updating alarm to execute in " + next + " ms.");
|
||||
service.debugLog("Updating alarm to execute in " + next + " ms.");
|
||||
PendingIntent pending = createIntent(service);
|
||||
manager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, service.repository.getConstants().TIMEOUT_MEASUREMENT, pending);
|
||||
}
|
||||
@@ -774,4 +816,30 @@ public abstract class SdkService extends Service {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs logging to a local file to debug issues with the service.
|
||||
* This code and all calls to it can be removed safely, once the app
|
||||
* is robust, until then we keep it to swap it in quickly.
|
||||
*
|
||||
* @param string The string to log.
|
||||
*/
|
||||
private void debugLog(String string) {
|
||||
// uncomment to enable file-based debug log
|
||||
/*
|
||||
synchronized (SdkService.class) {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
String message = now + " :: " + new Date(now).toString() + " :: " + string + "\n";
|
||||
File dest = new File(getFilesDir(), "debug.log");
|
||||
BufferedWriter w = new BufferedWriter(new FileWriter(dest.getAbsolutePath(), true));
|
||||
w.write(message);
|
||||
w.flush();
|
||||
w.close();
|
||||
} catch (IOException e) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class BufferTask extends AbstractTask<Void> {
|
||||
* @param listener The listener to signal the completion.
|
||||
*/
|
||||
public BufferTask(@NonNull SdkRepository repository, @NonNull Measurement measurement, @NonNull OnCompletionListener listener) {
|
||||
super(true);
|
||||
super(false);
|
||||
this.repository = repository;
|
||||
this.measurement = measurement;
|
||||
this.listener = listener;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class UploadTask extends AbstractTask<Void> {
|
||||
* @param client The api client to use.
|
||||
*/
|
||||
public UploadTask(@NonNull SdkRepository repository, @NonNull DefaultApi client) {
|
||||
super(true);
|
||||
super(false);
|
||||
this.repository = repository;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- The maximum time to wait for a gps location. Depends on the user's position (indoor/outdoor). -->
|
||||
<integer name="mowesta_sdk_service_gps_timeout">60000</integer>
|
||||
|
||||
</resources>
|
||||
@@ -46,7 +46,7 @@
|
||||
<!-- The maximum time to wait for a network location. Depends on the network connection. -->
|
||||
<integer name="mowesta_sdk_service_network_timeout">45000</integer>
|
||||
<!-- The maximum time to wait for a gps location. Depends on the user's position (indoor/outdoor). -->
|
||||
<integer name="mowesta_sdk_service_gps_timeout">60000</integer>
|
||||
<integer name="mowesta_sdk_service_gps_timeout">90000</integer>
|
||||
<!-- The minimum location accuracy in meters required to use a gps or network position. -->
|
||||
<integer name="mowesta_sdk_service_minimum_location_accuracy">75</integer>
|
||||
<!-- The maximum age in milliseconds that we will use a cached location before we validate the cache. -->
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#define WLAN_AP_PASSWORD "mowesta123456wifi"
|
||||
|
||||
// API-URL where measurements will be uploaded to
|
||||
//#define MOWESTA_UPLOAD_URL "https://www.mowesta.com/api/devices/current/measurements/now"
|
||||
#define MOWESTA_UPLOAD_URL "https://beta.mowesta.com/api/devices/current/measurements/now"
|
||||
#define MOWESTA_UPLOAD_URL "https://www.mowesta.com/api/devices/current/measurements/now"
|
||||
//#define MOWESTA_UPLOAD_URL "https://beta.mowesta.com/api/devices/current/measurements/now"
|
||||
#define MOWESTA_SOFTWARE_VERSION 2
|
||||
|
||||
// memory for json document
|
||||
@@ -124,8 +124,8 @@ void setup() {
|
||||
// power the button, voltage divider and sensor
|
||||
pinMode(BUTTON_OUT, OUTPUT);
|
||||
digitalWrite(BUTTON_OUT, LOW);
|
||||
pinMode(EXTERNAL_OUT, OUTPUT);
|
||||
digitalWrite(EXTERNAL_OUT, LOW);
|
||||
// set out to in, since it is connected directly to GND
|
||||
pinMode(EXTERNAL_OUT, INPUT);
|
||||
// Initialize EEPROM with complete size
|
||||
// Configure the button to enter setup
|
||||
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||
@@ -179,7 +179,7 @@ void loop() {
|
||||
if (sensor_bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID)) {
|
||||
// Setup with default settings from datasheet.
|
||||
sensor_bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, // Operating Mode.
|
||||
Adafruit_BMP280::SAMPLING_X2, // Temp. oversampling
|
||||
Adafruit_BMP280::SAMPLING_X16, // Temp. oversampling
|
||||
Adafruit_BMP280::SAMPLING_X16, // Pressure oversampling
|
||||
Adafruit_BMP280::FILTER_X16, // Filtering.
|
||||
Adafruit_BMP280::STANDBY_MS_500); // Standby time.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
+3
-3
@@ -5,7 +5,7 @@ apply plugin: 'maven-publish'
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.1'
|
||||
classpath 'com.android.tools.build:gradle:7.0.4'
|
||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
|
||||
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
|
||||
classpath "org.openbakery:xcode-plugin:0.19.1"
|
||||
@@ -24,7 +24,7 @@ allprojects {
|
||||
|
||||
// set version for our project
|
||||
group = 'com.mowesta'
|
||||
version = '1.0.20'
|
||||
version = '1.0.23'
|
||||
|
||||
// set versions for our libraries
|
||||
ext {
|
||||
@@ -54,7 +54,7 @@ allprojects {
|
||||
mapstructVersion = '1.3.1.Final'
|
||||
// shared android dependencies
|
||||
versionAndroidXTest = '1.4.0'
|
||||
versionAndroidXAppcompat = '1.3.1'
|
||||
versionAndroidXAppcompat = '1.4.0'
|
||||
versionAndroidXRoom = '2.3.0'
|
||||
versionAndroidXPreference = '1.1.1'
|
||||
versionRobolectric = '4.5'
|
||||
|
||||
@@ -75,6 +75,9 @@ swagger {
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn("generateSwaggerDocumentation")
|
||||
publish.dependsOn("generateSwaggerDocumentation")
|
||||
|
||||
// add the swagger defintion to the artifacts published by this module
|
||||
publishing {
|
||||
publications {
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.mowesta.tool.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mowesta.api.TimeRange;
|
||||
import com.mowesta.api.measurement.Measurement;
|
||||
import com.mowesta.api.measurement.MeasurementType;
|
||||
|
||||
public class FAIRKarlsruhe {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
File out = new File("karlsruhe");
|
||||
out.mkdirs();
|
||||
|
||||
|
||||
List<Long> devices = new ArrayList<>();
|
||||
// devices.add(41306043l);
|
||||
// devices.add(41306077l);
|
||||
// devices.add(41306087l);
|
||||
TimeRange range = new TimeRange(1629410400000l, 3888000000l);
|
||||
//
|
||||
// 8-15 sept
|
||||
// TimeRange range = new TimeRange(1631052000000l, 691200000l);
|
||||
|
||||
|
||||
devices.add(40549928l); // hmd
|
||||
devices.add(41236816l); // hmd
|
||||
devices.add(41238320l); // hmd
|
||||
|
||||
devices.add(41306043l); // esp 0
|
||||
devices.add(41306071l); // esp 1
|
||||
devices.add(41306077l); // esp 2
|
||||
devices.add(41306083l); // esp 3
|
||||
devices.add(41306087l); // esp 4
|
||||
devices.add(41306092l); // esp 5
|
||||
|
||||
|
||||
devices.add(41307981l); // markt
|
||||
devices.add(41310835l); // laser
|
||||
devices.add(41325252l); // schloss
|
||||
devices.add(42044973l); // schloss2
|
||||
|
||||
|
||||
// devices
|
||||
devices.add(41744821l); // Nexus 4
|
||||
devices.add(41744849l); // Nexus 4
|
||||
devices.add(41744861l); // Nexus 4
|
||||
devices.add(41751505l); // Nexus 5
|
||||
devices.add(41905035l); // HMD
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MeasurementDownloader downloader = new MeasurementDownloader("nesexperiments", "nespass!!!", out, devices);
|
||||
downloader.download(range);
|
||||
|
||||
|
||||
List<List<Measurement>> data = new ArrayList<>();
|
||||
devices.forEach((dev)-> data.add(MeasurementAnalyzer.loadMeasurements(new File(out, "measurement-" + dev + ".json"))));
|
||||
data.forEach((dt)-> Collections.sort(dt, (a, b) -> Long.compare(a.getTime(), b.getTime())));
|
||||
final int[] counters = new int[devices.size()];
|
||||
long interval = 30 * 60 * 1000;
|
||||
long current = range.getStart();
|
||||
while (current < range.getEnd()) {
|
||||
System.out.print(new Date(current) + "; ");
|
||||
final long start = current;
|
||||
final long stop = current + interval;
|
||||
data.forEach((dt) -> {
|
||||
List<Measurement> ms = dt.stream().filter(m -> m.getTime() >= start && m.getTime() < stop).collect(Collectors.toList());
|
||||
if (ms.size() > 0 && (ms.get(0).getData().get(MeasurementType.BATTERY_CHARGING) == null || ms.get(0).getData().get(MeasurementType.BATTERY_CHARGING).equals("false"))) {
|
||||
double temp = ms.get(0).getTemperature();
|
||||
counters[data.indexOf(dt)] += 1;
|
||||
System.out.print(temp + "; ");
|
||||
// System.out.print(ms.get(0).getData().get(MeasurementType.STATION_TEMPERATURE) + "; ");
|
||||
} else {
|
||||
System.out.print("; ");
|
||||
}
|
||||
|
||||
});
|
||||
System.out.println();
|
||||
current += interval;
|
||||
}
|
||||
System.out.println(Arrays.toString(counters));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,8 @@ war {
|
||||
}
|
||||
}
|
||||
|
||||
tasks['war'].dependsOn(project(":common-api").tasks["generateSwaggerDocumentation"])
|
||||
|
||||
// depend on wildfly task for testing
|
||||
test.dependsOn(project(":service-wildfly").tasks["build"])
|
||||
test.dependsOn(project(":service-ejb").tasks["copyTestLibraries"])
|
||||
|
||||
Reference in New Issue
Block a user