Called on first reception of low-accuracy location data from the network. Should be 29 | * available almost instantly if the user device has network-based or other non-GNSS location 30 | * sources available and enabled when the session is started.
31 | * 32 | *Note that this method will not be called if fine location data is received first.
33 | */ 34 | void onCoarseLocationReceived(); 35 | 36 | /** 37 | * Called on first reception of high-accuracy location data from GNSS. This may take a while to 38 | * be available, or may not be available at all if the user is in a location that does not have 39 | * adequate GNSS signal reception. 40 | */ 41 | void onAccurateLocationReceived(); 42 | 43 | /** 44 | * Called if the backend server is unreachable. 45 | */ 46 | void onServerConnectionLost(); 47 | 48 | /** 49 | * Called if the backend server was unreachable, but is now reachable again. 50 | */ 51 | void onServerConnectionRestored(); 52 | } 53 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/PromptCallback.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | /** 4 | * A callback interface that should be passed to all user prompts. The prompt calls either {@code 5 | * accept()} or {@code deny()} depending on the user's response to the prompt. 6 | * 7 | * @author Marius Lindvall 8 | */ 9 | public interface PromptCallback { 10 | /** 11 | * Called if the user accepted the prompt. 12 | */ 13 | void accept(); 14 | 15 | /** 16 | * Called if the user denied the prompt. 17 | */ 18 | void deny(); 19 | } 20 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/ServiceRelauncher.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | import android.content.Context; 4 | 5 | import info.varden.hauk.caching.ResumableSessions; 6 | import info.varden.hauk.caching.ResumeHandler; 7 | import info.varden.hauk.struct.Session; 8 | import info.varden.hauk.struct.Share; 9 | import info.varden.hauk.utils.Log; 10 | 11 | /** 12 | * {@link ResumeHandler} implementation used by {@link SessionManager} to automatically resume 13 | * sessions following a service relaunch. This can happen if the main activity is terminated, but 14 | * the share itself keeps running in the background. 15 | * 16 | * @author Marius Lindvall 17 | */ 18 | public final class ServiceRelauncher implements ResumeHandler { 19 | /** 20 | * The session manager to call to resume the shares. 21 | */ 22 | private final SessionManager manager; 23 | 24 | /** 25 | * The manager's resumption handler. This is used to clear the resumption data before the shares 26 | * are resumed by the session manager, as the session manager will re-flag the shares as 27 | * resumable when it adds them to its internal share list. 28 | */ 29 | private final ResumableSessions resumptionHandler; 30 | 31 | ServiceRelauncher(SessionManager manager, ResumableSessions resumptionHandler) { 32 | this.manager = manager; 33 | this.resumptionHandler = resumptionHandler; 34 | } 35 | 36 | @Override 37 | public void onSharesFetched(Context ctx, Session session, Share[] shares) { 38 | Log.i("Resuming %s share(s) automatically found for session %s", shares.length, session); //NON-NLS 39 | // The shares provided by ResumableSessions do not have a session attached to them. Attach 40 | // it to the shares so that they can be shown properly by the prompt and so that the updates 41 | // have a backend to be broadcast to when the shares are resumed. 42 | this.resumptionHandler.clearResumableSession(); 43 | for (Share share : shares) { 44 | share.setSession(session); 45 | this.manager.shareLocation(share, SessionInitiationReason.SERVICE_RELAUNCH); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/SessionInitiationReason.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | import info.varden.hauk.struct.Session; 4 | import info.varden.hauk.struct.Share; 5 | 6 | /** 7 | * Describes the reason a session was initiated. 8 | * 9 | * @author Marius Lindvall 10 | */ 11 | public enum SessionInitiationReason { 12 | /** 13 | * The user requested to start a new sharing session. 14 | */ 15 | USER_STARTED, 16 | 17 | /** 18 | * The user requested to resume a previous sharing session. 19 | */ 20 | USER_RESUMED, 21 | 22 | /** 23 | * The sharing session is automatically resumed as a result of a relaunch of the location 24 | * sharing service. 25 | */ 26 | SERVICE_RELAUNCH, 27 | 28 | /** 29 | * The session was created because a share was added to it. This should never be received by 30 | * {@link SessionListener#onSessionCreated(Session, Share, SessionInitiationReason)} under any 31 | * normal circumstances. 32 | */ 33 | SHARE_ADDED 34 | } 35 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/SessionInitiationResponseHandler.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | import info.varden.hauk.http.FailureHandler; 4 | import info.varden.hauk.struct.ShareMode; 5 | import info.varden.hauk.struct.Version; 6 | 7 | /** 8 | * A response handler interface that must be provided when starting a new session in order to 9 | * receive callbacks when the session initiation packet has been responded to. 10 | * 11 | * @author Marius Lindvall 12 | */ 13 | public interface SessionInitiationResponseHandler extends FailureHandler { 14 | /** 15 | * Called when the session initiation packet is being sent. 16 | */ 17 | void onInitiating(); 18 | 19 | /** 20 | * Called if the session was successfully initiated. 21 | */ 22 | void onSuccess(); 23 | 24 | /** 25 | * Called if the session was successfully initiated, but the backend is not compatible with the 26 | * share mode that was requested by the user. {@code onSuccess()} will still be called after 27 | * this callback in the event that this happens. 28 | * 29 | * @param downgradeTo The sharing mode that was picked instead of the requested mode. 30 | * @param backendVersion The version of the Hauk backend server. 31 | */ 32 | void onShareModeForciblyDowngraded(ShareMode downgradeTo, Version backendVersion); 33 | 34 | /** 35 | * Called if the session was successfully initiated, but the backend does not support end-to-end 36 | * encryption. {@code onSuccess()} will still be called after this callback in the event that 37 | * this happens. 38 | * 39 | * @param backendVersion The version of the Hauk backend server. 40 | */ 41 | void onE2EForciblyDisabled(Version backendVersion); 42 | } 43 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/SessionListener.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | import info.varden.hauk.struct.Session; 4 | import info.varden.hauk.struct.Share; 5 | 6 | /** 7 | * Callback interface that {@link SessionManager} handlers can attach to receive status updates 8 | * about session creation. 9 | * 10 | * @author Marius Lindvall 11 | */ 12 | public interface SessionListener { 13 | /** 14 | * Called whenever a new session is created. 15 | * 16 | * @param session The session that was created. 17 | * @param share The share that the session was created for. 18 | * @param reason The reason the session was created. 19 | */ 20 | void onSessionCreated(Session session, Share share, SessionInitiationReason reason); 21 | 22 | /** 23 | * Called if the session could not be initiated due to missing location permissions. 24 | */ 25 | void onSessionCreationFailedDueToPermissions(); 26 | } 27 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/ShareListener.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | import info.varden.hauk.struct.Share; 4 | 5 | /** 6 | * Callback interface that {@link SessionManager} handlers can attach to receive status updates 7 | * about share attachment. 8 | * 9 | * @author Marius Lindvall 10 | */ 11 | public interface ShareListener { 12 | /** 13 | * Called when a share has been joined on the server or locally. 14 | * 15 | * @param share The share that was joined. 16 | */ 17 | void onShareJoined(Share share); 18 | 19 | /** 20 | * Called when a share has been left. 21 | * 22 | * @param share The share that was left. 23 | */ 24 | void onShareParted(Share share); 25 | } 26 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/manager/StopSharingCallback.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.manager; 2 | 3 | import info.varden.hauk.http.FailureHandler; 4 | 5 | /** 6 | * Callback interface that is called upon when the user requests to stop the share. 7 | * 8 | * @author Marius Lindvall 9 | */ 10 | public interface StopSharingCallback extends FailureHandler { 11 | /** 12 | * Called if the share was successfully stopped. 13 | */ 14 | void onSuccess(); 15 | 16 | /** 17 | * Called if the share could not be stopped because the share or session did not exist. 18 | */ 19 | void onShareNull(); 20 | } 21 | -------------------------------------------------------------------------------- /android/app/src/main/java/info/varden/hauk/notify/CopyLinkReceiver.java: -------------------------------------------------------------------------------- 1 | package info.varden.hauk.notify; 2 | 3 | import android.content.ClipData; 4 | import android.content.ClipboardManager; 5 | import android.content.Context; 6 | 7 | import info.varden.hauk.R; 8 | import info.varden.hauk.utils.Log; 9 | 10 | /** 11 | * A broadcast receiver for the "Copy link" action on the persistent Hauk notification. 12 | * 13 | * @author Marius Lindvall 14 | */ 15 | public final class CopyLinkReceiver extends HaukBroadcastReceiver