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: add required fields to mobile config #670

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

sobolk
Copy link
Member

@sobolk sobolk commented Nov 16, 2023

Issue #, if available:

Description of changes:

This PR adds necessary fields for mobile authenticator to work.

Tested with the following app.

package dev.salih.myamplifyapp

import android.app.Application
import android.util.Log
import com.amplifyframework.AmplifyException
import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin
import com.amplifyframework.core.Amplify

class MyAmplifyApp: Application() {
    override fun onCreate() {
        super.onCreate()

        try {
            Log.i("MyAmplifyApp", "Before initializing Amplify")
            Amplify.addPlugin(AWSCognitoAuthPlugin())
            Amplify.configure(applicationContext)
            Log.i("MyAmplifyApp", "Initialized Amplify")
        } catch (error: AmplifyException) {
            Log.e("MyAmplifyApp", "Could not initialize Amplify", error)
        }
    }
}
package dev.salih.myamplifyapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.amplifyframework.ui.authenticator.ui.Authenticator
import dev.salih.myamplifyapp.ui.theme.MyAmplifyAppTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MyAmplifyAppTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Authenticator { state ->
                        Greeting(state.user.username)
                    }
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    MyAmplifyAppTheme {
        Greeting("Android")
    }
}

Authenticator rendered and appears to be working:
image
image
image

Log after change:

