Skip to content

Commit 6f28ca9

Browse files
committed
core changes
1 parent e1be2fd commit 6f28ca9

File tree

14 files changed

+50
-33
lines changed

14 files changed

+50
-33
lines changed

android-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ dependencies {
169169
androidTestImplementation "androidx.lifecycle:lifecycle-common:2.5.0"
170170
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
171171
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2-native-mt"
172-
androidTestImplementation("com.mparticle.internal:mocking:1.3.0")
172+
androidTestImplementation("com.mparticle.internal:mocking:1.4.0")
173173
androidTestImplementation 'androidx.test:rules:1.4.0'
174174
}
175175

android-core/src/main/java/com/mparticle/MParticle.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,8 @@ public interface ResetListener {
16341634
* @hidden
16351635
*/
16361636
public class Internal {
1637-
protected Internal() { }
1637+
1638+
private Internal() { }
16381639

16391640
/**
16401641
* The ConfigManager is tasked with incorporating server-based, run-time, and XML configuration,

android-core/src/main/java/com/mparticle/identity/IdentityApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public void run() {
392392
}
393393
} catch (Exception ex) {
394394
ConfigManager.setIdentityRequestInProgress(false);
395-
task.setFailed(new IdentityHttpResponse(IdentityApi.UNKNOWN_ERROR, ex.toString()));
395+
task.setFailed(new IdentityHttpResponse(IdentityApi.UNKNOWN_ERROR, ex));
396396
}
397397
}
398398
}

android-core/src/main/java/com/mparticle/identity/IdentityHttpResponse.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
public final class IdentityHttpResponse {
1616
private ArrayList<Error> errors = new ArrayList<Error>();
17-
private long mpId;
17+
private Long mpId = null;
1818
private String context;
1919
private int httpCode;
2020
private boolean loggedIn;
21+
private Exception exception;
2122

2223
@NonNull public static final String MPID = "mpid";
2324
@NonNull public static final String CONTEXT = "context";
@@ -42,6 +43,11 @@ public IdentityHttpResponse(int code, @NonNull String errorString) {
4243
this.errors.add(new Error(UNKNOWN, errorString));
4344
}
4445

46+
public IdentityHttpResponse(int code, @NonNull Exception exception) {
47+
this(code, exception.getMessage());
48+
this.exception = exception;
49+
}
50+
4551
public IdentityHttpResponse(int httpCode, @Nullable JSONObject jsonObject) throws JSONException {
4652
this.httpCode = httpCode;
4753
if (!MPUtility.isEmpty(jsonObject)) {
@@ -80,7 +86,8 @@ public List<Error> getErrors() {
8086
return errors;
8187
}
8288

83-
public long getMpId() {
89+
@Nullable
90+
public Long getMpId() {
8491
return mpId;
8592
}
8693

@@ -93,6 +100,11 @@ public int getHttpCode() {
93100
return httpCode;
94101
}
95102

103+
@Nullable
104+
public Exception getException() {
105+
return exception;
106+
}
107+
96108
public boolean isLoggedIn() {
97109
return loggedIn;
98110
}

android-core/src/main/java/com/mparticle/identity/MParticleIdentityClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private IdentityHttpResponse parseIdentityResponse(int httpCode, JSONObject json
250250
}
251251
return httpResponse;
252252
} catch (JSONException e) {
253-
return new IdentityHttpResponse(httpCode, e.getMessage());
253+
return new IdentityHttpResponse(httpCode, e);
254254
}
255255
}
256256

android-core/src/main/java/com/mparticle/internal/MParticleApiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public AliasNetworkResponse(int responseCode) {
3030
this(responseCode, null);
3131
}
3232

33-
AliasNetworkResponse(int responseCode, String errorMessage) {
33+
public AliasNetworkResponse(int responseCode, String errorMessage) {
3434
this.responseCode = responseCode;
3535
this.errorMessage = errorMessage;
3636
}

android-core/src/main/java/com/mparticle/internal/MParticleApiClientImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class MParticleApiClientImpl extends MParticleBaseClientImpl implements M
6868
private final String mApiKey;
6969
private final Context mContext;
7070
Integer mDeviceRampNumber = null;
71-
private static String sSupportedKits;
71+
private String supportedKits;
7272
private JSONObject mCurrentCookies;
7373

7474
/**
@@ -104,8 +104,8 @@ void setConfigUrl(MPUrl configUrl) {
104104
mConfigUrl = configUrl;
105105
}
106106

107-
static void setSupportedKitString(String supportedKitString) {
108-
sSupportedKits = supportedKitString;
107+
void setSupportedKitString(String supportedKitString) {
108+
supportedKits = supportedKitString;
109109
}
110110

111111

@@ -415,7 +415,7 @@ private void checkRampValue() throws MPRampException {
415415
}
416416

417417
private String getSupportedKitString(){
418-
if (sSupportedKits == null) {
418+
if (supportedKits == null) {
419419
MParticle instance = MParticle.getInstance();
420420
if (instance != null) {
421421
Set<Integer> supportedKitIds = instance.Internal().getKitManager().getSupportedKits();
@@ -429,13 +429,13 @@ private String getSupportedKitString(){
429429
buffer.append(",");
430430
}
431431
}
432-
sSupportedKits = buffer.toString();
432+
supportedKits = buffer.toString();
433433
}
434434
} else {
435-
sSupportedKits = "";
435+
supportedKits = "";
436436
}
437437
}
438-
return sSupportedKits;
438+
return supportedKits;
439439
}
440440

441441
public void setCookies(JSONObject serverCookies) {

android-core/src/main/java/com/mparticle/internal/UploadHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.Context;
44
import android.content.SharedPreferences;
5-
import android.os.Handler;
65
import android.os.Looper;
76
import android.os.Message;
87

@@ -17,7 +16,6 @@
1716
import com.mparticle.segmentation.SegmentListener;
1817

1918
import org.json.JSONException;
20-
import org.json.JSONObject;
2119

2220
import java.io.IOException;
2321
import java.net.MalformedURLException;

android-core/src/main/java/com/mparticle/networking/NetworkOptionsManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static NetworkOptions validateAndResolve(NetworkOptions networkOptions) {
3939
}
4040

4141

42-
static NetworkOptions defaultNetworkOptions() {
42+
public static NetworkOptions defaultNetworkOptions() {
4343
return NetworkOptions.builder()
4444
.addDomainMapping(DomainMapping.identityMapping(getDefaultUrl(Endpoint.IDENTITY))
4545
.setCertificates(defaultCertificates)

android-core/src/test/java/com/mparticle/MockMParticle.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class MockMParticle extends MParticle {
1919

2020
public MockMParticle() {
2121
mAppContext = new MockContext();
22-
mInternal = new Internal();
22+
mInternal = Mockito.mock(Internal.class);
2323
mConfigManager = Mockito.mock(ConfigManager.class);
2424
mKitManager = Mockito.mock(KitFrameworkWrapper.class);
2525
mAppStateManager = Mockito.mock(AppStateManager.class);
@@ -29,12 +29,13 @@ public MockMParticle() {
2929
mMessageManager = Mockito.mock(MessageManager.class);
3030
mMessaging = Mockito.mock(MPMessagingAPI.class);
3131
mMedia = Mockito.mock(MPMediaAPI.class);
32-
mIdentityApi = new IdentityApi(new MockContext(), mAppStateManager, mMessageManager, Internal().getConfigManager(), mKitManager, OperatingSystem.ANDROID);
3332
Mockito.when(mKitManager.updateKits(Mockito.any())).thenReturn(new KitsLoadedCallback());
34-
MPEvent event = new MPEvent.Builder("this")
35-
.customAttributes(new HashMap<String, String>())
36-
.build();
37-
Map<String, ?> attributes = event.getCustomAttributes();
33+
Mockito.when(mInternal.getAppStateManager()).thenReturn(mAppStateManager);
34+
Mockito.when(mInternal.getConfigManager()).thenReturn(mConfigManager);
35+
Mockito.when(mInternal.getKitManager()).thenReturn(mKitManager);
36+
Mockito.when(mInternal.getMessageManager()).thenReturn(mMessageManager);
37+
mIdentityApi = new IdentityApi(new MockContext(), mAppStateManager, mMessageManager, Internal().getConfigManager(), mKitManager, OperatingSystem.ANDROID);
38+
3839
}
3940

4041

0 commit comments

Comments
 (0)