.class public Lbolts/WebViewAppLinkResolver; .super Ljava/lang/Object; .source "WebViewAppLinkResolver.java" # interfaces .implements Lbolts/AppLinkResolver; # static fields .field private static final KEY_AL_VALUE:Ljava/lang/String; = "value" .field private static final KEY_ANDROID:Ljava/lang/String; = "android" .field private static final KEY_APP_NAME:Ljava/lang/String; = "app_name" .field private static final KEY_CLASS:Ljava/lang/String; = "class" .field private static final KEY_PACKAGE:Ljava/lang/String; = "package" .field private static final KEY_SHOULD_FALLBACK:Ljava/lang/String; = "should_fallback" .field private static final KEY_URL:Ljava/lang/String; = "url" .field private static final KEY_WEB:Ljava/lang/String; = "web" .field private static final KEY_WEB_URL:Ljava/lang/String; = "url" .field private static final META_TAG_PREFIX:Ljava/lang/String; = "al" .field private static final PREFER_HEADER:Ljava/lang/String; = "Prefer-Html-Meta-Tags" .field private static final TAG_EXTRACTION_JAVASCRIPT:Ljava/lang/String; = "javascript:boltsWebViewAppLinkResolverResult.setValue((function() { var metaTags = document.getElementsByTagName(\'meta\'); var results = []; for (var i = 0; i < metaTags.length; i++) { var property = metaTags[i].getAttribute(\'property\'); if (property && property.substring(0, \'al:\'.length) === \'al:\') { var tag = { \"property\": metaTags[i].getAttribute(\'property\') }; if (metaTags[i].hasAttribute(\'content\')) { tag[\'content\'] = metaTags[i].getAttribute(\'content\'); } results.push(tag); } } return JSON.stringify(results);})())" # instance fields .field private final context:Landroid/content/Context; # direct methods .method public constructor (Landroid/content/Context;)V .locals 0 .prologue .line 48 invoke-direct {p0}, Ljava/lang/Object;->()V .line 49 iput-object p1, p0, Lbolts/WebViewAppLinkResolver;->context:Landroid/content/Context; .line 50 return-void .end method .method static synthetic access$000(Lorg/json/JSONArray;)Ljava/util/Map; .locals 1 .prologue .line 40 invoke-static {p0}, Lbolts/WebViewAppLinkResolver;->parseAlData(Lorg/json/JSONArray;)Ljava/util/Map; move-result-object v0 return-object v0 .end method .method static synthetic access$100(Ljava/util/Map;Landroid/net/Uri;)Lbolts/AppLink; .locals 1 .prologue .line 40 invoke-static {p0, p1}, Lbolts/WebViewAppLinkResolver;->makeAppLinkFromAlData(Ljava/util/Map;Landroid/net/Uri;)Lbolts/AppLink; move-result-object v0 return-object v0 .end method .method static synthetic access$200(Lbolts/WebViewAppLinkResolver;)Landroid/content/Context; .locals 1 .prologue .line 40 iget-object v0, p0, Lbolts/WebViewAppLinkResolver;->context:Landroid/content/Context; return-object v0 .end method .method static synthetic access$300(Ljava/net/URLConnection;)Ljava/lang/String; .locals 1 .prologue .line 40 invoke-static {p0}, Lbolts/WebViewAppLinkResolver;->readFromConnection(Ljava/net/URLConnection;)Ljava/lang/String; move-result-object v0 return-object v0 .end method .method private static getAlList(Ljava/util/Map;Ljava/lang/String;)Ljava/util/List; .locals 1 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/util/Map", "<", "Ljava/lang/String;", "Ljava/lang/Object;", ">;", "Ljava/lang/String;", ")", "Ljava/util/List", "<", "Ljava/util/Map", "<", "Ljava/lang/String;", "Ljava/lang/Object;", ">;>;" } .end annotation .prologue .line 231 invoke-interface {p0, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/List; .line 232 if-nez v0, :cond_0 .line 233 invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List; move-result-object v0 .line 235 :cond_0 return-object v0 .end method .method private static makeAppLinkFromAlData(Ljava/util/Map;Landroid/net/Uri;)Lbolts/AppLink; .locals 13 .annotation system Ldalvik/annotation/Signature; value = { "(", "Ljava/util/Map", "<", "Ljava/lang/String;", "Ljava/lang/Object;", ">;", "Landroid/net/Uri;", ")", "Lbolts/AppLink;" } .end annotation .prologue .line 240 new-instance v4, Ljava/util/ArrayList; invoke-direct {v4}, Ljava/util/ArrayList;->()V .line 241 const-string v0, "android" invoke-interface {p0, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/List; .line 243 if-nez v0, :cond_0 .line 244 invoke-static {}, Ljava/util/Collections;->emptyList()Ljava/util/List; move-result-object v0 .line 246 :cond_0 invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator; move-result-object v5 :cond_1 invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z move-result v0 if-eqz v0, :cond_6 invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; .line 249 const-string v1, "url" invoke-static {v0, v1}, Lbolts/WebViewAppLinkResolver;->getAlList(Ljava/util/Map;Ljava/lang/String;)Ljava/util/List; move-result-object v6 .line 250 const-string v1, "package" invoke-static {v0, v1}, Lbolts/WebViewAppLinkResolver;->getAlList(Ljava/util/Map;Ljava/lang/String;)Ljava/util/List; move-result-object v7 .line 251 const-string v1, "class" invoke-static {v0, v1}, Lbolts/WebViewAppLinkResolver;->getAlList(Ljava/util/Map;Ljava/lang/String;)Ljava/util/List; move-result-object v8 .line 252 const-string v1, "app_name" invoke-static {v0, v1}, Lbolts/WebViewAppLinkResolver;->getAlList(Ljava/util/Map;Ljava/lang/String;)Ljava/util/List; move-result-object v9 .line 254 invoke-interface {v6}, Ljava/util/List;->size()I move-result v0 invoke-interface {v7}, Ljava/util/List;->size()I move-result v1 invoke-interface {v8}, Ljava/util/List;->size()I move-result v2 invoke-interface {v9}, Ljava/util/List;->size()I move-result v3 invoke-static {v2, v3}, Ljava/lang/Math;->max(II)I move-result v2 invoke-static {v1, v2}, Ljava/lang/Math;->max(II)I move-result v1 invoke-static {v0, v1}, Ljava/lang/Math;->max(II)I move-result v10 .line 256 const/4 v0, 0x0 move v3, v0 :goto_0 if-ge v3, v10, :cond_1 .line 257 invoke-interface {v6}, Ljava/util/List;->size()I move-result v0 if-le v0, v3, :cond_2 invoke-interface {v6, v3}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; const-string v1, "value" invoke-interface {v0, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 :goto_1 check-cast v0, Ljava/lang/String; check-cast v0, Ljava/lang/String; .line 259 invoke-static {v0}, Lbolts/WebViewAppLinkResolver;->tryCreateUrl(Ljava/lang/String;)Landroid/net/Uri; move-result-object v11 .line 260 invoke-interface {v7}, Ljava/util/List;->size()I move-result v0 if-le v0, v3, :cond_3 invoke-interface {v7, v3}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; const-string v1, "value" invoke-interface {v0, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 :goto_2 check-cast v0, Ljava/lang/String; check-cast v0, Ljava/lang/String; .line 262 invoke-interface {v8}, Ljava/util/List;->size()I move-result v1 if-le v1, v3, :cond_4 invoke-interface {v8, v3}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v1 check-cast v1, Ljava/util/Map; const-string v2, "value" invoke-interface {v1, v2}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v1 :goto_3 check-cast v1, Ljava/lang/String; check-cast v1, Ljava/lang/String; .line 264 invoke-interface {v9}, Ljava/util/List;->size()I move-result v2 if-le v2, v3, :cond_5 invoke-interface {v9, v3}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v2 check-cast v2, Ljava/util/Map; const-string v12, "value" invoke-interface {v2, v12}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v2 :goto_4 check-cast v2, Ljava/lang/String; check-cast v2, Ljava/lang/String; .line 266 new-instance v12, Lbolts/AppLink$Target; invoke-direct {v12, v0, v1, v11, v2}, Lbolts/AppLink$Target;->(Ljava/lang/String;Ljava/lang/String;Landroid/net/Uri;Ljava/lang/String;)V .line 267 invoke-interface {v4, v12}, Ljava/util/List;->add(Ljava/lang/Object;)Z .line 256 add-int/lit8 v0, v3, 0x1 move v3, v0 goto :goto_0 .line 257 :cond_2 const/4 v0, 0x0 goto :goto_1 .line 260 :cond_3 const/4 v0, 0x0 goto :goto_2 .line 262 :cond_4 const/4 v1, 0x0 goto :goto_3 .line 264 :cond_5 const/4 v2, 0x0 goto :goto_4 .line 272 :cond_6 const-string v0, "web" invoke-interface {p0, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/List; .line 273 if-eqz v0, :cond_9 invoke-interface {v0}, Ljava/util/List;->size()I move-result v1 if-lez v1, :cond_9 .line 274 const/4 v1, 0x0 invoke-interface {v0, v1}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; .line 275 const-string v1, "url" invoke-interface {v0, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v1 check-cast v1, Ljava/util/List; .line 276 const-string v2, "should_fallback" invoke-interface {v0, v2}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/List; .line 278 if-eqz v0, :cond_8 invoke-interface {v0}, Ljava/util/List;->size()I move-result v2 if-lez v2, :cond_8 .line 279 const/4 v2, 0x0 invoke-interface {v0, v2}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; const-string v2, "value" invoke-interface {v0, v2}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/lang/String; .line 280 const/4 v2, 0x3 new-array v2, v2, [Ljava/lang/String; const/4 v3, 0x0 const-string v5, "no" aput-object v5, v2, v3 const/4 v3, 0x1 const-string v5, "false" aput-object v5, v2, v3 const/4 v3, 0x2 const-string v5, "0" aput-object v5, v2, v3 invoke-static {v2}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List; move-result-object v2 invoke-virtual {v0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String; move-result-object v0 invoke-interface {v2, v0}, Ljava/util/List;->contains(Ljava/lang/Object;)Z move-result v0 if-eqz v0, :cond_8 .line 281 const/4 v0, 0x0 .line 284 :goto_5 if-eqz v0, :cond_7 if-eqz v1, :cond_7 invoke-interface {v1}, Ljava/util/List;->size()I move-result v2 if-lez v2, :cond_7 .line 285 const/4 v0, 0x0 invoke-interface {v1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; const-string v1, "value" invoke-interface {v0, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/lang/String; .line 286 invoke-static {v0}, Lbolts/WebViewAppLinkResolver;->tryCreateUrl(Ljava/lang/String;)Landroid/net/Uri; move-result-object v0 .line 289 :cond_7 :goto_6 new-instance v1, Lbolts/AppLink; invoke-direct {v1, p1, v4, v0}, Lbolts/AppLink;->(Landroid/net/Uri;Ljava/util/List;Landroid/net/Uri;)V return-object v1 :cond_8 move-object v0, p1 goto :goto_5 :cond_9 move-object v0, p1 goto :goto_6 .end method .method private static parseAlData(Lorg/json/JSONArray;)Ljava/util/Map; .locals 10 .annotation system Ldalvik/annotation/Signature; value = { "(", "Lorg/json/JSONArray;", ")", "Ljava/util/Map", "<", "Ljava/lang/String;", "Ljava/lang/Object;", ">;" } .end annotation .prologue const/4 v6, 0x0 const/4 v2, 0x0 .line 194 new-instance v5, Ljava/util/HashMap; invoke-direct {v5}, Ljava/util/HashMap;->()V move v1, v2 .line 195 :goto_0 invoke-virtual {p0}, Lorg/json/JSONArray;->length()I move-result v0 if-ge v1, v0, :cond_6 .line 196 invoke-virtual {p0, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject; move-result-object v7 .line 197 const-string v0, "property" invoke-virtual {v7, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String; move-result-object v0 .line 198 const-string v3, ":" invoke-virtual {v0, v3}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String; move-result-object v8 .line 199 aget-object v0, v8, v2 const-string v3, "al" invoke-virtual {v0, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z move-result v0 if-nez v0, :cond_1 .line 195 :cond_0 :goto_1 add-int/lit8 v0, v1, 0x1 move v1, v0 goto :goto_0 .line 203 :cond_1 const/4 v0, 0x1 move v3, v0 move-object v4, v5 :goto_2 array-length v0, v8 if-ge v3, v0, :cond_4 .line 205 aget-object v0, v8, v3 invoke-interface {v4, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/List; .line 207 if-nez v0, :cond_8 .line 208 new-instance v0, Ljava/util/ArrayList; invoke-direct {v0}, Ljava/util/ArrayList;->()V .line 209 aget-object v9, v8, v3 invoke-interface {v4, v9, v0}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; move-object v4, v0 .line 211 :goto_3 invoke-interface {v4}, Ljava/util/List;->size()I move-result v0 if-lez v0, :cond_3 invoke-interface {v4}, Ljava/util/List;->size()I move-result v0 add-int/lit8 v0, v0, -0x1 invoke-interface {v4, v0}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v0 check-cast v0, Ljava/util/Map; .line 212 :goto_4 if-eqz v0, :cond_2 array-length v9, v8 add-int/lit8 v9, v9, -0x1 if-ne v3, v9, :cond_7 .line 213 :cond_2 new-instance v0, Ljava/util/HashMap; invoke-direct {v0}, Ljava/util/HashMap;->()V .line 214 invoke-interface {v4, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z move-object v4, v0 .line 203 :goto_5 add-int/lit8 v0, v3, 0x1 move v3, v0 goto :goto_2 :cond_3 move-object v0, v6 .line 211 goto :goto_4 .line 218 :cond_4 const-string v0, "content" invoke-virtual {v7, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z move-result v0 if-eqz v0, :cond_0 .line 219 const-string v0, "content" invoke-virtual {v7, v0}, Lorg/json/JSONObject;->isNull(Ljava/lang/String;)Z move-result v0 if-eqz v0, :cond_5 .line 220 const-string v0, "value" invoke-interface {v4, v0, v6}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; goto :goto_1 .line 222 :cond_5 const-string v0, "value" const-string v3, "content" invoke-virtual {v7, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String; move-result-object v3 invoke-interface {v4, v0, v3}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; goto :goto_1 .line 226 :cond_6 return-object v5 :cond_7 move-object v4, v0 goto :goto_5 :cond_8 move-object v4, v0 goto :goto_3 .end method .method private static readFromConnection(Ljava/net/URLConnection;)Ljava/lang/String; .locals 8 .prologue const/4 v1, 0x0 .line 305 instance-of v0, p0, Ljava/net/HttpURLConnection; if-eqz v0, :cond_0 move-object v0, p0 .line 306 check-cast v0, Ljava/net/HttpURLConnection; .line 308 :try_start_0 invoke-virtual {p0}, Ljava/net/URLConnection;->getInputStream()Ljava/io/InputStream; :try_end_0 .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0 move-result-object v0 :goto_0 move-object v2, v0 .line 316 :goto_1 :try_start_1 new-instance v3, Ljava/io/ByteArrayOutputStream; invoke-direct {v3}, Ljava/io/ByteArrayOutputStream;->()V .line 317 const/16 v0, 0x400 new-array v0, v0, [B .line 319 :goto_2 invoke-virtual {v2, v0}, Ljava/io/InputStream;->read([B)I move-result v4 const/4 v5, -0x1 if-eq v4, v5, :cond_1 .line 320 const/4 v5, 0x0 invoke-virtual {v3, v0, v5, v4}, Ljava/io/ByteArrayOutputStream;->write([BII)V :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_0 goto :goto_2 .line 339 :catchall_0 move-exception v0 invoke-virtual {v2}, Ljava/io/InputStream;->close()V throw v0 .line 309 :catch_0 move-exception v2 .line 310 invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getErrorStream()Ljava/io/InputStream; move-result-object v0 goto :goto_0 .line 313 :cond_0 invoke-virtual {p0}, Ljava/net/URLConnection;->getInputStream()Ljava/io/InputStream; move-result-object v0 move-object v2, v0 goto :goto_1 .line 322 :cond_1 :try_start_2 invoke-virtual {p0}, Ljava/net/URLConnection;->getContentEncoding()Ljava/lang/String; move-result-object v0 .line 323 if-nez v0, :cond_3 .line 324 invoke-virtual {p0}, Ljava/net/URLConnection;->getContentType()Ljava/lang/String; move-result-object v4 .line 325 const-string v5, ";" invoke-virtual {v4, v5}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String; move-result-object v4 .line 326 array-length v5, v4 :goto_3 if-ge v1, v5, :cond_2 aget-object v6, v4, v1 .line 327 invoke-virtual {v6}, Ljava/lang/String;->trim()Ljava/lang/String; move-result-object v6 .line 328 const-string v7, "charset=" invoke-virtual {v6, v7}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z move-result v7 if-eqz v7, :cond_4 .line 329 const-string v0, "charset=" invoke-virtual {v0}, Ljava/lang/String;->length()I move-result v0 invoke-virtual {v6, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String; move-result-object v0 .line 333 :cond_2 if-nez v0, :cond_3 .line 334 const-string v0, "UTF-8" .line 337 :cond_3 new-instance v1, Ljava/lang/String; invoke-virtual {v3}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B move-result-object v3 invoke-direct {v1, v3, v0}, Ljava/lang/String;->([BLjava/lang/String;)V :try_end_2 .catchall {:try_start_2 .. :try_end_2} :catchall_0 .line 339 invoke-virtual {v2}, Ljava/io/InputStream;->close()V return-object v1 .line 326 :cond_4 add-int/lit8 v1, v1, 0x1 goto :goto_3 .end method .method private static tryCreateUrl(Ljava/lang/String;)Landroid/net/Uri; .locals 1 .prologue .line 293 if-nez p0, :cond_0 .line 294 const/4 v0, 0x0 .line 296 :goto_0 return-object v0 :cond_0 invoke-static {p0}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri; move-result-object v0 goto :goto_0 .end method # virtual methods .method public getAppLinkFromUrlInBackground(Landroid/net/Uri;)Lbolts/Task; .locals 4 .annotation system Ldalvik/annotation/Signature; value = { "(", "Landroid/net/Uri;", ")", "Lbolts/Task", "<", "Lbolts/AppLink;", ">;" } .end annotation .prologue .line 83 new-instance v0, Lbolts/Capture; invoke-direct {v0}, Lbolts/Capture;->()V .line 84 new-instance v1, Lbolts/Capture; invoke-direct {v1}, Lbolts/Capture;->()V .line 85 new-instance v2, Lbolts/WebViewAppLinkResolver$3; invoke-direct {v2, p0, p1, v0, v1}, Lbolts/WebViewAppLinkResolver$3;->(Lbolts/WebViewAppLinkResolver;Landroid/net/Uri;Lbolts/Capture;Lbolts/Capture;)V invoke-static {v2}, Lbolts/Task;->callInBackground(Ljava/util/concurrent/Callable;)Lbolts/Task; move-result-object v2 new-instance v3, Lbolts/WebViewAppLinkResolver$2; invoke-direct {v3, p0, v1, p1, v0}, Lbolts/WebViewAppLinkResolver$2;->(Lbolts/WebViewAppLinkResolver;Lbolts/Capture;Landroid/net/Uri;Lbolts/Capture;)V sget-object v0, Lbolts/Task;->UI_THREAD_EXECUTOR:Ljava/util/concurrent/Executor; invoke-virtual {v2, v3, v0}, Lbolts/Task;->onSuccessTask(Lbolts/Continuation;Ljava/util/concurrent/Executor;)Lbolts/Task; move-result-object v0 new-instance v1, Lbolts/WebViewAppLinkResolver$1; invoke-direct {v1, p0, p1}, Lbolts/WebViewAppLinkResolver$1;->(Lbolts/WebViewAppLinkResolver;Landroid/net/Uri;)V invoke-virtual {v0, v1}, Lbolts/Task;->onSuccess(Lbolts/Continuation;)Lbolts/Task; move-result-object v0 return-object v0 .end method