text:
.class Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;
.super Ljava/lang/Thread;
.source "Vpn.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/android/server/connectivity/Vpn;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "LegacyVpnRunner"
.end annotation

# static fields
.field private static final TAG:Ljava/lang/String; = "LegacyVpnRunner"

# instance fields
.field private final mArguments:[[Ljava/lang/String;

.field private final mBroadcastReceiver:Landroid/content/BroadcastReceiver;

.field private final mDaemons:[Ljava/lang/String;

.field private final mOuterConnection:Ljava/util/concurrent/atomic/AtomicInteger;

.field private final mOuterInterface:Ljava/lang/String;

.field private final mSockets:[Landroid/net/LocalSocket;

.field private mTimer:J

.field final synthetic this$0:Lcom/android/server/connectivity/Vpn;

# direct methods
.method public constructor <init>(Lcom/android/server/connectivity/Vpn;Lcom/android/internal/net/VpnConfig;[Ljava/lang/String;[Ljava/lang/String;)V
    .locals 8
    .param p2, "config"    # Lcom/android/internal/net/VpnConfig;
    .param p3, "racoon"    # [Ljava/lang/String;
    .param p4, "mtpd"    # [Ljava/lang/String;

    .prologue
    const/4 v7, 0x2

    const/4 v6, 0x1

    const/4 v4, 0x0

    const/4 v5, -0x1

    .line 1091
    iput-object p1, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    .line 1092
    const-string v2, "LegacyVpnRunner"

    invoke-direct {p0, v2}, Ljava/lang/Thread;-><init>(Ljava/lang/String;)V

    .line 1063
    new-instance v2, Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-direct {v2, v5}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>(I)V

    iput-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterConnection:Ljava/util/concurrent/atomic/AtomicInteger;

    .line 1066
    const-wide/16 v2, -0x1

    iput-wide v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mTimer:J

    .line 1071
    new-instance v2, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner$1;

    invoke-direct {v2, p0}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner$1;-><init>(Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;)V

    iput-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

    .line 1093
    # setter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static {p1, p2}, Lcom/android/server/connectivity/Vpn;->access$1602(Lcom/android/server/connectivity/Vpn;Lcom/android/internal/net/VpnConfig;)Lcom/android/internal/net/VpnConfig;

    .line 1094
    new-array v2, v7, [Ljava/lang/String;

    const-string v3, "racoon"

    aput-object v3, v2, v4

    const-string v3, "mtpd"

    aput-object v3, v2, v6

    iput-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .line 1096
    new-array v2, v7, [[Ljava/lang/String;

    aput-object p3, v2, v4

    aput-object p4, v2, v6

    iput-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mArguments:[[Ljava/lang/String;

    .line 1097
    iget-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    array-length v2, v2

    new-array v2, v2, [Landroid/net/LocalSocket;

    iput-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    .line 1105
    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static {p1}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v2

    iget-object v2, v2, Lcom/android/internal/net/VpnConfig;->interfaze:Ljava/lang/String;

    iput-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterInterface:Ljava/lang/String;

    .line 1108
    :try_start_0
    iget-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterConnection:Ljava/util/concurrent/atomic/AtomicInteger;

    # getter for: Lcom/android/server/connectivity/Vpn;->mConnService:Landroid/net/IConnectivityManager;
    invoke-static {p1}, Lcom/android/server/connectivity/Vpn;->access$1700(Lcom/android/server/connectivity/Vpn;)Landroid/net/IConnectivityManager;

    move-result-object v3

    iget-object v4, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterInterface:Ljava/lang/String;

    invoke-interface {v3, v4}, Landroid/net/IConnectivityManager;->findConnectionTypeForIface(Ljava/lang/String;)I

    move-result v3

    invoke-virtual {v2, v3}, Ljava/util/concurrent/atomic/AtomicInteger;->set(I)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 1114
    :goto_0
    new-instance v1, Landroid/content/IntentFilter;

    invoke-direct {v1}, Landroid/content/IntentFilter;-><init>()V

    .line 1115
    .local v1, "filter":Landroid/content/IntentFilter;
    const-string v2, "android.net.conn.CONNECTIVITY_CHANGE"

    invoke-virtual {v1, v2}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 1116
    # getter for: Lcom/android/server/connectivity/Vpn;->mContext:Landroid/content/Context;
    invoke-static {p1}, Lcom/android/server/connectivity/Vpn;->access$1000(Lcom/android/server/connectivity/Vpn;)Landroid/content/Context;

    move-result-object v2

    iget-object v3, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v2, v3, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 1117
    return-void

    .line 1110
    .end local v1    # "filter":Landroid/content/IntentFilter;
    :catch_0
    move-exception v0

    .line 1111
    .local v0, "e":Ljava/lang/Exception;
    iget-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterConnection:Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v2, v5}, Ljava/util/concurrent/atomic/AtomicInteger;->set(I)V

    goto :goto_0
.end method

.method static synthetic access$1300(Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;)Ljava/util/concurrent/atomic/AtomicInteger;
    .locals 1
    .param p0, "x0"    # Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;

    .prologue
    .line 1056
    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterConnection:Ljava/util/concurrent/atomic/AtomicInteger;

    return-object v0
.end method

.method static synthetic access$1400(Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;)Ljava/lang/String;
    .locals 1
    .param p0, "x0"    # Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;

    .prologue
    .line 1056
    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterInterface:Ljava/lang/String;

    return-object v0
.end method

.method private checkpoint(Z)V
    .locals 8
    .param p1, "yield"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .prologue
    const-wide/16 v2, 0x1

    .line 1150
    invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J

    move-result-wide v0

    .line 1151
    .local v0, "now":J
    iget-wide v4, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mTimer:J

    const-wide/16 v6, -0x1

    cmp-long v4, v4, v6

    if-nez v4, :cond_0

    .line 1152
    iput-wide v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mTimer:J

    .line 1153
    invoke-static {v2, v3}, Ljava/lang/Thread;->sleep(J)V

    .line 1160
    :goto_0
    return-void

    .line 1154
    :cond_0
    iget-wide v4, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mTimer:J

    sub-long v4, v0, v4

    const-wide/32 v6, 0xea60

    cmp-long v4, v4, v6

    if-gtz v4, :cond_2

    .line 1155
    if-eqz p1, :cond_1

    const-wide/16 v2, 0xc8

    :cond_1
    invoke-static {v2, v3}, Ljava/lang/Thread;->sleep(J)V

    goto :goto_0

    .line 1157
    :cond_2
    iget-object v2, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    sget-object v3, Landroid/net/NetworkInfo$DetailedState;->FAILED:Landroid/net/NetworkInfo$DetailedState;

    const-string v4, "checkpoint"

    # invokes: Lcom/android/server/connectivity/Vpn;->updateState(Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;)V
    invoke-static {v2, v3, v4}, Lcom/android/server/connectivity/Vpn;->access$1800(Lcom/android/server/connectivity/Vpn;Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;)V

    .line 1158
    new-instance v2, Ljava/lang/IllegalStateException;

    const-string v3, "Time is up"

    invoke-direct {v2, v3}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v2
.end method

.method private execute()V
    .locals 28

    .prologue
    .line 1164
    const/16 v17, 0x0

    .line 1167
    .local v17, "initFinished":Z
    const/16 v24, 0x0

    :try_start_0
    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    .line 1170
    move-object/from16 v0, p0

    iget-object v8, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .local v8, "arr$":[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    .local v18, "len$":I
    const/4 v15, 0x0

    .local v15, "i$":I
    :goto_0
    move/from16 v0, v18

    if-ge v15, v0, :cond_1

    aget-object v10, v8, v15

    .line 1171
    .local v10, "daemon":Ljava/lang/String;
    :goto_1
    invoke-static {v10}, Landroid/os/SystemService;->isStopped(Ljava/lang/String;)Z

    move-result v24

    if-nez v24, :cond_0

    .line 1172
    const/16 v24, 0x1

    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_1

    .line 1341
    .end local v8    # "arr$":[Ljava/lang/String;
    .end local v10    # "daemon":Ljava/lang/String;
    .end local v15    # "i$":I
    .end local v18    # "len$":I
    :catch_0
    move-exception v12

    .line 1342
    .local v12, "e":Ljava/lang/Exception;
    :try_start_1
    const-string v24, "LegacyVpnRunner"

    const-string v25, "Aborting"

    move-object/from16 v0, v24

    move-object/from16 v1, v25

    invoke-static {v0, v1, v12}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    .line 1343
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    sget-object v25, Landroid/net/NetworkInfo$DetailedState;->FAILED:Landroid/net/NetworkInfo$DetailedState;

    invoke-virtual {v12}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v26

    # invokes: Lcom/android/server/connectivity/Vpn;->updateState(Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;)V
    invoke-static/range {v24 .. v26}, Lcom/android/server/connectivity/Vpn;->access$1800(Lcom/android/server/connectivity/Vpn;Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;)V

    .line 1344
    invoke-virtual/range {p0 .. p0}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->exit()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 1347
    if-nez v17, :cond_20

    .line 1348
    move-object/from16 v0, p0

    iget-object v8, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .restart local v8    # "arr$":[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    .restart local v18    # "len$":I
    const/4 v15, 0x0

    .restart local v15    # "i$":I
    :goto_2
    move/from16 v0, v18

    if-ge v15, v0, :cond_20

    aget-object v10, v8, v15

    .line 1349
    .restart local v10    # "daemon":Ljava/lang/String;
    invoke-static {v10}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1348
    add-int/lit8 v15, v15, 0x1

    goto :goto_2

    .line 1170
    .end local v12    # "e":Ljava/lang/Exception;
    :cond_0
    add-int/lit8 v15, v15, 0x1

    goto :goto_0

    .line 1177
    .end local v10    # "daemon":Ljava/lang/String;
    :cond_1
    :try_start_2
    new-instance v23, Ljava/io/File;

    const-string v24, "/data/misc/vpn/state"

    invoke-direct/range {v23 .. v24}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 1178
    .local v23, "state":Ljava/io/File;
    invoke-virtual/range {v23 .. v23}, Ljava/io/File;->delete()Z

    .line 1179
    invoke-virtual/range {v23 .. v23}, Ljava/io/File;->exists()Z

    move-result v24

    if-eqz v24, :cond_2

    .line 1180
    new-instance v24, Ljava/lang/IllegalStateException;

    const-string v25, "Cannot delete the state"

    invoke-direct/range {v24 .. v25}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v24
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 1347
    .end local v8    # "arr$":[Ljava/lang/String;
    .end local v15    # "i$":I
    .end local v18    # "len$":I
    .end local v23    # "state":Ljava/io/File;
    :catchall_0
    move-exception v24

    if-nez v17, :cond_22

    .line 1348
    move-object/from16 v0, p0

    iget-object v8, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .restart local v8    # "arr$":[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    .restart local v18    # "len$":I
    const/4 v15, 0x0

    .restart local v15    # "i$":I
    :goto_3
    move/from16 v0, v18

    if-ge v15, v0, :cond_22

    aget-object v10, v8, v15

    .line 1349
    .restart local v10    # "daemon":Ljava/lang/String;
    invoke-static {v10}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1348
    add-int/lit8 v15, v15, 0x1

    goto :goto_3

    .line 1182
    .end local v10    # "daemon":Ljava/lang/String;
    .restart local v23    # "state":Ljava/io/File;
    :cond_2
    :try_start_3
    new-instance v24, Ljava/io/File;

    const-string v25, "/data/misc/vpn/abort"

    invoke-direct/range {v24 .. v25}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual/range {v24 .. v24}, Ljava/io/File;->delete()Z

    .line 1183
    const/16 v17, 0x1

    .line 1186
    const/16 v21, 0x0

    .line 1187
    .local v21, "restart":Z
    move-object/from16 v0, p0

    iget-object v8, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mArguments:[[Ljava/lang/String;

    .local v8, "arr$":[[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    const/4 v15, 0x0

    :goto_4
    move/from16 v0, v18

    if-ge v15, v0, :cond_5

    aget-object v7, v8, v15

    .line 1188
    .local v7, "arguments":[Ljava/lang/String;
    if-nez v21, :cond_3

    if-eqz v7, :cond_4

    :cond_3
    const/16 v21, 0x1

    .line 1187
    :goto_5
    add-int/lit8 v15, v15, 0x1

    goto :goto_4

    .line 1188
    :cond_4
    const/16 v21, 0x0

    goto :goto_5

    .line 1190
    .end local v7    # "arguments":[Ljava/lang/String;
    :cond_5
    if-nez v21, :cond_9

    .line 1191
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_0
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 1347
    if-nez v17, :cond_6

    .line 1348
    move-object/from16 v0, p0

    iget-object v8, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .local v8, "arr$":[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    const/4 v15, 0x0

    :goto_6
    move/from16 v0, v18

    if-ge v15, v0, :cond_6

    aget-object v10, v8, v15

    .line 1349
    .restart local v10    # "daemon":Ljava/lang/String;
    invoke-static {v10}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1348
    add-int/lit8 v15, v15, 0x1

    goto :goto_6

    .line 1354
    .end local v8    # "arr$":[Ljava/lang/String;
    .end local v10    # "daemon":Ljava/lang/String;
    :cond_6
    if-eqz v17, :cond_7

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mNetworkInfo:Landroid/net/NetworkInfo;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$2000(Lcom/android/server/connectivity/Vpn;)Landroid/net/NetworkInfo;

    move-result-object v24

    invoke-virtual/range {v24 .. v24}, Landroid/net/NetworkInfo;->getDetailedState()Landroid/net/NetworkInfo$DetailedState;

    move-result-object v24

    sget-object v25, Landroid/net/NetworkInfo$DetailedState;->CONNECTING:Landroid/net/NetworkInfo$DetailedState;

    move-object/from16 v0, v24

    move-object/from16 v1, v25

    if-ne v0, v1, :cond_8

    .line 1355
    :cond_7
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    .line 1358
    .end local v15    # "i$":I
    .end local v18    # "len$":I
    .end local v21    # "restart":Z
    .end local v23    # "state":Ljava/io/File;
    :cond_8
    :goto_7
    return-void

    .line 1194
    .local v8, "arr$":[[Ljava/lang/String;
    .restart local v15    # "i$":I
    .restart local v18    # "len$":I
    .restart local v21    # "restart":Z
    .restart local v23    # "state":Ljava/io/File;
    :cond_9
    :try_start_4
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    sget-object v25, Landroid/net/NetworkInfo$DetailedState;->CONNECTING:Landroid/net/NetworkInfo$DetailedState;

    const-string v26, "execute"

    # invokes: Lcom/android/server/connectivity/Vpn;->updateState(Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;)V
    invoke-static/range {v24 .. v26}, Lcom/android/server/connectivity/Vpn;->access$1800(Lcom/android/server/connectivity/Vpn;Landroid/net/NetworkInfo$DetailedState;Ljava/lang/String;)V

    .line 1197
    const/4 v14, 0x0

    .end local v8    # "arr$":[[Ljava/lang/String;
    .local v14, "i":I
    :goto_8
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    move-object/from16 v24, v0

    move-object/from16 v0, v24

    array-length v0, v0

    move/from16 v24, v0

    move/from16 v0, v24

    if-ge v14, v0, :cond_10

    .line 1198
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mArguments:[[Ljava/lang/String;

    move-object/from16 v24, v0

    aget-object v7, v24, v14

    .line 1199
    .restart local v7    # "arguments":[Ljava/lang/String;
    if-nez v7, :cond_b

    .line 1197
    :cond_a
    add-int/lit8 v14, v14, 0x1

    goto :goto_8

    .line 1204
    :cond_b
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    move-object/from16 v24, v0

    aget-object v10, v24, v14

    .line 1205
    .restart local v10    # "daemon":Ljava/lang/String;
    const-string v24, "LegacyVpnRunner"

    new-instance v25, Ljava/lang/StringBuilder;

    invoke-direct/range {v25 .. v25}, Ljava/lang/StringBuilder;-><init>()V

    const-string v26, "systemservice start "

    invoke-virtual/range {v25 .. v26}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    move-object/from16 v0, v25

    invoke-virtual {v0, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    invoke-virtual/range {v25 .. v25}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v25

    invoke-static/range {v24 .. v25}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 1206
    invoke-static {v10}, Landroid/os/SystemService;->start(Ljava/lang/String;)V

    .line 1209
    :goto_9
    invoke-static {v10}, Landroid/os/SystemService;->isRunning(Ljava/lang/String;)Z

    move-result v24

    if-nez v24, :cond_c

    .line 1210
    const/16 v24, 0x1

    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    goto :goto_9

    .line 1214
    :cond_c
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    move-object/from16 v24, v0

    new-instance v25, Landroid/net/LocalSocket;

    invoke-direct/range {v25 .. v25}, Landroid/net/LocalSocket;-><init>()V

    aput-object v25, v24, v14

    .line 1215
    new-instance v5, Landroid/net/LocalSocketAddress;

    sget-object v24, Landroid/net/LocalSocketAddress$Namespace;->RESERVED:Landroid/net/LocalSocketAddress$Namespace;

    move-object/from16 v0, v24

    invoke-direct {v5, v10, v0}, Landroid/net/LocalSocketAddress;-><init>(Ljava/lang/String;Landroid/net/LocalSocketAddress$Namespace;)V
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    .line 1221
    .local v5, "address":Landroid/net/LocalSocketAddress;
    :goto_a
    :try_start_5
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    move-object/from16 v24, v0

    aget-object v24, v24, v14

    move-object/from16 v0, v24

    invoke-virtual {v0, v5}, Landroid/net/LocalSocket;->connect(Landroid/net/LocalSocketAddress;)V
    :try_end_5
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_5} :catch_1
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    .line 1228
    :try_start_6
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    move-object/from16 v24, v0

    aget-object v24, v24, v14

    const/16 v25, 0x1f4

    invoke-virtual/range {v24 .. v25}, Landroid/net/LocalSocket;->setSoTimeout(I)V

    .line 1231
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    move-object/from16 v24, v0

    aget-object v24, v24, v14

    invoke-virtual/range {v24 .. v24}, Landroid/net/LocalSocket;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v19

    .line 1232
    .local v19, "out":Ljava/io/OutputStream;
    move-object v8, v7

    .local v8, "arr$":[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    const/4 v15, 0x0

    :goto_b
    move/from16 v0, v18

    if-ge v15, v0, :cond_e

    aget-object v6, v8, v15

    .line 1233
    .local v6, "argument":Ljava/lang/String;
    sget-object v24, Ljava/nio/charset/StandardCharsets;->UTF_8:Ljava/nio/charset/Charset;

    move-object/from16 v0, v24

    invoke-virtual {v6, v0}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B

    move-result-object v9

    .line 1234
    .local v9, "bytes":[B
    array-length v0, v9

    move/from16 v24, v0

    const v25, 0xffff

    move/from16 v0, v24

    move/from16 v1, v25

    if-lt v0, v1, :cond_d

    .line 1235
    new-instance v24, Ljava/lang/IllegalArgumentException;

    const-string v25, "Argument is too large"

    invoke-direct/range {v24 .. v25}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v24

    .line 1223
    .end local v6    # "argument":Ljava/lang/String;
    .end local v8    # "arr$":[Ljava/lang/String;
    .end local v9    # "bytes":[B
    .end local v19    # "out":Ljava/io/OutputStream;
    :catch_1
    move-exception v24

    .line 1226
    const/16 v24, 0x1

    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    goto :goto_a

    .line 1237
    .restart local v6    # "argument":Ljava/lang/String;
    .restart local v8    # "arr$":[Ljava/lang/String;
    .restart local v9    # "bytes":[B
    .restart local v19    # "out":Ljava/io/OutputStream;
    :cond_d
    array-length v0, v9

    move/from16 v24, v0

    shr-int/lit8 v24, v24, 0x8

    move-object/from16 v0, v19

    move/from16 v1, v24

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 1238
    array-length v0, v9

    move/from16 v24, v0

    move-object/from16 v0, v19

    move/from16 v1, v24

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 1239
    move-object/from16 v0, v19

    invoke-virtual {v0, v9}, Ljava/io/OutputStream;->write([B)V

    .line 1240
    const/16 v24, 0x0

    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    .line 1232
    add-int/lit8 v15, v15, 0x1

    goto :goto_b

    .line 1242
    .end local v6    # "argument":Ljava/lang/String;
    .end local v9    # "bytes":[B
    :cond_e
    const/16 v24, 0xff

    move-object/from16 v0, v19

    move/from16 v1, v24

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 1243
    const/16 v24, 0xff

    move-object/from16 v0, v19

    move/from16 v1, v24

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 1244
    invoke-virtual/range {v19 .. v19}, Ljava/io/OutputStream;->flush()V

    .line 1247
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    move-object/from16 v24, v0

    aget-object v24, v24, v14

    invoke-virtual/range {v24 .. v24}, Landroid/net/LocalSocket;->getInputStream()Ljava/io/InputStream;
    :try_end_6
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_0
    .catchall {:try_start_6 .. :try_end_6} :catchall_0

    move-result-object v16

    .line 1250
    .local v16, "in":Ljava/io/InputStream;
    :goto_c
    :try_start_7
    invoke-virtual/range {v16 .. v16}, Ljava/io/InputStream;->read()I
    :try_end_7
    .catch Ljava/lang/Exception; {:try_start_7 .. :try_end_7} :catch_3
    .catchall {:try_start_7 .. :try_end_7} :catchall_0

    move-result v24

    const/16 v25, -0x1

    move/from16 v0, v24

    move/from16 v1, v25

    if-eq v0, v1, :cond_a

    .line 1256
    :goto_d
    const/16 v24, 0x1

    :try_start_8
    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    goto :goto_c

    .line 1269
    .end local v5    # "address":Landroid/net/LocalSocketAddress;
    .end local v7    # "arguments":[Ljava/lang/String;
    .end local v8    # "arr$":[Ljava/lang/String;
    .end local v10    # "daemon":Ljava/lang/String;
    .end local v16    # "in":Ljava/io/InputStream;
    .end local v19    # "out":Ljava/io/OutputStream;
    :cond_f
    const/16 v24, 0x1

    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    .line 1261
    :cond_10
    invoke-virtual/range {v23 .. v23}, Ljava/io/File;->exists()Z

    move-result v24

    if-nez v24, :cond_12

    .line 1263
    const/4 v14, 0x0

    :goto_e
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    move-object/from16 v24, v0

    move-object/from16 v0, v24

    array-length v0, v0

    move/from16 v24, v0

    move/from16 v0, v24

    if-ge v14, v0, :cond_f

    .line 1264
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    move-object/from16 v24, v0

    aget-object v10, v24, v14

    .line 1265
    .restart local v10    # "daemon":Ljava/lang/String;
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mArguments:[[Ljava/lang/String;

    move-object/from16 v24, v0

    aget-object v24, v24, v14

    if-eqz v24, :cond_11

    invoke-static {v10}, Landroid/os/SystemService;->isRunning(Ljava/lang/String;)Z

    move-result v24

    if-nez v24, :cond_11

    .line 1266
    new-instance v24, Ljava/lang/IllegalStateException;

    new-instance v25, Ljava/lang/StringBuilder;

    invoke-direct/range {v25 .. v25}, Ljava/lang/StringBuilder;-><init>()V

    move-object/from16 v0, v25

    invoke-virtual {v0, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    const-string v26, " is dead"

    invoke-virtual/range {v25 .. v26}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    invoke-virtual/range {v25 .. v25}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v25

    invoke-direct/range {v24 .. v25}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v24

    .line 1263
    :cond_11
    add-int/lit8 v14, v14, 0x1

    goto :goto_e

    .line 1273
    .end local v10    # "daemon":Ljava/lang/String;
    :cond_12
    const/16 v24, 0x0

    const/16 v25, 0x0

    invoke-static/range {v23 .. v25}, Landroid/os/FileUtils;->readTextFile(Ljava/io/File;ILjava/lang/String;)Ljava/lang/String;

    move-result-object v24

    const-string v25, "\n"

    const/16 v26, -0x1

    invoke-virtual/range {v24 .. v26}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;

    move-result-object v20

    .line 1274
    .local v20, "parameters":[Ljava/lang/String;
    move-object/from16 v0, v20

    array-length v0, v0

    move/from16 v24, v0

    const/16 v25, 0x7

    move/from16 v0, v24

    move/from16 v1, v25

    if-eq v0, v1, :cond_13

    .line 1275
    new-instance v24, Ljava/lang/IllegalStateException;

    const-string v25, "Cannot parse the state"

    invoke-direct/range {v24 .. v25}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v24

    .line 1279
    :cond_13
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    const/16 v25, 0x0

    aget-object v25, v20, v25

    invoke-virtual/range {v25 .. v25}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v25

    move-object/from16 v0, v25

    move-object/from16 v1, v24

    iput-object v0, v1, Lcom/android/internal/net/VpnConfig;->interfaze:Ljava/lang/String;

    .line 1281
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    const/16 v25, 0x1

    aget-object v25, v20, v25

    invoke-virtual/range {v24 .. v25}, Lcom/android/internal/net/VpnConfig;->addLegacyAddresses(Ljava/lang/String;)V

    .line 1283
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->routes:Ljava/util/List;

    move-object/from16 v24, v0

    if-eqz v24, :cond_14

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->routes:Ljava/util/List;

    move-object/from16 v24, v0

    invoke-interface/range {v24 .. v24}, Ljava/util/List;->isEmpty()Z

    move-result v24

    if-eqz v24, :cond_15

    .line 1284
    :cond_14
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    const/16 v25, 0x2

    aget-object v25, v20, v25

    invoke-virtual/range {v24 .. v25}, Lcom/android/internal/net/VpnConfig;->addLegacyRoutes(Ljava/lang/String;)V

    .line 1288
    :cond_15
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->dnsServers:Ljava/util/List;

    move-object/from16 v24, v0

    if-eqz v24, :cond_16

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->dnsServers:Ljava/util/List;

    move-object/from16 v24, v0

    invoke-interface/range {v24 .. v24}, Ljava/util/List;->size()I

    move-result v24

    if-nez v24, :cond_17

    .line 1289
    :cond_16
    const/16 v24, 0x3

    aget-object v24, v20, v24

    invoke-virtual/range {v24 .. v24}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v11

    .line 1290
    .local v11, "dnsServers":Ljava/lang/String;
    invoke-virtual {v11}, Ljava/lang/String;->isEmpty()Z

    move-result v24

    if-nez v24, :cond_17

    .line 1291
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    const-string v25, " "

    move-object/from16 v0, v25

    invoke-virtual {v11, v0}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v25

    invoke-static/range {v25 .. v25}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;

    move-result-object v25

    move-object/from16 v0, v25

    move-object/from16 v1, v24

    iput-object v0, v1, Lcom/android/internal/net/VpnConfig;->dnsServers:Ljava/util/List;

    .line 1296
    .end local v11    # "dnsServers":Ljava/lang/String;
    :cond_17
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->searchDomains:Ljava/util/List;

    move-object/from16 v24, v0

    if-eqz v24, :cond_18

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->searchDomains:Ljava/util/List;

    move-object/from16 v24, v0

    invoke-interface/range {v24 .. v24}, Ljava/util/List;->size()I

    move-result v24

    if-nez v24, :cond_19

    .line 1297
    :cond_18
    const/16 v24, 0x4

    aget-object v24, v20, v24

    invoke-virtual/range {v24 .. v24}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v22

    .line 1298
    .local v22, "searchDomains":Ljava/lang/String;
    invoke-virtual/range {v22 .. v22}, Ljava/lang/String;->isEmpty()Z

    move-result v24

    if-nez v24, :cond_19

    .line 1299
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    const-string v25, " "

    move-object/from16 v0, v22

    move-object/from16 v1, v25

    invoke-virtual {v0, v1}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v25

    invoke-static/range {v25 .. v25}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;

    move-result-object v25

    move-object/from16 v0, v25

    move-object/from16 v1, v24

    iput-object v0, v1, Lcom/android/internal/net/VpnConfig;->searchDomains:Ljava/util/List;

    .line 1304
    .end local v22    # "searchDomains":Ljava/lang/String;
    :cond_19
    const/16 v24, 0x5

    aget-object v13, v20, v24

    .line 1305
    .local v13, "endpoint":Ljava/lang/String;
    invoke-virtual {v13}, Ljava/lang/String;->isEmpty()Z
    :try_end_8
    .catch Ljava/lang/Exception; {:try_start_8 .. :try_end_8} :catch_0
    .catchall {:try_start_8 .. :try_end_8} :catchall_0

    move-result v24

    if-nez v24, :cond_1a

    .line 1307
    :try_start_9
    invoke-static {v13}, Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;

    move-result-object v4

    .line 1308
    .local v4, "addr":Ljava/net/InetAddress;
    instance-of v0, v4, Ljava/net/Inet4Address;

    move/from16 v24, v0

    if-eqz v24, :cond_1b

    .line 1309
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->routes:Ljava/util/List;

    move-object/from16 v24, v0

    new-instance v25, Landroid/net/RouteInfo;

    new-instance v26, Landroid/net/IpPrefix;

    const/16 v27, 0x20

    move-object/from16 v0, v26

    move/from16 v1, v27

    invoke-direct {v0, v4, v1}, Landroid/net/IpPrefix;-><init>(Ljava/net/InetAddress;I)V

    const/16 v27, 0x9

    invoke-direct/range {v25 .. v27}, Landroid/net/RouteInfo;-><init>(Landroid/net/IpPrefix;I)V

    invoke-interface/range {v24 .. v25}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_9
    .catch Ljava/lang/IllegalArgumentException; {:try_start_9 .. :try_end_9} :catch_2
    .catch Ljava/lang/Exception; {:try_start_9 .. :try_end_9} :catch_0
    .catchall {:try_start_9 .. :try_end_9} :catchall_0

    .line 1321
    .end local v4    # "addr":Ljava/net/InetAddress;
    :cond_1a
    :goto_f
    :try_start_a
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v25, v0

    monitor-enter v25
    :try_end_a
    .catch Ljava/lang/Exception; {:try_start_a .. :try_end_a} :catch_0
    .catchall {:try_start_a .. :try_end_a} :catchall_0

    .line 1323
    :try_start_b
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J

    move-result-wide v26

    move-wide/from16 v0, v26

    move-object/from16 v2, v24

    iput-wide v0, v2, Lcom/android/internal/net/VpnConfig;->startTime:J

    .line 1326
    const/16 v24, 0x0

    move-object/from16 v0, p0

    move/from16 v1, v24

    invoke-direct {v0, v1}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->checkpoint(Z)V

    .line 1329
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v26, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v26 .. v26}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v26

    move-object/from16 v0, v26

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->interfaze:Ljava/lang/String;

    move-object/from16 v26, v0

    move-object/from16 v0, v24

    move-object/from16 v1, v26

    # invokes: Lcom/android/server/connectivity/Vpn;->jniCheck(Ljava/lang/String;)I
    invoke-static {v0, v1}, Lcom/android/server/connectivity/Vpn;->access$700(Lcom/android/server/connectivity/Vpn;Ljava/lang/String;)I

    move-result v24

    if-nez v24, :cond_1d

    .line 1330
    new-instance v24, Ljava/lang/IllegalStateException;

    new-instance v26, Ljava/lang/StringBuilder;

    invoke-direct/range {v26 .. v26}, Ljava/lang/StringBuilder;-><init>()V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v27, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v27 .. v27}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v27

    move-object/from16 v0, v27

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->interfaze:Ljava/lang/String;

    move-object/from16 v27, v0

    invoke-virtual/range {v26 .. v27}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v26

    const-string v27, " is gone"

    invoke-virtual/range {v26 .. v27}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v26

    invoke-virtual/range {v26 .. v26}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v26

    move-object/from16 v0, v24

    move-object/from16 v1, v26

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v24

    .line 1340
    :catchall_1
    move-exception v24

    monitor-exit v25
    :try_end_b
    .catchall {:try_start_b .. :try_end_b} :catchall_1

    :try_start_c
    throw v24
    :try_end_c
    .catch Ljava/lang/Exception; {:try_start_c .. :try_end_c} :catch_0
    .catchall {:try_start_c .. :try_end_c} :catchall_0

    .line 1310
    .restart local v4    # "addr":Ljava/net/InetAddress;
    :cond_1b
    :try_start_d
    instance-of v0, v4, Ljava/net/Inet6Address;

    move/from16 v24, v0

    if-eqz v24, :cond_1c

    .line 1311
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v24

    move-object/from16 v0, v24

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->routes:Ljava/util/List;

    move-object/from16 v24, v0

    new-instance v25, Landroid/net/RouteInfo;

    new-instance v26, Landroid/net/IpPrefix;

    const/16 v27, 0x80

    move-object/from16 v0, v26

    move/from16 v1, v27

    invoke-direct {v0, v4, v1}, Landroid/net/IpPrefix;-><init>(Ljava/net/InetAddress;I)V

    const/16 v27, 0x9

    invoke-direct/range {v25 .. v27}, Landroid/net/RouteInfo;-><init>(Landroid/net/IpPrefix;I)V

    invoke-interface/range {v24 .. v25}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_d
    .catch Ljava/lang/IllegalArgumentException; {:try_start_d .. :try_end_d} :catch_2
    .catch Ljava/lang/Exception; {:try_start_d .. :try_end_d} :catch_0
    .catchall {:try_start_d .. :try_end_d} :catchall_0

    goto/16 :goto_f

    .line 1315
    .end local v4    # "addr":Ljava/net/InetAddress;
    :catch_2
    move-exception v12

    .line 1316
    .local v12, "e":Ljava/lang/IllegalArgumentException;
    :try_start_e
    const-string v24, "LegacyVpnRunner"

    new-instance v25, Ljava/lang/StringBuilder;

    invoke-direct/range {v25 .. v25}, Ljava/lang/StringBuilder;-><init>()V

    const-string v26, "Exception constructing throw route to "

    invoke-virtual/range {v25 .. v26}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    move-object/from16 v0, v25

    invoke-virtual {v0, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    const-string v26, ": "

    invoke-virtual/range {v25 .. v26}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    move-object/from16 v0, v25

    invoke-virtual {v0, v12}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v25

    invoke-virtual/range {v25 .. v25}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v25

    invoke-static/range {v24 .. v25}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_e
    .catch Ljava/lang/Exception; {:try_start_e .. :try_end_e} :catch_0
    .catchall {:try_start_e .. :try_end_e} :catchall_0

    goto/16 :goto_f

    .line 1313
    .end local v12    # "e":Ljava/lang/IllegalArgumentException;
    .restart local v4    # "addr":Ljava/net/InetAddress;
    :cond_1c
    :try_start_f
    const-string v24, "LegacyVpnRunner"

    new-instance v25, Ljava/lang/StringBuilder;

    invoke-direct/range {v25 .. v25}, Ljava/lang/StringBuilder;-><init>()V

    const-string v26, "Unknown IP address family for VPN endpoint: "

    invoke-virtual/range {v25 .. v26}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    move-object/from16 v0, v25

    invoke-virtual {v0, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v25

    invoke-virtual/range {v25 .. v25}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v25

    invoke-static/range {v24 .. v25}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_f
    .catch Ljava/lang/IllegalArgumentException; {:try_start_f .. :try_end_f} :catch_2
    .catch Ljava/lang/Exception; {:try_start_f .. :try_end_f} :catch_0
    .catchall {:try_start_f .. :try_end_f} :catchall_0

    goto/16 :goto_f

    .line 1334
    .end local v4    # "addr":Ljava/net/InetAddress;
    :cond_1d
    :try_start_10
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v26, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mConfig:Lcom/android/internal/net/VpnConfig;
    invoke-static/range {v26 .. v26}, Lcom/android/server/connectivity/Vpn;->access$1600(Lcom/android/server/connectivity/Vpn;)Lcom/android/internal/net/VpnConfig;

    move-result-object v26

    move-object/from16 v0, v26

    iget-object v0, v0, Lcom/android/internal/net/VpnConfig;->interfaze:Ljava/lang/String;

    move-object/from16 v26, v0

    move-object/from16 v0, v24

    move-object/from16 v1, v26

    # setter for: Lcom/android/server/connectivity/Vpn;->mInterface:Ljava/lang/String;
    invoke-static {v0, v1}, Lcom/android/server/connectivity/Vpn;->access$602(Lcom/android/server/connectivity/Vpn;Ljava/lang/String;)Ljava/lang/String;

    .line 1335
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    new-instance v26, Ljava/util/ArrayList;

    invoke-direct/range {v26 .. v26}, Ljava/util/ArrayList;-><init>()V

    move-object/from16 v0, v24

    move-object/from16 v1, v26

    # setter for: Lcom/android/server/connectivity/Vpn;->mVpnUsers:Ljava/util/List;
    invoke-static {v0, v1}, Lcom/android/server/connectivity/Vpn;->access$002(Lcom/android/server/connectivity/Vpn;Ljava/util/List;)Ljava/util/List;

    .line 1337
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # invokes: Lcom/android/server/connectivity/Vpn;->agentConnect()V
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1900(Lcom/android/server/connectivity/Vpn;)V

    .line 1339
    const-string v24, "LegacyVpnRunner"

    const-string v26, "Connected!"

    move-object/from16 v0, v24

    move-object/from16 v1, v26

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 1340
    monitor-exit v25
    :try_end_10
    .catchall {:try_start_10 .. :try_end_10} :catchall_1

    .line 1347
    if-nez v17, :cond_1e

    .line 1348
    move-object/from16 v0, p0

    iget-object v8, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .restart local v8    # "arr$":[Ljava/lang/String;
    array-length v0, v8

    move/from16 v18, v0

    const/4 v15, 0x0

    :goto_10
    move/from16 v0, v18

    if-ge v15, v0, :cond_1e

    aget-object v10, v8, v15

    .line 1349
    .restart local v10    # "daemon":Ljava/lang/String;
    invoke-static {v10}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1348
    add-int/lit8 v15, v15, 0x1

    goto :goto_10

    .line 1354
    .end local v8    # "arr$":[Ljava/lang/String;
    .end local v10    # "daemon":Ljava/lang/String;
    :cond_1e
    if-eqz v17, :cond_1f

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mNetworkInfo:Landroid/net/NetworkInfo;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$2000(Lcom/android/server/connectivity/Vpn;)Landroid/net/NetworkInfo;

    move-result-object v24

    invoke-virtual/range {v24 .. v24}, Landroid/net/NetworkInfo;->getDetailedState()Landroid/net/NetworkInfo$DetailedState;

    move-result-object v24

    sget-object v25, Landroid/net/NetworkInfo$DetailedState;->CONNECTING:Landroid/net/NetworkInfo$DetailedState;

    move-object/from16 v0, v24

    move-object/from16 v1, v25

    if-ne v0, v1, :cond_8

    .line 1355
    :cond_1f
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    goto/16 :goto_7

    .line 1354
    .end local v13    # "endpoint":Ljava/lang/String;
    .end local v14    # "i":I
    .end local v15    # "i$":I
    .end local v18    # "len$":I
    .end local v20    # "parameters":[Ljava/lang/String;
    .end local v21    # "restart":Z
    .end local v23    # "state":Ljava/io/File;
    .local v12, "e":Ljava/lang/Exception;
    :cond_20
    if-eqz v17, :cond_21

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mNetworkInfo:Landroid/net/NetworkInfo;
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$2000(Lcom/android/server/connectivity/Vpn;)Landroid/net/NetworkInfo;

    move-result-object v24

    invoke-virtual/range {v24 .. v24}, Landroid/net/NetworkInfo;->getDetailedState()Landroid/net/NetworkInfo$DetailedState;

    move-result-object v24

    sget-object v25, Landroid/net/NetworkInfo$DetailedState;->CONNECTING:Landroid/net/NetworkInfo$DetailedState;

    move-object/from16 v0, v24

    move-object/from16 v1, v25

    if-ne v0, v1, :cond_8

    .line 1355
    :cond_21
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v24, v0

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static/range {v24 .. v24}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    goto/16 :goto_7

    .line 1354
    .end local v12    # "e":Ljava/lang/Exception;
    :cond_22
    if-eqz v17, :cond_23

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v25, v0

    # getter for: Lcom/android/server/connectivity/Vpn;->mNetworkInfo:Landroid/net/NetworkInfo;
    invoke-static/range {v25 .. v25}, Lcom/android/server/connectivity/Vpn;->access$2000(Lcom/android/server/connectivity/Vpn;)Landroid/net/NetworkInfo;

    move-result-object v25

    invoke-virtual/range {v25 .. v25}, Landroid/net/NetworkInfo;->getDetailedState()Landroid/net/NetworkInfo$DetailedState;

    move-result-object v25

    sget-object v26, Landroid/net/NetworkInfo$DetailedState;->CONNECTING:Landroid/net/NetworkInfo$DetailedState;

    move-object/from16 v0, v25

    move-object/from16 v1, v26

    if-ne v0, v1, :cond_24

    .line 1355
    :cond_23
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    move-object/from16 v25, v0

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static/range {v25 .. v25}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    :cond_24
    throw v24

    .line 1253
    .restart local v5    # "address":Landroid/net/LocalSocketAddress;
    .restart local v7    # "arguments":[Ljava/lang/String;
    .restart local v8    # "arr$":[Ljava/lang/String;
    .restart local v10    # "daemon":Ljava/lang/String;
    .restart local v14    # "i":I
    .restart local v15    # "i$":I
    .restart local v16    # "in":Ljava/io/InputStream;
    .restart local v18    # "len$":I
    .restart local v19    # "out":Ljava/io/OutputStream;
    .restart local v21    # "restart":Z
    .restart local v23    # "state":Ljava/io/File;
    :catch_3
    move-exception v24

    goto/16 :goto_d
.end method

.method private monitorDaemons()V
    .locals 8

    .prologue
    .line 1365
    iget-object v6, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    # getter for: Lcom/android/server/connectivity/Vpn;->mNetworkInfo:Landroid/net/NetworkInfo;
    invoke-static {v6}, Lcom/android/server/connectivity/Vpn;->access$2000(Lcom/android/server/connectivity/Vpn;)Landroid/net/NetworkInfo;

    move-result-object v6

    invoke-virtual {v6}, Landroid/net/NetworkInfo;->isConnected()Z

    move-result v6

    if-nez v6, :cond_0

    .line 1387
    :goto_0
    return-void

    .line 1371
    :cond_0
    const-wide/16 v6, 0x7d0

    :try_start_0
    invoke-static {v6, v7}, Ljava/lang/Thread;->sleep(J)V

    .line 1372
    const/4 v3, 0x0

    .local v3, "i":I
    :goto_1
    iget-object v6, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    array-length v6, v6

    if-ge v3, v6, :cond_0

    .line 1373
    iget-object v6, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mArguments:[[Ljava/lang/String;

    aget-object v6, v6, v3

    if-eqz v6, :cond_2

    iget-object v6, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    aget-object v6, v6, v3

    invoke-static {v6}, Landroid/os/SystemService;->isStopped(Ljava/lang/String;)Z
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result v6

    if-eqz v6, :cond_2

    .line 1381
    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .local v0, "arr$":[Ljava/lang/String;
    array-length v5, v0

    .local v5, "len$":I
    const/4 v4, 0x0

    .local v4, "i$":I
    :goto_2
    if-ge v4, v5, :cond_1

    aget-object v1, v0, v4

    .line 1382
    .local v1, "daemon":Ljava/lang/String;
    invoke-static {v1}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1381
    add-int/lit8 v4, v4, 0x1

    goto :goto_2

    .line 1385
    .end local v1    # "daemon":Ljava/lang/String;
    :cond_1
    iget-object v6, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static {v6}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    goto :goto_0

    .line 1372
    .end local v0    # "arr$":[Ljava/lang/String;
    .end local v4    # "i$":I
    .end local v5    # "len$":I
    :cond_2
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .line 1378
    .end local v3    # "i":I
    :catch_0
    move-exception v2

    .line 1379
    .local v2, "e":Ljava/lang/InterruptedException;
    :try_start_1
    const-string v6, "LegacyVpnRunner"

    const-string v7, "interrupted during monitorDaemons(); stopping services"

    invoke-static {v6, v7}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 1381
    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .restart local v0    # "arr$":[Ljava/lang/String;
    array-length v5, v0

    .restart local v5    # "len$":I
    const/4 v4, 0x0

    .restart local v4    # "i$":I
    :goto_3
    if-ge v4, v5, :cond_3

    aget-object v1, v0, v4

    .line 1382
    .restart local v1    # "daemon":Ljava/lang/String;
    invoke-static {v1}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1381
    add-int/lit8 v4, v4, 0x1

    goto :goto_3

    .line 1385
    .end local v1    # "daemon":Ljava/lang/String;
    :cond_3
    iget-object v6, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static {v6}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    goto :goto_0

    .line 1381
    .end local v0    # "arr$":[Ljava/lang/String;
    .end local v2    # "e":Ljava/lang/InterruptedException;
    .end local v4    # "i$":I
    .end local v5    # "len$":I
    :catchall_0
    move-exception v6

    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mDaemons:[Ljava/lang/String;

    .restart local v0    # "arr$":[Ljava/lang/String;
    array-length v5, v0

    .restart local v5    # "len$":I
    const/4 v4, 0x0

    .restart local v4    # "i$":I
    :goto_4
    if-ge v4, v5, :cond_4

    aget-object v1, v0, v4

    .line 1382
    .restart local v1    # "daemon":Ljava/lang/String;
    invoke-static {v1}, Landroid/os/SystemService;->stop(Ljava/lang/String;)V

    .line 1381
    add-int/lit8 v4, v4, 0x1

    goto :goto_4

    .line 1385
    .end local v1    # "daemon":Ljava/lang/String;
    :cond_4
    iget-object v7, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static {v7}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    throw v6
.end method

# virtual methods
.method public check(Ljava/lang/String;)V
    .locals 3
    .param p1, "interfaze"    # Ljava/lang/String;

    .prologue
    .line 1120
    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mOuterInterface:Ljava/lang/String;

    invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1121
    const-string v0, "LegacyVpnRunner"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Legacy VPN is going down with "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 1122
    invoke-virtual {p0}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->exit()V

    .line 1124
    :cond_0
    return-void
.end method

.method public exit()V
    .locals 6

    .prologue
    .line 1128
    invoke-virtual {p0}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->interrupt()V

    .line 1129
    iget-object v0, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mSockets:[Landroid/net/LocalSocket;

    .local v0, "arr$":[Landroid/net/LocalSocket;
    array-length v2, v0

    .local v2, "len$":I
    const/4 v1, 0x0

    .local v1, "i$":I
    :goto_0
    if-ge v1, v2, :cond_0

    aget-object v3, v0, v1

    .line 1130
    .local v3, "socket":Landroid/net/LocalSocket;
    invoke-static {v3}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    .line 1129
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 1132
    .end local v3    # "socket":Landroid/net/LocalSocket;
    :cond_0
    iget-object v4, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    # invokes: Lcom/android/server/connectivity/Vpn;->agentDisconnect()V
    invoke-static {v4}, Lcom/android/server/connectivity/Vpn;->access$1100(Lcom/android/server/connectivity/Vpn;)V

    .line 1134
    :try_start_0
    iget-object v4, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->this$0:Lcom/android/server/connectivity/Vpn;

    # getter for: Lcom/android/server/connectivity/Vpn;->mContext:Landroid/content/Context;
    invoke-static {v4}, Lcom/android/server/connectivity/Vpn;->access$1000(Lcom/android/server/connectivity/Vpn;)Landroid/content/Context;

    move-result-object v4

    iget-object v5, p0, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v4, v5}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V
    :try_end_0
    .catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_0

    .line 1136
    :goto_1
    return-void

    .line 1135
    :catch_0
    move-exception v4

    goto :goto_1
.end method

.method public run()V
    .locals 3

    .prologue
    .line 1141
    const-string v0, "LegacyVpnRunner"

    const-string v1, "Waiting"

    invoke-static {v0, v1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1142
    const-string v1, "LegacyVpnRunner"

    monitor-enter v1

    .line 1143
    :try_start_0
    const-string v0, "LegacyVpnRunner"

    const-string v2, "Executing"

    invoke-static {v0, v2}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I

    .line 1144
    invoke-direct {p0}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->execute()V

    .line 1145
    invoke-direct {p0}, Lcom/android/server/connectivity/Vpn$LegacyVpnRunner;->monitorDaemons()V

    .line 1146
    monitor-exit v1

    .line 1147
    return-void

    .line 1146
    :catchall_0
    move-exception v0

    monitor-exit v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method


text:
package org.apache.falcon.regression.core.util;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.falcon.entity.v0.EntityType;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.supportClasses.ExecResult;
import org.apache.falcon.resource.APIResult;
import org.apache.falcon.resource.InstancesResult;
import org.apache.hadoop.fs.ContentSummary;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.log4j.Logger;
import org.apache.oozie.client.Job;
import org.apache.oozie.client.OozieClient;
import org.apache.oozie.client.OozieClientException;
import org.testng.Assert;

import javax.xml.bind.JAXBException;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

/**
 * Util methods for assert.
 */
public final class AssertUtil {

    private AssertUtil() {
        throw new AssertionError("Instantiating utility class...");
    }

    private static final Logger LOGGER = Logger.getLogger(AssertUtil.class);

    /**
     * Checks that any path in list doesn't contains a string.
     *
     * @param paths list of paths
     * @param shouldNotBePresent string that shouldn't be present
     */
    public static void failIfStringFoundInPath(
        List<Path> paths, String... shouldNotBePresent) {
        for (Path path : paths) {
            for (String aShouldNotBePresent : shouldNotBePresent) {
                if (path.toUri().toString().contains(aShouldNotBePresent)) {
                    Assert.fail("String " + aShouldNotBePresent + " was not expected in path "
                            +
                            path.toUri().toString());
                }
            }
        }
    }

    /**
     * Checks that two lists have same size.
     *
     * @param expected expected list
     * @param actual   actual list
     */
    public static void checkForListSizes(List<?> expected, List<?> actual) {
        if (expected.size() != actual.size()) {
            LOGGER.info("expected = " + expected);
        }
        checkForListSize(actual, expected.size());
    }

    /**
     * Checks that two lists have same size.
     *
     * @param elements list of elements
     * @param expectedSize expected size of the list
     */
    public static void checkForListSize(List<?> elements, int expectedSize) {
        if (elements.size() != expectedSize) {
            LOGGER.info("expectedSize = " + expectedSize);
            LOGGER.info("elements.size() = " + elements.size());
            LOGGER.info("elements = " + elements);
        }
        Assert.assertEquals(elements.size(), expectedSize,
            "Size of expected and actual list don't match.");
    }

    /**
     * Checks that two lists has expected diff element.
     *
     * @param initialState first list
     * @param finalState   second list
     * @param filename     expected diff element
     * @param expectedDiff diff count (positive for new elements)
     */
    public static void compareDataStoreStates(List<String> initialState,
                                              List<String> finalState, String filename,
                                              int expectedDiff) {

        if (expectedDiff > -1) {
            finalState.removeAll(initialState);
            Assert.assertEquals(finalState.size(), expectedDiff);
            if (expectedDiff != 0) {
                Assert.assertTrue(finalState.get(0).contains(filename));
            }
        } else {
            expectedDiff = expectedDiff * -1;
            initialState.removeAll(finalState);
            Assert.assertEquals(initialState.size(), expectedDiff);
            if (expectedDiff != 0) {
                Assert.assertTrue(initialState.get(0).contains(filename));
            }
        }

    }

    /**
     * Checks that two lists has expected diff element.
     *
     * @param initialState first list
     * @param finalState   second list
     * @param expectedDiff diff count (positive for new elements)
     */
    public static void compareDataStoreStates(List<String> initialState,
                                              List<String> finalState, int expectedDiff) {

        if (expectedDiff > -1) {
            finalState.removeAll(initialState);
            Assert.assertEquals(finalState.size(), expectedDiff);

        } else {
            expectedDiff = expectedDiff * -1;
            initialState.removeAll(finalState);
            Assert.assertEquals(initialState.size(), expectedDiff);

        }

    }

    /**
     * Checks that ServiceResponse status is SUCCEEDED.
     *
     * @param response ServiceResponse
     * @throws JAXBException
     */
    public static void assertSucceeded(ServiceResponse response) throws JAXBException {
        final APIResult apiResult = Util.parseResponse(response);
        Assert.assertNotNull(apiResult.getMessage(), "Status message is null");
        Assert.assertEquals(apiResult.getStatus(), APIResult.Status.SUCCEEDED,
            "Status should be SUCCEEDED. Message: " + apiResult.getMessage());
        Assert.assertEquals(response.getCode(), 200,
            "Status code should be 200. Message: " + apiResult.getMessage());
    }

    /**
     * Checks that ServiceResponse status is SUCCEEDED.
     *
     * @param response ServiceResponse
     * @return if the response was a success or not
     */
    public static boolean checkSucceeded(ServiceResponse response) {
        final APIResult apiResult;
        try {
            apiResult = Util.parseResponse(response);
        } catch (JAXBException e) {
            return false;
        }
        return apiResult.getStatus() == APIResult.Status.SUCCEEDED
            && response.getCode() == 200
            && apiResult.getMessage() != null;
    }

    /**
     * Checks that ProcessInstancesResult status is SUCCEEDED.
     *
     * @param response ProcessInstancesResult
     */
    public static void assertSucceeded(InstancesResult response) {
        Assert.assertNotNull(response.getMessage(), "Status message is null");
        Assert.assertEquals(response.getStatus(), APIResult.Status.SUCCEEDED,
            "Status should be SUCCEEDED. Message: " + response.getMessage());
    }

    /**
     * Checks that ServiceResponse status is status FAILED.
     *
     * @param response ServiceResponse
     * @param message  message for exception
     * @throws JAXBException
     */
    public static void assertFailed(final ServiceResponse response, final String message)
        throws JAXBException {
        assertFailedWithStatus(response, 400, message);
    }

    /**
     * Assert that command executed unsuccessfully.
     *
     * @param execResult ExecResult of the command execution
     */
    public static void assertFailed(ExecResult execResult, String expectedMessage) {
        Assert.assertFalse(execResult.hasSuceeded(),
            "Unexpectedly succeeded execResult: " + execResult);
        Assert.assertTrue((execResult.getError() + execResult.getOutput()).contains(expectedMessage),
            "Expected error: " + expectedMessage + " in execResult: " + execResult);
    }

    /**
     * Checks that ServiceResponse status is status FAILED with some status code.
     *
     * @param response   ServiceResponse
     * @param statusCode expected status code
     * @param message    message for exception
     * @throws JAXBException
     */
    public static void assertFailedWithStatus(final ServiceResponse response, final int statusCode,
                                              final String message) throws JAXBException {
        Assert.assertNotEquals(response.getMessage(), "null", "response message should not be null");
        Assert.assertEquals(Util.parseResponse(response).getStatus(),
            APIResult.Status.FAILED, message);
        Assert.assertEquals(response.getCode(), statusCode, message);
        Assert.assertNotNull(Util.parseResponse(response).getRequestId(), "RequestId is null");
    }

    /**
     * Checks that ServiceResponse status is status PARTIAL.
     *
     * @param response ServiceResponse
     * @throws JAXBException
     */
    public static void assertPartial(ServiceResponse response) throws JAXBException {
        Assert.assertEquals(Util.parseResponse(response).getStatus(), APIResult.Status.PARTIAL);
        Assert.assertEquals(response.getCode(), 400);
        Assert.assertNotNull(Util.parseResponse(response).getMessage());
    }

    /**
     * Checks that ServiceResponse status is status FAILED with status code 400.
     *
     * @param response ServiceResponse
     * @throws JAXBException
     */
    public static void assertFailed(ServiceResponse response) throws JAXBException {
        Assert.assertNotEquals(response.getMessage(), "null",
            "response message should not be null");

        Assert.assertEquals(Util.parseResponse(response).getStatus(), APIResult.Status.FAILED);
        Assert.assertEquals(response.getCode(), 400);
    }

    /**
     * Checks that ServiceResponse status is status FAILED with status code 403.
     *
     * @param response ServiceResponse
     * @throws JAXBException
     */
    public static void assertFailedWith403(ServiceResponse response) throws JAXBException {
        Assert.assertNotEquals(response.getMessage(), "null", "response message should not be null");

        Assert.assertEquals(Util.parseResponse(response).getStatus(), APIResult.Status.FAILED);
        Assert.assertEquals(response.getCode(), 403);
    }
    /**
     * Checks that status of some entity job is equal to expected. Method can wait
     * 100 seconds for expected status.
     *
     * @param oozieClient    OozieClient
     * @param entityType     FEED or PROCESS
     * @param data           feed or proceess XML
     * @param expectedStatus expected Job.Status of entity
     * @throws OozieClientException
     */
    public static void checkStatus(OozieClient oozieClient, EntityType entityType, String data,
                                   Job.Status expectedStatus)
        throws OozieClientException {
        String name = null;
        if (entityType == EntityType.FEED) {
            name = Util.readEntityName(data);
        } else if (entityType == EntityType.PROCESS) {
            name = Util.readEntityName(data);
        }
        Assert.assertEquals(
            OozieUtil.verifyOozieJobStatus(oozieClient, name, entityType, expectedStatus), true,
            "Status should be " + expectedStatus);
    }

    /**
     * Checks that status of some entity job is equal to expected. Method can wait
     * 100 seconds for expected status.
     *
     * @param oozieClient    OozieClient
     * @param entityType     FEED or PROCESS
     * @param bundle         Bundle with feed or process data
     * @param expectedStatus expected Job.Status of entity
     * @throws OozieClientException
     */
    public static void checkStatus(OozieClient oozieClient, EntityType entityType, Bundle bundle,
                                   Job.Status expectedStatus)
        throws OozieClientException {
        String data = null;
        if (entityType == EntityType.FEED) {
            data = bundle.getDataSets().get(0);
        } else if (entityType == EntityType.PROCESS) {
            data = bundle.getProcessData();
        }
        checkStatus(oozieClient, entityType, data, expectedStatus);
    }

    /**
     * Checks that status of some entity job is NOT equal to expected.
     *
     * @param oozieClient    OozieClient
     * @param entityType     FEED or PROCESS
     * @param data           feed or proceess XML
     * @param expectedStatus expected Job.Status of entity
     * @throws OozieClientException
     */
    public static void checkNotStatus(OozieClient oozieClient, EntityType entityType, String data,
                                      Job.Status expectedStatus)
        throws OozieClientException {
        String processName = null;
        if (entityType == EntityType.FEED) {
            processName = Util.readEntityName(data);
        } else if (entityType == EntityType.PROCESS) {
            processName = Util.readEntityName(data);
        }
        Assert.assertNotEquals(OozieUtil.getOozieJobStatus(oozieClient, processName,
            entityType), expectedStatus, "Status should not be " + expectedStatus);
    }

    /**
     * Checks that status of some entity job is NOT equal to expected.
     *
     * @param oozieClient    OozieClient
     * @param entityType     FEED or PROCESS
     * @param bundle         Bundle with feed or process data
     * @param expectedStatus expected Job.Status of entity
     * @throws OozieClientException
     */
    public static void checkNotStatus(OozieClient oozieClient, EntityType entityType,
                                      Bundle bundle, Job.Status expectedStatus)
        throws OozieClientException {
        String data = null;
        if (entityType == EntityType.FEED) {
            data = bundle.getDataSets().get(0);
        } else if (entityType == EntityType.PROCESS) {
            data = bundle.getProcessData();
        }
        checkNotStatus(oozieClient, entityType, data, expectedStatus);
    }

    /**
     * Checks size of the content a two locations.
     *
     * @param firstPath  path to the first location
     * @param secondPath path to the second location
     * @param fs         hadoop file system for the locations
     * @throws IOException
     */
    public static void checkContentSize(String firstPath, String secondPath, FileSystem fs) throws
        IOException {
        final ContentSummary firstSummary = fs.getContentSummary(new Path(firstPath));
        final ContentSummary secondSummary = fs.getContentSummary(new Path(secondPath));
        LOGGER.info(firstPath + " : firstSummary = " + firstSummary.toString(false));
        LOGGER.info(secondPath + " : secondSummary = " + secondSummary.toString(false));
        Assert.assertEquals(firstSummary.getLength(), secondSummary.getLength(),
            "Contents at the two locations don't have same size.");
    }

    /**
     * Fail the test because of the supplied exception.
     * @param e exception
     */
    public static void fail(Exception e) {
        LOGGER.info("Got exception: " + ExceptionUtils.getStackTrace(e));
        Assert.fail("Failing because of exception.");
    }

    public static void assertEmpty(String str, String message) {
        if (StringUtils.isNotEmpty(str)) {
            Assert.fail(String.format("%s expected [empty string/null] found [%s]", message, str));
        }
    }

    public static <E> void assertEmpty(Collection<E> collection, String message) {
        if (!collection.isEmpty()) {
            Assert.fail(
                String.format("%s expected [empty collection] found [%s]", message, collection));
        }
    }
    public static void assertNotEmpty(String str, String message) {
        if (StringUtils.isEmpty(str)) {
            Assert.fail(String.format("%s expected non-empty string found [%s]", message, str));
        }
    }

    /**
     * Checks that job logs are copied to user defined cluster staging path.
     *
     * @param logFlag     denotes whether is is failed/succeeded log
     * @param entityName  name of entity
     * @param clusterFS   hadoop file system for the locations
     * @param entityType  feed or process
     */
    public static boolean assertPath(boolean logFlag, String entityName, FileSystem clusterFS,
                                     String entityType) throws Exception {
        String stagingDir= MerlinConstants.STAGING_LOCATION;
        String path=stagingDir+"/falcon/workflows/"+ entityType + "/" + entityName +"/logs";
        List<Path> logmoverPaths = HadoopUtil
                .getAllFilesRecursivelyHDFS(clusterFS, new Path(HadoopUtil.cutProtocol(path)));
        String part = logFlag ? "SUCCEEDED" : "FAILED";
        for (Path logmoverPath : logmoverPaths) {
            if (logmoverPath.toString().contains(part)) {
                return true;
            }
        }
        return false;
    }

    /**
     * Checks that job logs are copied to user defined cluster staging path.
     *
     * @param logFlag     denotes whether is is failed/succeeded log
     * @param entityName  name of entity
     * @param clusterFS   hadoop file system for the locations
     * @param entityType  feed or process
     * @param message     message returned if assert fails
     */
    public static void assertLogMoverPath(boolean logFlag, String entityName, FileSystem clusterFS,
                                          String entityType, String message) throws Exception {
        Assert.assertTrue(assertPath(logFlag, entityName, clusterFS, entityType), message);
    }

}

redpajama_set_name: RedPajamaGithub


text:
package math.function;

public class CosineFunction extends TrignometricFunction{

	public CosineFunction(Function arg1) {
		super(arg1);
	}

	@Override
	public double f(double[] inputs, String[] variableNames) {
		return Math.cos(getFunction1().f(inputs, variableNames));
	}

	@Override
	public String toString() {
		return "cos(" + getFunction1().toString() + ")";
	}

}


text:
package com.asakusafw.yaess.core;

import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Resolves variables in form of ${variable_name}.
 * @since 0.2.2
 * @version 0.7.4
 */
public class VariableResolver {

    static final Logger LOG = LoggerFactory.getLogger(VariableResolver.class);

    private static final Pattern VARIABLE = Pattern.compile("\\$\\{(.*?)\\}");

    private static final char SEPARATOR_DEFAULT_VALUE = '-';

    private final Map<String, String> entries;

    /**
     * Creates a new instance.
     * @param entries the variable key and its value pairs
     * @throws IllegalArgumentException if any parameter is {@code null}
     */
    public VariableResolver(Map<String, String> entries) {
        if (entries == null) {
            throw new IllegalArgumentException("entries must not be null"); //$NON-NLS-1$
        }
        this.entries = Collections.unmodifiableMap(new TreeMap<>(entries));
    }

    /**
     * Creates a new instance from environment variables and system properties.
     * If both have same entry, the system properties takes precedence over the environment variables.
     * @return the created instance
     */
    public static VariableResolver system() {
        Map<String, String> entries = new HashMap<>();
        entries.putAll(System.getenv());
        for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
            Object key = entry.getKey();
            Object value = entry.getValue();
            if (key instanceof String && value instanceof String) {
                entries.put((String) key, (String) value);
            }
        }
        return new VariableResolver(entries);
    }

    /**
     * Replaces parameters in the target string.
     * The parameters are represented as ${variable-name}.
     * @param string target string
     * @param strict {@code false} to keep undefined parameters,
     *     or {@code true} to raise an exception
     * @return replaced string
     * @throws IllegalArgumentException if undefined parameters exist on strict mode,
     *     or any parameters contain {@code null}
     */
    public String replace(String string, boolean strict) {
        if (string == null) {
            throw new IllegalArgumentException("string must not be null"); //$NON-NLS-1$
        }
        StringBuilder buf = new StringBuilder();
        int start = 0;
        Matcher matcher = VARIABLE.matcher(string);
        while (matcher.find(start)) {
            String placeholder = matcher.group(1);
            String replacement = resolve(placeholder);
            if (replacement == null) {
                if (strict) {
                    throw new IllegalArgumentException(MessageFormat.format(
                            "parameter \"{0}\" is not defined in the list: {1}",
                            placeholder,
                            this));
                } else {
                    buf.append(string.substring(start, matcher.start() + 1));
                }
                start = matcher.start() + 1;
            } else {
                buf.append(string.substring(start, matcher.start()));
                buf.append(replacement);
                start = matcher.end();
            }
        }
        buf.append(string.substring(start));
        return buf.toString();
    }

    private String resolve(String placeholder) {
        String name;
        String defaultValue;
        int defaultAt = placeholder.indexOf(SEPARATOR_DEFAULT_VALUE);
        if (defaultAt < 0) {
            name = placeholder;
            defaultValue = null;
        } else {
            name = placeholder.substring(0, defaultAt);
            defaultValue = placeholder.substring(defaultAt + 1);
        }
        String replacement = entries.get(name);
        if (replacement != null) {
            return replacement;
        }
        return defaultValue;
    }

    @Override
    public String toString() {
        return entries.toString();
    }
}


text:
namespace utils {

    namespace {

        uint64_t GetCurrentTimeNs() {
            struct timespec currentTime;
            clock_gettime(CLOCK_MONOTONIC, &currentTime);
            return currentTime.tv_sec * 1'000'000'000llu + currentTime.tv_nsec;
        }

    }  // anonymous namespace

    class PosixTimer : public Timer {
      public:
        PosixTimer() : Timer(), mRunning(false) {
        }

        ~PosixTimer() override = default;

        void Start() override {
            mStartTimeNs = GetCurrentTimeNs();
            mRunning = true;
        }

        void Stop() override {
            mStopTimeNs = GetCurrentTimeNs();
            mRunning = false;
        }

        double GetElapsedTime() const override {
            uint64_t endTimeNs;
            if (mRunning) {
                endTimeNs = GetCurrentTimeNs();
            } else {
                endTimeNs = mStopTimeNs;
            }

            return (endTimeNs - mStartTimeNs) * 1e-9;
        }

        double GetAbsoluteTime() override {
            return GetCurrentTimeNs() * 1e-9;
        }

      private:
        bool mRunning;
        uint64_t mStartTimeNs;
        uint64_t mStopTimeNs;
    };

    Timer* CreateTimer() {
        return new PosixTimer();
    }

}  // namespace utils


text:
Version 1.4.0
-------------

- Added device id (IMEI/UUID) support
- Log out after fetching the blob to close the newly open session on LP server to prevent triggering anti-hacking logic (hopefully)
- Verify that the recieved blob is marked with ENDM chunk and hasn't been truncated in the process

Version 1.3.0
-------------

- Added proxy support

Version 1.2.1
-------------

- Fixed the decryption bug on long shared folder names.

Version 1.2.0
-------------

- Server secure note support

Version 1.1.0
-------------

- Shared folder support

Version 1.0.1
-------------

- Ruby 2.0 compatibility

Version 1.0.0
-------------

- First public gem release


text:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="com.abk.mrw">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:allowBackup="true"
            tools:ignore="GoogleAppIndexingWarning">
        <receiver
                android:name=".WidgetProvider"
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
            </intent-filter>

            <meta-data
                    android:name="android.appwidget.provider"
                    android:resource="@xml/widget_provider"/>
        </receiver>
        <!-- Receive Wi-Fi connection state changes -->
        <receiver android:name=".util.NetworkConnectivityReceiver">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
            </intent-filter>
        </receiver>

        <service
                android:name=".WidgetService"
                android:permission="android.permission.BIND_REMOTEVIEWS"/>
        <service
                android:name=".NewsFeedLoadService"
                android:exported="false"/>

        <activity
                android:name=".settings.SettingsActivity"
                android:label="@string/title_activity_settings"
                android:theme="@style/Theme.AppCompat.Light">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
            </intent-filter>
        </activity>
    </application>
</manifest>


text:
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
        <group>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/LoginPage.java</file>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/StudentLandingPage.java</file>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/teacher/TeacherLandingPage.java</file>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/dataentry/DataEntryLandingPage.java</file>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/administrator/AdministratorLandingPage.java</file>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/StudentRegistration.java</file>
            <file>file:/Users/mac/Documents/Developer/MavericksRepo/student-system/src/student/registration/utils/DBConnect.java</file>
        </group>
    </open-files>
</project-private>


text:
import * as bt from '@babel/types'
import { NodePath } from 'ast-types/lib/node-path'
import { visit } from 'recast'
import Documentation from '../Documentation'
import { ParseOptions } from '../parse'
import getDocblock from '../utils/getDocblock'
import getDoclets from '../utils/getDoclets'
import getTypeFromAnnotation from '../utils/getTypeFromAnnotation'
import { setEventDescriptor } from '../script-handlers/eventHandler'
import { getTypeDefinitionFromIdentifier } from './utils/tsUtils'

/**
 * Extract information from an setup-style VueJs 3 component
 * about what events can be emitted
 * @param {NodePath} astPath
 * @param {Array<NodePath>} componentDefinitions
 * @param {string} originalFilePath
 */
export default async function setupEventHandler(
	documentation: Documentation,
	componentDefinition: NodePath,
	astPath: bt.File,
	opt: ParseOptions
) {
	function buildEventDescriptor(eventName: string, eventPath: NodePath) {
		const eventDescriptor = documentation.getEventDescriptor(eventName)

		const typeParam = eventPath.get('parameters', 1, 'typeAnnotation')
		if (bt.isTSTypeAnnotation(typeParam.node)) {
			const type = getTypeFromAnnotation(typeParam.node)?.name
			if (type) {
				eventDescriptor.type = { names: [type] }
			}
		}

		const docBlock = getDocblock(eventPath)
		if (docBlock) {
			const jsDoc = getDoclets(docBlock)
			setEventDescriptor(eventDescriptor, jsDoc)
		}
	}

	function readEventsTSTypes(refs: any) {
		refs.each((member: NodePath) => {
			if (bt.isTSCallSignatureDeclaration(member.node)) {
				const firstParam = member.node.parameters[0].typeAnnotation
				if (
					bt.isTSTypeAnnotation(firstParam) &&
					bt.isTSLiteralType(firstParam.typeAnnotation) &&
          !bt.isUnaryExpression(firstParam.typeAnnotation.literal) &&
					typeof firstParam.typeAnnotation.literal.value === 'string'
				) {
					buildEventDescriptor(firstParam.typeAnnotation.literal.value, member)
				}
			}
		})
	}

	visit(astPath.program, {
		visitCallExpression(nodePath) {
			if (bt.isIdentifier(nodePath.node.callee) && nodePath.node.callee.name === 'defineEmits') {
				// Array of string where no type is specified
				if (bt.isArrayExpression(nodePath.get('arguments', 0).node)) {
					nodePath.get('arguments', 0, 'elements').each((element: NodePath) => {
						if (bt.isStringLiteral(element.node)) {
							buildEventDescriptor(element.node.value, element)
						}
					})
				}

				// Object where the arguments are validated manually
				if (bt.isObjectExpression(nodePath.get('arguments', 0).node)) {
					nodePath.get('arguments', 0, 'properties').each((element: NodePath) => {
						if (bt.isObjectProperty(element.node) && bt.isIdentifier(element.node.key)) {
							buildEventDescriptor(element.node.key.name, element)
						}
					})
				}

				// typescript validation of arguments
				if (bt.isTSTypeParameterInstantiation(nodePath.get('typeParameters').node)) {
					nodePath.get('typeParameters', 'params').each((param: NodePath) => {
						if (bt.isTSTypeLiteral(param.node)) {
							readEventsTSTypes(param.get('members'))
						} else if (bt.isTSTypeReference(param.node) && bt.isIdentifier(param.node.typeName)) {
							const resolvedType = getTypeDefinitionFromIdentifier(
								astPath,
								param.node.typeName.name
							)
							if (resolvedType) {
								readEventsTSTypes(resolvedType)
							}
						}
					})
				}
			}

			return false
		}
	})
}