Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1416 - Wrap flow params into a Bundle to avoid a ClassNotFoundEx… #1453

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.firebase.ui.auth.data.model;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.DrawableRes;
Expand Down Expand Up @@ -86,8 +87,14 @@ public FlowParameters(
*/
public static FlowParameters fromIntent(Intent intent) {
//this is required to fix #1416 - ClassNotFound for FlowParameters
intent.setExtrasClassLoader(AuthUI.class.getClassLoader());
return intent.getParcelableExtra(ExtraConstants.FLOW_PARAMS);
Bundle bundle = intent.getBundleExtra(ExtraConstants.FLOW_BUNDLE);
return bundle.getParcelable(ExtraConstants.FLOW_PARAMS);
}

public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelable(ExtraConstants.FLOW_PARAMS, this);
return bundle;
}

@Override
Expand Down Expand Up @@ -154,4 +161,5 @@ public boolean isPrivacyPolicyUrlProvided() {
public boolean isAnonymousUpgradeEnabled() {
return enableAnonymousUpgrade;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ protected static Intent createBaseIntent(
return new Intent(
checkNotNull(context, "context cannot be null"),
checkNotNull(target, "target activity cannot be null"))
.putExtra(ExtraConstants.FLOW_PARAMS,
checkNotNull(flowParams, "flowParams cannot be null"));
.putExtra(ExtraConstants.FLOW_BUNDLE,
checkNotNull(flowParams, "flowParams cannot be null").toBundle());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final class ExtraConstants {
public static final String FLOW_BUNDLE = "extra_flow_bundle";
public static final String FLOW_PARAMS = "extra_flow_params";
public static final String IDP_RESPONSE = "extra_idp_response";
public static final String USER = "extra_user";
Expand Down
10 changes: 4 additions & 6 deletions auth/src/test/java/com/firebase/ui/auth/AuthUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ public void setUp() {

@Test
public void testCreateStartIntent_shouldHaveEmailAsDefaultProvider() {
FlowParameters flowParameters = mAuthUi
FlowParameters flowParameters = FlowParameters.fromIntent(mAuthUi
.createSignInIntentBuilder()
.build()
.getParcelableExtra(ExtraConstants.FLOW_PARAMS);
.build());
assertEquals(1, flowParameters.providers.size());
assertEquals(EmailAuthProvider.PROVIDER_ID,
flowParameters.providers.get(0).getProviderId());
Expand All @@ -64,16 +63,15 @@ public void testCreateStartIntent_shouldOnlyAllowOneInstanceOfAnIdp() {

@Test
public void testCreatingStartIntent() {
FlowParameters flowParameters = mAuthUi
FlowParameters flowParameters = FlowParameters.fromIntent(mAuthUi
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(
new IdpConfig.EmailBuilder().build(),
new IdpConfig.GoogleBuilder().build(),
new IdpConfig.FacebookBuilder().build(),
new IdpConfig.AnonymousBuilder().build()))
.setTosAndPrivacyPolicyUrls(TestConstants.TOS_URL, TestConstants.PRIVACY_URL)
.build()
.getParcelableExtra(ExtraConstants.FLOW_PARAMS);
.build());

assertEquals(4, flowParameters.providers.size());
assertEquals(TestHelper.MOCK_APP.getName(), flowParameters.appName);
Expand Down