2023-11-15 20:39:22.185 21285-21285 ziparchive              dev.salih.myamplifyapp               W  Unable to open '/data/app/~~vgkWezzuBqrE8HTQU552UQ==/dev.salih.myamplifyapp-CXTcKrhVgOlk6Dlqg0INfg==/base.dm': No such file or directory
2023-11-15 20:39:22.185 21285-21285 ziparchive              dev.salih.myamplifyapp               W  Unable to open '/data/app/~~vgkWezzuBqrE8HTQU552UQ==/dev.salih.myamplifyapp-CXTcKrhVgOlk6Dlqg0INfg==/base.dm': No such file or directory
2023-11-15 20:39:22.505 21285-21285 nativeloader            dev.salih.myamplifyapp               D  Configuring clns-6 for other apk /data/app/~~vgkWezzuBqrE8HTQU552UQ==/dev.salih.myamplifyapp-CXTcKrhVgOlk6Dlqg0INfg==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~vgkWezzuBqrE8HTQU552UQ==/dev.salih.myamplifyapp-CXTcKrhVgOlk6Dlqg0INfg==/lib/arm64, permitted_path=/data:/mnt/expand:/data/user/0/dev.salih.myamplifyapp
2023-11-15 20:39:22.512 21285-21285 GraphicsEnvironment     dev.salih.myamplifyapp               V  Currently set values for:
2023-11-15 20:39:22.512 21285-21285 GraphicsEnvironment     dev.salih.myamplifyapp               V    angle_gl_driver_selection_pkgs=[]
2023-11-15 20:39:22.513 21285-21285 GraphicsEnvironment     dev.salih.myamplifyapp               V    angle_gl_driver_selection_values=[]
2023-11-15 20:39:22.516 21285-21285 GraphicsEnvironment     dev.salih.myamplifyapp               V  ANGLE GameManagerService for dev.salih.myamplifyapp: false
2023-11-15 20:39:22.516 21285-21285 GraphicsEnvironment     dev.salih.myamplifyapp               V  dev.salih.myamplifyapp is not listed in per-application setting
2023-11-15 20:39:22.516 21285-21285 GraphicsEnvironment     dev.salih.myamplifyapp               V  Neither updatable production driver nor prerelease driver is supported.
2023-11-15 20:39:22.528 21285-21285 MyAmplifyApp            dev.salih.myamplifyapp               I  Before initializing Amplify
2023-11-15 20:39:22.621 21285-21285 MyAmplifyApp            dev.salih.myamplifyapp               I  Initialized Amplify
2023-11-15 20:39:22.653 21285-21307 libEGL                  dev.salih.myamplifyapp               D  loaded /vendor/lib64/egl/libEGL_emulation.so
2023-11-15 20:39:22.658 21285-21307 libEGL                  dev.salih.myamplifyapp               D  loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
2023-11-15 20:39:22.660 21285-21285 Compatibil...geReporter dev.salih.myamplifyapp               D  Compat change id reported: 237531167; UID 10191; state: DISABLED
2023-11-15 20:39:22.662 21285-21285 OpenGLRenderer          dev.salih.myamplifyapp               W  Unknown dataspace 0
2023-11-15 20:39:22.666 21285-21307 libEGL                  dev.salih.myamplifyapp               D  loaded /vendor/lib64/egl/libGLESv2_emulation.so
2023-11-15 20:39:22.732 21285-21285 ih.myamplifyapp         dev.salih.myamplifyapp               W  Method java.lang.Object androidx.compose.runtime.snapshots.SnapshotStateMap.mutate(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
                                                                                                    Common causes for lock verification issues are non-optimized dex code
                                                                                                    and incorrect proguard optimizations.
2023-11-15 20:39:22.733 21285-21285 ih.myamplifyapp         dev.salih.myamplifyapp               W  Method void androidx.compose.runtime.snapshots.SnapshotStateMap.update(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
2023-11-15 20:39:22.734 21285-21285 ih.myamplifyapp         dev.salih.myamplifyapp               W  Method boolean androidx.compose.runtime.snapshots.SnapshotStateMap.removeIf$runtime_release(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
2023-11-15 20:39:22.813 21285-21302 EngineFactory           dev.salih.myamplifyapp               I  Provider GmsCore_OpenSSL not available
2023-11-15 20:39:22.828 21285-21285 ih.myamplifyapp         dev.salih.myamplifyapp               W  Method boolean androidx.compose.runtime.snapshots.SnapshotStateList.conditionalUpdate(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
2023-11-15 20:39:22.829 21285-21285 ih.myamplifyapp         dev.salih.myamplifyapp               W  Method java.lang.Object androidx.compose.runtime.snapshots.SnapshotStateList.mutate(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
2023-11-15 20:39:22.829 21285-21285 ih.myamplifyapp         dev.salih.myamplifyapp               W  Method void androidx.compose.runtime.snapshots.SnapshotStateList.update(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
2023-11-15 20:39:22.844 21285-21285 Compatibil...geReporter dev.salih.myamplifyapp               D  Compat change id reported: 171228096; UID 10191; state: ENABLED
2023-11-15 20:39:22.907 21285-21305 OpenGLRenderer          dev.salih.myamplifyapp               W  Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2023-11-15 20:39:22.908 21285-21305 OpenGLRenderer          dev.salih.myamplifyapp               W  Failed to initialize 101010-2 format, error = EGL_SUCCESS
2023-11-15 20:39:22.920 21285-21305 Gralloc4                dev.salih.myamplifyapp               I  mapper 4.x is not supported
2023-11-15 20:39:22.928 21285-21305 OpenGLRenderer          dev.salih.myamplifyapp               E  Unable to match the desired swap behavior.
2023-11-15 20:39:23.027 21285-21301 System.err              dev.salih.myamplifyapp               W  SLF4J: No SLF4J providers were found.
2023-11-15 20:39:23.042 21285-21301 System.err              dev.salih.myamplifyapp               W  SLF4J: Defaulting to no-operation (NOP) logger implementation
2023-11-15 20:39:23.043 21285-21301 System.err              dev.salih.myamplifyapp               W  SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
2023-11-15 20:39:23.446 21285-21301 ih.myamplifyapp         dev.salih.myamplifyapp               W  Verification of java.util.List kotlin.text.StringsKt___StringsKt.windowed(java.lang.CharSequence, int, int, boolean) took 185.969ms (75.28 bytecodes/s) (1704B approximate peak alloc)
2023-11-15 20:39:23.665 21285-21331 TrafficStats            dev.salih.myamplifyapp               D  tagSocket(97) with statsTag=0xffffffff, statsUid=-1
2023-11-15 20:39:23.678 21285-21331 TrafficStats            dev.salih.myamplifyapp               D  tagSocket(97) with statsTag=0xffffffff, statsUid=-1
2023-11-15 20:39:23.989 21285-21285 Compatibil...geReporter dev.salih.myamplifyapp               D  Compat change id reported: 289878283; UID 10191; state: DISABLED
2023-11-15 20:39:24.187 21285-21305 EGL_emulation           dev.salih.myamplifyapp               D  app_time_stats: avg=18.86ms min=0.88ms max=237.74ms count=39

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

changeset-bot bot commented Nov 16, 2023

🦋 Changeset detected

Latest commit: 2f6d958

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@aws-amplify/client-config Patch
@aws-amplify/sandbox Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Amplifiyer
Copy link
Contributor

Any possibility for adding e2e tests for mobile configs?

@sobolk
Copy link
Member Author

sobolk commented Nov 16, 2023

Any possibility for adding e2e tests for mobile configs?

With mobile app and simulator? If so, I'd rather not do that. The problem is solvable by establishing known schema and both sides keeping the contract. The problem now is that we're reverse engineering current schema.
Going for real mobile app is possible but hopefully we won't have to do that - it's gonna be heavy solution.

@sobolk sobolk merged commit 50934da into main Nov 16, 2023
20 checks passed
@sobolk sobolk deleted the add-more-fields-to-mobile-config branch November 16, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants