public static Intent createPlatformServiceIntent(Context context) { for (NativeAppInfo appInfo : facebookAppInfoList) { Intent intent = new Intent(INTENT_ACTION_PLATFORM_SERVICE) .setPackage(appInfo.getPackage()) .addCategory(Intent.CATEGORY_DEFAULT); intent = validateServiceIntent(context, intent, appInfo); if (intent != null) { return intent; } } return null; }
public static Intent createTokenRefreshIntent(Context context) { for (NativeAppInfo appInfo : facebookAppInfoList) { Intent intent = new Intent().setClassName(appInfo.getPackage(), FACEBOOK_TOKEN_REFRESH_ACTIVITY); intent = validateServiceIntent(context, intent, appInfo); if (intent != null) { return intent; } } return null; }
public static Intent createProxyAuthIntent( Context context, String applicationId, List<String> permissions, String e2e, boolean isRerequest, SessionDefaultAudience defaultAudience) { for (NativeAppInfo appInfo : facebookAppInfoList) { Intent intent = new Intent() .setClassName(appInfo.getPackage(), FACEBOOK_PROXY_AUTH_ACTIVITY) .putExtra(FACEBOOK_PROXY_AUTH_APP_ID_KEY, applicationId); if (!Utility.isNullOrEmpty(permissions)) { intent.putExtra(FACEBOOK_PROXY_AUTH_PERMISSIONS_KEY, TextUtils.join(",", permissions)); } if (!Utility.isNullOrEmpty(e2e)) { intent.putExtra(FACEBOOK_PROXY_AUTH_E2E_KEY, e2e); } intent.putExtra( ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN); intent.putExtra( ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE); intent.putExtra( ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, defaultAudience.getNativeProtocolAudience()); if (!Settings.getPlatformCompatibilityEnabled()) { // Override the API Version for Auth intent.putExtra( ServerProtocol.DIALOG_PARAM_LEGACY_OVERRIDE, ServerProtocol.GRAPH_API_VERSION); // Only set the rerequest auth type for non legacy requests if (isRerequest) { intent.putExtra( ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE); } } intent = validateActivityIntent(context, intent, appInfo); if (intent != null) { return intent; } } return null; }
private static Intent findActivityIntent( Context context, String activityAction, String internalAction) { List<NativeAppInfo> list = actionToAppInfoMap.get(internalAction); if (list == null) { return null; } Intent intent = null; for (NativeAppInfo appInfo : list) { intent = new Intent() .setAction(activityAction) .setPackage(appInfo.getPackage()) .addCategory(Intent.CATEGORY_DEFAULT); intent = validateActivityIntent(context, intent, appInfo); if (intent != null) { return intent; } } return intent; }
static Intent validateServiceIntent(Context context, Intent intent, NativeAppInfo appInfo) { if (intent == null) { return null; } ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0); if (resolveInfo == null) { return null; } if (!appInfo.validateSignature(context, resolveInfo.serviceInfo.packageName)) { return null; } return intent; }
private static Uri buildPlatformProviderVersionURI(NativeAppInfo appInfo) { return Uri.parse(CONTENT_SCHEME + appInfo.getPackage() + PLATFORM_PROVIDER_VERSIONS); }