12 Commits
Author SHA1 Message Date
Marcus Handte 70c9a07469 Release 1.0.3
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:51:59 +02:00
Marcus Handte 32d97e9c78 Fix geocoder, bump android version code.
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:31:22 +02:00
Marcus Handte 9ac137b9f7 Add package lock.
LocationBasedServices/maptology/master This commit looks good
2019-09-13 21:11:33 +02:00
Marcus Handte 204c1b3e7a Fix android lint errors.
LocationBasedServices/maptology/master There was a failure building this commit
2019-09-13 21:07:31 +02:00
Marcus Handte 4a13f36971 Fix android timings and revert geocoder changes.
LocationBasedServices/maptology/master There was a failure building this commit
Use time tick to work around samsung scheduling differences.
Revert deprecation warning fix in geocoder to support current wildfly version.
2019-09-13 21:00:39 +02:00
Marcus Handte e1022fb785 Replace set window with set exact.
LocationBasedServices/maptology/master This commit looks good
2019-08-08 18:38:27 +02:00
Marcus Handte 35785b719c Update to 1.0.3-SNAPSHOT
LocationBasedServices/maptology/master This commit looks good
2019-08-08 09:35:49 +02:00
Marcus Handte 4f85f70d3e Release 1.0.2
LocationBasedServices/maptology/master This commit looks good
2019-08-08 09:29:25 +02:00
Marcus Handte 5bb2e6fee6 Fix android scheduling and layouts.
LocationBasedServices/maptology/master This commit looks good
Closes #64 Hide password on login.
Closes #63 Fix scheduling on Android 9.
Remove unused import in statistics bean.
2019-08-08 09:20:12 +02:00
handte d577cadf39 Improve logging and statistics.
LocationBasedServices/maptology/master This commit looks good
Avoid logging of credentials, except for failing device tokens.
Increase severity of invalid logins to simplfy intrusion detection.
Generate statistics about released positions as part of admin view.
2019-08-07 20:15:43 +02:00
handte cb4b3331f4 Improve layout of place order select.
LocationBasedServices/maptology/master This commit looks good
2019-08-07 16:31:42 +02:00
handte 12c5d79686 Update to 1.0.2-SNAPSHOT
LocationBasedServices/maptology/master This commit looks good
2019-08-07 16:21:11 +02:00
16 changed files with 118 additions and 58 deletions
+13 -2
View File
@@ -27,10 +27,13 @@ android {
applicationId "com.maptology.android.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 5
versionName "1.0.1"
versionCode 8
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "application_long", "Maptology"
resValue "string", "application_short", "Maptology"
}
signingConfigs {
@@ -50,8 +53,16 @@ android {
// add signing config if key is provided via system property
if (System.properties['android.keystore.password'] != null) signingConfig signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-dbg"
resValue "string", "application_long", "Maptology (Debug)"
resValue "string", "application_short", "M (Debug)"
}
}
testOptions {
unitTests {
includeAndroidResources = true
@@ -66,7 +66,7 @@ public class LocationService extends Service {
/**
* The minimum time between two localization attempts.
*/
private static final long LOCALIZATION_TIMEOUT = 60000;
private static final long LOCALIZATION_TIMEOUT = 55000;
/**
* The time to wait for wifi scans.
@@ -196,6 +196,17 @@ public class LocationService extends Service {
}
};
/**
* A broadcast receiver to receive timer ticks in the background.
*/
private BroadcastReceiver timeTickReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Tick received.");
onStartCommand(null, 0, 0);
}
};
/**
* A location listener that simply forwards its locations to
* the service.
@@ -267,7 +278,6 @@ public class LocationService extends Service {
}
@Override
@SuppressLint("InlinedApi")
public void onCreate() {
Log.d(TAG, "Creating location service.");
super.onCreate();
@@ -283,6 +293,7 @@ public class LocationService extends Service {
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
registerReceiver(idleModeReceiver, new IntentFilter(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED));
registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
}
@Override
@@ -304,6 +315,7 @@ public class LocationService extends Service {
app.getRepository().uploadingLocations.removeValueListener(uploadListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
unregisterReceiver(idleModeReceiver);
unregisterReceiver(timeTickReceiver);
Log.d(TAG, "Releasing wake lock.");
if (wakeLock.isHeld()) wakeLock.release();
stopForeground(true);
@@ -323,21 +335,19 @@ public class LocationService extends Service {
stopSelf();
return START_NOT_STICKY;
}
if (!isPeriodicExecution(intent)) {
Log.d(TAG, "Scheduling periodic execution.");
scheduleExecution(this, localizationTime);
}
// ensure that localization is only running, if it is not
// running already or has been run only seconds ago
// start localization, if we are not running one already
long now = SystemClock.elapsedRealtime();
if (currentState == LocationState.IDLE) {
if (isDeviceIdle()) {
onDeviceIdle();
} else if (now - localizationTime > LOCALIZATION_TIMEOUT - 1000) {
if (now - localizationTime > LOCALIZATION_TIMEOUT / 2) {
Log.d(TAG, "Starting localization state machine.");
changeState();
} else {
Log.d(TAG, "Ignoring start request while timeout has not expired.");
if (isDeviceIdle()) {
onDeviceIdle();
}
Log.d(TAG, "Scheduling periodic execution.");
scheduleExecution(this, localizationTime);
}
} else {
Log.d(TAG, "Ignoring start request while service is " + currentState + ".");
@@ -940,17 +950,23 @@ public class LocationService extends Service {
}
/**
* Schedules the service for periodic execution.
* Schedules the service for the next execution.
*
* @param context The context used to schedule this.
*/
private static void scheduleExecution(Context context, long lastTime) {
PendingIntent pending = createIntent(context);
AlarmManager manager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
long now = SystemClock.elapsedRealtime();
long next = Math.max(0, (lastTime + LOCALIZATION_TIMEOUT) - now);
long next = Math.max(5000, (lastTime + LOCALIZATION_TIMEOUT) - now);
Log.d(TAG, "Updating alarm to execute in " + next + " ms.");
manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT, pending);
// this is too imprecise on Android 9
//manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT, pending);
PendingIntent pending = createIntent(context);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, pending);
} else {
manager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT / 2, pending);
}
}
/**
@@ -262,8 +262,8 @@ public class MainActivity extends AppCompatActivity implements
* Method to request location permission for the app.
*/
private void checkPermissions() {
boolean permissionGranted = PermissionChecker.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
boolean permissionGranted = PermissionChecker.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED &&
PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
if (!permissionGranted) {
Log.d(TAG, "Requesting permissions.");
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, CODE_REQUEST_PERMISSIONS);
@@ -41,6 +41,7 @@ public abstract class AbstractLoginFragment extends AbstractFragment {
private int title;
private int explanation;
private int login;
private boolean passwordVisible = false;
/**
* The listener that listens to changes announced by the async task.
@@ -86,7 +87,6 @@ public abstract class AbstractLoginFragment extends AbstractFragment {
public void onClick(View v) {
String username = usernameText.getText().toString();
String password = passwordText.getText().toString();
username = analyzeInput(username);
password = analyzeInput(password);
if (username == null || password == null) {
@@ -101,17 +101,9 @@ public abstract class AbstractLoginFragment extends AbstractFragment {
});
passwordButton = (ImageButton) view.findViewById(R.id.button_password);
passwordButton.setOnClickListener(new View.OnClickListener() {
private boolean visible = false;
@Override
public void onClick(View v) {
visible = !visible;
if (visible) {
passwordButton.setImageResource(R.drawable.ic_visibility_off_black_24dp);
passwordText.setTransformationMethod(null);
} else {
passwordButton.setImageResource(R.drawable.ic_visibility_black_24dp);
passwordText.setTransformationMethod(new PasswordTransformationMethod());
}
setPasswordVisible(!passwordVisible);
}
});
noLoginButton.setOnClickListener(new View.OnClickListener() {
@@ -175,6 +167,17 @@ public abstract class AbstractLoginFragment extends AbstractFragment {
}
}
private void setPasswordVisible(boolean visible) {
if (visible) {
passwordButton.setImageResource(R.drawable.ic_visibility_off_black_24dp);
passwordText.setTransformationMethod(null);
} else {
passwordButton.setImageResource(R.drawable.ic_visibility_black_24dp);
passwordText.setTransformationMethod(new PasswordTransformationMethod());
}
this.passwordVisible = visible;
}
private void setEnabled(boolean enabled) {
loginButton.setEnabled(enabled);
noLoginButton.setEnabled(enabled);
@@ -182,6 +185,7 @@ public abstract class AbstractLoginFragment extends AbstractFragment {
usernameText.setEnabled(enabled);
passwordText.setEnabled(enabled);
progressBar.setVisibility(enabled?View.GONE:View.VISIBLE);
if (!enabled) setPasswordVisible(false);
}
private String analyzeInput(String input) {
@@ -4,13 +4,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_width="@dimen/max_view_width"
android:layout_height="match_parent">
<ScrollView android:layout_width="match_parent"
<ScrollView android:layout_width="@dimen/max_view_width"
android:fillViewport="true"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="match_parent"
@@ -50,6 +46,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/space_large"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/input_password"
@@ -69,7 +66,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/space_medium"
android:background="@color/white"
android:background="@android:color/transparent"
android:src="@drawable/ic_visibility_black_24dp" />
</LinearLayout>
@@ -106,7 +103,6 @@
</ScrollView>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
<string name="application_long" translatable="false">Maptology</string>
<string name="application_short" translatable="false">Maptology</string>
-->
<string name="maptology_url_default" translatable="false">https://www.maptology.com/api</string>
<string name="maptology_url_share" translatable="false">https://www.maptology.com/app/shares/</string>
+2 -2
View File
@@ -1,6 +1,6 @@
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5'
classpath files('gradle/gradle-android-eclipse-1.1.jar')
@@ -25,7 +25,7 @@ buildscript {
allprojects {
// set version for our project
group = 'com.maptology'
version = '1.0.1'
version = '1.0.3'
// set versions for our libraries
ext {
@@ -51,13 +51,13 @@ public class LoginManager {
public User login(String login, String password) {
UserEntity entity = UserEntity.findByLogin(em, login);
if (entity == null) {
log.log(Level.INFO, "User '" + login + "' does not exist.");
log.log(Level.SEVERE, "User '" + login + "' does not exist.");
} else if (entity.isDeleted()) {
log.log(Level.INFO, "User '" + login + "' is deleted.");
log.log(Level.SEVERE, "User '" + login + "' is deleted.");
} else if (entity.isSuspended()) {
log.log(Level.INFO, "User '" + login + "' is suspended.");
log.log(Level.SEVERE, "User '" + login + "' is suspended.");
} else if(!isEmailVerified(entity)){
log.log(Level.INFO, "User '" + login + "' has no verified email.");
log.log(Level.SEVERE, "User '" + login + "' has no verified email.");
}
else {
SecureHash hash = new SecureHash(entity.getIterations(), entity.getSalt(), entity.getHash());
@@ -66,7 +66,7 @@ public class LoginManager {
UserConverter c = new UserConverter(true);
return c.convert(entity);
} else {
log.log(Level.INFO, "User '" + login + "' provided wrong password.");
log.log(Level.SEVERE, "User '" + login + "' provided wrong password.");
}
}
return null;
@@ -96,15 +96,15 @@ public class LoginManager {
log.log(Level.INFO, "Validating device token");
DeviceEntity entity = DeviceEntity.findByToken(em, token);
if (entity == null) {
log.log(Level.INFO, "Device '" + token + "' does not exist.");
log.log(Level.SEVERE, "Device '" + token + "' does not exist.");
} else if (entity.isDeleted()) {
log.log(Level.INFO, "Device '" + token + "' is deleted.");
log.log(Level.SEVERE, "Device '" + entity.getId() + "' is deleted.");
} else if (entity.getUser() != null && entity.getUser().isDeleted()) {
log.log(Level.INFO, "User '" + entity.getUser().getLogin() + "' is deleted.");
log.log(Level.SEVERE, "User '" + entity.getUser().getLogin() + "' is deleted.");
} else if (entity.getUser() != null && entity.getUser().isSuspended()) {
log.log(Level.INFO, "User '" + entity.getUser().getLogin() + "' is suspended.");
log.log(Level.SEVERE, "User '" + entity.getUser().getLogin() + "' is suspended.");
} else {
log.log(Level.INFO, "Device '" + token + "' authenticated.");
log.log(Level.INFO, "Device '" + entity.getId() + "' authenticated.");
DeviceConverter c = new DeviceConverter(true);
return c.convert(entity);
}
@@ -47,6 +47,11 @@ public class DebugPositionSessionBean implements IPositionSessionBean {
return empty;
}
@Override
public long getPositionCount() {
return 0;
}
@Override
@RolesAllowed(Roles.ADMIN)
public long getLastModifiedPosition() {
@@ -30,11 +30,17 @@ public interface IPositionSessionBean {
*/
PositionPage getPositions(PageConfig pageConfig);
/**
* Returns the total number of positions.
*
* @return The total number of positions.
*/
long getPositionCount();
/**
* Returns the highest creation time stamp of the positions.
*
* @return The highest creaton time stamp.
* @return The highest creation time stamp.
*/
long getLastModifiedPosition();
@@ -85,6 +85,12 @@ public class PositionSessionBean implements IPositionSessionBean {
return PositionEntity.getLast(em);
}
@Override
@RolesAllowed(Roles.ADMIN)
public long getPositionCount() {
return PositionEntity.getCount(em);
}
@Override
@RolesAllowed(Roles.ADMIN)
public PositionPage getPositions(PageConfig pageConfig) {
@@ -12,6 +12,7 @@ import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import com.maptology.api.access.Roles;
import com.maptology.api.log.EntityStatistic;
@@ -24,6 +25,7 @@ import com.maptology.service.entity.EmailEntity;
import com.maptology.service.entity.LocationEntity;
import com.maptology.service.entity.NoticeEntity;
import com.maptology.service.entity.PlaceEntity;
import com.maptology.service.entity.PositionEntity;
import com.maptology.service.entity.PrivilegeEntity;
import com.maptology.service.entity.RoleEntity;
import com.maptology.service.entity.ShareEntity;
@@ -50,6 +52,12 @@ public class StatisticsSessionBean extends AbstractSessionBean {
*/
private static final int NUMBER_NOT_AVAILABLE = -1;
/**
* The position session to retrieve position related statistics.
*/
@Inject
protected IPositionSessionBean positionSession;
/**
* The list of entities.
*/
@@ -77,6 +85,12 @@ public class StatisticsSessionBean extends AbstractSessionBean {
s.setTotal(total);
result.add(s);
}
// add position statistics
EntityStatistic positionStatistic = new EntityStatistic();
positionStatistic.setName(PositionEntity.class.getSimpleName());
positionStatistic.setDeleted(0);
positionStatistic.setTotal(positionSession.getPositionCount());
result.add(positionStatistic);
return result;
}
@@ -71,11 +71,12 @@ public class GeocoderBuilder {
*
* @return The geo coder service.
*/
@SuppressWarnings("deprecation")
public IGeocoderService build() {
ResteasyClientBuilder builder = new ResteasyClientBuilder();
builder.httpEngine(new URLConnectionEngine());
if (socketTimeout != null) builder.readTimeout(socketTimeout, TimeUnit.SECONDS);
if (connectionTimeout != null) builder.connectTimeout(connectionTimeout, TimeUnit.SECONDS);
if (socketTimeout != null) builder.socketTimeout(socketTimeout,TimeUnit.SECONDS);
if (connectionTimeout != null) builder.establishConnectionTimeout(connectionTimeout, TimeUnit.SECONDS);
ResteasyClient client = builder.build();
return client.target(GEOCODER_URL).proxy(IGeocoderService.class);
}
@@ -65,7 +65,6 @@ public class MaptologyAuthModule extends AbstractHttpServletAuthModule {
if (headers != null) {
while (headers.hasMoreElements()) {
String header = headers.nextElement();
log.log(Level.SEVERE, "Found auth header: " + header);
String[] subHeaders = header.split(",");
for (String subHeader: subHeaders) {
subHeader = subHeader.trim();
@@ -101,7 +100,7 @@ public class MaptologyAuthModule extends AbstractHttpServletAuthModule {
LoginManager manager = new LoginManager(em);
ta.begin();
if (deviceCredential != null) device = manager.login(deviceCredential.getToken());
if (userCredential != null) user = manager.login(userCredential.getUsername(), userCredential.getPassword());
if (userCredential != null) user = manager.login(userCredential.getUsername(), userCredential.getPassword());
} finally {
ta.commit();
}
@@ -129,7 +128,7 @@ public class MaptologyAuthModule extends AbstractHttpServletAuthModule {
}
try {
MaptologyPrincipal principal = new MaptologyPrincipal(username + ":" + devicename, userId, deviceId);
log.log(Level.INFO, "Creating principal: " + principal);
log.log(Level.INFO, "Successful login for device(" + principal.getDevice() + ") and user(" + principal.getUser() + ").");
callbackHandler.handle(new Callback[]{
new CallerPrincipalCallback(clientSubject, principal),
new GroupPrincipalCallback(clientSubject, roles.toArray(new String[roles.size()]))
View File
@@ -2,9 +2,9 @@
<mat-toolbar>
<mat-icon>pie_chart_outlined</mat-icon>
<span style="margin-left: 10px">{{ res.strings('places_title') }}</span>
<div style="padding-top:5px;" flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
<div style="padding-top:20px;" flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
<form style="font-size: 12px;" fxLayoutAlign="center center" flexLayout="row">
<mat-form-field fxFlex="1 1 200px">
<mat-form-field fxFlex="1 1 180px">
<mat-select [placeholder]="res.strings('places_order_placeholder')" [value]="order.getValue()" (selectionChange)="order.next($event.source.value)">
<mat-option *ngFor="let o of getOrders()" [value]="o">
<span>{{ getOrderName(o) }}</span>