Loading core/java/android/credentials/ui/Entry.java +25 −10 Original line number Original line Diff line number Diff line Loading @@ -82,32 +82,46 @@ public class Entry implements Parcelable { public static final String EXTRA_ENTRY_AUTHENTICATION_ACTION = public static final String EXTRA_ENTRY_AUTHENTICATION_ACTION = "android.credentials.ui.extra.ENTRY_AUTHENTICATION_ACTION"; "android.credentials.ui.extra.ENTRY_AUTHENTICATION_ACTION"; // TODO: change to string key + string subkey. @NonNull private final String mKey; private final int mId; @NonNull private final String mSubkey; @NonNull @NonNull private final Slice mSlice; private final Slice mSlice; protected Entry(@NonNull Parcel in) { protected Entry(@NonNull Parcel in) { int entryId = in.readInt(); String key = in.readString8(); String subkey = in.readString8(); Slice slice = Slice.CREATOR.createFromParcel(in); Slice slice = Slice.CREATOR.createFromParcel(in); mId = entryId; mKey = key; AnnotationValidations.validate(NonNull.class, null, mKey); mSubkey = subkey; AnnotationValidations.validate(NonNull.class, null, mSubkey); mSlice = slice; mSlice = slice; AnnotationValidations.validate(NonNull.class, null, mSlice); AnnotationValidations.validate(NonNull.class, null, mSlice); } } public Entry(int id, @NonNull Slice slice) { public Entry(@NonNull String key, @NonNull String subkey, @NonNull Slice slice) { mId = id; mKey = key; mSubkey = subkey; mSlice = slice; mSlice = slice; } } /** /** * Returns the id of this entry that's unique within the context of the CredentialManager * Returns the identifier of this entry that's unique within the context of the CredentialManager * request. * request. */ */ public int getEntryId() { @NonNull return mId; public String getKey() { return mKey; } /** * Returns the sub-identifier of this entry that's unique within the context of the {@code key}. */ @NonNull public String getSubkey() { return mSubkey; } } /** /** Loading @@ -120,7 +134,8 @@ public class Entry implements Parcelable { @Override @Override public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mId); dest.writeString8(mKey); dest.writeString8(mSubkey); mSlice.writeToParcel(dest, flags); mSlice.writeToParcel(dest, flags); } } Loading core/java/android/credentials/ui/UserSelectionDialogResult.java +24 −13 Original line number Original line Diff line number Diff line Loading @@ -54,18 +54,17 @@ public class UserSelectionDialogResult extends BaseDialogResult implements Parce private static final String EXTRA_USER_SELECTION_RESULT = private static final String EXTRA_USER_SELECTION_RESULT = "android.credentials.ui.extra.USER_SELECTION_RESULT"; "android.credentials.ui.extra.USER_SELECTION_RESULT"; @NonNull @NonNull private final String mProviderId; private final String mProviderId; @NonNull private final String mEntryKey; @NonNull private final String mEntrySubkey; // TODO: consider switching to string or other types, depending on the service implementation. private final int mEntryId; public UserSelectionDialogResult( public UserSelectionDialogResult( @NonNull IBinder requestToken, @NonNull String providerId, @NonNull IBinder requestToken, @NonNull String providerId, int entryId) { @NonNull String entryKey, @NonNull String entrySubkey) { super(requestToken); super(requestToken); mProviderId = providerId; mProviderId = providerId; mEntryId = entryId; mEntryKey = entryKey; mEntrySubkey = entrySubkey; } } /** Returns provider package name whose entry was selected by the user. */ /** Returns provider package name whose entry was selected by the user. */ Loading @@ -74,26 +73,38 @@ public class UserSelectionDialogResult extends BaseDialogResult implements Parce return mProviderId; return mProviderId; } } /** Returns the id of the visual entry that the user selected. */ /** Returns the key of the visual entry that the user selected. */ public int getEntryId() { @NonNull return mEntryId; public String getEntryKey() { return mEntryKey; } /** Returns the subkey of the visual entry that the user selected. */ @NonNull public String getEntrySubkey() { return mEntrySubkey; } } protected UserSelectionDialogResult(@NonNull Parcel in) { protected UserSelectionDialogResult(@NonNull Parcel in) { super(in); super(in); String providerId = in.readString8(); String providerId = in.readString8(); int entryId = in.readInt(); String entryKey = in.readString8(); String entrySubkey = in.readString8(); mProviderId = providerId; mProviderId = providerId; AnnotationValidations.validate(NonNull.class, null, mProviderId); AnnotationValidations.validate(NonNull.class, null, mProviderId); mEntryId = entryId; mEntryKey = entryKey; AnnotationValidations.validate(NonNull.class, null, mEntryKey); mEntrySubkey = entrySubkey; AnnotationValidations.validate(NonNull.class, null, mEntrySubkey); } } @Override @Override public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) { super.writeToParcel(dest, flags); super.writeToParcel(dest, flags); dest.writeString8(mProviderId); dest.writeString8(mProviderId); dest.writeInt(mEntryId); dest.writeString8(mEntryKey); dest.writeString8(mEntrySubkey); } } @Override @Override Loading packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt +24 −15 Original line number Original line Diff line number Diff line Loading @@ -71,11 +71,12 @@ class CredentialManagerRepo( resultReceiver?.send(BaseDialogResult.RESULT_CODE_DIALOG_CANCELED, resultData) resultReceiver?.send(BaseDialogResult.RESULT_CODE_DIALOG_CANCELED, resultData) } } fun onOptionSelected(providerPackageName: String, entryId: Int) { fun onOptionSelected(providerPackageName: String, entryKey: String, entrySubkey: String) { val userSelectionDialogResult = UserSelectionDialogResult( val userSelectionDialogResult = UserSelectionDialogResult( requestInfo.token, requestInfo.token, providerPackageName, providerPackageName, entryId entryKey, entrySubkey ) ) val resultData = Bundle() val resultData = Bundle() UserSelectionDialogResult.addToBundle(userSelectionDialogResult, resultData) UserSelectionDialogResult.addToBundle(userSelectionDialogResult, resultData) Loading Loading @@ -137,16 +138,16 @@ class CredentialManagerRepo( Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) .setCredentialEntries( .setCredentialEntries( listOf<Entry>( listOf<Entry>( newEntry(1, "elisa.beckett@gmail.com", "Elisa Backett", newEntry("key1", "subkey-1", "elisa.beckett@gmail.com", "20 passwords and 7 passkeys saved"), "Elisa Backett", "20 passwords and 7 passkeys saved"), newEntry(2, "elisa.work@google.com", "Elisa Backett Work", newEntry("key1", "subkey-2", "elisa.work@google.com", "20 passwords and 7 passkeys saved"), "Elisa Backett Work", "20 passwords and 7 passkeys saved"), ) ) ).setActionChips( ).setActionChips( listOf<Entry>( listOf<Entry>( newEntry(3, "Go to Settings", "", newEntry("key2", "subkey-1", "Go to Settings", "", "20 passwords and 7 passkeys saved"), "20 passwords and 7 passkeys saved"), newEntry(4, "Switch Account", "", newEntry("key2", "subkey-2", "Switch Account", "", "20 passwords and 7 passkeys saved"), "20 passwords and 7 passkeys saved"), ), ), ).build(), ).build(), Loading @@ -156,21 +157,28 @@ class CredentialManagerRepo( Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) .setCredentialEntries( .setCredentialEntries( listOf<Entry>( listOf<Entry>( newEntry(1, "elisa.beckett@dashlane.com", "Elisa Backett", newEntry("key1", "subkey-3", "elisa.beckett@dashlane.com", "20 passwords and 7 passkeys saved"), "Elisa Backett", "20 passwords and 7 passkeys saved"), newEntry(2, "elisa.work@dashlane.com", "Elisa Backett Work", newEntry("key1", "subkey-4", "elisa.work@dashlane.com", "20 passwords and 7 passkeys saved"), "Elisa Backett Work", "20 passwords and 7 passkeys saved"), ) ) ).setActionChips( ).setActionChips( listOf<Entry>( listOf<Entry>( newEntry(3, "Manage Accounts", "Manage your accounts in the dashlane app", newEntry("key2", "subkey-3", "Manage Accounts", "Manage your accounts in the dashlane app", "20 passwords and 7 passkeys saved"), "20 passwords and 7 passkeys saved"), ), ), ).build(), ).build(), ) ) } } private fun newEntry(id: Int, title: String, subtitle: String, usageData: String): Entry { private fun newEntry( key: String, subkey: String, title: String, subtitle: String, usageData: String ): Entry { val slice = Slice.Builder( val slice = Slice.Builder( Entry.CREDENTIAL_MANAGER_ENTRY_URI, SliceSpec(Entry.VERSION, 1) Entry.CREDENTIAL_MANAGER_ENTRY_URI, SliceSpec(Entry.VERSION, 1) ) ) Loading @@ -183,7 +191,8 @@ class CredentialManagerRepo( .addText(usageData, Slice.SUBTYPE_MESSAGE, listOf(Entry.HINT_SUBTITLE)) .addText(usageData, Slice.SUBTYPE_MESSAGE, listOf(Entry.HINT_SUBTITLE)) .build() .build() return Entry( return Entry( id, key, subkey, slice slice ) ) } } Loading packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt +4 −2 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ class GetFlowUtils { ?: context.getDrawable(R.drawable.ic_passkey)!!, ?: context.getDrawable(R.drawable.ic_passkey)!!, title = credentialEntryUi.userName.toString(), title = credentialEntryUi.userName.toString(), subtitle = credentialEntryUi.displayName?.toString() ?: "Unknown display name", subtitle = credentialEntryUi.displayName?.toString() ?: "Unknown display name", id = it.entryId, entryKey = it.key, entrySubkey = it.subkey, usageData = credentialEntryUi.usageData?.toString() ?: "Unknown usageData", usageData = credentialEntryUi.usageData?.toString() ?: "Unknown usageData", ) ) } } Loading Loading @@ -99,7 +100,8 @@ class CreateFlowUtils { ?: context.getDrawable(R.drawable.ic_passkey)!!, ?: context.getDrawable(R.drawable.ic_passkey)!!, title = saveEntryUi.title.toString(), title = saveEntryUi.title.toString(), subtitle = saveEntryUi.subTitle?.toString() ?: "Unknown subtitle", subtitle = saveEntryUi.subTitle?.toString() ?: "Unknown subtitle", id = it.entryId, entryKey = it.key, entrySubkey = it.subkey, usageData = saveEntryUi.usageData?.toString() ?: "Unknown usageData", usageData = saveEntryUi.usageData?.toString() ?: "Unknown usageData", ) ) } } Loading packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,8 @@ data class CreateOptionInfo( val icon: Drawable, val icon: Drawable, val title: String, val title: String, val subtitle: String, val subtitle: String, val id: Int, val entryKey: String, val entrySubkey: String, val usageData: String val usageData: String ) ) Loading Loading
core/java/android/credentials/ui/Entry.java +25 −10 Original line number Original line Diff line number Diff line Loading @@ -82,32 +82,46 @@ public class Entry implements Parcelable { public static final String EXTRA_ENTRY_AUTHENTICATION_ACTION = public static final String EXTRA_ENTRY_AUTHENTICATION_ACTION = "android.credentials.ui.extra.ENTRY_AUTHENTICATION_ACTION"; "android.credentials.ui.extra.ENTRY_AUTHENTICATION_ACTION"; // TODO: change to string key + string subkey. @NonNull private final String mKey; private final int mId; @NonNull private final String mSubkey; @NonNull @NonNull private final Slice mSlice; private final Slice mSlice; protected Entry(@NonNull Parcel in) { protected Entry(@NonNull Parcel in) { int entryId = in.readInt(); String key = in.readString8(); String subkey = in.readString8(); Slice slice = Slice.CREATOR.createFromParcel(in); Slice slice = Slice.CREATOR.createFromParcel(in); mId = entryId; mKey = key; AnnotationValidations.validate(NonNull.class, null, mKey); mSubkey = subkey; AnnotationValidations.validate(NonNull.class, null, mSubkey); mSlice = slice; mSlice = slice; AnnotationValidations.validate(NonNull.class, null, mSlice); AnnotationValidations.validate(NonNull.class, null, mSlice); } } public Entry(int id, @NonNull Slice slice) { public Entry(@NonNull String key, @NonNull String subkey, @NonNull Slice slice) { mId = id; mKey = key; mSubkey = subkey; mSlice = slice; mSlice = slice; } } /** /** * Returns the id of this entry that's unique within the context of the CredentialManager * Returns the identifier of this entry that's unique within the context of the CredentialManager * request. * request. */ */ public int getEntryId() { @NonNull return mId; public String getKey() { return mKey; } /** * Returns the sub-identifier of this entry that's unique within the context of the {@code key}. */ @NonNull public String getSubkey() { return mSubkey; } } /** /** Loading @@ -120,7 +134,8 @@ public class Entry implements Parcelable { @Override @Override public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mId); dest.writeString8(mKey); dest.writeString8(mSubkey); mSlice.writeToParcel(dest, flags); mSlice.writeToParcel(dest, flags); } } Loading
core/java/android/credentials/ui/UserSelectionDialogResult.java +24 −13 Original line number Original line Diff line number Diff line Loading @@ -54,18 +54,17 @@ public class UserSelectionDialogResult extends BaseDialogResult implements Parce private static final String EXTRA_USER_SELECTION_RESULT = private static final String EXTRA_USER_SELECTION_RESULT = "android.credentials.ui.extra.USER_SELECTION_RESULT"; "android.credentials.ui.extra.USER_SELECTION_RESULT"; @NonNull @NonNull private final String mProviderId; private final String mProviderId; @NonNull private final String mEntryKey; @NonNull private final String mEntrySubkey; // TODO: consider switching to string or other types, depending on the service implementation. private final int mEntryId; public UserSelectionDialogResult( public UserSelectionDialogResult( @NonNull IBinder requestToken, @NonNull String providerId, @NonNull IBinder requestToken, @NonNull String providerId, int entryId) { @NonNull String entryKey, @NonNull String entrySubkey) { super(requestToken); super(requestToken); mProviderId = providerId; mProviderId = providerId; mEntryId = entryId; mEntryKey = entryKey; mEntrySubkey = entrySubkey; } } /** Returns provider package name whose entry was selected by the user. */ /** Returns provider package name whose entry was selected by the user. */ Loading @@ -74,26 +73,38 @@ public class UserSelectionDialogResult extends BaseDialogResult implements Parce return mProviderId; return mProviderId; } } /** Returns the id of the visual entry that the user selected. */ /** Returns the key of the visual entry that the user selected. */ public int getEntryId() { @NonNull return mEntryId; public String getEntryKey() { return mEntryKey; } /** Returns the subkey of the visual entry that the user selected. */ @NonNull public String getEntrySubkey() { return mEntrySubkey; } } protected UserSelectionDialogResult(@NonNull Parcel in) { protected UserSelectionDialogResult(@NonNull Parcel in) { super(in); super(in); String providerId = in.readString8(); String providerId = in.readString8(); int entryId = in.readInt(); String entryKey = in.readString8(); String entrySubkey = in.readString8(); mProviderId = providerId; mProviderId = providerId; AnnotationValidations.validate(NonNull.class, null, mProviderId); AnnotationValidations.validate(NonNull.class, null, mProviderId); mEntryId = entryId; mEntryKey = entryKey; AnnotationValidations.validate(NonNull.class, null, mEntryKey); mEntrySubkey = entrySubkey; AnnotationValidations.validate(NonNull.class, null, mEntrySubkey); } } @Override @Override public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) { super.writeToParcel(dest, flags); super.writeToParcel(dest, flags); dest.writeString8(mProviderId); dest.writeString8(mProviderId); dest.writeInt(mEntryId); dest.writeString8(mEntryKey); dest.writeString8(mEntrySubkey); } } @Override @Override Loading
packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt +24 −15 Original line number Original line Diff line number Diff line Loading @@ -71,11 +71,12 @@ class CredentialManagerRepo( resultReceiver?.send(BaseDialogResult.RESULT_CODE_DIALOG_CANCELED, resultData) resultReceiver?.send(BaseDialogResult.RESULT_CODE_DIALOG_CANCELED, resultData) } } fun onOptionSelected(providerPackageName: String, entryId: Int) { fun onOptionSelected(providerPackageName: String, entryKey: String, entrySubkey: String) { val userSelectionDialogResult = UserSelectionDialogResult( val userSelectionDialogResult = UserSelectionDialogResult( requestInfo.token, requestInfo.token, providerPackageName, providerPackageName, entryId entryKey, entrySubkey ) ) val resultData = Bundle() val resultData = Bundle() UserSelectionDialogResult.addToBundle(userSelectionDialogResult, resultData) UserSelectionDialogResult.addToBundle(userSelectionDialogResult, resultData) Loading Loading @@ -137,16 +138,16 @@ class CredentialManagerRepo( Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) .setCredentialEntries( .setCredentialEntries( listOf<Entry>( listOf<Entry>( newEntry(1, "elisa.beckett@gmail.com", "Elisa Backett", newEntry("key1", "subkey-1", "elisa.beckett@gmail.com", "20 passwords and 7 passkeys saved"), "Elisa Backett", "20 passwords and 7 passkeys saved"), newEntry(2, "elisa.work@google.com", "Elisa Backett Work", newEntry("key1", "subkey-2", "elisa.work@google.com", "20 passwords and 7 passkeys saved"), "Elisa Backett Work", "20 passwords and 7 passkeys saved"), ) ) ).setActionChips( ).setActionChips( listOf<Entry>( listOf<Entry>( newEntry(3, "Go to Settings", "", newEntry("key2", "subkey-1", "Go to Settings", "", "20 passwords and 7 passkeys saved"), "20 passwords and 7 passkeys saved"), newEntry(4, "Switch Account", "", newEntry("key2", "subkey-2", "Switch Account", "", "20 passwords and 7 passkeys saved"), "20 passwords and 7 passkeys saved"), ), ), ).build(), ).build(), Loading @@ -156,21 +157,28 @@ class CredentialManagerRepo( Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) Icon.createWithResource(context, R.drawable.ic_launcher_foreground)) .setCredentialEntries( .setCredentialEntries( listOf<Entry>( listOf<Entry>( newEntry(1, "elisa.beckett@dashlane.com", "Elisa Backett", newEntry("key1", "subkey-3", "elisa.beckett@dashlane.com", "20 passwords and 7 passkeys saved"), "Elisa Backett", "20 passwords and 7 passkeys saved"), newEntry(2, "elisa.work@dashlane.com", "Elisa Backett Work", newEntry("key1", "subkey-4", "elisa.work@dashlane.com", "20 passwords and 7 passkeys saved"), "Elisa Backett Work", "20 passwords and 7 passkeys saved"), ) ) ).setActionChips( ).setActionChips( listOf<Entry>( listOf<Entry>( newEntry(3, "Manage Accounts", "Manage your accounts in the dashlane app", newEntry("key2", "subkey-3", "Manage Accounts", "Manage your accounts in the dashlane app", "20 passwords and 7 passkeys saved"), "20 passwords and 7 passkeys saved"), ), ), ).build(), ).build(), ) ) } } private fun newEntry(id: Int, title: String, subtitle: String, usageData: String): Entry { private fun newEntry( key: String, subkey: String, title: String, subtitle: String, usageData: String ): Entry { val slice = Slice.Builder( val slice = Slice.Builder( Entry.CREDENTIAL_MANAGER_ENTRY_URI, SliceSpec(Entry.VERSION, 1) Entry.CREDENTIAL_MANAGER_ENTRY_URI, SliceSpec(Entry.VERSION, 1) ) ) Loading @@ -183,7 +191,8 @@ class CredentialManagerRepo( .addText(usageData, Slice.SUBTYPE_MESSAGE, listOf(Entry.HINT_SUBTITLE)) .addText(usageData, Slice.SUBTYPE_MESSAGE, listOf(Entry.HINT_SUBTITLE)) .build() .build() return Entry( return Entry( id, key, subkey, slice slice ) ) } } Loading
packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt +4 −2 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ class GetFlowUtils { ?: context.getDrawable(R.drawable.ic_passkey)!!, ?: context.getDrawable(R.drawable.ic_passkey)!!, title = credentialEntryUi.userName.toString(), title = credentialEntryUi.userName.toString(), subtitle = credentialEntryUi.displayName?.toString() ?: "Unknown display name", subtitle = credentialEntryUi.displayName?.toString() ?: "Unknown display name", id = it.entryId, entryKey = it.key, entrySubkey = it.subkey, usageData = credentialEntryUi.usageData?.toString() ?: "Unknown usageData", usageData = credentialEntryUi.usageData?.toString() ?: "Unknown usageData", ) ) } } Loading Loading @@ -99,7 +100,8 @@ class CreateFlowUtils { ?: context.getDrawable(R.drawable.ic_passkey)!!, ?: context.getDrawable(R.drawable.ic_passkey)!!, title = saveEntryUi.title.toString(), title = saveEntryUi.title.toString(), subtitle = saveEntryUi.subTitle?.toString() ?: "Unknown subtitle", subtitle = saveEntryUi.subTitle?.toString() ?: "Unknown subtitle", id = it.entryId, entryKey = it.key, entrySubkey = it.subkey, usageData = saveEntryUi.usageData?.toString() ?: "Unknown usageData", usageData = saveEntryUi.usageData?.toString() ?: "Unknown usageData", ) ) } } Loading
packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -30,7 +30,8 @@ data class CreateOptionInfo( val icon: Drawable, val icon: Drawable, val title: String, val title: String, val subtitle: String, val subtitle: String, val id: Int, val entryKey: String, val entrySubkey: String, val usageData: String val usageData: String ) ) Loading