Merge "Add cross profile uri for Events and Calendars table in CalendarContract."
diff --git a/api/system-current.txt b/api/system-current.txt
index 57b7eed..9873c37 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -2925,6 +2925,13 @@
field public static final int RADIO_TUNER = 1998; // 0x7ce
}
+ public static class MediaTimestamp.Builder {
+ ctor public MediaTimestamp.Builder();
+ ctor public MediaTimestamp.Builder(android.media.MediaTimestamp);
+ method public android.media.MediaTimestamp build();
+ method public android.media.MediaTimestamp.Builder setMediaTimestamp(long, long, float);
+ }
+
public class PlayerProxy {
method public void pause();
method public void setPan(float);
@@ -2945,7 +2952,7 @@
ctor public TimedMetaData.Builder();
ctor public TimedMetaData.Builder(android.media.TimedMetaData);
method public android.media.TimedMetaData build();
- method public android.media.TimedMetaData.Builder setTimedMetaData(int, byte[]);
+ method public android.media.TimedMetaData.Builder setTimedMetaData(long, byte[]);
}
}
@@ -3035,7 +3042,6 @@
package android.media.session {
public final class MediaSessionManager {
- method public android.media.session.ISession createSession(android.media.session.MediaSession.CallbackStub, java.lang.String, int);
method public void setOnMediaKeyListener(android.media.session.MediaSessionManager.OnMediaKeyListener, android.os.Handler);
method public void setOnVolumeKeyLongPressListener(android.media.session.MediaSessionManager.OnVolumeKeyLongPressListener, android.os.Handler);
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 594ae6b..1dd42b8 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1595,7 +1595,7 @@
@hide This should only be used by ManagedProvisioning app.
-->
<permission android:name="android.permission.NETWORK_MANAGED_PROVISIONING"
- android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature" />
<!-- #SystemApi @hide Allows applications to access information about LoWPAN interfaces.
<p>Not for use by third-party applications. -->
diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java
index 3e3e651..24d2725 100644
--- a/media/java/android/media/AudioFormat.java
+++ b/media/java/android/media/AudioFormat.java
@@ -670,27 +670,43 @@
}
/**
- * Private constructor with an ignored argument to differentiate from the removed default ctor
- * @param ignoredArgument
- */
- private AudioFormat(int ignoredArgument) {
- }
-
- /**
* Constructor used by the JNI. Parameters are not checked for validity.
*/
// Update sound trigger JNI in core/jni/android_hardware_SoundTrigger.cpp when modifying this
// constructor
@UnsupportedAppUsage
private AudioFormat(int encoding, int sampleRate, int channelMask, int channelIndexMask) {
- mEncoding = encoding;
- mSampleRate = sampleRate;
- mChannelMask = channelMask;
- mChannelIndexMask = channelIndexMask;
- mPropertySetMask = AUDIO_FORMAT_HAS_PROPERTY_ENCODING |
- AUDIO_FORMAT_HAS_PROPERTY_SAMPLE_RATE |
- AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_MASK |
- AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK;
+ this(
+ AUDIO_FORMAT_HAS_PROPERTY_ENCODING
+ | AUDIO_FORMAT_HAS_PROPERTY_SAMPLE_RATE
+ | AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_MASK
+ | AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK,
+ encoding, sampleRate, channelMask, channelIndexMask
+ );
+ }
+
+ private AudioFormat(int propertySetMask,
+ int encoding, int sampleRate, int channelMask, int channelIndexMask) {
+ mPropertySetMask = propertySetMask;
+ mEncoding = (propertySetMask & AUDIO_FORMAT_HAS_PROPERTY_ENCODING) != 0
+ ? encoding : ENCODING_INVALID;
+ mSampleRate = (propertySetMask & AUDIO_FORMAT_HAS_PROPERTY_SAMPLE_RATE) != 0
+ ? sampleRate : SAMPLE_RATE_UNSPECIFIED;
+ mChannelMask = (propertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_MASK) != 0
+ ? channelMask : CHANNEL_INVALID;
+ mChannelIndexMask = (propertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK) != 0
+ ? channelIndexMask : CHANNEL_INVALID;
+
+ // Compute derived values.
+
+ final int channelIndexCount = Integer.bitCount(getChannelIndexMask());
+ int channelCount = channelCountFromOutChannelMask(getChannelMask());
+ if (channelCount == 0) {
+ channelCount = channelIndexCount;
+ } else if (channelCount != channelIndexCount && channelIndexCount != 0) {
+ channelCount = 0; // position and index channel count mismatch
+ }
+ mChannelCount = channelCount;
}
/** @hide */
@@ -704,14 +720,20 @@
/** @hide */
public final static int AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK = 0x1 << 3;
+ // This is an immutable class, all member variables are final.
+
+ // Essential values.
@UnsupportedAppUsage
- private int mEncoding;
+ private final int mEncoding;
@UnsupportedAppUsage
- private int mSampleRate;
+ private final int mSampleRate;
@UnsupportedAppUsage
- private int mChannelMask;
- private int mChannelIndexMask;
- private int mPropertySetMask;
+ private final int mChannelMask;
+ private final int mChannelIndexMask;
+ private final int mPropertySetMask;
+
+ // Derived values computed in the constructor, cached here.
+ private final int mChannelCount;
/**
* Return the encoding.
@@ -721,9 +743,6 @@
* {@link AudioFormat#ENCODING_INVALID} if not set.
*/
public int getEncoding() {
- if ((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_ENCODING) == 0) {
- return ENCODING_INVALID;
- }
return mEncoding;
}
@@ -745,9 +764,6 @@
* {@link AudioFormat#CHANNEL_INVALID} if not set.
*/
public int getChannelMask() {
- if ((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_MASK) == 0) {
- return CHANNEL_INVALID;
- }
return mChannelMask;
}
@@ -760,9 +776,6 @@
* {@link AudioFormat#CHANNEL_INVALID} if not set or an invalid mask was used.
*/
public int getChannelIndexMask() {
- if ((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK) == 0) {
- return CHANNEL_INVALID;
- }
return mChannelIndexMask;
}
@@ -772,14 +785,7 @@
* Zero is returned if both the channel position mask and the channel index mask are not set.
*/
public int getChannelCount() {
- final int channelIndexCount = Integer.bitCount(getChannelIndexMask());
- int channelCount = channelCountFromOutChannelMask(getChannelMask());
- if (channelCount == 0) {
- channelCount = channelIndexCount;
- } else if (channelCount != channelIndexCount && channelIndexCount != 0) {
- channelCount = 0; // position and index channel count mismatch
- }
- return channelCount;
+ return mChannelCount;
}
/** @hide */
@@ -790,7 +796,7 @@
/** @hide */
public String toLogFriendlyString() {
return String.format("%dch %dHz %s",
- getChannelCount(), mSampleRate, toLogFriendlyEncoding(mEncoding));
+ mChannelCount, mSampleRate, toLogFriendlyEncoding(mEncoding));
}
/**
@@ -839,14 +845,13 @@
* @return a new {@link AudioFormat} object
*/
public AudioFormat build() {
- AudioFormat af = new AudioFormat(1980/*ignored*/);
- af.mEncoding = mEncoding;
- // not calling setSampleRate is equivalent to calling
- // setSampleRate(SAMPLE_RATE_UNSPECIFIED)
- af.mSampleRate = mSampleRate;
- af.mChannelMask = mChannelMask;
- af.mChannelIndexMask = mChannelIndexMask;
- af.mPropertySetMask = mPropertySetMask;
+ AudioFormat af = new AudioFormat(
+ mPropertySetMask,
+ mEncoding,
+ mSampleRate,
+ mChannelMask,
+ mChannelIndexMask
+ );
return af;
}
@@ -1049,11 +1054,13 @@
}
private AudioFormat(Parcel in) {
- mPropertySetMask = in.readInt();
- mEncoding = in.readInt();
- mSampleRate = in.readInt();
- mChannelMask = in.readInt();
- mChannelIndexMask = in.readInt();
+ this(
+ in.readInt(), // propertySetMask
+ in.readInt(), // encoding
+ in.readInt(), // sampleRate
+ in.readInt(), // channelMask
+ in.readInt() // channelIndexMask
+ );
}
public static final Parcelable.Creator<AudioFormat> CREATOR =
diff --git a/media/java/android/media/MediaPlayer2.java b/media/java/android/media/MediaPlayer2.java
index 4805780..9038f72 100644
--- a/media/java/android/media/MediaPlayer2.java
+++ b/media/java/android/media/MediaPlayer2.java
@@ -1711,10 +1711,12 @@
public MediaTimestamp getTimestamp() {
try {
// TODO: get the timestamp from native side
- return new MediaTimestamp(
- getCurrentPosition() * 1000L,
- System.nanoTime(),
- getState() == PLAYER_STATE_PLAYING ? getPlaybackParams().getSpeed() : 0.f);
+ return new MediaTimestamp.Builder()
+ .setMediaTimestamp(
+ getCurrentPosition() * 1000L,
+ System.nanoTime(),
+ getState() == PLAYER_STATE_PLAYING ? getPlaybackParams().getSpeed() : 0.f)
+ .build();
} catch (IllegalStateException e) {
return null;
}
@@ -2398,11 +2400,13 @@
return;
}
Iterator<Value> in = playerMsg.getValuesList().iterator();
- SubtitleData data = new SubtitleData(
- in.next().getInt32Value(), // trackIndex
- in.next().getInt64Value(), // startTimeUs
- in.next().getInt64Value(), // durationUs
- in.next().getBytesValue().toByteArray()); // data
+ SubtitleData data = new SubtitleData.Builder()
+ .setSubtitleData(
+ in.next().getInt32Value(), // trackIndex
+ in.next().getInt64Value(), // startTimeUs
+ in.next().getInt64Value(), // durationUs
+ in.next().getBytesValue().toByteArray()) // data
+ .build();
sendEvent(new EventNotifier() {
@Override
public void notify(EventCallback callback) {
@@ -2426,9 +2430,11 @@
return;
}
Iterator<Value> in = playerMsg.getValuesList().iterator();
- data = new TimedMetaData(
- in.next().getInt64Value(), // timestampUs
- in.next().getBytesValue().toByteArray()); // metaData
+ data = new TimedMetaData.Builder()
+ .setTimedMetaData(
+ in.next().getInt64Value(), // timestampUs
+ in.next().getBytesValue().toByteArray()) // metaData
+ .build();
} else {
data = null;
}
diff --git a/media/java/android/media/MediaTimestamp.java b/media/java/android/media/MediaTimestamp.java
index e079a8e..03e454c 100644
--- a/media/java/android/media/MediaTimestamp.java
+++ b/media/java/android/media/MediaTimestamp.java
@@ -16,6 +16,9 @@
package android.media;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+
/**
* An immutable object that represents the linear correlation between the media time
* and the system time. It contains the media clock rate, together with the media timestamp
@@ -117,4 +120,71 @@
+ " clockRate=" + clockRate
+ "}";
}
+
+ /**
+ * Builder class for {@link MediaTimestamp} objects.
+ * <p> Here is an example where <code>Builder</code> is used to define the
+ * {@link MediaTimestamp}:
+ *
+ * <pre class="prettyprint">
+ * MediaTimestamp mts = new MediaTimestamp.Builder()
+ * .setMediaTimestamp(mediaTime, systemTime, rate)
+ * .build();
+ * </pre>
+ * @hide
+ */
+ @SystemApi
+ public static class Builder {
+ long mMediaTimeUs;
+ long mNanoTime;
+ float mClockRate = 1.0f;
+
+ /**
+ * Constructs a new Builder with the defaults.
+ */
+ public Builder() {
+ }
+
+ /**
+ * Constructs a new Builder from a given {@link MediaTimestamp} instance
+ * @param mts the {@link MediaTimestamp} object whose data will be reused
+ * in the new Builder.
+ */
+ public Builder(@NonNull MediaTimestamp mts) {
+ if (mts == null) {
+ throw new IllegalArgumentException("null MediaTimestamp is not allowed");
+ }
+ mMediaTimeUs = mts.mediaTimeUs;
+ mNanoTime = mts.nanoTime;
+ mClockRate = mts.clockRate;
+ }
+
+ /**
+ * Combines all of the fields that have been set and return a new
+ * {@link MediaTimestamp} object.
+ *
+ * @return a new {@link MediaTimestamp} object
+ */
+ public @NonNull MediaTimestamp build() {
+ return new MediaTimestamp(mMediaTimeUs, mNanoTime, mClockRate);
+ }
+
+ /**
+ * Sets the info of media timestamp.
+ *
+ * @param mediaTimeUs the media time of the anchor in microseconds
+ * @param nanoTime the {@link java.lang.System#nanoTime system time} corresponding to
+ * the media time in nanoseconds.
+ * @param clockRate the rate of the media clock in relation to the system time.
+ * @return the same Builder instance.
+ */
+ public @NonNull Builder setMediaTimestamp(
+ long mediaTimeUs, long nanoTime, float clockRate) {
+ mMediaTimeUs = mediaTimeUs;
+ mNanoTime = nanoTime;
+ mClockRate = clockRate;
+
+ return this;
+ }
+ }
}
diff --git a/media/java/android/media/TimedMetaData.java b/media/java/android/media/TimedMetaData.java
index bcc18ef..2a89888 100644
--- a/media/java/android/media/TimedMetaData.java
+++ b/media/java/android/media/TimedMetaData.java
@@ -148,7 +148,7 @@
* It should not be null.
* @return the same Builder instance.
*/
- public @NonNull Builder setTimedMetaData(int timestamp, @NonNull byte[] metaData) {
+ public @NonNull Builder setTimedMetaData(long timestamp, @NonNull byte[] metaData) {
if (metaData == null) {
throw new IllegalArgumentException("null metaData is not allowed");
}
diff --git a/media/java/android/media/session/MediaSessionManager.java b/media/java/android/media/session/MediaSessionManager.java
index 5a9a7c8..6a06dd0 100644
--- a/media/java/android/media/session/MediaSessionManager.java
+++ b/media/java/android/media/session/MediaSessionManager.java
@@ -96,15 +96,9 @@
* @return The binder object from the system
* @hide
*/
- @SystemApi
public @NonNull ISession createSession(@NonNull MediaSession.CallbackStub cbStub,
- @NonNull String tag, int userId) {
- try {
- return mService.createSession(mContext.getPackageName(), cbStub, tag, userId);
- } catch (RemoteException e) {
- e.rethrowFromSystemServer();
- }
- return null;
+ @NonNull String tag, int userId) throws RemoteException {
+ return mService.createSession(mContext.getPackageName(), cbStub, tag, userId);
}
/**
diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
index d087176..1737b64 100644
--- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
+++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
@@ -26,7 +26,6 @@
import android.car.Car;
import android.car.CarNotConnectedException;
import android.car.media.CarAudioManager;
-import android.car.media.ICarVolumeCallback;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -106,7 +105,8 @@
private ListItemAdapter mPagedListAdapter;
private Car mCar;
private CarAudioManager mCarAudioManager;
- private final ICarVolumeCallback mVolumeChangeCallback = new ICarVolumeCallback.Stub() {
+ private final CarAudioManager.CarVolumeCallback mVolumeChangeCallback =
+ new CarAudioManager.CarVolumeCallback() {
@Override
public void onGroupVolumeChanged(int zoneId, int groupId, int flags) {
// TODO: Include zoneId into consideration.
@@ -162,7 +162,7 @@
if (mPagedListAdapter != null) {
mPagedListAdapter.notifyDataSetChanged();
}
- mCarAudioManager.registerVolumeCallback(mVolumeChangeCallback.asBinder());
+ mCarAudioManager.registerCarVolumeCallback(mVolumeChangeCallback);
} catch (CarNotConnectedException e) {
Log.e(TAG, "Car is not connected!", e);
}
@@ -440,11 +440,7 @@
}
private void cleanupAudioManager() {
- try {
- mCarAudioManager.unregisterVolumeCallback(mVolumeChangeCallback.asBinder());
- } catch (CarNotConnectedException e) {
- Log.e(TAG, "Car is not connected!", e);
- }
+ mCarAudioManager.unregisterCarVolumeCallback(mVolumeChangeCallback);
mVolumeLineItems.clear();
mCarAudioManager = null;
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index 8495fd3..86ce60d 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -224,6 +224,9 @@
// next tap
mTouchState.scheduleDoubleTapTimeoutCallback();
}
+ // Fall through
+ case MotionEvent.ACTION_CANCEL:
+ mTouchState.reset();
break;
}
return true;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c16f1db..40da881 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1199,8 +1199,8 @@
void setProfileProc(ProcessRecord profileProc) {
mProfileProc = profileProc;
if (mAtmInternal != null) {
- mAtmInternal.setProfileProc(
- profileProc.getWindowProcessController());
+ mAtmInternal.setProfileProc(profileProc == null ? null
+ : profileProc.getWindowProcessController());
}
}
diff --git a/services/core/java/com/android/server/location/GnssGeofenceProvider.java b/services/core/java/com/android/server/location/GnssGeofenceProvider.java
index 6ac4aeb..a84b0b1 100644
--- a/services/core/java/com/android/server/location/GnssGeofenceProvider.java
+++ b/services/core/java/com/android/server/location/GnssGeofenceProvider.java
@@ -1,18 +1,12 @@
package com.android.server.location;
import android.location.IGpsGeofenceHardware;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Looper;
import android.util.Log;
import android.util.SparseArray;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.FutureTask;
-
/**
* Manages GNSS Geofence operations.
*/
@@ -34,26 +28,26 @@
public boolean paused;
}
+ private final Object mLock = new Object();
+ @GuardedBy("mLock")
private final GnssGeofenceProviderNative mNative;
+ @GuardedBy("mLock")
private final SparseArray<GeofenceEntry> mGeofenceEntries = new SparseArray<>();
- private final Handler mHandler;
- GnssGeofenceProvider(Looper looper) {
- this(looper, new GnssGeofenceProviderNative());
+ GnssGeofenceProvider() {
+ this(new GnssGeofenceProviderNative());
}
@VisibleForTesting
- GnssGeofenceProvider(Looper looper, GnssGeofenceProviderNative gnssGeofenceProviderNative) {
- mHandler = new Handler(looper);
+ GnssGeofenceProvider(GnssGeofenceProviderNative gnssGeofenceProviderNative) {
mNative = gnssGeofenceProviderNative;
}
- // TODO(b/37460011): use this method in HAL death recovery.
void resumeIfStarted() {
if (DEBUG) {
Log.d(TAG, "resumeIfStarted");
}
- mHandler.post(() -> {
+ synchronized (mLock) {
for (int i = 0; i < mGeofenceEntries.size(); i++) {
GeofenceEntry entry = mGeofenceEntries.valueAt(i);
boolean added = mNative.addGeofence(entry.geofenceId, entry.latitude,
@@ -65,30 +59,21 @@
mNative.pauseGeofence(entry.geofenceId);
}
}
- });
- }
-
- private boolean runOnHandlerThread(Callable<Boolean> callable) {
- FutureTask<Boolean> futureTask = new FutureTask<>(callable);
- mHandler.post(futureTask);
- try {
- return futureTask.get();
- } catch (InterruptedException | ExecutionException e) {
- Log.e(TAG, "Failed running callable.", e);
}
- return false;
}
@Override
public boolean isHardwareGeofenceSupported() {
- return runOnHandlerThread(mNative::isGeofenceSupported);
+ synchronized (mLock) {
+ return mNative.isGeofenceSupported();
+ }
}
@Override
public boolean addCircularHardwareGeofence(int geofenceId, double latitude,
double longitude, double radius, int lastTransition, int monitorTransitions,
int notificationResponsiveness, int unknownTimer) {
- return runOnHandlerThread(() -> {
+ synchronized (mLock) {
boolean added = mNative.addGeofence(geofenceId, latitude, longitude, radius,
lastTransition, monitorTransitions, notificationResponsiveness,
unknownTimer);
@@ -105,23 +90,23 @@
mGeofenceEntries.put(geofenceId, entry);
}
return added;
- });
+ }
}
@Override
public boolean removeHardwareGeofence(int geofenceId) {
- return runOnHandlerThread(() -> {
+ synchronized (mLock) {
boolean removed = mNative.removeGeofence(geofenceId);
if (removed) {
mGeofenceEntries.remove(geofenceId);
}
return removed;
- });
+ }
}
@Override
public boolean pauseHardwareGeofence(int geofenceId) {
- return runOnHandlerThread(() -> {
+ synchronized (mLock) {
boolean paused = mNative.pauseGeofence(geofenceId);
if (paused) {
GeofenceEntry entry = mGeofenceEntries.get(geofenceId);
@@ -130,12 +115,12 @@
}
}
return paused;
- });
+ }
}
@Override
public boolean resumeHardwareGeofence(int geofenceId, int monitorTransitions) {
- return runOnHandlerThread(() -> {
+ synchronized (mLock) {
boolean resumed = mNative.resumeGeofence(geofenceId, monitorTransitions);
if (resumed) {
GeofenceEntry entry = mGeofenceEntries.get(geofenceId);
@@ -145,7 +130,7 @@
}
}
return resumed;
- });
+ }
}
@VisibleForTesting
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java
index d5e4681..330d1d5 100644
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -762,7 +762,7 @@
looper, this);
mHandler.post(mGnssSatelliteBlacklistHelper::updateSatelliteBlacklist);
mGnssBatchingProvider = new GnssBatchingProvider();
- mGnssGeofenceProvider = new GnssGeofenceProvider(looper);
+ mGnssGeofenceProvider = new GnssGeofenceProvider();
}
/**
@@ -1824,7 +1824,7 @@
/**
* Converts the GPS HAL status to the internal Geofence Hardware status.
*/
- private int getGeofenceStatus(int status) {
+ private static int getGeofenceStatus(int status) {
switch (status) {
case GPS_GEOFENCE_OPERATION_SUCCESS:
return GeofenceHardware.GEOFENCE_SUCCESS;
@@ -1849,75 +1849,87 @@
*/
private void reportGeofenceTransition(int geofenceId, Location location, int transition,
long transitionTimestamp) {
- if (mGeofenceHardwareImpl == null) {
- mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
- }
+ mHandler.post(() -> {
+ if (mGeofenceHardwareImpl == null) {
+ mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
+ }
- mGeofenceHardwareImpl.reportGeofenceTransition(
- geofenceId,
- location,
- transition,
- transitionTimestamp,
- GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE,
- FusedBatchOptions.SourceTechnologies.GNSS);
+ mGeofenceHardwareImpl.reportGeofenceTransition(
+ geofenceId,
+ location,
+ transition,
+ transitionTimestamp,
+ GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE,
+ FusedBatchOptions.SourceTechnologies.GNSS);
+ });
}
/**
* called from native code to report GPS status change.
*/
private void reportGeofenceStatus(int status, Location location) {
- if (mGeofenceHardwareImpl == null) {
- mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
- }
- int monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_UNAVAILABLE;
- if (status == GPS_GEOFENCE_AVAILABLE) {
- monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE;
- }
- mGeofenceHardwareImpl.reportGeofenceMonitorStatus(
- GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE,
- monitorStatus,
- location,
- FusedBatchOptions.SourceTechnologies.GNSS);
+ mHandler.post(() -> {
+ if (mGeofenceHardwareImpl == null) {
+ mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
+ }
+ int monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_UNAVAILABLE;
+ if (status == GPS_GEOFENCE_AVAILABLE) {
+ monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE;
+ }
+ mGeofenceHardwareImpl.reportGeofenceMonitorStatus(
+ GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE,
+ monitorStatus,
+ location,
+ FusedBatchOptions.SourceTechnologies.GNSS);
+ });
}
/**
* called from native code - Geofence Add callback
*/
private void reportGeofenceAddStatus(int geofenceId, int status) {
- if (mGeofenceHardwareImpl == null) {
- mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
- }
- mGeofenceHardwareImpl.reportGeofenceAddStatus(geofenceId, getGeofenceStatus(status));
+ mHandler.post(() -> {
+ if (mGeofenceHardwareImpl == null) {
+ mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
+ }
+ mGeofenceHardwareImpl.reportGeofenceAddStatus(geofenceId, getGeofenceStatus(status));
+ });
}
/**
* called from native code - Geofence Remove callback
*/
private void reportGeofenceRemoveStatus(int geofenceId, int status) {
- if (mGeofenceHardwareImpl == null) {
- mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
- }
- mGeofenceHardwareImpl.reportGeofenceRemoveStatus(geofenceId, getGeofenceStatus(status));
+ mHandler.post(() -> {
+ if (mGeofenceHardwareImpl == null) {
+ mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
+ }
+ mGeofenceHardwareImpl.reportGeofenceRemoveStatus(geofenceId, getGeofenceStatus(status));
+ });
}
/**
* called from native code - Geofence Pause callback
*/
private void reportGeofencePauseStatus(int geofenceId, int status) {
- if (mGeofenceHardwareImpl == null) {
- mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
- }
- mGeofenceHardwareImpl.reportGeofencePauseStatus(geofenceId, getGeofenceStatus(status));
+ mHandler.post(() -> {
+ if (mGeofenceHardwareImpl == null) {
+ mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
+ }
+ mGeofenceHardwareImpl.reportGeofencePauseStatus(geofenceId, getGeofenceStatus(status));
+ });
}
/**
* called from native code - Geofence Resume callback
*/
private void reportGeofenceResumeStatus(int geofenceId, int status) {
- if (mGeofenceHardwareImpl == null) {
- mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
- }
- mGeofenceHardwareImpl.reportGeofenceResumeStatus(geofenceId, getGeofenceStatus(status));
+ mHandler.post(() -> {
+ if (mGeofenceHardwareImpl == null) {
+ mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
+ }
+ mGeofenceHardwareImpl.reportGeofenceResumeStatus(geofenceId, getGeofenceStatus(status));
+ });
}
//=============================================================
diff --git a/services/robotests/src/com/android/server/location/GnssGeofenceProviderTest.java b/services/robotests/src/com/android/server/location/GnssGeofenceProviderTest.java
index beb5941..30c7336 100644
--- a/services/robotests/src/com/android/server/location/GnssGeofenceProviderTest.java
+++ b/services/robotests/src/com/android/server/location/GnssGeofenceProviderTest.java
@@ -7,7 +7,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.os.Looper;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
@@ -44,7 +43,7 @@
when(mMockNative.pauseGeofence(anyInt())).thenReturn(true);
when(mMockNative.removeGeofence(anyInt())).thenReturn(true);
when(mMockNative.resumeGeofence(anyInt(), anyInt())).thenReturn(true);
- mTestProvider = new GnssGeofenceProvider(Looper.myLooper(), mMockNative);
+ mTestProvider = new GnssGeofenceProvider(mMockNative);
mTestProvider.addCircularHardwareGeofence(GEOFENCE_ID, LATITUDE,
LONGITUDE, RADIUS, LAST_TRANSITION, MONITOR_TRANSITIONS,
NOTIFICATION_RESPONSIVENESS,