Skip to content

Attempt another fix at Samsung parcelable unmarshalling errors #1452

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

Closed
wants to merge 1 commit into from
Closed
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 All @@ -23,7 +24,6 @@
import android.support.annotation.StyleRes;
import android.text.TextUtils;

import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.AuthUI.IdpConfig;
import com.firebase.ui.auth.util.ExtraConstants;
import com.firebase.ui.auth.util.Preconditions;
Expand Down Expand Up @@ -85,9 +85,15 @@ public FlowParameters(
* Extract FlowParameters from an Intent.
*/
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);
return intent.getBundleExtra(ExtraConstants.FLOW_PARAMS)
.getParcelable(ExtraConstants.FLOW_PARAMS);
}

/** See #1416 */
public Bundle toBundle() {
Bundle b = new Bundle();
b.putParcelable(ExtraConstants.FLOW_PARAMS, this);
return b;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ 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_PARAMS, flowParams.toBundle());
}

@Override
Expand Down
11 changes: 4 additions & 7 deletions auth/src/test/java/com/firebase/ui/auth/AuthUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.firebase.ui.auth.data.model.FlowParameters;
import com.firebase.ui.auth.testhelpers.TestConstants;
import com.firebase.ui.auth.testhelpers.TestHelper;
import com.firebase.ui.auth.util.ExtraConstants;
import com.google.firebase.auth.EmailAuthProvider;

import org.junit.Before;
Expand All @@ -45,10 +44,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 +62,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