diff options
author | Eric Erfanian <erfanian@google.com> | 2017-04-06 09:41:50 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-04-06 09:41:50 -0700 |
commit | d8046e520a866b9948ee9ba47cf642b441ca8e23 (patch) | |
tree | 8d08d4f2292aa84dc435d455891e7ab633d95a25 /java/com/android/incallui/calllocation | |
parent | cdb1edf966a892abebcba425a85b7d4e47758302 (diff) | |
download | android_packages_apps_Dialer-d8046e520a866b9948ee9ba47cf642b441ca8e23.tar.gz android_packages_apps_Dialer-d8046e520a866b9948ee9ba47cf642b441ca8e23.tar.bz2 android_packages_apps_Dialer-d8046e520a866b9948ee9ba47cf642b441ca8e23.zip |
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
Diffstat (limited to 'java/com/android/incallui/calllocation')
3 files changed, 67 insertions, 20 deletions
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<LocationPresenter, LocationPr locationMap.setVisibility(View.VISIBLE); locationMap.setImageDrawable(mapImage); displayWhenReady(); + Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_MAP); } @Override @@ -139,6 +142,8 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr updateText(addressLine1, address); updateText(addressLine2, null); } + + Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_ADDRESS); } displayWhenReady(); } @@ -155,6 +160,8 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr getContext() .getString( R.string.lat_long_format, location.getLatitude(), location.getLongitude())); + + Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_GOT_LOCATION); } displayWhenReady(); } @@ -186,6 +193,8 @@ public class LocationFragment extends BaseFragment<LocationPresenter, LocationPr startActivity( LocationUrlBuilder.getShowMapIntent( location, addressLine1.getText(), addressLine2.getText())); + + Logger.get(getContext()).logImpression(DialerImpression.Type.EMERGENCY_LAUNCHED_MAP); } } diff --git a/java/com/android/incallui/calllocation/impl/LocationHelper.java b/java/com/android/incallui/calllocation/impl/LocationHelper.java index 645e9b86a..3a1478945 100644 --- a/java/com/android/incallui/calllocation/impl/LocationHelper.java +++ b/java/com/android/incallui/calllocation/impl/LocationHelper.java @@ -22,6 +22,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Bundle; import android.os.Handler; +import android.support.annotation.IntDef; import android.support.annotation.MainThread; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; @@ -35,6 +36,8 @@ import com.google.android.gms.common.api.Status; import com.google.android.gms.location.LocationListener; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; @@ -45,6 +48,23 @@ public class LocationHelper { private static final int LAST_UPDATE_THRESHOLD_MS = 60 * 1000; private static final int LOCATION_ACCURACY_THRESHOLD_METERS = 100; + public static final int LOCATION_STATUS_UNKNOWN = 0; + public static final int LOCATION_STATUS_OK = 1; + public static final int LOCATION_STATUS_STALE = 2; + public static final int LOCATION_STATUS_INACCURATE = 3; + public static final int LOCATION_STATUS_NO_LOCATION = 4; + + /** Possible return values for {@code checkLocation()} */ + @IntDef({ + LOCATION_STATUS_UNKNOWN, + LOCATION_STATUS_OK, + LOCATION_STATUS_STALE, + LOCATION_STATUS_INACCURATE, + LOCATION_STATUS_NO_LOCATION + }) + @Retention(RetentionPolicy.SOURCE) + public @interface LocationStatus {} + private final LocationHelperInternal locationHelperInternal; private final List<LocationListener> 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<LocationPresenter.LocationUi> 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<LocationPresenter.LocationUi> } 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); + } + } } } } |