Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworks.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworks.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworks.java |
| index 0910cce61f0f43bfb9868740d15ceedb80e5a498..60404fb017811b1f7d736a945efafa58e6ca5fee 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworks.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworks.java |
| @@ -33,10 +33,10 @@ public class VisibleNetworks { |
| private VisibleNetworks(@Nullable VisibleWifi connectedWifi, |
| @Nullable VisibleCell connectedCell, @Nullable Set<VisibleWifi> allVisibleWifis, |
| @Nullable Set<VisibleCell> allVisibleCells) { |
| - this.mConnectedWifi = connectedWifi; |
| - this.mConnectedCell = connectedCell; |
| - this.mAllVisibleWifis = allVisibleWifis; |
| - this.mAllVisibleCells = allVisibleCells; |
| + mConnectedWifi = connectedWifi; |
| + mConnectedCell = connectedCell; |
| + mAllVisibleWifis = allVisibleWifis; |
| + mAllVisibleCells = allVisibleCells; |
| } |
| public static VisibleNetworks create(@Nullable VisibleWifi connectedWifi, |
| @@ -101,11 +101,10 @@ public class VisibleNetworks { |
| return false; |
| } |
| VisibleNetworks that = (VisibleNetworks) object; |
| - return ApiCompatibilityUtils.objectEquals(this.mConnectedWifi, that.connectedWifi()) |
| - && ApiCompatibilityUtils.objectEquals(this.mConnectedCell, that.connectedCell()) |
| - && ApiCompatibilityUtils.objectEquals(this.mAllVisibleWifis, that.allVisibleWifis()) |
| - && ApiCompatibilityUtils.objectEquals( |
| - this.mAllVisibleCells, that.allVisibleCells()); |
| + return ApiCompatibilityUtils.objectEquals(mConnectedWifi, that.connectedWifi()) |
| + && ApiCompatibilityUtils.objectEquals(mConnectedCell, that.connectedCell()) |
| + && ApiCompatibilityUtils.objectEquals(mAllVisibleWifis, that.allVisibleWifis()) |
| + && ApiCompatibilityUtils.objectEquals(mAllVisibleCells, that.allVisibleCells()); |
| } |
| private static int objectsHashCode(Object o) { |
| @@ -118,8 +117,8 @@ public class VisibleNetworks { |
| @Override |
| public int hashCode() { |
| - return objectsHash(this.mConnectedWifi, this.mConnectedCell, |
| - objectsHashCode(this.mAllVisibleWifis), objectsHashCode(this.mAllVisibleCells)); |
| + return objectsHash(mConnectedWifi, mConnectedCell, objectsHashCode(mAllVisibleWifis), |
| + objectsHashCode(mAllVisibleCells)); |
| } |
| /** |
| @@ -139,10 +138,10 @@ public class VisibleNetworks { |
| private VisibleWifi(@Nullable String ssid, @Nullable String bssid, @Nullable Integer level, |
| @Nullable Long timestampMs) { |
| - this.mSsid = ssid; |
| - this.mBssid = bssid; |
| - this.mLevel = level; |
| - this.mTimestampMs = timestampMs; |
| + mSsid = ssid; |
| + mBssid = bssid; |
| + mLevel = level; |
| + mTimestampMs = timestampMs; |
| } |
| public static VisibleWifi create(@Nullable String ssid, @Nullable String bssid, |
| @@ -194,13 +193,42 @@ public class VisibleNetworks { |
| } |
| VisibleWifi that = (VisibleWifi) object; |
| - return ApiCompatibilityUtils.objectEquals(this.mSsid, that.ssid()) |
| - && ApiCompatibilityUtils.objectEquals(this.mBssid, that.bssid()); |
| + return ApiCompatibilityUtils.objectEquals(mSsid, that.ssid()) |
| + && ApiCompatibilityUtils.objectEquals(mBssid, that.bssid()); |
| } |
| @Override |
| public int hashCode() { |
| - return VisibleNetworks.objectsHash(this.mSsid, this.mBssid); |
| + return VisibleNetworks.objectsHash(mSsid, mBssid); |
| + } |
| + |
| + /** |
| + * Encodes a VisibleWifi into its corresponding PartnerLocationDescriptor.VisibleNetwork |
| + * proto. |
| + */ |
| + public PartnerLocationDescriptor.VisibleNetwork toProto(boolean connected) { |
| + PartnerLocationDescriptor.VisibleNetwork visibleNetwork = |
| + new PartnerLocationDescriptor.VisibleNetwork(); |
| + |
| + PartnerLocationDescriptor.VisibleNetwork.WiFi wifi = |
| + new PartnerLocationDescriptor.VisibleNetwork.WiFi(); |
| + |
| + String bssid = bssid(); |
| + if (bssid != null) { |
| + wifi.bssid = bssid(); |
|
Ted C
2017/05/17 17:44:25
what is the default value for wifi.bssid? Is it n
lbargu
2017/05/18 12:42:48
Sorry, forgot this is nano protos. Should be ok to
|
| + } |
| + Integer level = level(); |
| + if (level != null) { |
| + wifi.levelDbm = level(); |
| + } |
| + visibleNetwork.wifi = wifi; |
| + |
| + Long timestampMs = timestampMs(); |
| + if (timestampMs != null) { |
| + visibleNetwork.timestampMs = timestampMs; |
| + } |
| + visibleNetwork.connected = connected; |
| + return visibleNetwork; |
|
dougt
2017/05/17 20:51:17
two questions:
Can any of these accessors return
lbargu
2017/05/18 12:42:48
Done.
|
| } |
| } |
| @@ -252,15 +280,15 @@ public class VisibleNetworks { |
| private Long mTimestampMs; |
| private VisibleCell(Builder builder) { |
| - this.mRadioType = builder.mRadioType; |
| - this.mCellId = builder.mCellId; |
| - this.mLocationAreaCode = builder.mLocationAreaCode; |
| - this.mMobileCountryCode = builder.mMobileCountryCode; |
| - this.mMobileNetworkCode = builder.mMobileNetworkCode; |
| - this.mPrimaryScramblingCode = builder.mPrimaryScramblingCode; |
| - this.mPhysicalCellId = builder.mPhysicalCellId; |
| - this.mTrackingAreaCode = builder.mTrackingAreaCode; |
| - this.mTimestampMs = builder.mTimestampMs; |
| + mRadioType = builder.mRadioType; |
| + mCellId = builder.mCellId; |
| + mLocationAreaCode = builder.mLocationAreaCode; |
| + mMobileCountryCode = builder.mMobileCountryCode; |
| + mMobileNetworkCode = builder.mMobileNetworkCode; |
| + mPrimaryScramblingCode = builder.mPrimaryScramblingCode; |
| + mPhysicalCellId = builder.mPhysicalCellId; |
| + mTrackingAreaCode = builder.mTrackingAreaCode; |
| + mTimestampMs = builder.mTimestampMs; |
| } |
| /** |
| @@ -347,27 +375,100 @@ public class VisibleNetworks { |
| return false; |
| } |
| VisibleCell that = (VisibleCell) object; |
| - return ApiCompatibilityUtils.objectEquals(this.mRadioType, that.radioType()) |
| - && ApiCompatibilityUtils.objectEquals(this.mCellId, that.cellId()) |
| - && ApiCompatibilityUtils.objectEquals( |
| - this.mLocationAreaCode, that.locationAreaCode()) |
| + return ApiCompatibilityUtils.objectEquals(mRadioType, that.radioType()) |
| + && ApiCompatibilityUtils.objectEquals(mCellId, that.cellId()) |
| && ApiCompatibilityUtils.objectEquals( |
| - this.mMobileCountryCode, that.mobileCountryCode()) |
| + mLocationAreaCode, that.locationAreaCode()) |
| && ApiCompatibilityUtils.objectEquals( |
| - this.mMobileNetworkCode, that.mobileNetworkCode()) |
| + mMobileCountryCode, that.mobileCountryCode()) |
| && ApiCompatibilityUtils.objectEquals( |
| - this.mPrimaryScramblingCode, that.primaryScramblingCode()) |
| + mMobileNetworkCode, that.mobileNetworkCode()) |
| && ApiCompatibilityUtils.objectEquals( |
| - this.mPhysicalCellId, that.physicalCellId()) |
| + mPrimaryScramblingCode, that.primaryScramblingCode()) |
| + && ApiCompatibilityUtils.objectEquals(mPhysicalCellId, that.physicalCellId()) |
| && ApiCompatibilityUtils.objectEquals( |
| - this.mTrackingAreaCode, that.trackingAreaCode()); |
| + mTrackingAreaCode, that.trackingAreaCode()); |
| } |
| @Override |
| public int hashCode() { |
| - return VisibleNetworks.objectsHash(this.mRadioType, this.mCellId, |
| - this.mLocationAreaCode, this.mMobileCountryCode, this.mMobileNetworkCode, |
| - this.mPrimaryScramblingCode, this.mPhysicalCellId, this.mTrackingAreaCode); |
| + return VisibleNetworks.objectsHash(mRadioType, mCellId, mLocationAreaCode, |
| + mMobileCountryCode, mMobileNetworkCode, mPrimaryScramblingCode, mPhysicalCellId, |
| + mTrackingAreaCode); |
| + } |
| + |
| + /** |
| + * Encodes a VisibleCell into its corresponding PartnerLocationDescriptor.VisibleNetwork |
| + * proto. |
| + */ |
| + public PartnerLocationDescriptor.VisibleNetwork toProto(boolean connected) { |
| + PartnerLocationDescriptor.VisibleNetwork visibleNetwork = |
| + new PartnerLocationDescriptor.VisibleNetwork(); |
| + |
| + PartnerLocationDescriptor.VisibleNetwork.Cell cell = |
| + new PartnerLocationDescriptor.VisibleNetwork.Cell(); |
| + |
| + switch (radioType()) { |
| + case VisibleCell.CDMA_RADIO_TYPE: |
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.CDMA; |
| + break; |
| + case VisibleCell.GSM_RADIO_TYPE: |
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.GSM; |
| + break; |
| + case VisibleCell.LTE_RADIO_TYPE: |
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.LTE; |
| + break; |
| + case VisibleCell.WCDMA_RADIO_TYPE: |
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.WCDMA; |
| + break; |
| + case VisibleCell.UNKNOWN_RADIO_TYPE: |
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.UNKNOWN; |
| + break; |
| + case VisibleCell.UNKNOWN_MISSING_LOCATION_PERMISSION_RADIO_TYPE: |
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.UNKNOWN; |
| + break; |
| + default: |
|
Ted C
2017/05/17 17:44:25
should we just fall through these?
case VisibleCe
lbargu
2017/05/18 12:42:48
Done.
|
| + cell.type = PartnerLocationDescriptor.VisibleNetwork.Cell.UNKNOWN; |
| + break; |
| + } |
| + |
| + Integer cellId = cellId(); |
| + if (cellId != null) { |
| + cell.cellId = cellId; |
|
dougt
2017/05/17 20:51:17
same nullable question here.
lbargu
2017/05/18 12:42:48
Done.
|
| + } |
| + Integer locationAreaCode = locationAreaCode(); |
| + if (locationAreaCode != null) { |
| + cell.locationAreaCode = locationAreaCode; |
| + } |
| + Integer mobileCountryCode = mobileCountryCode(); |
| + if (mobileCountryCode != null) { |
| + cell.mobileCountryCode = mobileCountryCode; |
| + } |
| + Integer mobileNetworkCode = mobileNetworkCode(); |
| + if (mobileNetworkCode != null) { |
| + cell.mobileNetworkCode = mobileNetworkCode; |
| + } |
| + Integer primaryScramblingCode = primaryScramblingCode(); |
| + if (primaryScramblingCode != null) { |
| + cell.primaryScramblingCode = primaryScramblingCode; |
| + } |
| + Integer physicalCellId = physicalCellId(); |
| + if (physicalCellId != null) { |
| + cell.physicalCellId = physicalCellId; |
| + } |
| + Integer trackingAreaCode = trackingAreaCode(); |
| + if (trackingAreaCode != null) { |
| + cell.trackingAreaCode = trackingAreaCode; |
| + } |
| + |
| + visibleNetwork.cell = cell; |
| + |
| + Long timestampMs = timestampMs(); |
| + if (timestampMs != null) { |
| + visibleNetwork.timestampMs = timestampMs; |
| + } |
| + visibleNetwork.connected = connected; |
| + return visibleNetwork; |
| } |
| /** |