|
31 | 31 | import android.content.ComponentName; |
32 | 32 | import android.content.Context; |
33 | 33 | import android.content.Intent; |
34 | | -import android.content.pm.ResolveInfo; |
35 | 34 | import android.support.annotation.NonNull; |
36 | 35 | import android.support.annotation.Nullable; |
37 | 36 | import android.support.annotation.VisibleForTesting; |
|
44 | 43 | import org.openyolo.api.internal.FinishWithResultActivity; |
45 | 44 | import org.openyolo.api.internal.KnownProviders; |
46 | 45 | import org.openyolo.api.internal.ProviderPickerActivity; |
| 46 | +import org.openyolo.api.internal.ProviderResolver; |
47 | 47 | import org.openyolo.api.persistence.AppSettings; |
48 | 48 | import org.openyolo.api.persistence.internal.AppSettingsImpl; |
49 | 49 | import org.openyolo.protocol.Credential; |
@@ -213,7 +213,8 @@ public Intent getCredentialRetrieveIntent(CredentialRetrieveRequest request) { |
213 | 213 | */ |
214 | 214 | @NonNull |
215 | 215 | public Intent getHintRetrieveIntent(final HintRetrieveRequest request) { |
216 | | - List<ComponentName> hintProviders = findProviders(HINT_CREDENTIAL_ACTION); |
| 216 | + List<ComponentName> hintProviders = |
| 217 | + ProviderResolver.findProviders(mApplicationContext, HINT_CREDENTIAL_ACTION); |
217 | 218 |
|
218 | 219 | if (hintProviders.isEmpty()) { |
219 | 220 | ActivityResult result = ActivityResult.of( |
@@ -282,7 +283,8 @@ public Intent getSaveIntent(final Credential credential) { |
282 | 283 | */ |
283 | 284 | @NonNull |
284 | 285 | public Intent getSaveIntent(final CredentialSaveRequest saveRequest) { |
285 | | - List<ComponentName> saveProviders = findProviders(SAVE_CREDENTIAL_ACTION); |
| 286 | + List<ComponentName> saveProviders = |
| 287 | + ProviderResolver.findProviders(mApplicationContext, SAVE_CREDENTIAL_ACTION); |
286 | 288 |
|
287 | 289 | if (saveProviders.isEmpty()) { |
288 | 290 | ActivityResult result = ActivityResult.of( |
@@ -360,7 +362,7 @@ public Intent getDeleteIntent(@NonNull CredentialDeleteRequest request) { |
360 | 362 | require(request, notNullValue()); |
361 | 363 |
|
362 | 364 | List<ComponentName> deleteProviders = |
363 | | - findProviders(DELETE_CREDENTIAL_ACTION); |
| 365 | + ProviderResolver.findProviders(mApplicationContext, DELETE_CREDENTIAL_ACTION); |
364 | 366 |
|
365 | 367 | if (deleteProviders.isEmpty()) { |
366 | 368 | ActivityResult result = ActivityResult.of( |
@@ -632,23 +634,6 @@ public void disableAutoSignIn() { |
632 | 634 | mDeviceState.setIsAutoSignInDisabled(true); |
633 | 635 | } |
634 | 636 |
|
635 | | - private List<ComponentName> findProviders(@NonNull String action) { |
636 | | - Intent saveIntent = new Intent(action); |
637 | | - saveIntent.addCategory(OPENYOLO_CATEGORY); |
638 | | - |
639 | | - List<ResolveInfo> resolveInfos = |
640 | | - mApplicationContext.getPackageManager().queryIntentActivities(saveIntent, 0); |
641 | | - |
642 | | - ArrayList<ComponentName> responders = new ArrayList<>(); |
643 | | - for (ResolveInfo info : resolveInfos) { |
644 | | - responders.add(new ComponentName( |
645 | | - info.activityInfo.packageName, |
646 | | - info.activityInfo.name)); |
647 | | - } |
648 | | - |
649 | | - return responders; |
650 | | - } |
651 | | - |
652 | 637 | @Nullable |
653 | 638 | private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) { |
654 | 639 | // In the future, the user will be able to explicitly set their preferred provider in |
|
0 commit comments