summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapLoadEvent.java
blob: 61156b7f18195093f65a3687f0f321f15fb04d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package com.mapbox.mapboxsdk.module.telemetry;

import android.annotation.SuppressLint;
import android.os.Build;

import com.mapbox.mapboxsdk.BuildConfig;

/**
 * Event will be sent while map is loaded.
 */
@SuppressLint("ParcelCreator")
class MapLoadEvent extends MapBaseEvent {
  private static final String EVENT_NAME = "map.load";
  private final String operatingSystem = "Android - " + Build.VERSION.RELEASE;
  private final String sdkIdentifier = BuildConfig.MAPBOX_SDK_IDENTIFIER;
  private final String sdkVersion = BuildConfig.MAPBOX_SDK_VERSION;
  private final String model = Build.MODEL;
  private final String userId;
  private final String carrier;
  private final String cellularNetworkType;
  private final String orientation;
  private final float resolution;
  private final float accessibilityFontScale;
  private final int batteryLevel;
  private final boolean pluggedIn;
  private final boolean wifi;

  MapLoadEvent(String userId, PhoneState phoneState) {
    super(phoneState);
    this.userId = userId;
    this.batteryLevel = phoneState.getBatteryLevel();
    this.pluggedIn = phoneState.isPluggedIn();
    this.cellularNetworkType = phoneState.getCellularNetworkType();
    this.carrier = phoneState.getCarrier();
    this.resolution = phoneState.getResolution();
    this.accessibilityFontScale = phoneState.getAccessibilityFontScale();
    this.wifi = phoneState.isWifi();
    this.orientation = phoneState.getOrientation();
  }

  @Override
  String getEventName() {
    return EVENT_NAME;
  }

  String getOperatingSystem() {
    return operatingSystem;
  }

  String getSdkIdentifier() {
    return sdkIdentifier;
  }

  String getSdkVersion() {
    return sdkVersion;
  }

  String getModel() {
    return model;
  }

  String getCreated() {
    return created;
  }

  String getUserId() {
    return userId;
  }

  String getCarrier() {
    return carrier;
  }

  String getCellularNetworkType() {
    return cellularNetworkType;
  }

  String getOrientation() {
    return orientation;
  }

  float getResolution() {
    return resolution;
  }

  float getAccessibilityFontScale() {
    return accessibilityFontScale;
  }

  int getBatteryLevel() {
    return batteryLevel;
  }

  boolean isPluggedIn() {
    return pluggedIn;
  }

  boolean isWifi() {
    return wifi;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    MapLoadEvent that = (MapLoadEvent) o;

    if (Float.compare(that.resolution, resolution) != 0) {
      return false;
    }
    if (Float.compare(that.accessibilityFontScale, accessibilityFontScale) != 0) {
      return false;
    }
    if (batteryLevel != that.batteryLevel) {
      return false;
    }
    if (pluggedIn != that.pluggedIn) {
      return false;
    }
    if (wifi != that.wifi) {
      return false;
    }
    if (!operatingSystem.equals(that.operatingSystem)) {
      return false;
    }
    if (model != null ? !model.equals(that.model) : that.model != null) {
      return false;
    }
    if (created != null ? !created.equals(that.created) : that.created != null) {
      return false;
    }
    if (userId != null ? !userId.equals(that.userId) : that.userId != null) {
      return false;
    }
    if (carrier != null ? !carrier.equals(that.carrier) : that.carrier != null) {
      return false;
    }
    if (cellularNetworkType != null ? !cellularNetworkType.equals(that.cellularNetworkType) :
      that.cellularNetworkType != null) {
      return false;
    }
    return orientation != null ? orientation.equals(that.orientation) : that.orientation == null;
  }

  @Override
  public int hashCode() {
    int result = event.hashCode();
    result = 31 * result + operatingSystem.hashCode();
    result = 31 * result + sdkIdentifier.hashCode();
    result = 31 * result + sdkVersion.hashCode();
    result = 31 * result + (model != null ? model.hashCode() : 0);
    result = 31 * result + (created != null ? created.hashCode() : 0);
    result = 31 * result + (userId != null ? userId.hashCode() : 0);
    result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
    result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
    result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
    result = 31 * result + (resolution != +0.0f ? Float.floatToIntBits(resolution) : 0);
    result = 31 * result + (accessibilityFontScale != +0.0f ? Float.floatToIntBits(accessibilityFontScale) : 0);
    result = 31 * result + batteryLevel;
    result = 31 * result + (pluggedIn ? 1 : 0);
    result = 31 * result + (wifi ? 1 : 0);
    return result;
  }

  @Override
  public String toString() {
    return "MapLoadEvent{"
      + "event='" + event + '\''
      + ", operatingSystem='" + operatingSystem + '\''
      + ", sdkIdentifier='" + sdkIdentifier + '\''
      + ", sdkVersion='" + sdkVersion + '\''
      + ", model='" + model + '\''
      + ", created='" + created + '\''
      + ", userId='" + userId + '\''
      + ", carrier='" + carrier + '\''
      + ", cellularNetworkType='" + cellularNetworkType + '\''
      + ", orientation='" + orientation + '\''
      + ", resolution=" + resolution
      + ", accessibilityFontScale=" + accessibilityFontScale
      + ", batteryLevel=" + batteryLevel
      + ", pluggedIn=" + pluggedIn
      + ", wifi=" + wifi
      + '}';
  }
}