Merge remote-tracking branch 'origin/master' into bug3893

This commit is contained in:
fmittag
2016-09-12 16:56:03 +02:00
16 changed files with 134 additions and 37 deletions
Vendored Regular → Executable
+1 -1
View File
@@ -1,4 +1,4 @@
#Tue Aug 30 16:06:50 CEST 2016
#Mon Sep 12 09:37:26 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
@@ -0,0 +1,16 @@
This library ("Advanced RecyclerView")
----------------------------------------------------------------------
Copyright (C) 2015 Haruki Hasegawa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1 @@
Copyright (C) 2014 The Android Open Source Project
@@ -0,0 +1,3 @@
Copyright 2012 Jake Wharton
Copyright 2011 Patrik Åkerfeldt
Copyright 2011 Francisco Figueiredo Jr.
@@ -0,0 +1,2 @@
Copyright 2003-2013 The Apache Software Foundation
This product includes software developed at The Apache Software Foundation (http://www.apache.org/).
@@ -0,0 +1 @@
Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
@@ -0,0 +1 @@
Copyright 2013 Philip Schiffer
@@ -1,5 +1,14 @@
package com.sap.sailing.android.shared.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.content.Context;
import com.sap.sailing.android.shared.R;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
@@ -21,27 +30,66 @@ public class LicenseHelper {
return new Notice(name, url, copyright, license);
}
public Notice getAndroidSupportNotice() {
public Notice getAndroidSupportNotice(Context context) {
String name = "Android Support Library";
String url = "http://developer.android.com/tools/support-library/index.html";
String copyright = "Copyright (C) Google";
String copyright = getContent(context, R.raw.android_support_library);
License license = new ApacheSoftwareLicense20();
return new Notice(name, url, copyright, license);
}
public Notice getAdvancedRecyclerViewNotice() {
public Notice getAdvancedRecyclerViewNotice(Context context) {
String name = "Advanced RecyclerView";
String url = "https://github.com/h6ah4i/android-advancedrecyclerview";
String copyright = "Copyright (C) 2015 Haruki Hasegawa";
String copyright = getContent(context, R.raw.advanced_recylerview);
License license = new ApacheSoftwareLicense20();
return new Notice(name, url, copyright, license);
}
public Notice getDialogNotice() {
String name = "LicensesDialog";
String url = "http://psdev.de";
String copyright = "Copyright 2013 Philip Schiffer <admin@psdev.de>";
public Notice getViewPageIndicator(Context context) {
String name = "Android-ViewPagerIndicator";
String url = "http://github.com/JakeWharton/Android-ViewPagerIndicator";
String copyright = getContent(context, R.raw.android_viewpageindicator);
License license = new ApacheSoftwareLicense20();
return new Notice(name, url, copyright, license);
}
public Notice getDialogNotice(Context context) {
String name = "LicensesDialog";
String url = "http://psdev.de";
String copyright = getContent(context, R.raw.licensesdialog);
License license = new ApacheSoftwareLicense20();
return new Notice(name, url, copyright, license);
}
private String getContent(final Context context, final int contentResourceId) {
BufferedReader reader = null;
try {
final InputStream inputStream = context.getResources().openRawResource(contentResourceId);
if (inputStream != null) {
reader = new BufferedReader(new InputStreamReader(inputStream));
return toString(reader);
}
throw new IOException("Error opening license file.");
} catch (final IOException e) {
throw new IllegalStateException(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (final IOException e) {
// Don't care.
}
}
}
}
private String toString(final BufferedReader reader) throws IOException {
final StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line).append(System.getProperty("line.separator"));
}
return builder.toString();
}
}
@@ -55,10 +55,11 @@ public class AboutFragment extends com.sap.sailing.android.ui.fragments.BaseFrag
private void showLicenseDialog() {
Notices notices = new Notices();
LicenseHelper licenseHelper = new LicenseHelper();
notices.addNotice(licenseHelper.getAndroidSupportNotice());
notices.addNotice(licenseHelper.getAndroidSupportNotice(getActivity()));
notices.addNotice(licenseHelper.getOpenSansNotice());
notices.addNotice(licenseHelper.getJsonSimpleNotice());
notices.addNotice(licenseHelper.getDialogNotice());
notices.addNotice(licenseHelper.getViewPageIndicator(getActivity()));
notices.addNotice(licenseHelper.getDialogNotice(getActivity()));
LicensesDialog.Builder builder = new LicensesDialog.Builder(getActivity());
builder.setTitle(getString(R.string.license_information));
builder.setNotices(notices);
@@ -49,10 +49,10 @@ public class AboutFragment extends BaseFragment {
private void showLicenseDialog() {
Notices notices = new Notices();
LicenseHelper licenseHelper = new LicenseHelper();
notices.addNotice(licenseHelper.getAndroidSupportNotice());
notices.addNotice(licenseHelper.getAndroidSupportNotice(getActivity()));
notices.addNotice(licenseHelper.getOpenSansNotice());
notices.addNotice(licenseHelper.getJsonSimpleNotice());
notices.addNotice(licenseHelper.getDialogNotice());
notices.addNotice(licenseHelper.getDialogNotice(getActivity()));
LicensesDialog.Builder builder = new LicensesDialog.Builder(getActivity());
builder.setTitle(getString(R.string.license_information));
builder.setNotices(notices);
@@ -7,13 +7,11 @@ public class AppConstants {
// Intent extra fields
public final static String COURSE_AREA_UUID_KEY = "courseUuid";
public final static String RACE_ID_KEY = "raceUuid";
public final static String SERVICE_UNIQUE_ID = "serviceUID";
public final static String STARTPROCEDURE_SPECIFIC_EVENT_ID = "startProcedureSpecificEventId";
public final static String EXTRAS_RACE_STATE_EVENT = "raceStateEvent";
public final static String FLAG_KEY = "raceFlag";
public final static String EXTRAS_WIND_FIX = "windfix";
public final static String EXTRA_FORCE_REFRESH = "forceRefresh";
public final static String INTENT_EXTRA_RACE_ID = PACKAGE_NAME + ".raceUuid";
public final static String INTENT_EXTRA_TIMEPOINT_MILLIS = PACKAGE_NAME + ".timePoint.millis";
public final static String INTENT_EXTRA_EVENTNAME = PACKAGE_NAME + ".eventName";
public final static String FLAG_KEY = PACKAGE_NAME + ".raceFlag";
public final static String EXTRA_FORCE_REFRESH = PACKAGE_NAME + ".forceRefresh";
public final static String AUTHOR_TYPE_OFFICER_START = "Race Officer on Start Vessel";
public final static String AUTHOR_TYPE_OFFICER_FINISH = "Race Officer on Finish Vessel";
@@ -44,7 +42,7 @@ public class AppConstants {
// Inner process events
public final static String INTENT_ACTION_TOGGLE = PACKAGE_NAME + ".action.toggle";
public final static String INTENT_ACTION_EXTRA = "extra";
public final static String INTENT_ACTION_EXTRA = PACKAGE_NAME + ".extra";
public final static String INTENT_ACTION_TOGGLE_PROCEDURE = "procedure";
public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_MODE = "more_mode";
public final static String INTENT_ACTION_TOGGLE_PROCEDURE_MORE_PATHFINDER = "more_pathfinder";
@@ -31,6 +31,7 @@ import com.sap.sailing.domain.abstractlog.race.impl.RaceLogChangedVisitor;
import com.sap.sailing.domain.abstractlog.race.state.RaceState;
import com.sap.sailing.domain.abstractlog.race.state.RaceStateEvent;
import com.sap.sailing.domain.abstractlog.race.state.RaceStateEventScheduler;
import com.sap.sailing.domain.abstractlog.race.state.impl.RaceStateEventImpl;
import com.sap.sailing.domain.abstractlog.race.state.impl.RaceStateEvents;
import com.sap.sailing.racecommittee.app.AppConstants;
import com.sap.sailing.racecommittee.app.R;
@@ -44,6 +45,7 @@ import com.sap.sailing.racecommittee.app.ui.activities.LoginActivity;
import com.sap.sailing.server.gateway.serialization.JsonSerializer;
import com.sap.sailing.server.gateway.serialization.impl.CompetitorJsonSerializer;
import com.sap.sailing.server.gateway.serialization.racelog.impl.RaceLogEventSerializer;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class RaceStateService extends Service {
@@ -207,7 +209,7 @@ public class RaceStateService extends Service {
break;
default:
String id = intent.getStringExtra(AppConstants.RACE_ID_KEY);
String id = intent.getStringExtra(AppConstants.INTENT_EXTRA_RACE_ID);
ManagedRace race = dataManager.getDataStore().getRace(id);
if (race == null) {
ExLog.w(this, TAG, "No race for id " + id);
@@ -216,10 +218,12 @@ public class RaceStateService extends Service {
switch (action) {
case AppConstants.INTENT_ACTION_ALARM_ACTION:
RaceStateEvent stateEvent = (RaceStateEvent) intent.getExtras().getSerializable(AppConstants.EXTRAS_RACE_STATE_EVENT);
ExLog.i(this, TAG, String.format("Processing %s", stateEvent.toString()));
race.getState().processStateEvent(stateEvent);
clearAlarmByName(race, stateEvent.getEventName());
long timePoint = intent.getLongExtra(AppConstants.INTENT_EXTRA_TIMEPOINT_MILLIS, 0);
String eventName = intent.getStringExtra(AppConstants.INTENT_EXTRA_EVENTNAME);
RaceStateEvent event = new RaceStateEventImpl(new MillisecondsTimePoint(timePoint), RaceStateEvents.valueOf(eventName));
ExLog.i(this, TAG, String.format("Processing %s", event.toString()));
race.getState().processStateEvent(event);
clearAlarmByName(race, event.getEventName());
break;
}
}
@@ -240,7 +244,7 @@ public class RaceStateService extends Service {
private final ManagedRace managedRace;
public RemoveRaceAction(@NonNull ManagedRace race) {
/* package */ RemoveRaceAction(@NonNull ManagedRace race) {
managedRace = race;
}
@@ -321,10 +325,11 @@ public class RaceStateService extends Service {
}
private PendingIntent createAlarmPendingIntent(ManagedRace managedRace, RaceStateEvent event) {
Intent intent = new Intent(this, RaceStateService.class);
Intent intent = new Intent().setClass(this, RaceStateService.class);
intent.setAction(AppConstants.INTENT_ACTION_ALARM_ACTION);
intent.putExtra(AppConstants.RACE_ID_KEY, managedRace.getId());
intent.putExtra(AppConstants.EXTRAS_RACE_STATE_EVENT, event);
intent.putExtra(AppConstants.INTENT_EXTRA_RACE_ID, managedRace.getId());
intent.putExtra(AppConstants.INTENT_EXTRA_TIMEPOINT_MILLIS, event.getTimePoint().asMillis());
intent.putExtra(AppConstants.INTENT_EXTRA_EVENTNAME, event.getEventName().name());
return PendingIntent.getService(this, alarmManagerRequestCode++, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
@@ -549,7 +549,7 @@ public class RacingActivity extends SessionActivity implements RaceListCallbacks
private void processIntent(final Intent intent) {
final Bundle args = new Bundle();
if (mSelectedRace != null) {
args.putSerializable(AppConstants.RACE_ID_KEY, mSelectedRace.getId());
args.putSerializable(AppConstants.INTENT_EXTRA_RACE_ID, mSelectedRace.getId());
}
// artificial delay (to prevent "java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState")
@@ -127,10 +127,10 @@ public class SystemInformationActivityHelper {
private void showLicenseDialog() {
Notices notices = new Notices();
LicenseHelper licenseHelper = new LicenseHelper();
notices.addNotice(licenseHelper.getAndroidSupportNotice());
notices.addNotice(licenseHelper.getAdvancedRecyclerViewNotice());
notices.addNotice(licenseHelper.getAndroidSupportNotice(activity));
notices.addNotice(licenseHelper.getAdvancedRecyclerViewNotice(activity));
notices.addNotice(licenseHelper.getJsonSimpleNotice());
notices.addNotice(licenseHelper.getDialogNotice());
notices.addNotice(licenseHelper.getDialogNotice(activity));
LicensesDialog.Builder builder = new LicensesDialog.Builder(activity);
builder.setTitle(activity.getString(R.string.license_information));
builder.setNotices(notices);
@@ -53,7 +53,7 @@ public abstract class RaceFragment extends LoggableFragment implements TickListe
public static Bundle createArguments(ManagedRace race) {
Bundle arguments = new Bundle();
arguments.putString(AppConstants.RACE_ID_KEY, race.getId());
arguments.putString(AppConstants.INTENT_EXTRA_RACE_ID, race.getId());
return arguments;
}
@@ -72,7 +72,7 @@ public abstract class RaceFragment extends LoggableFragment implements TickListe
*/
protected Bundle getRecentArguments() {
Bundle args = new Bundle();
args.putString(AppConstants.RACE_ID_KEY, managedRace.getId());
args.putString(AppConstants.INTENT_EXTRA_RACE_ID, managedRace.getId());
return args;
}
@@ -89,7 +89,7 @@ public abstract class RaceFragment extends LoggableFragment implements TickListe
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getArguments() != null) {
String raceId = getArguments().getString(AppConstants.RACE_ID_KEY);
String raceId = getArguments().getString(AppConstants.INTENT_EXTRA_RACE_ID);
managedRace = OnlineDataManager.create(getActivity()).getDataStore().getRace(raceId);
if (managedRace == null) {
throw new IllegalStateException("Unable to obtain ManagedRace " + raceId + " from datastore on start of " + getClass().getName());
@@ -214,3 +214,24 @@ Experience has shown that sometimes the SAP HTTP proxy doesn't properly resolve
Run this inside a tmux window to be sure that logging off does not interrupt the process. After the process completes, copy the resulting declination-<year> file to your git workspace to 'java/com.sap.sailing.declination/resources' and commit.
There is also a script java/target/importdeclination that automates these steps.
## Dynamic Remote Debugging using the SAP JVM
The SAP JVM (see [http://sapjvm:1080](here)) offers a nice feature. It can be switched into debug mode during runtime, using the ``jvmmon`` tool from the ``bin`` folder of the VM distribution, next to the ``java`` binary. Imagine you have started a VM in production mode and it starts misbehaving. You isolate the instance, e.g., by removing it from the load balancer (ELB) or by replacing it in the central Apache configuration by a new one. Now you have time to investigate the VM's state more closely. But attaching a jconsole often isn't sufficient to understand what has gone wrong. With the SAP JVM you can proceed as follows:
<pre>
[sailing@ip-172-31-28-55 ~]$ /opt/sapjvm_8/bin/jvmmon &lt;java PID&gt;
$ start debugging
$ print debugging information
State : Debugging back is waiting for debugger to connect
Port : 8000
$ exit
</pre>
Now connect an Eclipse debugger to that VM's port 8000. This may require an SSH tunnel that forwards the port accordingly. When done, use ``jvmmon`` again to stop debugging, just like you started it:
<pre>
[sailing@ip-172-31-28-55 ~]$ /opt/sapjvm_8/bin/jvmmon &lt;java PID&gt;
$ stop debugging
$ exit
</pre>