MD5 校验值:d7f913ab91d7343430e85d5ce2e5aff0
Intents.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.mopub.common.util; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v4.media.b; import android.support.v4.media.c; import android.text.TextUtils; import com.mopub.common.BrowserAgentManager; import com.mopub.common.Constants; import com.mopub.common.MoPubBrowser; import com.mopub.common.Preconditions; import com.mopub.common.UrlAction; import com.mopub.common.logging.MoPubLog; import com.mopub.exceptions.IntentNotResolvableException; import com.mopub.exceptions.UrlParseException; import com.ottplay.ottplay.epg.EpgSource; import java.util.Collections; import java.util.HashMap; import java.util.Map; import u.f; public class Intents { public static final Map<String, String> f18875a; static { HashMap hashMap = new HashMap(); hashMap.put("market", "https://play.google.com/store/apps/details?%s"); hashMap.put("amzn", "https://www.amazon.com/gp/mas/dl/android?%s"); f18875a = Collections.unmodifiableMap(hashMap); } private Intents() { } @Deprecated public static boolean canHandleApplicationUrl(Context context, Uri uri) { return false; } @Deprecated public static boolean canHandleApplicationUrl(Context context, Uri uri, boolean z10) { return false; } public static boolean canLaunchApplicationUrl(Context context, Uri uri) { Preconditions.checkNotNull(context); Preconditions.checkNotNull(uri); Intent intent = new Intent("android.intent.action.VIEW", uri); if (deviceCanHandleIntent(context, intent)) { return true; } return (!f18875a.containsKey(intent.getScheme()) || intent.getData() == null || TextUtils.isEmpty(intent.getData().getQuery())) ? false : true; } public static boolean deviceCanHandleIntent(Context context, Intent intent) { try { return !context.getPackageManager().queryIntentActivities(intent, 0).isEmpty(); } catch (NullPointerException unused) { return false; } } public static Uri getPlayStoreUri(Intent intent) { Preconditions.checkNotNull(intent); return Uri.parse("market://details?id=" + intent.getPackage()); } public static Intent getStartActivityIntent(Context context, Class cls, Bundle bundle) { Intent intent = new Intent(context, (Class<?>) cls); if (!(context instanceof Activity)) { intent.addFlags(268435456); } if (bundle != null) { intent.putExtras(bundle); } return intent; } public static Intent intentForNativeBrowserScheme(Uri uri) { Preconditions.checkNotNull(uri); if (!UrlAction.OPEN_NATIVE_BROWSER.shouldTryHandlingUrl(uri)) { throw new UrlParseException(c.a("URI does not have ", BrowserAgentManager.getBrowserAgent() == BrowserAgentManager.BrowserAgent.NATIVE ? "mopubnativebrowser://, https://" : "mopubnativebrowser://", " scheme.")); } if (!"mopubnativebrowser".equalsIgnoreCase(uri.getScheme())) { if (BrowserAgentManager.getBrowserAgent() == BrowserAgentManager.BrowserAgent.NATIVE) { return new Intent("android.intent.action.VIEW", uri); } StringBuilder a10 = b.a("Invalid URI: "); a10.append(uri.toString()); throw new UrlParseException(a10.toString()); } Preconditions.checkNotNull(uri); if (!"navigate".equals(uri.getHost())) { throw new UrlParseException("URL missing 'navigate' host parameter."); } try { String queryParameter = uri.getQueryParameter(EpgSource.EPG_URL); if (queryParameter != null) { return new Intent("android.intent.action.VIEW", Uri.parse(queryParameter)); } throw new UrlParseException("URL missing 'url' query parameter."); } catch (UnsupportedOperationException unused) { MoPubLog.log(MoPubLog.SdkLogEvent.CUSTOM, "Could not handle url: " + uri); throw new UrlParseException("Passed-in URL did not create a hierarchical URI."); } } public static Intent intentForShareTweet(Uri uri) { if (!UrlAction.HANDLE_SHARE_TWEET.shouldTryHandlingUrl(uri)) { throw new UrlParseException("URL does not have mopubshare://tweet? format."); } try { String queryParameter = uri.getQueryParameter("screen_name"); String queryParameter2 = uri.getQueryParameter("tweet_id"); if (TextUtils.isEmpty(queryParameter)) { throw new UrlParseException("URL missing non-empty 'screen_name' query parameter."); } if (TextUtils.isEmpty(queryParameter2)) { throw new UrlParseException("URL missing non-empty 'tweet_id' query parameter."); } String format = String.format("Check out @%s's Tweet: %s", queryParameter, String.format("https://twitter.com/%s/status/%s", queryParameter, queryParameter2)); Intent intent = new Intent("android.intent.action.SEND"); intent.setType("text/plain"); intent.putExtra("android.intent.extra.SUBJECT", format); intent.putExtra("android.intent.extra.TEXT", format); return intent; } catch (UnsupportedOperationException unused) { MoPubLog.log(MoPubLog.SdkLogEvent.CUSTOM, "Could not handle url: " + uri); throw new UrlParseException("Passed-in URL did not create a hierarchical URI."); } } public static void launchActionViewIntent(Context context, Uri uri, String str) { Preconditions.checkNotNull(context); Preconditions.checkNotNull(uri); Intent intent = new Intent("android.intent.action.VIEW", uri); if (!(context instanceof Activity)) { intent.addFlags(268435456); } launchIntentForUserClick(context, intent, str); } public static void launchApplicationIntent(Context context, Intent intent) { Preconditions.checkNotNull(context); Preconditions.checkNotNull(intent); try { String str = "Unable to open intent: " + intent; if (!(context instanceof Activity)) { intent.addFlags(268435456); } launchIntentForUserClick(context, intent, str); } catch (IntentNotResolvableException unused) { String stringExtra = intent.getStringExtra("browser_fallback_url"); if (!TextUtils.isEmpty(stringExtra)) { Uri parse = Uri.parse(stringExtra); if (Constants.HTTPS.equalsIgnoreCase(parse.getScheme())) { showMoPubBrowserForUrl(context, parse, null); return; } else { launchApplicationUrl(context, parse); return; } } if (!f18875a.containsKey(intent.getScheme()) && !TextUtils.isEmpty(intent.getPackage())) { launchApplicationUrl(context, getPlayStoreUri(intent)); } else { StringBuilder a10 = b.a("Device could not handle neither intent nor market url.\nIntent: "); a10.append(intent.toString()); throw new IntentNotResolvableException(a10.toString()); } } } public static void launchApplicationUrl(Context context, Uri uri) { Intent intent = new Intent("android.intent.action.VIEW", uri); Preconditions.checkNotNull(context); Preconditions.checkNotNull(uri); if (deviceCanHandleIntent(context, intent)) { launchApplicationIntent(context, intent); return; } Map<String, String> map = f18875a; if (map.containsKey(intent.getScheme()) && intent.getData() != null && !TextUtils.isEmpty(intent.getData().getQuery())) { launchApplicationIntent(context, new Intent("android.intent.action.VIEW", Uri.parse(String.format(map.get(intent.getScheme()), intent.getData().getQuery())))); return; } throw new IntentNotResolvableException("Could not handle application specific action: " + uri + "\n\tYou may be running in the emulator or another device which does not have the required application."); } public static void launchIntentForUserClick(Context context, Intent intent, String str) { Preconditions.NoThrow.checkNotNull(context); Preconditions.NoThrow.checkNotNull(intent); try { startActivity(context, intent); } catch (IntentNotResolvableException e10) { StringBuilder a10 = f.a(str, "\n"); a10.append(e10.getMessage()); throw new IntentNotResolvableException(a10.toString()); } } public static void showMoPubBrowserForUrl(Context context, Uri uri, String str) { Preconditions.checkNotNull(context); Preconditions.checkNotNull(uri); MoPubLog.log(MoPubLog.SdkLogEvent.CUSTOM, "Final URI to show in browser: " + uri); Bundle bundle = new Bundle(); bundle.putString(MoPubBrowser.DESTINATION_URL_KEY, uri.toString()); if (!TextUtils.isEmpty(str)) { bundle.putString(MoPubBrowser.DSP_CREATIVE_ID, str); } launchIntentForUserClick(context, getStartActivityIntent(context, MoPubBrowser.class, bundle), "Could not show MoPubBrowser for url: " + uri + "\n\tPerhaps you forgot to declare com.mopub.common.MoPubBrowser in your Android manifest file."); } public static void startActivity(Context context, Intent intent) { Preconditions.checkNotNull(context); Preconditions.checkNotNull(intent); if (!(context instanceof Activity)) { intent.addFlags(268435456); } try { context.startActivity(intent); } catch (ActivityNotFoundException e10) { throw new IntentNotResolvableException(e10); } } }