From d8046e520a866b9948ee9ba47cf642b441ca8e23 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 6 Apr 2017 09:41:50 -0700 Subject: Update AOSP Dialer source from internal google3 repository at cl/152373142. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/151342913 (3/27/2017) to cl/152373142 (4/06/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: I2fbc88cf6867b90ac8b65f75e5e34468988c7217 --- .../calllocation/impl/LocationFragment.java | 9 ++++ .../incallui/calllocation/impl/LocationHelper.java | 60 +++++++++++++++------- .../calllocation/impl/LocationPresenter.java | 18 ++++++- 3 files changed, 67 insertions(+), 20 deletions(-) (limited to 'java/com/android/incallui/calllocation/impl') diff --git a/java/com/android/incallui/calllocation/impl/LocationFragment.java b/java/com/android/incallui/calllocation/impl/LocationFragment.java index b152cd683..3c5d2f972 100644 --- a/java/com/android/incallui/calllocation/impl/LocationFragment.java +++ b/java/com/android/incallui/calllocation/impl/LocationFragment.java @@ -30,6 +30,8 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.ViewAnimator; import com.android.dialer.common.LogUtil; +import com.android.dialer.logging.Logger; +import com.android.dialer.logging.nano.DialerImpression; import com.android.incallui.baseui.BaseFragment; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -114,6 +116,7 @@ public class LocationFragment extends BaseFragment listeners = new ArrayList<>(); @@ -71,28 +91,32 @@ public class LocationHelper { } /** - * Whether the location is valid. We consider it valid if it was recorded within the specified - * time threshold of the present and has an accuracy less than the specified distance threshold. + * Check whether the location is valid. We consider it valid if it was recorded within the + * specified time threshold of the present and has an accuracy less than the specified distance + * threshold. * * @param location The location to determine the validity of. - * @return {@code true} if the location is valid, and {@code false} otherwise. + * @return {@code LocationStatus} indicating if the location is valid or the reason its not valid */ - static boolean isValidLocation(Location location) { - if (location != null) { - long locationTimeMs = location.getTime(); - long elapsedTimeMs = System.currentTimeMillis() - locationTimeMs; - if (elapsedTimeMs > LAST_UPDATE_THRESHOLD_MS) { - LogUtil.i("LocationHelper.isValidLocation", "stale location, age: " + elapsedTimeMs); - return false; - } - if (location.getAccuracy() > LOCATION_ACCURACY_THRESHOLD_METERS) { - LogUtil.i("LocationHelper.isValidLocation", "poor accuracy: " + location.getAccuracy()); - return false; - } - return true; + static @LocationStatus int checkLocation(Location location) { + if (location == null) { + LogUtil.i("LocationHelper.checkLocation", "no location"); + return LOCATION_STATUS_NO_LOCATION; } - LogUtil.i("LocationHelper.isValidLocation", "no location"); - return false; + + long locationTimeMs = location.getTime(); + long elapsedTimeMs = System.currentTimeMillis() - locationTimeMs; + if (elapsedTimeMs > LAST_UPDATE_THRESHOLD_MS) { + LogUtil.i("LocationHelper.checkLocation", "stale location, age: " + elapsedTimeMs); + return LOCATION_STATUS_STALE; + } + + if (location.getAccuracy() > LOCATION_ACCURACY_THRESHOLD_METERS) { + LogUtil.i("LocationHelper.checkLocation", "poor accuracy: " + location.getAccuracy()); + return LOCATION_STATUS_INACCURATE; + } + + return LOCATION_STATUS_OK; } @MainThread diff --git a/java/com/android/incallui/calllocation/impl/LocationPresenter.java b/java/com/android/incallui/calllocation/impl/LocationPresenter.java index a56fd3b3c..155d9fdfd 100644 --- a/java/com/android/incallui/calllocation/impl/LocationPresenter.java +++ b/java/com/android/incallui/calllocation/impl/LocationPresenter.java @@ -21,6 +21,8 @@ import android.graphics.drawable.Drawable; import android.location.Location; import android.os.AsyncTask; import com.android.dialer.common.LogUtil; +import com.android.dialer.logging.Logger; +import com.android.dialer.logging.nano.DialerImpression; import com.android.incallui.baseui.Presenter; import com.android.incallui.baseui.Ui; import com.google.android.gms.location.LocationListener; @@ -71,8 +73,9 @@ public class LocationPresenter extends Presenter LogUtil.i("LocationPresenter.updateLocation", "location: " + location); if (forceUpdate || !Objects.equals(mLastLocation, location)) { mLastLocation = location; - if (LocationHelper.isValidLocation(location)) { - LocationUi ui = getUi(); + int status = LocationHelper.checkLocation(location); + LocationUi ui = getUi(); + if (status == LocationHelper.LOCATION_STATUS_OK) { mDownloadMapTask = new DownloadMapImageTask(new WeakReference<>(ui)).execute(location); mReverseGeocodeTask = new ReverseGeocodeTask(new WeakReference<>(ui)).execute(location); if (ui != null) { @@ -80,6 +83,17 @@ public class LocationPresenter extends Presenter } else { LogUtil.i("LocationPresenter.updateLocation", "no Ui"); } + } else if (status != LocationHelper.LOCATION_STATUS_NO_LOCATION) { + // Log impression indicating why the location is not valid + // Note: its possible for this to be called before the UI has been initialized. + Context context = (ui != null) ? ui.getContext() : null; + if (context != null) { + if (status == LocationHelper.LOCATION_STATUS_STALE) { + Logger.get(context).logImpression(DialerImpression.Type.EMERGENCY_STALE_LOCATION); + } else if (status == LocationHelper.LOCATION_STATUS_INACCURATE) { + Logger.get(context).logImpression(DialerImpression.Type.EMERGENCY_INACCURATE_LOCATION); + } + } } } } -- cgit v1.2.3