Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -297,6 +297,7 @@ LOCAL_SRC_FILES += \ location/java/android/location/IGeocodeProvider.aidl \ location/java/android/location/IGeofenceProvider.aidl \ location/java/android/location/IGpsMeasurementsListener.aidl \ location/java/android/location/IGpsNavigationMessageListener.aidl \ location/java/android/location/IGpsStatusListener.aidl \ location/java/android/location/IGpsStatusProvider.aidl \ location/java/android/location/ILocationListener.aidl \ Loading location/java/android/location/GpsMeasurementListenerTransport.java +21 −69 Original line number Diff line number Diff line Loading @@ -16,99 +16,51 @@ package android.location; import com.android.internal.util.Preconditions; import android.annotation.NonNull; import android.content.Context; import android.os.RemoteException; import android.util.Log; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; /** * A handler class to manage transport listeners for {@link GpsMeasurementsEvent.Listener}, * and post the events in a handler. * A handler class to manage transport listeners for {@link GpsMeasurementsEvent.Listener}. * * @hide */ class GpsMeasurementListenerTransport { private static final String TAG = "GpsMeasurementListenerTransport"; class GpsMeasurementListenerTransport extends LocalListenerHelper<GpsMeasurementsEvent.Listener> { private final Context mContext; private final ILocationManager mLocationManager; private final IGpsMeasurementsListener mListenerTransport = new ListenerTransport(); private final HashSet<GpsMeasurementsEvent.Listener> mListeners = new HashSet<GpsMeasurementsEvent.Listener>(); public GpsMeasurementListenerTransport(Context context, ILocationManager locationManager) { super("GpsMeasurementListenerTransport"); mContext = context; mLocationManager = locationManager; } public boolean add(@NonNull GpsMeasurementsEvent.Listener listener) { Preconditions.checkNotNull(listener); synchronized (mListeners) { // we need to register with the service first, because we need to find out if the // service will actually support the request before we attempt anything if (mListeners.isEmpty()) { boolean registeredWithServer; try { registeredWithServer = mLocationManager.addGpsMeasurementsListener( @Override protected boolean registerWithServer() throws RemoteException { return mLocationManager.addGpsMeasurementsListener( mListenerTransport, mContext.getPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error handling first listener.", e); return false; } if (!registeredWithServer) { Log.e(TAG, "Unable to register listener transport."); return false; } } if (mListeners.contains(listener)) { return true; } mListeners.add(listener); } return true; } public void remove(@NonNull GpsMeasurementsEvent.Listener listener) { Preconditions.checkNotNull(listener); synchronized (mListeners) { boolean removed = mListeners.remove(listener); boolean isLastListener = removed && mListeners.isEmpty(); if (isLastListener) { try { @Override protected void unregisterFromServer() throws RemoteException { mLocationManager.removeGpsMeasurementsListener(mListenerTransport); } catch (RemoteException e) { Log.e(TAG, "Error handling last listener.", e); } } } } private class ListenerTransport extends IGpsMeasurementsListener.Stub { @Override public void onGpsMeasurementsReceived(final GpsMeasurementsEvent eventArgs) { Collection<GpsMeasurementsEvent.Listener> listeners; synchronized (mListeners) { listeners = new ArrayList<GpsMeasurementsEvent.Listener>(mListeners); public void onGpsMeasurementsReceived(final GpsMeasurementsEvent event) { ListenerOperation<GpsMeasurementsEvent.Listener> operation = new ListenerOperation<GpsMeasurementsEvent.Listener>() { @Override public void execute(GpsMeasurementsEvent.Listener listener) throws RemoteException { listener.onGpsMeasurementsReceived(event); } }; for (final GpsMeasurementsEvent.Listener listener : listeners) { listener.onGpsMeasurementsReceived(eventArgs); } foreach(operation); } } } location/java/android/location/GpsNavigationMessage.java 0 → 100644 +276 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * 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 */ package android.location; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import java.security.InvalidParameterException; /** * A class containing a GPS satellite Navigation Message. * * @hide */ public class GpsNavigationMessage implements Parcelable { private static final String TAG = "GpsNavigationMessage"; private static final byte[] EMPTY_ARRAY = new byte[0]; // The following enumerations must be in sync with the values declared in gps.h /** * The type of the navigation message is not available or unknown. */ public static final byte TYPE_UNKNOWN = 0; /** * The Navigation Message is of type L1 C/A. */ public static final byte TYPE_L1CA = 1; /** * The Navigation Message is of type L1-CNAV. */ public static final byte TYPE_L2CNAV = 2; /** * The Navigation Message is of type L5-CNAV. */ public static final byte TYPE_L5CNAV = 3; /** * The Navigation Message is of type CNAV-2. */ public static final byte TYPE_CNAV2 = 4; // End enumerations in sync with gps.h private byte mType; private byte mPrn; private short mMessageId; private short mSubmessageId; private byte[] mData; GpsNavigationMessage() { initialize(); } /** * Sets all contents to the values stored in the provided object. */ public void set(GpsNavigationMessage navigationMessage) { mType = navigationMessage.mType; mPrn = navigationMessage.mPrn; mMessageId = navigationMessage.mMessageId; mSubmessageId = navigationMessage.mSubmessageId; mData = navigationMessage.mData; } /** * Resets all the contents to its original state. */ public void reset() { initialize(); } /** * Gets the type of the navigation message contained in the object. */ public byte getType() { return mType; } /** * Sets the type of the navigation message. */ public void setType(byte value) { switch (value) { case TYPE_UNKNOWN: case TYPE_L1CA: case TYPE_L2CNAV: case TYPE_L5CNAV: case TYPE_CNAV2: mType = value; break; default: Log.d(TAG, "Sanitizing invalid 'type': " + value); mType = TYPE_UNKNOWN; break; } } /** * Gets a string representation of the 'type'. * For internal and logging use only. */ private String getTypeString() { switch (mType) { case TYPE_UNKNOWN: return "Unknown"; case TYPE_L1CA: return "L1 C/A"; case TYPE_L2CNAV: return "L2-CNAV"; case TYPE_L5CNAV: return "L5-CNAV"; case TYPE_CNAV2: return "CNAV-2"; default: return "<Invalid>"; } } /** * Gets the Pseudo-random number. * Range: [1, 32]. */ public byte getPrn() { return mPrn; } /** * Sets the Pseud-random number. */ public void setPrn(byte value) { mPrn = value; } /** * Gets the Message Identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. for L1 C/A * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. * Subframe 1, 2, 3 does not contain a 'frame id' and this might be reported as -1. */ public short getMessageId() { return mMessageId; } /** * Sets the Message Identifier. */ public void setMessageId(short value) { mMessageId = value; } /** * Gets the Sub-message Identifier. * If required by {@link #getType()}, this value contains a sub-index within the current message * (or frame) that is being transmitted. i.e. for L1 C/A the sub-message identifier corresponds * to the sub-frame Id of the navigation message. */ public short getSubmessageId() { return mSubmessageId; } /** * Sets the Sub-message identifier. */ public void setSubmessageId(short value) { mSubmessageId = value; } /** * Gets the data associated with the Navigation Message. * The bytes (or words) specified using big endian format (MSB first). */ @NonNull public byte[] getData() { return mData; } /** * Sets the data associated with the Navigation Message. */ public void setData(byte[] value) { if (value == null) { throw new InvalidParameterException("Data must be a non-null array"); } mData = value; } public static final Creator<GpsNavigationMessage> CREATOR = new Creator<GpsNavigationMessage>() { @Override public GpsNavigationMessage createFromParcel(Parcel parcel) { GpsNavigationMessage navigationMessage = new GpsNavigationMessage(); navigationMessage.setType(parcel.readByte()); navigationMessage.setPrn(parcel.readByte()); navigationMessage.setMessageId((short) parcel.readInt()); navigationMessage.setSubmessageId((short) parcel.readInt()); int dataLength = parcel.readInt(); byte[] data = new byte[dataLength]; parcel.readByteArray(data); navigationMessage.setData(data); return navigationMessage; } @Override public GpsNavigationMessage[] newArray(int size) { return new GpsNavigationMessage[size]; } }; public void writeToParcel(Parcel parcel, int flags) { parcel.writeByte(mType); parcel.writeByte(mPrn); parcel.writeInt(mMessageId); parcel.writeInt(mSubmessageId); parcel.writeInt(mData.length); parcel.writeByteArray(mData); } @Override public int describeContents() { return 0; } @Override public String toString() { final String format = " %-15s = %s\n"; StringBuilder builder = new StringBuilder("GpsNavigationMessage:\n"); builder.append(String.format(format, "Type", getTypeString())); builder.append(String.format(format, "Prn", mPrn)); builder.append(String.format(format, "MessageId", mMessageId)); builder.append(String.format(format, "SubmessageId", mSubmessageId)); builder.append(String.format(format, "Data", "{")); String prefix = " "; for(byte value : mData) { builder.append(prefix); builder.append(value); prefix = ", "; } builder.append(" }"); return builder.toString(); } private void initialize() { mType = TYPE_UNKNOWN; mPrn = 0; mMessageId = -1; mSubmessageId = -1; mData = EMPTY_ARRAY; } } location/java/android/location/GpsNavigationMessageEvent.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014, The Android Open Source Project * * 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. */ package android.location; parcelable GpsNavigationMessageEvent; location/java/android/location/GpsNavigationMessageEvent.java 0 → 100644 +92 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * 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 */ package android.location; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import java.security.InvalidParameterException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; /** * A class implementing a container for data associated with a navigation message event. * Events are delivered to registered instances of {@link Listener}. * * @hide */ public class GpsNavigationMessageEvent implements Parcelable { private final GpsNavigationMessage mNavigationMessage; /** * Used for receiving GPS satellite Navigation Messages from the GPS engine. * You can implement this interface and call * {@link LocationManager#addGpsNavigationMessageListener}. * * @hide */ public interface Listener { void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event); } public GpsNavigationMessageEvent(GpsNavigationMessage message) { if (message == null) { throw new InvalidParameterException("Parameter 'message' must not be null."); } mNavigationMessage = message; } @NonNull public GpsNavigationMessage getNavigationMessage() { return mNavigationMessage; } public static final Creator<GpsNavigationMessageEvent> CREATOR = new Creator<GpsNavigationMessageEvent>() { @Override public GpsNavigationMessageEvent createFromParcel(Parcel in) { ClassLoader classLoader = getClass().getClassLoader(); GpsNavigationMessage navigationMessage = in.readParcelable(classLoader); return new GpsNavigationMessageEvent(navigationMessage); } @Override public GpsNavigationMessageEvent[] newArray(int size) { return new GpsNavigationMessageEvent[size]; } }; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeParcelable(mNavigationMessage, flags); } @Override public String toString() { StringBuilder builder = new StringBuilder("[ GpsNavigationMessageEvent:\n\n"); builder.append(mNavigationMessage.toString()); builder.append("\n]"); return builder.toString(); } } Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -297,6 +297,7 @@ LOCAL_SRC_FILES += \ location/java/android/location/IGeocodeProvider.aidl \ location/java/android/location/IGeofenceProvider.aidl \ location/java/android/location/IGpsMeasurementsListener.aidl \ location/java/android/location/IGpsNavigationMessageListener.aidl \ location/java/android/location/IGpsStatusListener.aidl \ location/java/android/location/IGpsStatusProvider.aidl \ location/java/android/location/ILocationListener.aidl \ Loading
location/java/android/location/GpsMeasurementListenerTransport.java +21 −69 Original line number Diff line number Diff line Loading @@ -16,99 +16,51 @@ package android.location; import com.android.internal.util.Preconditions; import android.annotation.NonNull; import android.content.Context; import android.os.RemoteException; import android.util.Log; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; /** * A handler class to manage transport listeners for {@link GpsMeasurementsEvent.Listener}, * and post the events in a handler. * A handler class to manage transport listeners for {@link GpsMeasurementsEvent.Listener}. * * @hide */ class GpsMeasurementListenerTransport { private static final String TAG = "GpsMeasurementListenerTransport"; class GpsMeasurementListenerTransport extends LocalListenerHelper<GpsMeasurementsEvent.Listener> { private final Context mContext; private final ILocationManager mLocationManager; private final IGpsMeasurementsListener mListenerTransport = new ListenerTransport(); private final HashSet<GpsMeasurementsEvent.Listener> mListeners = new HashSet<GpsMeasurementsEvent.Listener>(); public GpsMeasurementListenerTransport(Context context, ILocationManager locationManager) { super("GpsMeasurementListenerTransport"); mContext = context; mLocationManager = locationManager; } public boolean add(@NonNull GpsMeasurementsEvent.Listener listener) { Preconditions.checkNotNull(listener); synchronized (mListeners) { // we need to register with the service first, because we need to find out if the // service will actually support the request before we attempt anything if (mListeners.isEmpty()) { boolean registeredWithServer; try { registeredWithServer = mLocationManager.addGpsMeasurementsListener( @Override protected boolean registerWithServer() throws RemoteException { return mLocationManager.addGpsMeasurementsListener( mListenerTransport, mContext.getPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error handling first listener.", e); return false; } if (!registeredWithServer) { Log.e(TAG, "Unable to register listener transport."); return false; } } if (mListeners.contains(listener)) { return true; } mListeners.add(listener); } return true; } public void remove(@NonNull GpsMeasurementsEvent.Listener listener) { Preconditions.checkNotNull(listener); synchronized (mListeners) { boolean removed = mListeners.remove(listener); boolean isLastListener = removed && mListeners.isEmpty(); if (isLastListener) { try { @Override protected void unregisterFromServer() throws RemoteException { mLocationManager.removeGpsMeasurementsListener(mListenerTransport); } catch (RemoteException e) { Log.e(TAG, "Error handling last listener.", e); } } } } private class ListenerTransport extends IGpsMeasurementsListener.Stub { @Override public void onGpsMeasurementsReceived(final GpsMeasurementsEvent eventArgs) { Collection<GpsMeasurementsEvent.Listener> listeners; synchronized (mListeners) { listeners = new ArrayList<GpsMeasurementsEvent.Listener>(mListeners); public void onGpsMeasurementsReceived(final GpsMeasurementsEvent event) { ListenerOperation<GpsMeasurementsEvent.Listener> operation = new ListenerOperation<GpsMeasurementsEvent.Listener>() { @Override public void execute(GpsMeasurementsEvent.Listener listener) throws RemoteException { listener.onGpsMeasurementsReceived(event); } }; for (final GpsMeasurementsEvent.Listener listener : listeners) { listener.onGpsMeasurementsReceived(eventArgs); } foreach(operation); } } }
location/java/android/location/GpsNavigationMessage.java 0 → 100644 +276 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * 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 */ package android.location; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import java.security.InvalidParameterException; /** * A class containing a GPS satellite Navigation Message. * * @hide */ public class GpsNavigationMessage implements Parcelable { private static final String TAG = "GpsNavigationMessage"; private static final byte[] EMPTY_ARRAY = new byte[0]; // The following enumerations must be in sync with the values declared in gps.h /** * The type of the navigation message is not available or unknown. */ public static final byte TYPE_UNKNOWN = 0; /** * The Navigation Message is of type L1 C/A. */ public static final byte TYPE_L1CA = 1; /** * The Navigation Message is of type L1-CNAV. */ public static final byte TYPE_L2CNAV = 2; /** * The Navigation Message is of type L5-CNAV. */ public static final byte TYPE_L5CNAV = 3; /** * The Navigation Message is of type CNAV-2. */ public static final byte TYPE_CNAV2 = 4; // End enumerations in sync with gps.h private byte mType; private byte mPrn; private short mMessageId; private short mSubmessageId; private byte[] mData; GpsNavigationMessage() { initialize(); } /** * Sets all contents to the values stored in the provided object. */ public void set(GpsNavigationMessage navigationMessage) { mType = navigationMessage.mType; mPrn = navigationMessage.mPrn; mMessageId = navigationMessage.mMessageId; mSubmessageId = navigationMessage.mSubmessageId; mData = navigationMessage.mData; } /** * Resets all the contents to its original state. */ public void reset() { initialize(); } /** * Gets the type of the navigation message contained in the object. */ public byte getType() { return mType; } /** * Sets the type of the navigation message. */ public void setType(byte value) { switch (value) { case TYPE_UNKNOWN: case TYPE_L1CA: case TYPE_L2CNAV: case TYPE_L5CNAV: case TYPE_CNAV2: mType = value; break; default: Log.d(TAG, "Sanitizing invalid 'type': " + value); mType = TYPE_UNKNOWN; break; } } /** * Gets a string representation of the 'type'. * For internal and logging use only. */ private String getTypeString() { switch (mType) { case TYPE_UNKNOWN: return "Unknown"; case TYPE_L1CA: return "L1 C/A"; case TYPE_L2CNAV: return "L2-CNAV"; case TYPE_L5CNAV: return "L5-CNAV"; case TYPE_CNAV2: return "CNAV-2"; default: return "<Invalid>"; } } /** * Gets the Pseudo-random number. * Range: [1, 32]. */ public byte getPrn() { return mPrn; } /** * Sets the Pseud-random number. */ public void setPrn(byte value) { mPrn = value; } /** * Gets the Message Identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. for L1 C/A * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. * Subframe 1, 2, 3 does not contain a 'frame id' and this might be reported as -1. */ public short getMessageId() { return mMessageId; } /** * Sets the Message Identifier. */ public void setMessageId(short value) { mMessageId = value; } /** * Gets the Sub-message Identifier. * If required by {@link #getType()}, this value contains a sub-index within the current message * (or frame) that is being transmitted. i.e. for L1 C/A the sub-message identifier corresponds * to the sub-frame Id of the navigation message. */ public short getSubmessageId() { return mSubmessageId; } /** * Sets the Sub-message identifier. */ public void setSubmessageId(short value) { mSubmessageId = value; } /** * Gets the data associated with the Navigation Message. * The bytes (or words) specified using big endian format (MSB first). */ @NonNull public byte[] getData() { return mData; } /** * Sets the data associated with the Navigation Message. */ public void setData(byte[] value) { if (value == null) { throw new InvalidParameterException("Data must be a non-null array"); } mData = value; } public static final Creator<GpsNavigationMessage> CREATOR = new Creator<GpsNavigationMessage>() { @Override public GpsNavigationMessage createFromParcel(Parcel parcel) { GpsNavigationMessage navigationMessage = new GpsNavigationMessage(); navigationMessage.setType(parcel.readByte()); navigationMessage.setPrn(parcel.readByte()); navigationMessage.setMessageId((short) parcel.readInt()); navigationMessage.setSubmessageId((short) parcel.readInt()); int dataLength = parcel.readInt(); byte[] data = new byte[dataLength]; parcel.readByteArray(data); navigationMessage.setData(data); return navigationMessage; } @Override public GpsNavigationMessage[] newArray(int size) { return new GpsNavigationMessage[size]; } }; public void writeToParcel(Parcel parcel, int flags) { parcel.writeByte(mType); parcel.writeByte(mPrn); parcel.writeInt(mMessageId); parcel.writeInt(mSubmessageId); parcel.writeInt(mData.length); parcel.writeByteArray(mData); } @Override public int describeContents() { return 0; } @Override public String toString() { final String format = " %-15s = %s\n"; StringBuilder builder = new StringBuilder("GpsNavigationMessage:\n"); builder.append(String.format(format, "Type", getTypeString())); builder.append(String.format(format, "Prn", mPrn)); builder.append(String.format(format, "MessageId", mMessageId)); builder.append(String.format(format, "SubmessageId", mSubmessageId)); builder.append(String.format(format, "Data", "{")); String prefix = " "; for(byte value : mData) { builder.append(prefix); builder.append(value); prefix = ", "; } builder.append(" }"); return builder.toString(); } private void initialize() { mType = TYPE_UNKNOWN; mPrn = 0; mMessageId = -1; mSubmessageId = -1; mData = EMPTY_ARRAY; } }
location/java/android/location/GpsNavigationMessageEvent.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014, The Android Open Source Project * * 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. */ package android.location; parcelable GpsNavigationMessageEvent;
location/java/android/location/GpsNavigationMessageEvent.java 0 → 100644 +92 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * 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 */ package android.location; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import java.security.InvalidParameterException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; /** * A class implementing a container for data associated with a navigation message event. * Events are delivered to registered instances of {@link Listener}. * * @hide */ public class GpsNavigationMessageEvent implements Parcelable { private final GpsNavigationMessage mNavigationMessage; /** * Used for receiving GPS satellite Navigation Messages from the GPS engine. * You can implement this interface and call * {@link LocationManager#addGpsNavigationMessageListener}. * * @hide */ public interface Listener { void onGpsNavigationMessageReceived(GpsNavigationMessageEvent event); } public GpsNavigationMessageEvent(GpsNavigationMessage message) { if (message == null) { throw new InvalidParameterException("Parameter 'message' must not be null."); } mNavigationMessage = message; } @NonNull public GpsNavigationMessage getNavigationMessage() { return mNavigationMessage; } public static final Creator<GpsNavigationMessageEvent> CREATOR = new Creator<GpsNavigationMessageEvent>() { @Override public GpsNavigationMessageEvent createFromParcel(Parcel in) { ClassLoader classLoader = getClass().getClassLoader(); GpsNavigationMessage navigationMessage = in.readParcelable(classLoader); return new GpsNavigationMessageEvent(navigationMessage); } @Override public GpsNavigationMessageEvent[] newArray(int size) { return new GpsNavigationMessageEvent[size]; } }; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeParcelable(mNavigationMessage, flags); } @Override public String toString() { StringBuilder builder = new StringBuilder("[ GpsNavigationMessageEvent:\n\n"); builder.append(mNavigationMessage.toString()); builder.append("\n]"); return builder.toString(); } }