text:
.class public final Landroid/nfc/NfcActivityManager;
.super Landroid/nfc/IAppCallback$Stub;
.source "NfcActivityManager.java"

# interfaces
.implements Landroid/app/Application$ActivityLifecycleCallbacks;

# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Landroid/nfc/NfcActivityManager$NfcApplicationState;,
        Landroid/nfc/NfcActivityManager$NfcActivityState;
    }
.end annotation

# static fields
.field static final DBG:Ljava/lang/Boolean;

.field static final TAG:Ljava/lang/String; = "NFC"

# instance fields
.field final mActivities:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Landroid/nfc/NfcActivityManager$NfcActivityState;",
            ">;"
        }
    .end annotation
.end field

.field final mAdapter:Landroid/nfc/NfcAdapter;

.field final mApps:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Landroid/nfc/NfcActivityManager$NfcApplicationState;",
            ">;"
        }
    .end annotation
.end field

# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 46
    const/4 v0, 0x0

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    sput-object v0, Landroid/nfc/NfcActivityManager;->DBG:Ljava/lang/Boolean;

    .line 43
    return-void
.end method

.method public constructor <init>(Landroid/nfc/NfcAdapter;)V
    .locals 2
    .param p1, "adapter"    # Landroid/nfc/NfcAdapter;

    .prologue
    .line 198
    invoke-direct {p0}, Landroid/nfc/IAppCallback$Stub;-><init>()V

    .line 199
    iput-object p1, p0, Landroid/nfc/NfcActivityManager;->mAdapter:Landroid/nfc/NfcAdapter;

    .line 200
    new-instance v0, Ljava/util/LinkedList;

    invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V

    iput-object v0, p0, Landroid/nfc/NfcActivityManager;->mActivities:Ljava/util/List;

    .line 201
    new-instance v0, Ljava/util/ArrayList;

    const/4 v1, 0x1

    invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(I)V

    iput-object v0, p0, Landroid/nfc/NfcActivityManager;->mApps:Ljava/util/List;

    .line 198
    return-void
.end method

# virtual methods
.method public createBeamShareData(B)Landroid/nfc/BeamShareData;
    .locals 19
    .param p1, "peerLlcpVersion"    # B

    .prologue
    .line 362
    new-instance v3, Landroid/nfc/NfcEvent;

    move-object/from16 v0, p0

    iget-object v15, v0, Landroid/nfc/NfcActivityManager;->mAdapter:Landroid/nfc/NfcAdapter;

    move/from16 v0, p1

    invoke-direct {v3, v15, v0}, Landroid/nfc/NfcEvent;-><init>(Landroid/nfc/NfcAdapter;B)V

    .line 363
    .local v3, "event":Landroid/nfc/NfcEvent;
    monitor-enter p0

    .line 364
    :try_start_0
    invoke-virtual/range {p0 .. p0}, Landroid/nfc/NfcActivityManager;->findResumedActivityState()Landroid/nfc/NfcActivityManager$NfcActivityState;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-object v10

    .line 365
    .local v10, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    if-nez v10, :cond_0

    const/4 v15, 0x0

    monitor-exit p0

    return-object v15

    .line 367
    :cond_0
    :try_start_1
    iget-object v8, v10, Landroid/nfc/NfcActivityManager$NfcActivityState;->ndefMessageCallback:Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;

    .line 368
    .local v8, "ndefCallback":Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;
    iget-object v13, v10, Landroid/nfc/NfcActivityManager$NfcActivityState;->uriCallback:Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;

    .line 369
    .local v13, "urisCallback":Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;
    iget-object v5, v10, Landroid/nfc/NfcActivityManager$NfcActivityState;->ndefMessage:Landroid/nfc/NdefMessage;

    .line 370
    .local v5, "message":Landroid/nfc/NdefMessage;
    iget-object v12, v10, Landroid/nfc/NfcActivityManager$NfcActivityState;->uris:[Landroid/net/Uri;

    .line 371
    .local v12, "uris":[Landroid/net/Uri;
    iget v4, v10, Landroid/nfc/NfcActivityManager$NfcActivityState;->flags:I

    .line 372
    .local v4, "flags":I
    iget-object v2, v10, Landroid/nfc/NfcActivityManager$NfcActivityState;->activity:Landroid/app/Activity;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .local v2, "activity":Landroid/app/Activity;
    monitor-exit p0

    .line 374
    invoke-static {}, Landroid/os/Binder;->clearCallingIdentity()J

    move-result-wide v6

    .line 377
    .local v6, "ident":J
    if-eqz v8, :cond_1

    .line 378
    :try_start_2
    invoke-interface {v8, v3}, Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;->createNdefMessage(Landroid/nfc/NfcEvent;)Landroid/nfc/NdefMessage;

    move-result-object v5

    .line 380
    :cond_1
    if-eqz v13, :cond_6

    .line 381
    invoke-interface {v13, v3}, Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;->createBeamUris(Landroid/nfc/NfcEvent;)[Landroid/net/Uri;

    move-result-object v12

    .line 382
    if-eqz v12, :cond_6

    .line 383
    new-instance v14, Ljava/util/ArrayList;

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

    .line 384
    .local v14, "validUris":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/net/Uri;>;"
    const/4 v15, 0x0

    array-length v0, v12

    move/from16 v16, v0

    :goto_0
    move/from16 v0, v16

    if-ge v15, v0, :cond_5

    aget-object v11, v12, v15

    .line 385
    .local v11, "uri":Landroid/net/Uri;
    if-nez v11, :cond_2

    .line 386
    const-string/jumbo v17, "NFC"

    const-string/jumbo v18, "Uri not allowed to be null."

    invoke-static/range {v17 .. v18}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    .line 384
    :goto_1
    add-int/lit8 v15, v15, 0x1

    goto :goto_0

    .line 363
    .end local v2    # "activity":Landroid/app/Activity;
    .end local v4    # "flags":I
    .end local v5    # "message":Landroid/nfc/NdefMessage;
    .end local v6    # "ident":J
    .end local v8    # "ndefCallback":Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;
    .end local v10    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    .end local v11    # "uri":Landroid/net/Uri;
    .end local v12    # "uris":[Landroid/net/Uri;
    .end local v13    # "urisCallback":Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;
    .end local v14    # "validUris":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/net/Uri;>;"
    :catchall_0
    move-exception v15

    monitor-exit p0

    throw v15

    .line 389
    .restart local v2    # "activity":Landroid/app/Activity;
    .restart local v4    # "flags":I
    .restart local v5    # "message":Landroid/nfc/NdefMessage;
    .restart local v6    # "ident":J
    .restart local v8    # "ndefCallback":Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;
    .restart local v10    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    .restart local v11    # "uri":Landroid/net/Uri;
    .restart local v12    # "uris":[Landroid/net/Uri;
    .restart local v13    # "urisCallback":Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;
    .restart local v14    # "validUris":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/net/Uri;>;"
    :cond_2
    :try_start_3
    invoke-virtual {v11}, Landroid/net/Uri;->getScheme()Ljava/lang/String;

    move-result-object v9

    .line 390
    .local v9, "scheme":Ljava/lang/String;
    if-eqz v9, :cond_4

    const-string/jumbo v17, "file"

    move-object/from16 v0, v17

    invoke-virtual {v9, v0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v17

    if-nez v17, :cond_3

    .line 391
    const-string/jumbo v17, "content"

    move-object/from16 v0, v17

    invoke-virtual {v9, v0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v17

    if-eqz v17, :cond_4

    .line 396
    :cond_3
    invoke-static {}, Landroid/os/UserHandle;->myUserId()I

    move-result v17

    move/from16 v0, v17

    invoke-static {v11, v0}, Landroid/content/ContentProvider;->maybeAddUserId(Landroid/net/Uri;I)Landroid/net/Uri;

    move-result-object v11

    .line 397
    invoke-virtual {v14, v11}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    goto :goto_1

    .line 410
    .end local v9    # "scheme":Ljava/lang/String;
    .end local v11    # "uri":Landroid/net/Uri;
    .end local v14    # "validUris":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/net/Uri;>;"
    :catchall_1
    move-exception v15

    .line 411
    invoke-static {v6, v7}, Landroid/os/Binder;->restoreCallingIdentity(J)V

    .line 410
    throw v15

    .line 392
    .restart local v9    # "scheme":Ljava/lang/String;
    .restart local v11    # "uri":Landroid/net/Uri;
    .restart local v14    # "validUris":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/net/Uri;>;"
    :cond_4
    :try_start_4
    const-string/jumbo v17, "NFC"

    const-string/jumbo v18, "Uri needs to have either scheme file or scheme content"

    invoke-static/range {v17 .. v18}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_1

    .line 400
    .end local v9    # "scheme":Ljava/lang/String;
    .end local v11    # "uri":Landroid/net/Uri;
    :cond_5
    invoke-virtual {v14}, Ljava/util/ArrayList;->size()I

    move-result v15

    new-array v15, v15, [Landroid/net/Uri;

    invoke-virtual {v14, v15}, Ljava/util/ArrayList;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;

    move-result-object v15

    move-object v0, v15

    check-cast v0, [Landroid/net/Uri;

    move-object v12, v0

    .line 403
    .end local v14    # "validUris":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Landroid/net/Uri;>;"
    :cond_6
    if-eqz v12, :cond_7

    array-length v15, v12

    if-lez v15, :cond_7

    .line 404
    const/4 v15, 0x0

    array-length v0, v12

    move/from16 v16, v0

    :goto_2
    move/from16 v0, v16

    if-ge v15, v0, :cond_7

    aget-object v11, v12, v15

    .line 406
    .restart local v11    # "uri":Landroid/net/Uri;
    const-string/jumbo v17, "com.android.nfc"

    .line 407
    const/16 v18, 0x1

    .line 406
    move-object/from16 v0, v17

    move/from16 v1, v18

    invoke-virtual {v2, v0, v11, v1}, Landroid/app/Activity;->grantUriPermission(Ljava/lang/String;Landroid/net/Uri;I)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

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

    goto :goto_2

    .line 411
    .end local v11    # "uri":Landroid/net/Uri;
    :cond_7
    invoke-static {v6, v7}, Landroid/os/Binder;->restoreCallingIdentity(J)V

    .line 413
    new-instance v15, Landroid/nfc/BeamShareData;

    new-instance v16, Landroid/os/UserHandle;

    invoke-static {}, Landroid/os/UserHandle;->myUserId()I

    move-result v17

    invoke-direct/range {v16 .. v17}, Landroid/os/UserHandle;-><init>(I)V

    move-object/from16 v0, v16

    invoke-direct {v15, v5, v12, v0, v4}, Landroid/nfc/BeamShareData;-><init>(Landroid/nfc/NdefMessage;[Landroid/net/Uri;Landroid/os/UserHandle;I)V

    return-object v15
.end method

.method declared-synchronized destroyActivityState(Landroid/app/Activity;)V
    .locals 2
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    monitor-enter p0

    .line 191
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v0

    .line 192
    .local v0, "activityState":Landroid/nfc/NfcActivityManager$NfcActivityState;
    if-eqz v0, :cond_0

    .line 193
    invoke-virtual {v0}, Landroid/nfc/NfcActivityManager$NfcActivityState;->destroy()V

    .line 194
    iget-object v1, p0, Landroid/nfc/NfcActivityManager;->mActivities:Ljava/util/List;

    invoke-interface {v1, v0}, Ljava/util/List;->remove(Ljava/lang/Object;)Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :cond_0
    monitor-exit p0

    .line 190
    return-void

    .end local v0    # "activityState":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public disableReaderMode(Landroid/app/Activity;)V
    .locals 6
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    const/4 v5, 0x0

    const/4 v4, 0x0

    .line 224
    monitor-enter p0

    .line 225
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 226
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    const/4 v3, 0x0

    iput-object v3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerCallback:Landroid/nfc/NfcAdapter$ReaderCallback;

    .line 227
    const/4 v3, 0x0

    iput v3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeFlags:I

    .line 228
    const/4 v3, 0x0

    iput-object v3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeExtras:Landroid/os/Bundle;

    .line 229
    iget-object v2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->token:Landroid/os/Binder;

    .line 230
    .local v2, "token":Landroid/os/Binder;
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 232
    if-eqz v0, :cond_0

    .line 233
    invoke-virtual {p0, v2, v5, v4}, Landroid/nfc/NfcActivityManager;->setReaderMode(Landroid/os/Binder;ILandroid/os/Bundle;)V

    .line 221
    :cond_0
    return-void

    .line 224
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    .end local v2    # "token":Landroid/os/Binder;
    :catchall_0
    move-exception v3

    monitor-exit p0

    throw v3
.end method

.method public enableReaderMode(Landroid/app/Activity;Landroid/nfc/NfcAdapter$ReaderCallback;ILandroid/os/Bundle;)V
    .locals 4
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "callback"    # Landroid/nfc/NfcAdapter$ReaderCallback;
    .param p3, "flags"    # I
    .param p4, "extras"    # Landroid/os/Bundle;

    .prologue
    .line 208
    monitor-enter p0

    .line 209
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 210
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iput-object p2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerCallback:Landroid/nfc/NfcAdapter$ReaderCallback;

    .line 211
    iput p3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeFlags:I

    .line 212
    iput-object p4, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeExtras:Landroid/os/Bundle;

    .line 213
    iget-object v2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->token:Landroid/os/Binder;

    .line 214
    .local v2, "token":Landroid/os/Binder;
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 216
    if-eqz v0, :cond_0

    .line 217
    invoke-virtual {p0, v2, p3, p4}, Landroid/nfc/NfcActivityManager;->setReaderMode(Landroid/os/Binder;ILandroid/os/Bundle;)V

    .line 205
    :cond_0
    return-void

    .line 208
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    .end local v2    # "token":Landroid/os/Binder;
    :catchall_0
    move-exception v3

    monitor-exit p0

    throw v3
.end method

.method declared-synchronized findActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;
    .locals 3
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    monitor-enter p0

    .line 163
    :try_start_0
    iget-object v2, p0, Landroid/nfc/NfcActivityManager;->mActivities:Ljava/util/List;

    invoke-interface {v2}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .local v1, "state$iterator":Ljava/util/Iterator;
    :cond_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/nfc/NfcActivityManager$NfcActivityState;

    .line 164
    .local v0, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iget-object v2, v0, Landroid/nfc/NfcActivityManager$NfcActivityState;->activity:Landroid/app/Activity;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-ne v2, p1, :cond_0

    monitor-exit p0

    .line 165
    return-object v0

    .line 168
    .end local v0    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_1
    const/4 v2, 0x0

    monitor-exit p0

    return-object v2

    .end local v1    # "state$iterator":Ljava/util/Iterator;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method findAppState(Landroid/app/Application;)Landroid/nfc/NfcActivityManager$NfcApplicationState;
    .locals 3
    .param p1, "app"    # Landroid/app/Application;

    .prologue
    .line 80
    iget-object v2, p0, Landroid/nfc/NfcActivityManager;->mApps:Ljava/util/List;

    invoke-interface {v2}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .local v1, "appState$iterator":Ljava/util/Iterator;
    :cond_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/nfc/NfcActivityManager$NfcApplicationState;

    .line 81
    .local v0, "appState":Landroid/nfc/NfcActivityManager$NfcApplicationState;
    iget-object v2, v0, Landroid/nfc/NfcActivityManager$NfcApplicationState;->app:Landroid/app/Application;

    if-ne v2, p1, :cond_0

    .line 82
    return-object v0

    .line 85
    .end local v0    # "appState":Landroid/nfc/NfcActivityManager$NfcApplicationState;
    :cond_1
    const/4 v2, 0x0

    return-object v2
.end method

.method declared-synchronized findResumedActivityState()Landroid/nfc/NfcActivityManager$NfcActivityState;
    .locals 3

    .prologue
    monitor-enter p0

    .line 182
    :try_start_0
    iget-object v2, p0, Landroid/nfc/NfcActivityManager;->mActivities:Ljava/util/List;

    invoke-interface {v2}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .local v1, "state$iterator":Ljava/util/Iterator;
    :cond_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/nfc/NfcActivityManager$NfcActivityState;

    .line 183
    .local v0, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iget-boolean v2, v0, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v2, :cond_0

    monitor-exit p0

    .line 184
    return-object v0

    .line 187
    .end local v0    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_1
    const/4 v2, 0x0

    monitor-exit p0

    return-object v2

    .end local v1    # "state$iterator":Ljava/util/Iterator;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method declared-synchronized getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;
    .locals 2
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    monitor-enter p0

    .line 173
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v0

    .line 174
    .local v0, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    if-nez v0, :cond_0

    .line 175
    new-instance v0, Landroid/nfc/NfcActivityManager$NfcActivityState;

    .end local v0    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    invoke-direct {v0, p0, p1}, Landroid/nfc/NfcActivityManager$NfcActivityState;-><init>(Landroid/nfc/NfcActivityManager;Landroid/app/Activity;)V

    .line 176
    .restart local v0    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iget-object v1, p0, Landroid/nfc/NfcActivityManager;->mActivities:Ljava/util/List;

    invoke-interface {v1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :cond_0
    monitor-exit p0

    .line 178
    return-object v0

    .end local v0    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public onActivityCreated(Landroid/app/Activity;Landroid/os/Bundle;)V
    .locals 0
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "savedInstanceState"    # Landroid/os/Bundle;

    .prologue
    .line 451
    return-void
.end method

.method public onActivityDestroyed(Landroid/app/Activity;)V
    .locals 4
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    .line 508
    monitor-enter p0

    .line 509
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v0

    .line 510
    .local v0, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    sget-object v1, Landroid/nfc/NfcActivityManager;->DBG:Ljava/lang/Boolean;

    invoke-virtual {v1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-eqz v1, :cond_0

    const-string/jumbo v1, "NFC"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string/jumbo v3, "onDestroy() for "

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

    move-result-object v2

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

    move-result-object v2

    const-string/jumbo v3, " "

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

    move-result-object v2

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

    move-result-object v2

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

    move-result-object v2

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

    .line 511
    :cond_0
    if-eqz v0, :cond_1

    .line 513
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->destroyActivityState(Landroid/app/Activity;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :cond_1
    monitor-exit p0

    .line 507
    return-void

    .line 508
    .end local v0    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public onActivityPaused(Landroid/app/Activity;)V
    .locals 8
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    const/4 v7, 0x0

    const/4 v6, 0x0

    .line 483
    monitor-enter p0

    .line 484
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 485
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    sget-object v3, Landroid/nfc/NfcActivityManager;->DBG:Ljava/lang/Boolean;

    invoke-virtual {v3}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v3

    if-eqz v3, :cond_0

    const-string/jumbo v3, "NFC"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string/jumbo v5, "onPause() for "

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

    move-result-object v4

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

    move-result-object v4

    const-string/jumbo v5, " "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 486
    :cond_0
    if-nez v1, :cond_1

    monitor-exit p0

    return-void

    .line 487
    :cond_1
    const/4 v3, 0x0

    :try_start_1
    iput-boolean v3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z

    .line 488
    iget-object v2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->token:Landroid/os/Binder;

    .line 489
    .local v2, "token":Landroid/os/Binder;
    iget v3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeFlags:I
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    if-eqz v3, :cond_3

    const/4 v0, 0x1

    .local v0, "readerModeFlagsSet":Z
    :goto_0
    monitor-exit p0

    .line 491
    if-eqz v0, :cond_2

    .line 493
    invoke-virtual {p0, v2, v6, v7}, Landroid/nfc/NfcActivityManager;->setReaderMode(Landroid/os/Binder;ILandroid/os/Bundle;)V

    .line 480
    :cond_2
    return-void

    .line 489
    .end local v0    # "readerModeFlagsSet":Z
    :cond_3
    const/4 v0, 0x0

    .restart local v0    # "readerModeFlagsSet":Z
    goto :goto_0

    .line 483
    .end local v0    # "readerModeFlagsSet":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    .end local v2    # "token":Landroid/os/Binder;
    :catchall_0
    move-exception v3

    monitor-exit p0

    throw v3
.end method

.method public onActivityResumed(Landroid/app/Activity;)V
    .locals 7
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    .line 460
    const/4 v1, 0x0

    .line 461
    .local v1, "readerModeFlags":I
    const/4 v0, 0x0

    .line 463
    .local v0, "readerModeExtras":Landroid/os/Bundle;
    monitor-enter p0

    .line 464
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v2

    .line 465
    .local v2, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    sget-object v4, Landroid/nfc/NfcActivityManager;->DBG:Ljava/lang/Boolean;

    invoke-virtual {v4}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v4

    if-eqz v4, :cond_0

    const-string/jumbo v4, "NFC"

    new-instance v5, Ljava/lang/StringBuilder;

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

    const-string/jumbo v6, "onResume() for "

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

    move-result-object v5

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

    move-result-object v5

    const-string/jumbo v6, " "

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

    move-result-object v5

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

    move-result-object v5

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

    move-result-object v5

    invoke-static {v4, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 466
    :cond_0
    if-nez v2, :cond_1

    monitor-exit p0

    return-void

    .line 467
    :cond_1
    const/4 v4, 0x1

    :try_start_1
    iput-boolean v4, v2, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z

    .line 468
    iget-object v3, v2, Landroid/nfc/NfcActivityManager$NfcActivityState;->token:Landroid/os/Binder;

    .line 469
    .local v3, "token":Landroid/os/Binder;
    iget v1, v2, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeFlags:I

    .line 470
    iget-object v0, v2, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerModeExtras:Landroid/os/Bundle;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .local v0, "readerModeExtras":Landroid/os/Bundle;
    monitor-exit p0

    .line 472
    if-eqz v1, :cond_2

    .line 473
    invoke-virtual {p0, v3, v1, v0}, Landroid/nfc/NfcActivityManager;->setReaderMode(Landroid/os/Binder;ILandroid/os/Bundle;)V

    .line 475
    :cond_2
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->requestNfcServiceCallback()V

    .line 459
    return-void

    .line 463
    .end local v2    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    .end local v3    # "token":Landroid/os/Binder;
    .local v0, "readerModeExtras":Landroid/os/Bundle;
    :catchall_0
    move-exception v4

    monitor-exit p0

    throw v4
.end method

.method public onActivitySaveInstanceState(Landroid/app/Activity;Landroid/os/Bundle;)V
    .locals 0
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "outState"    # Landroid/os/Bundle;

    .prologue
    .line 503
    return-void
.end method

.method public onActivityStarted(Landroid/app/Activity;)V
    .locals 0
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    .line 455
    return-void
.end method

.method public onActivityStopped(Landroid/app/Activity;)V
    .locals 0
    .param p1, "activity"    # Landroid/app/Activity;

    .prologue
    .line 499
    return-void
.end method

.method public onNdefPushComplete(B)V
    .locals 4
    .param p1, "peerLlcpVersion"    # B

    .prologue
    .line 420
    monitor-enter p0

    .line 421
    :try_start_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->findResumedActivityState()Landroid/nfc/NfcActivityManager$NfcActivityState;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-object v2

    .line 422
    .local v2, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    if-nez v2, :cond_0

    monitor-exit p0

    return-void

    .line 424
    :cond_0
    :try_start_1
    iget-object v0, v2, Landroid/nfc/NfcActivityManager$NfcActivityState;->onNdefPushCompleteCallback:Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .local v0, "callback":Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;
    monitor-exit p0

    .line 426
    new-instance v1, Landroid/nfc/NfcEvent;

    iget-object v3, p0, Landroid/nfc/NfcActivityManager;->mAdapter:Landroid/nfc/NfcAdapter;

    invoke-direct {v1, v3, p1}, Landroid/nfc/NfcEvent;-><init>(Landroid/nfc/NfcAdapter;B)V

    .line 428
    .local v1, "event":Landroid/nfc/NfcEvent;
    if-eqz v0, :cond_1

    .line 429
    invoke-interface {v0, v1}, Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;->onNdefPushComplete(Landroid/nfc/NfcEvent;)V

    .line 418
    :cond_1
    return-void

    .line 420
    .end local v0    # "callback":Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;
    .end local v1    # "event":Landroid/nfc/NfcEvent;
    .end local v2    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v3

    monitor-exit p0

    throw v3
.end method

.method public onTagDiscovered(Landroid/nfc/Tag;)V
    .locals 3
    .param p1, "tag"    # Landroid/nfc/Tag;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 436
    monitor-enter p0

    .line 437
    :try_start_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->findResumedActivityState()Landroid/nfc/NfcActivityManager$NfcActivityState;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-object v1

    .line 438
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    if-nez v1, :cond_0

    monitor-exit p0

    return-void

    .line 440
    :cond_0
    :try_start_1
    iget-object v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->readerCallback:Landroid/nfc/NfcAdapter$ReaderCallback;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .local v0, "callback":Landroid/nfc/NfcAdapter$ReaderCallback;
    monitor-exit p0

    .line 444
    if-eqz v0, :cond_1

    .line 445
    invoke-interface {v0, p1}, Landroid/nfc/NfcAdapter$ReaderCallback;->onTagDiscovered(Landroid/nfc/Tag;)V

    .line 434
    :cond_1
    return-void

    .line 436
    .end local v0    # "callback":Landroid/nfc/NfcAdapter$ReaderCallback;
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method registerApplication(Landroid/app/Application;)V
    .locals 2
    .param p1, "app"    # Landroid/app/Application;

    .prologue
    .line 89
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findAppState(Landroid/app/Application;)Landroid/nfc/NfcActivityManager$NfcApplicationState;

    move-result-object v0

    .line 90
    .local v0, "appState":Landroid/nfc/NfcActivityManager$NfcApplicationState;
    if-nez v0, :cond_0

    .line 91
    new-instance v0, Landroid/nfc/NfcActivityManager$NfcApplicationState;

    .end local v0    # "appState":Landroid/nfc/NfcActivityManager$NfcApplicationState;
    invoke-direct {v0, p0, p1}, Landroid/nfc/NfcActivityManager$NfcApplicationState;-><init>(Landroid/nfc/NfcActivityManager;Landroid/app/Application;)V

    .line 92
    .restart local v0    # "appState":Landroid/nfc/NfcActivityManager$NfcApplicationState;
    iget-object v1, p0, Landroid/nfc/NfcActivityManager;->mApps:Ljava/util/List;

    invoke-interface {v1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 94
    :cond_0
    invoke-virtual {v0}, Landroid/nfc/NfcActivityManager$NfcApplicationState;->register()V

    .line 88
    return-void
.end method

.method requestNfcServiceCallback()V
    .locals 2

    .prologue
    .line 339
    :try_start_0
    sget-object v1, Landroid/nfc/NfcAdapter;->sService:Landroid/nfc/INfcAdapter;

    invoke-interface {v1, p0}, Landroid/nfc/INfcAdapter;->setAppCallback(Landroid/nfc/IAppCallback;)V
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 337
    :goto_0
    return-void

    .line 340
    :catch_0
    move-exception v0

    .line 341
    .local v0, "e":Landroid/os/RemoteException;
    iget-object v1, p0, Landroid/nfc/NfcActivityManager;->mAdapter:Landroid/nfc/NfcAdapter;

    invoke-virtual {v1, v0}, Landroid/nfc/NfcAdapter;->attemptDeadServiceRecovery(Ljava/lang/Exception;)V

    goto :goto_0
.end method

.method public setNdefPushContentUri(Landroid/app/Activity;[Landroid/net/Uri;)V
    .locals 3
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "uris"    # [Landroid/net/Uri;

    .prologue
    .line 249
    monitor-enter p0

    .line 250
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 251
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iput-object p2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->uris:[Landroid/net/Uri;

    .line 252
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 254
    if-eqz v0, :cond_0

    .line 256
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->requestNfcServiceCallback()V

    .line 247
    :goto_0
    return-void

    .line 249
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2

    .line 259
    .restart local v0    # "isResumed":Z
    .restart local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->verifyNfcPermission()V

    goto :goto_0
.end method

.method public setNdefPushContentUriCallback(Landroid/app/Activity;Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;)V
    .locals 3
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "callback"    # Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;

    .prologue
    .line 267
    monitor-enter p0

    .line 268
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 269
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iput-object p2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->uriCallback:Landroid/nfc/NfcAdapter$CreateBeamUrisCallback;

    .line 270
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 272
    if-eqz v0, :cond_0

    .line 274
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->requestNfcServiceCallback()V

    .line 265
    :goto_0
    return-void

    .line 267
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2

    .line 277
    .restart local v0    # "isResumed":Z
    .restart local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->verifyNfcPermission()V

    goto :goto_0
.end method

.method public setNdefPushMessage(Landroid/app/Activity;Landroid/nfc/NdefMessage;I)V
    .locals 3
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "message"    # Landroid/nfc/NdefMessage;
    .param p3, "flags"    # I

    .prologue
    .line 283
    monitor-enter p0

    .line 284
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 285
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iput-object p2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->ndefMessage:Landroid/nfc/NdefMessage;

    .line 286
    iput p3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->flags:I

    .line 287
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 289
    if-eqz v0, :cond_0

    .line 291
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->requestNfcServiceCallback()V

    .line 281
    :goto_0
    return-void

    .line 283
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2

    .line 294
    .restart local v0    # "isResumed":Z
    .restart local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->verifyNfcPermission()V

    goto :goto_0
.end method

.method public setNdefPushMessageCallback(Landroid/app/Activity;Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;I)V
    .locals 3
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "callback"    # Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;
    .param p3, "flags"    # I

    .prologue
    .line 301
    monitor-enter p0

    .line 302
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 303
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iput-object p2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->ndefMessageCallback:Landroid/nfc/NfcAdapter$CreateNdefMessageCallback;

    .line 304
    iput p3, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->flags:I

    .line 305
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 307
    if-eqz v0, :cond_0

    .line 309
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->requestNfcServiceCallback()V

    .line 299
    :goto_0
    return-void

    .line 301
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2

    .line 312
    .restart local v0    # "isResumed":Z
    .restart local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->verifyNfcPermission()V

    goto :goto_0
.end method

.method public setOnNdefPushCompleteCallback(Landroid/app/Activity;Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;)V
    .locals 3
    .param p1, "activity"    # Landroid/app/Activity;
    .param p2, "callback"    # Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;

    .prologue
    .line 319
    monitor-enter p0

    .line 320
    :try_start_0
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->getActivityState(Landroid/app/Activity;)Landroid/nfc/NfcActivityManager$NfcActivityState;

    move-result-object v1

    .line 321
    .local v1, "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    iput-object p2, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->onNdefPushCompleteCallback:Landroid/nfc/NfcAdapter$OnNdefPushCompleteCallback;

    .line 322
    iget-boolean v0, v1, Landroid/nfc/NfcActivityManager$NfcActivityState;->resumed:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .local v0, "isResumed":Z
    monitor-exit p0

    .line 324
    if-eqz v0, :cond_0

    .line 326
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->requestNfcServiceCallback()V

    .line 317
    :goto_0
    return-void

    .line 319
    .end local v0    # "isResumed":Z
    .end local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2

    .line 329
    .restart local v0    # "isResumed":Z
    .restart local v1    # "state":Landroid/nfc/NfcActivityManager$NfcActivityState;
    :cond_0
    invoke-virtual {p0}, Landroid/nfc/NfcActivityManager;->verifyNfcPermission()V

    goto :goto_0
.end method

.method public setReaderMode(Landroid/os/Binder;ILandroid/os/Bundle;)V
    .locals 3
    .param p1, "token"    # Landroid/os/Binder;
    .param p2, "flags"    # I
    .param p3, "extras"    # Landroid/os/Bundle;

    .prologue
    .line 239
    sget-object v1, Landroid/nfc/NfcActivityManager;->DBG:Ljava/lang/Boolean;

    invoke-virtual {v1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-eqz v1, :cond_0

    const-string/jumbo v1, "NFC"

    const-string/jumbo v2, "Setting reader mode"

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

    .line 241
    :cond_0
    :try_start_0
    sget-object v1, Landroid/nfc/NfcAdapter;->sService:Landroid/nfc/INfcAdapter;

    invoke-interface {v1, p1, p0, p2, p3}, Landroid/nfc/INfcAdapter;->setReaderMode(Landroid/os/IBinder;Landroid/nfc/IAppCallback;ILandroid/os/Bundle;)V
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 238
    :goto_0
    return-void

    .line 242
    :catch_0
    move-exception v0

    .line 243
    .local v0, "e":Landroid/os/RemoteException;
    iget-object v1, p0, Landroid/nfc/NfcActivityManager;->mAdapter:Landroid/nfc/NfcAdapter;

    invoke-virtual {v1, v0}, Landroid/nfc/NfcAdapter;->attemptDeadServiceRecovery(Ljava/lang/Exception;)V

    goto :goto_0
.end method

.method unregisterApplication(Landroid/app/Application;)V
    .locals 4
    .param p1, "app"    # Landroid/app/Application;

    .prologue
    .line 98
    invoke-virtual {p0, p1}, Landroid/nfc/NfcActivityManager;->findAppState(Landroid/app/Application;)Landroid/nfc/NfcActivityManager$NfcApplicationState;

    move-result-object v0

    .line 99
    .local v0, "appState":Landroid/nfc/NfcActivityManager$NfcApplicationState;
    if-nez v0, :cond_0

    .line 100
    const-string/jumbo v1, "NFC"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string/jumbo v3, "app was not registered "

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

    move-result-object v2

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

    move-result-object v2

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

    move-result-object v2

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

    .line 101
    return-void

    .line 103
    :cond_0
    invoke-virtual {v0}, Landroid/nfc/NfcActivityManager$NfcApplicationState;->unregister()V

    .line 97
    return-void
.end method

.method verifyNfcPermission()V
    .locals 2

    .prologue
    .line 347
    :try_start_0
    sget-object v1, Landroid/nfc/NfcAdapter;->sService:Landroid/nfc/INfcAdapter;

    invoke-interface {v1}, Landroid/nfc/INfcAdapter;->verifyNfcPermission()V
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 345
    :goto_0
    return-void

    .line 348
    :catch_0
    move-exception v0

    .line 349
    .local v0, "e":Landroid/os/RemoteException;
    iget-object v1, p0, Landroid/nfc/NfcActivityManager;->mAdapter:Landroid/nfc/NfcAdapter;

    invoke-virtual {v1, v0}, Landroid/nfc/NfcAdapter;->attemptDeadServiceRecovery(Ljava/lang/Exception;)V

    goto :goto_0
.end method

redpajama_set_name: RedPajamaGithub


text:
import os

def is_systemd():
    """
    Check if the system is using systemd
    """
    return os.path.isdir("/run/systemd/system")

def is_arc_installed():
    """
    Check if the system is an on prem machine running Arc
    """
    # Using systemctl to check this since Arc only supports VM that have systemd
    check_arc = os.system("systemctl status himdsd 1>/dev/null 2>&1")
    return check_arc == 0

def get_arc_endpoint():
    """
    Find the endpoint for arc Hybrid IMDS
    """
    endpoint_filepath = "/lib/systemd/system.conf.d/azcmagent.conf"
    with open(endpoint_filepath, "r") as f:
        data = f.read()
    endpoint = data.split("\"IMDS_ENDPOINT=")[1].split("\"\n")[0]

    return endpoint


text:
using System;
using FasterTests.Core.Integration.Nunit.SetupFixturesContexts.SetupFixtures;
using FasterTests.Core.Interfaces.Models;
using FasterTests.Tests.NunitTestAssembly;
using Machine.Specifications;
using Machine.Fakes;

namespace FasterTests.Tests.Core.Integration.Nunit.SetupFixturesContexts.SetupFixtures.SetupFixtureSpecs
{
    [Subject(typeof(SetupFixture))]
    public class When_teardown_is_executed_after_setup : SetupFixtureSpecification<RootSetupFixture>
    {
        Establish context = () =>
            Subject.Setup(An<IObserver<TestResult>>());

        Because of = () =>
            Subject.Teardown(An<IObserver<TestResult>>());

        It should_invoke_underlying_nunit_fixture = () => The<ISetupFixtureAdapter>().WasToldTo(a => a.Teardown()).OnlyOnce();

        It should_move_to_no_setup_state = () => Subject.IsExecuted.ShouldBeFalse();

        It should_create_adapter = () => The<ISetupFixtureAdapterFactory>().WasToldTo(f => f.Create(typeof(RootSetupFixture))).OnlyOnce();
    }
}


text:
package org.javarosa.core.model.instance.test;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.javarosa.core.model.IDataReference;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.core.model.data.IntegerData;
import org.javarosa.core.model.data.StringData;
import org.javarosa.core.model.instance.AbstractTreeElement;
import org.javarosa.core.model.instance.FormInstance;
import org.javarosa.core.model.instance.TreeElement;
import org.javarosa.core.model.instance.utils.ITreeVisitor;
import org.javarosa.core.util.externalizable.DeserializationException;
import org.javarosa.core.util.externalizable.PrototypeFactory;

public class QuestionDataElementTests extends TestCase{
	private final String stringElementName = "String Data Element";

	StringData stringData;
	IntegerData integerData;

	IDataReference stringReference;

	IDataReference integerReference;

	TreeElement stringElement;
	TreeElement intElement;

	private static int NUM_TESTS = 7;

	public void setUp() throws Exception {
		super.setUp();
		stringData = new StringData("Answer Value");
		integerData = new IntegerData(4);

		stringReference = new IDataReference() {
			String reference = "stringValue";

			public Object getReference() {
				return reference;
			}

			public void setReference(Object reference) {
				this.reference = (String)reference;
			}
			/*
			public boolean referenceMatches(IDataReference reference) {
				return this.reference.equals(reference.getReference());
			}

			public IDataReference clone()  {
				IDataReference newReference = null;
				try {
					newReference = (IDataReference)this.getClass().newInstance();
				} catch (InstantiationException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
				newReference.setReference(reference);
				return newReference;
			}
			*/
			public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {}

			public void writeExternal(DataOutputStream out) throws IOException {}

		};

		integerReference = new IDataReference() {
			Integer intReference = new Integer(15);

			public Object getReference() {
				return intReference;
			}

			public void setReference(Object reference) {
				this.intReference = (Integer)reference;
			}
			/*
			public boolean referenceMatches(IDataReference reference) {
				return this.intReference.equals(reference.getReference());
			}

			public IDataReference clone()  {
				IDataReference newReference = null;
				try {
					newReference = (IDataReference)this.getClass().newInstance();
				} catch (InstantiationException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
				newReference.setReference(intReference);
				return newReference;
			}
			*/
			public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {}

			public void writeExternal(DataOutputStream out) throws IOException {}

		};

		intElement  = new TreeElement("intElement");
		intElement.setValue(integerData);

		stringElement = new TreeElement(stringElementName);
		stringElement.setValue(stringData);

	}

	public QuestionDataElementTests(String name) {
		super(name);
		System.out.println("Running " + this.getClass().getName() + " test: " + name + "...");
	}

	public static Test suite() {
		TestSuite aSuite = new TestSuite();

		for (int i = 1; i <= NUM_TESTS; i++) {
			final int testID = i;

			aSuite.addTest(new QuestionDataElementTests(testMaster(testID)));
		}

		return aSuite;
	}
	public static String testMaster (int testID) {
		//System.out.println("running " + testID);

		switch (testID) {
			case 1: return "testIsLeaf";
			case 2: return "testGetName";
			case 3: return "testSetName";
			case 4: return "testGetValue";
			case 5: return "testSetValue";
			case 6: return "testAcceptsVisitor";
			case 7: return "testSuperclassMethods";

		}
		throw new IllegalStateException("Unexpected index");
	}

	public void testIsLeaf() {
		assertTrue("Question Data Element returned negative for being a leaf",stringElement.isLeaf());
	}

	public void testGetName() {
		assertEquals("Question Data Element 'string' did not properly get its name", stringElement.getName(), stringElementName);
	}

	public void testSetName() {
		String newName = new String("New Name");
		stringElement.setName(newName);

		assertEquals("Question Data Element 'string' did not properly set its name", stringElement.getName(), newName);
	}

	public void testGetValue() {
		IAnswerData data = stringElement.getValue();
		assertEquals("Question Data Element did not return the correct value",data,stringData);
	}

	public void testSetValue() {
		stringElement.setValue(integerData);
		assertEquals("Question Data Element did not set value correctly",stringElement.getValue(),integerData);

		try {
			stringElement.setValue(null);
		} catch(Exception e) {
			fail("Question Data Element did not allow for its value to be set as null");
		}

		assertEquals("Question Data Element did not return a null value correctly", stringElement.getValue(),null);

	}

	private class MutableBoolean {
		private boolean bool;

		public MutableBoolean(boolean bool) {
			this.bool = bool;
		}

		void setValue(boolean bool) {
			this.bool = bool;
		}

		boolean getValue() {
			return bool;
		}
	}

	public void testAcceptsVisitor() {
		final MutableBoolean visitorAccepted = new MutableBoolean(false);
		final MutableBoolean dispatchedWrong = new MutableBoolean(false);
		ITreeVisitor sampleVisitor = new ITreeVisitor() {

			public void visit(FormInstance tree) {
				dispatchedWrong.bool = true;
			}
			public void visit(AbstractTreeElement element) {
				visitorAccepted.bool = true;
			}
		};

		stringElement.accept(sampleVisitor);
		assertTrue("The visitor's visit method was not called correctly by the QuestionDataElement",visitorAccepted.getValue());

		assertTrue("The visitor was dispatched incorrectly by the QuestionDataElement",!dispatchedWrong.getValue());
	}

	public void testSuperclassMethods() {
		//stringElement should not have a root at this point.

		//TODO: Implement tests for the 'attribute' system.
	}
}


text:
  echo -e "Starting to update gh-pages\n"

  #copy data we're interested in to other place
  mkdir -p $HOME/$TRAVIS_BUILD_NUMBER
  cp -R .pioenvs/nodemcuv2/firmware.elf $HOME/$TRAVIS_BUILD_NUMBER/firmware.elf
  cp -R .pioenvs/nodemcuv2/firmware.bin $HOME/$TRAVIS_BUILD_NUMBER/firmware.bin

  #go to home and setup git
  cd $HOME
  git config --global user.email "travis@travis-ci.org"
  git config --global user.name "Travis"

  #remove old clone if exists
  rm -rf gh-pages

  #using token clone gh-pages branch
  git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/ciandt-dev/garage-kelvin-celsius.git  gh-pages > /dev/null

  #go into diractory and copy data we're interested in to that directory
  cd $HOME/gh-pages
  mkdir -p $HOME/gh-pages/build/$TRAVIS_BUILD_NUMBER
  cp -Rf $HOME/$TRAVIS_BUILD_NUMBER/* $HOME/gh-pages/build/$TRAVIS_BUILD_NUMBER

  #add, commit and push files
  git add -f .
  git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages"
  git push -fq origin gh-pages > /dev/null

  echo -e "Done.\n"
#fi

ls $HOME/gh-pages/build/$TRAVIS_BUILD_NUMBER


text:
package org.jcodec.codecs.mjpeg;

import java.util.Arrays;

import org.jcodec.common.dct.DCT;
import org.jcodec.common.dct.IntDCT;
import org.jcodec.common.dct.SlowDCT;
import org.jcodec.common.tools.Debug;

public class VerifyDCT extends DCT {

    private static SlowDCT slow = SlowDCT.INSTANCE;
    private static IntDCT fast = IntDCT.INSTANCE;

    static int diffcnt = 0;

    public int[] decode(int[] orig) {
        int[] expected = slow.decode(orig);
        int[] actual = fast.decode(orig);
        if (!Arrays.equals(expected, actual)) {
            System.out.println("\nwhile decoding: ");
            Debug.print8x8(orig);
            System.out.println("expected: ");
            Debug.print8x8(expected);
            System.out.println("actual: ");
            Debug.print8x8(actual);
            System.out.println("diff: ");
            for (int i = 0; i < expected.length; i++) {
                if (i % 8 == 0) {
                    System.out.println();
                }
                System.out.printf("%3d, ", (expected[i] - actual[i]));
            }
            diffcnt++;

            if (diffcnt == 10) {
                throw new IllegalStateException();
            }
        }
        return expected;
    }

}


text:
import Button from 'app/element/button';
import Checkbox from 'app/element/checkbox';
import Select from 'app/element/select';
import Textbox from 'app/element/textbox';
import WebComponent from 'app/element/web-component';
import { ElementType } from 'app/xpath-options';
import { ElementHandle, Page } from 'puppeteer';
import { waitForDocumentTitle, waitWhileLoading } from 'utils/waits-utils';
import { buildXPath } from 'app/xpath-builders';
import { AccessTierDisplayNames, LinkText } from 'app/text-labels';
import NewWorkspaceModal from 'app/modal/new-workspace-modal';
import WorkspaceBase, { UseFreeCredits } from './workspace-base';
import { config } from 'resources/workbench-config';
import BaseElement from 'app/element/base-element';
import { makeWorkspaceName } from 'utils/str-utils';
import WorkspaceDataPage from './workspace-data-page';

const faker = require('faker/locale/en_US');

export const PageTitle = 'Create|Duplicate|Edit Workspace';

export const LabelAlias = {
  SELECT_BILLING: 'Select a current billing account', // Select a current billing account
  RESEARCH_PURPOSE: 'Research purpose',
  EDUCATION_PURPOSE: 'Educational Purpose',
  FOR_PROFIT_PURPOSE: 'For-Profit Purpose',
  OTHER_PURPOSE: 'Other Purpose',
  DISEASE_FOCUSED_RESEARCH: 'Disease-focused research',
  POPULATION_HEALTH: 'Population Health/Public Health Research',
  METHODS_DEVELOPMENT: 'Methods development/validation study',
  DRUG_THERAPEUTIC_DEVELOPMENT: 'Drug/Therapeutics Development Research',
  RESEARCH_CONTROL: 'Research Control',
  GENETIC_RESEARCH: 'Genetic Research',
  SOCIAL_BEHAVIORAL_RESEARCH: 'Social/Behavioral Research',
  ETHICAL_LEGAL_SOCIAL_IMPLICATIONS: 'Ethical, Legal, and Social Implications (ELSI) Research',
  INTENT_TO_STUDY: 'What are the specific scientific question(s) you intend to study',
  SCIENTIFIC_APPROACHES: 'What are the scientific approaches you plan to use for your study',
  ANTICIPATED_FINDINGS: 'What are the anticipated findings from the study',
  PUBLICATION_IN_JOURNALS: 'Publication in peer-reviewed scientific journals',
  SOCIAL_MEDIA: 'Social media (Facebook, Instagram, Twitter)',
  PRESENTATION_AT_CONFERENCES: 'Presentation at national or international scientific conferences',
  PRESENTATION_AT_COMMUNITY_FORUMS: 'Presentation at community forums or advisory groups',
  PRESS_RELEASE: 'Press release or media article covering scientific publication',
  PUBLICATION_IN_COMMUNITY_JOURNALS: 'Publication in community-based journals or blog',
  PUBLICATION_IN_PERSONAL_BLOG: 'Publication of article in a personal blog',
  OTHER: 'Other',
  INCREASE_WELLNESS: 'This research project seeks to increase wellness and resilience',
  SEEKS_TO_REDUCE_HEALTH_DISPARITIES:
    'This research project seeks to reduce health disparities and improve health equity ',
  SEEKS_TO_DEVELOP_RISK_ASSESSMENT:
    'This research project seeks to develop improved risk assessment and prevention strategies to preempt disease',
  SEEKS_TO_PROVIDE_ACCURATE_DIAGNOSIS:
    'This research project seeks to provide earlier and more accurate diagnosis to decrease illness burden',
  SEEKS_TO_REDUCE_BURDEN: 'This research project seeks to improve health outcomes and reduce disease/illness burden',
  YES_FOCUS_ON_UNDERREPRESENTED_POPULATION:
    'Yes, my study will focus on one or more specific underrepresented populations',
  NO_FOCUS_ON_UNDERREPRESENTED_POPULATION: 'No, my study will not center on underrepresented populations',
  RACE_MULTI_ANCESTRY: 'Multi-Ancestry or more than one race',
  AGE_GROUPS_ADOLESCENTS: 'Adolescents',
  SEX_AT_BIRTH: 'Participants who report something other than female or male as their sex at birth',
  GENDER_IDENTITY: 'Participants who identify as gender variant',
  GEOGRAPHY_RURAL: 'Participants who live in a rural or non-metropolitan setting',
  EDUCATION_LEVEL_HIGHSCHOOL: 'Participants with less than a high school degree or equivalent',
  DISABILITY_STATUS_WITH_DISABILITY: 'Participants with a physical and/or cognitive disability',
  NO_REQUEST_REVIEW: 'No, I have no concerns at this time about potential stigmatization',
  YES_REQUEST_REVIEW: 'Yes, I would like to request a review of my research purpose',
  SHARE_WITH_COLLABORATORS: 'Share workspace with the same set of collaborators' // visible when clone workspace
};

export const DataTestAlias = {
  WORKSPACE_NAME: 'workspace-name',
  ACCESS_TIER_SELECT: 'select-access-tier',
  CDR_VERSION_SELECT: 'select-cdr-version'
};

export const FIELD = {
  createWorkspaceButton: {
    textOption: { name: LinkText.CreateWorkspace }
  },
  duplicateWorkspaceButton: {
    textOption: { name: LinkText.DuplicateWorkspace }
  },
  cancelWorkspaceButton: {
    textOption: { name: LinkText.Cancel }
  },
  workspaceNameTextbox: {
    textOption: { dataTestId: DataTestAlias.WORKSPACE_NAME, type: ElementType.Textbox }
  },
  accessTierSelect: {
    textOption: { dataTestId: DataTestAlias.ACCESS_TIER_SELECT, type: ElementType.Select }
  },
  cdrVersionSelect: {
    textOption: { dataTestId: DataTestAlias.CDR_VERSION_SELECT, type: ElementType.Select }
  },
  billingAccountSelect: {
    textOption: { name: LabelAlias.SELECT_BILLING, type: ElementType.Select }
  },
  shareWithCollaboratorsCheckbox: {
    textOption: { name: LabelAlias.SHARE_WITH_COLLABORATORS, type: ElementType.Checkbox }
  },
  PRIMARY_PURPOSE: {
    // fields in question #1
    researchPurposeCheckbox: {
      textOption: { name: LabelAlias.RESEARCH_PURPOSE, ancestorLevel: 3, type: ElementType.Checkbox }
    },
    diseaseFocusedResearchCheckbox: {
      textOption: { name: LabelAlias.DISEASE_FOCUSED_RESEARCH, ancestorLevel: 2, type: ElementType.Checkbox },
      affiliated: ElementType.Textbox
    },
    methodsDevelopmentValidationStudyCheckbox: {
      textOption: { name: LabelAlias.METHODS_DEVELOPMENT, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    researchControlCheckbox: {
      textOption: { name: LabelAlias.RESEARCH_CONTROL, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    geneticResearchCheckbox: {
      textOption: { name: LabelAlias.GENETIC_RESEARCH, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    socialBehavioralResearchCheckbox: {
      textOption: { name: LabelAlias.SOCIAL_BEHAVIORAL_RESEARCH, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    populationHealthCheckbox: {
      textOption: { name: LabelAlias.POPULATION_HEALTH, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    ethicalLegalSocialImplicationsResearchCheckbox: {
      textOption: { name: LabelAlias.ETHICAL_LEGAL_SOCIAL_IMPLICATIONS, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    drugTherapeuticsDevelopmentResearchCheckbox: {
      textOption: { name: LabelAlias.DRUG_THERAPEUTIC_DEVELOPMENT, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    educationPurposeCheckbox: {
      textOption: { name: LabelAlias.EDUCATION_PURPOSE, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    forProfitPurposeCheckbox: {
      textOption: { name: LabelAlias.FOR_PROFIT_PURPOSE, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    otherPurposeCheckbox: {
      textOption: { name: LabelAlias.OTHER_PURPOSE, ancestorLevel: 2, type: ElementType.Checkbox },
      affiliated: ElementType.Textarea
    }
  },
  RESEARCH_PURPOSE_SUMMARY: {
    // fields in question #2
    scientificQuestionsIntentToStudyTextarea: {
      textOption: { containsText: LabelAlias.INTENT_TO_STUDY, ancestorLevel: 3, type: ElementType.Textarea }
    },
    scientificApproachesToUseTextarea: {
      textOption: { containsText: LabelAlias.SCIENTIFIC_APPROACHES, ancestorLevel: 3, type: ElementType.Textarea }
    },
    anticipatedFindingsFromStudyTextarea: {
      textOption: { containsText: LabelAlias.ANTICIPATED_FINDINGS, ancestorLevel: 3, type: ElementType.Textarea }
    }
  },
  DISSEMINATE_RESEARCH_FINDINGS: {
    // fields in question #3
    publicationInScientificJournalsCheckbox: {
      textOption: { containsText: LabelAlias.PUBLICATION_IN_JOURNALS, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    socialMediaCheckbox: {
      textOption: { containsText: LabelAlias.SOCIAL_MEDIA, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    presentationAtScientificConferencesCheckbox: {
      textOption: { containsText: LabelAlias.PRESENTATION_AT_CONFERENCES, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    presentationAtCommunityForumsCheckbox: {
      textOption: {
        containsText: LabelAlias.PRESENTATION_AT_COMMUNITY_FORUMS,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    },
    pressReleaseCheckbox: {
      textOption: { containsText: LabelAlias.PRESS_RELEASE, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    publicationInCommunityJournalsCheckbox: {
      textOption: {
        containsText: LabelAlias.PUBLICATION_IN_COMMUNITY_JOURNALS,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    },
    publicationInPersonalBlogCheckbox: {
      textOption: {
        containsText: LabelAlias.PUBLICATION_IN_PERSONAL_BLOG,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    },
    otherCheckbox: {
      textOption: { name: LabelAlias.OTHER, ancestorLevel: 2, type: ElementType.Checkbox },
      affiliated: ElementType.Textarea
    }
  },
  DESCRIBE_ANTICIPATED_OUTCOMES: {
    // fields in question #4
    seeksIncreaseWellnessCheckbox: {
      textOption: { containsText: LabelAlias.INCREASE_WELLNESS, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    seeksToReduceHealthDisparitiesCheckbox: {
      textOption: {
        containsText: LabelAlias.SEEKS_TO_REDUCE_HEALTH_DISPARITIES,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    },
    seeksToDevelopRiskAssessmentCheckbox: {
      textOption: {
        containsText: LabelAlias.SEEKS_TO_DEVELOP_RISK_ASSESSMENT,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    },
    seeksToProvideEarlierDiagnosisCheckbox: {
      textOption: {
        containsText: LabelAlias.SEEKS_TO_PROVIDE_ACCURATE_DIAGNOSIS,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    },
    seeksToReduceBurdenCheckbox: {
      textOption: { containsText: LabelAlias.SEEKS_TO_REDUCE_BURDEN, ancestorLevel: 2, type: ElementType.Checkbox }
    }
  },
  POPULATION_OF_INTEREST: {
    // fields in question #5
    yesRadiobutton: {
      textOption: { containsText: LabelAlias.YES_FOCUS_ON_UNDERREPRESENTED_POPULATION, type: ElementType.RadioButton }
    },
    noRadiobutton: {
      textOption: { containsText: LabelAlias.NO_FOCUS_ON_UNDERREPRESENTED_POPULATION, type: ElementType.RadioButton }
    },
    raceMultiAncestryCheckbox: {
      textOption: { containsText: LabelAlias.RACE_MULTI_ANCESTRY, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    ageGroupsAdolescentsCheckbox: {
      textOption: { containsText: LabelAlias.AGE_GROUPS_ADOLESCENTS, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    sexAtBirthCheckbox: {
      textOption: { containsText: LabelAlias.SEX_AT_BIRTH, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    genderIdentityCheckbox: {
      textOption: { containsText: LabelAlias.GENDER_IDENTITY, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    geographyRuralCheckbox: {
      textOption: { containsText: LabelAlias.GEOGRAPHY_RURAL, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    educationLevelHighSchoolCheckbox: {
      textOption: { containsText: LabelAlias.EDUCATION_LEVEL_HIGHSCHOOL, ancestorLevel: 2, type: ElementType.Checkbox }
    },
    disabilityStatusWithDisabilityCheckbox: {
      textOption: {
        containsText: LabelAlias.DISABILITY_STATUS_WITH_DISABILITY,
        ancestorLevel: 2,
        type: ElementType.Checkbox
      }
    }
  },
  REQUEST_FOR_REVIEW: {
    // fields in question #6
    yesRequestReviewRadiobutton: {
      textOption: { containsText: LabelAlias.YES_REQUEST_REVIEW, type: ElementType.RadioButton }
    },
    noRequestReviewRadiobutton: {
      textOption: { containsText: LabelAlias.NO_REQUEST_REVIEW, type: ElementType.RadioButton }
    }
  }
};

// matches ui/src/app/utils/access-tiers.tsx
export enum AccessTierShortNames {
  Registered = 'registered',
  Controlled = 'controlled'
}

export default class WorkspaceEditPage extends WorkspaceBase {
  constructor(page: Page) {
    super(page);
  }

  async isLoaded(): Promise<boolean> {
    await waitForDocumentTitle(this.page, PageTitle);
    // Wait for Workspace name text-field, Billing Account Select.
    const select = new Select(this.page, buildXPath(FIELD.billingAccountSelect.textOption));
    await Promise.all([this.getWorkspaceNameTextbox().waitForXPath(), select.waitForXPath()]);
    await this.getCancelButton().waitUntilEnabled();
    await waitWhileLoading(this.page);
    return true;
  }

  getDataAccessTierSelect(): Select {
    return Select.findByName(this.page, FIELD.accessTierSelect.textOption);
  }

  /**
   * Find the CDR Version Select element.
   */
  getCdrVersionSelect(): Select {
    return Select.findByName(this.page, FIELD.cdrVersionSelect.textOption);
  }

  async getCdrVersionUpgradeMessage(): Promise<string> {
    const xpath = '//*[@data-test-id="cdr-version-upgrade"]';
    const element = BaseElement.asBaseElement(this.page, await this.page.waitForXPath(xpath, { visible: true }));
    return element.getTextContent();
  }

  getBillingAccountSelect(): Select {
    return Select.findByName(this.page, FIELD.billingAccountSelect.textOption);
  }

  getCreateWorkspaceButton(): Button {
    return Button.findByName(this.page, FIELD.createWorkspaceButton.textOption);
  }

  getDuplicateWorkspaceButton(): Button {
    // Cannot use Button.forLabel because it finds two elements on Duplicate workspace page.
    // Don't change. use this xpath to find the button "DUPLICATE WORKSPACE".
    return new Button(this.page, '//*[text()="Duplicate Workspace" and @role="button"]');
  }

  getUpdateWorkspaceButton(): Button {
    return new Button(this.page, '//*[text()="Update Workspace" and @role="button"]');
  }

  getCancelButton(): Button {
    return Button.findByName(this.page, FIELD.cancelWorkspaceButton.textOption);
  }

  getWorkspaceNameTextbox(): Textbox {
    return Textbox.findByName(this.page, FIELD.workspaceNameTextbox.textOption);
  }

  getShareWithCollaboratorsCheckbox(): Checkbox {
    return Checkbox.findByName(this.page, FIELD.shareWithCollaboratorsCheckbox.textOption);
  }

  question1_researchPurpose(): WebComponent {
    return new WebComponent(this.page, FIELD.PRIMARY_PURPOSE.researchPurposeCheckbox.textOption);
  }

  question1_educationalPurpose(): WebComponent {
    return new WebComponent(this.page, FIELD.PRIMARY_PURPOSE.educationPurposeCheckbox.textOption);
  }

  question1_otherPurpose(): WebComponent {
    return new WebComponent(this.page, FIELD.PRIMARY_PURPOSE.otherPurposeCheckbox.textOption);
  }

  question1_diseaseFocusedResearch(): WebComponent {
    return new WebComponent(this.page, FIELD.PRIMARY_PURPOSE.diseaseFocusedResearchCheckbox.textOption);
  }

  question2_scientificQuestionsIntendToStudy(): WebComponent {
    return new WebComponent(
      this.page,
      FIELD.RESEARCH_PURPOSE_SUMMARY.scientificQuestionsIntentToStudyTextarea.textOption
    );
  }

  question2_scientificApproaches(): WebComponent {
    return new WebComponent(this.page, FIELD.RESEARCH_PURPOSE_SUMMARY.scientificApproachesToUseTextarea.textOption);
  }

  question2_anticipatedFindings(): WebComponent {
    return new WebComponent(this.page, FIELD.RESEARCH_PURPOSE_SUMMARY.anticipatedFindingsFromStudyTextarea.textOption);
  }

  // Question 3. one of many checkboxes
  publicationInJournal(): WebComponent {
    return new WebComponent(
      this.page,
      FIELD.DISSEMINATE_RESEARCH_FINDINGS.publicationInScientificJournalsCheckbox.textOption
    );
  }

  // Question 4. one of many checkboxes
  increaseWellnessResilience(): WebComponent {
    return new WebComponent(this.page, FIELD.DESCRIBE_ANTICIPATED_OUTCOMES.seeksIncreaseWellnessCheckbox.textOption);
  }

  /**
   * Select Data Access Tier by name.
   * @param {string} value
   */
  async selectAccessTier(value: string = AccessTierDisplayNames.Registered): Promise<string> {
    const select = this.getDataAccessTierSelect();
    return select.selectOption(value);
  }

  /**
   * Select CDR Version by name.
   * @param {string} value
   */
  async selectCdrVersion(value: string = config.DEFAULT_CDR_VERSION_NAME): Promise<string> {
    const select = this.getCdrVersionSelect();
    return select.selectOption(value);
  }

  /**
   * Select Billing Account
   * @param {string} billingAccount
   */
  async selectBillingAccount(billingAccount: string = UseFreeCredits): Promise<void> {
    const billingAccountSelect = this.getBillingAccountSelect();
    await billingAccountSelect.selectOptionByValuePrefix(billingAccount);
  }

  /**
   * Assumption: Checked checkbox means to expand the section, hidden questions will become visible.
   * @param {boolean} yesOrNo: True means to check checkbox. False means to uncheck.
   */
  async expandResearchPurposeGroup(yesOrNo = true): Promise<void> {
    // expand Disease purpose section if needed
    const researchPurpose = this.question1_researchPurpose();
    const researchPurposeCheckbox = researchPurpose.asCheckBox();
    const is = await researchPurposeCheckbox.isChecked();
    if (yesOrNo !== is) {
      // click checkbox expands or collapses the section, reveal hidden questions contained inside.
      await researchPurposeCheckbox.check();
    }
  }

  /**
   * Type in new workspace name.
   * @return {string} new workspace name
   */
  async fillOutWorkspaceName(workspaceName: string = makeWorkspaceName({ includeHyphen: false })): Promise<string> {
    await this.getWorkspaceNameTextbox().type(workspaceName);
    await this.getWorkspaceNameTextbox().pressTab();
    return workspaceName;
  }

  /**
   *  Enter value in 'Disease-focused research' textbox
   * @param {string} diseaseName
   */
  async fillOutDiseaseFocusedResearch(diseaseName = 'diabetic cataract'): Promise<void> {
    const diseaseNameComponent = this.question1_diseaseFocusedResearch();
    await diseaseNameComponent.asCheckBox().check();
    await diseaseNameComponent.asTextBox().type(diseaseName);
    await diseaseNameComponent.asTextBox().pressTab();
  }

  /**
   * Enter value in Other Purpose textarea
   * @param {string} value
   */
  async fillOutOtherPurpose(value?: string): Promise<void> {
    if (value === undefined) {
      value = faker.lorem.paragraph();
    }
    // check Other-Purpose checkbox
    const otherPurpose = this.question1_otherPurpose();
    await otherPurpose.asCheckBox().check(); // enables textarea
    await otherPurpose.asTextArea().type(value);
  }

  /**
   * Question 6. Request for Review of Research Purpose Description
   * @param selected: True means select "Yes, Request Review" radiobutton. False means select "No, Request Review" radiobutton.
   */
  async requestForReviewRadiobutton(selected: boolean): Promise<void> {
    let radioComponent: WebComponent;
    if (selected) {
      radioComponent = new WebComponent(this.page, FIELD.REQUEST_FOR_REVIEW.yesRequestReviewRadiobutton.textOption);
    } else {
      radioComponent = new WebComponent(this.page, FIELD.REQUEST_FOR_REVIEW.noRequestReviewRadiobutton.textOption);
    }
    await radioComponent.asRadioButton().select();
  }

  /**
   * Find and click the CREATE WORKSPACE (FINISH) button
   */
  async clickCreateFinishButton(button: ElementHandle | Button): Promise<string[]> {
    await button.focus(); // bring into viewport
    await button.click();

    // confirm create in pop-up modal
    const modal = new NewWorkspaceModal(this.page);
    await modal.waitForLoad();
    const modalTextContent = await modal.getTextContent();
    await modal.clickButton(LinkText.Confirm, {
      waitForClose: true,
      waitForLoadingSpinner: false,
      timeout: 4 * 60 * 1000
    });
    await waitWhileLoading(this.page);
    return modalTextContent;
  }

  async clickShareWithCollaboratorsCheckbox(): Promise<void> {
    const checkbox = this.getShareWithCollaboratorsCheckbox();
    await checkbox.check();
  }

  // Fill out only the fields needed for a successful duplication
  async fillOutRequiredDuplicationFields(
    workspaceName: string = makeWorkspaceName({ includeHyphen: false })
  ): Promise<string> {
    await this.getWorkspaceNameTextbox().clear();
    await this.fillOutWorkspaceName(workspaceName);
    await this.requestForReviewRadiobutton(false);
    return workspaceName;
  }

  // click cancel button on edit page and navigate to dataPage
  async clickCancelButton(): Promise<WorkspaceDataPage> {
    const button = this.getCancelButton();
    await button.click();
    const dataPage = new WorkspaceDataPage(this.page);
    return dataPage;
  }
}


text:
package com.ecomhack.riddle.estimote;

import java.util.List;
import java.util.concurrent.TimeUnit;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.ecomhack.riddle.ApplicationState;
import com.ecomhack.riddle.SpecialDiscountActivity;
import com.ecomhack.riddle.StartActivity;
import com.estimote.sdk.Beacon;
import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;
import com.estimote.sdk.BeaconManager.MonitoringListener;
import com.ecomhack.riddle.R;

public class EstimoteManager {

    private static BeaconManager beaconManager;
    private static NotificationManager notificationManager;
    private static final int REGISTRATION_REGION_MAJOR = 25140;
    private static final Region REGISTRATION_REGION = new Region("registration_region", null, REGISTRATION_REGION_MAJOR, null);
    private static final Region ALL_ESTIMOTE_BEACONS = new Region("all_beacons", null, null, null);
    private final NearbyProductDiscovery nearbyProductDiscovery;

    private static Context currentContext;

    // Create everything we need to monitor the beacons
    public EstimoteManager(NotificationManager notificationMngr,
                           Context context, final Intent i) {
        notificationManager = notificationMngr;
        currentContext = context;
        nearbyProductDiscovery = new NearbyProductDiscovery(currentContext);
        try {

            // Create a beacon manager
            beaconManager = new BeaconManager(currentContext);

            // We want the beacons heartbeat to be set at one second.
            beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(1),
                    0);

            // Method called when a beacon gets...
            beaconManager.setMonitoringListener(new MonitoringListener() {
                // ... close to us.
                @Override
                public void onEnteredRegion(Region region, List<Beacon> beacons) {
                    Log.i("riddle", "found registration beacon.");
                    if (!ApplicationState.isGameActive()) {
                        final Intent intent = new Intent(currentContext, StartActivity.class);
                        intent.setAction(Intent.ACTION_MAIN);
                        intent.addCategory(Intent.CATEGORY_LAUNCHER);
                        postNotificationIntent("Play with us!",
                                "Tap to start the REWE RIDDLE", intent, 123);
                    }
                }

                // ... far away from us.
                @Override
                public void onExitedRegion(Region region) {
                    // NOOP
                }
            });

            beaconManager.setRangingListener(new BeaconManager.RangingListener() {
                @Override
                public void onBeaconsDiscovered(Region region, List<Beacon> list) {
                    nearbyProductDiscovery.discoverProducts(list);
                    if (!ApplicationState.getActiveWaitForAdBeacons().isEmpty()) {

                        if (ApplicationState.getActiveWaitForAdBeacons().contains(NearbyProductDiscovery.SPECIAL_DISCOUNT_BEACON)) {
                            Log.i("riddle", "activated special wait discount.");
                            ApplicationState.addReceivedSpecialDiscount(NearbyProductDiscovery.SPECIAL_DISCOUNT_BEACON);
                            final Intent intent = new Intent(currentContext, SpecialDiscountActivity.class);
                            intent.setAction(Intent.ACTION_MAIN);
                            postNotificationIntent("Alpia Vollmilch 20% !!!",
                                    "You've received a special discount!", intent, 124);
                        }
                    }
                }
            });

            // Connect to the beacon manager...
            beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
                @Override
                public void onServiceReady() {
                    try {
                        // ... and start the monitoring
                        beaconManager.startMonitoring(REGISTRATION_REGION);
                        beaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
                    } catch (Exception e) {
                    }
                }
            });
        } catch (Exception e) {
        }
    }

    // Pops a notification in the task bar
    public void postNotificationIntent(String title, String msg, Intent intent, int notificationId) {
        PendingIntent pendingIntent = PendingIntent.getActivity(currentContext, 0, intent, 0);
        Notification notification = new NotificationCompat.Builder(currentContext)
                .setSmallIcon(R.drawable.ic_stat_notification)
                .setAutoCancel(true)
                .setLargeIcon(BitmapFactory.decodeResource(currentContext.getResources(), R.drawable.ic_launcher))
                .setContentTitle(title)
                .setContentIntent(pendingIntent)
                .setFullScreenIntent(pendingIntent, true)
                .setContentText(msg)
                .setSubText("").build();
        notification.defaults |= Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_LIGHTS;

        notificationManager.notify(notificationId, notification);

    }

    // Stop beacons monitoring, and closes the service
    public void stop() {
        Log.i("riddle", "Stopping estimote manager.");
        try {
            if (nearbyProductDiscovery != null) {
                nearbyProductDiscovery.close();
            }
            beaconManager.stopMonitoring(REGISTRATION_REGION);
            beaconManager.disconnect();
        } catch (Exception e) {
            Log.e("riddle", "Error during Estimote manager shutdown.", e);
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AppW_LoginUsuario
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        VentanaSaludo loginCorrecto;

        public MainWindow()
        {
            InitializeComponent();
            loginCorrecto = new VentanaSaludo();
        }

        string PASSCORRECTA = "lol";
        string USERCORRECTO = "Beel";

        int NINTENTOSMAXIMOS = 3;
        int nIntentos = 0;

        private void btn_Aceptar_Click(object sender, RoutedEventArgs e)
        {
            nIntentos++;

            if (txtB_NombreUsuario.Text == USERCORRECTO && passB_ClaveUsuario.Password == PASSCORRECTA)
            {
                loginCorrecto.ShowDialog();
                lbl_Info.Content = "¡Correcto!";
            }
            else
                lbl_Info.Content = "Datos incorrectos";

            if (nIntentos == NINTENTOSMAXIMOS)
            {
                btn_Aceptar.IsEnabled = false;
                lbl_Info.Content = "Login cancelado";
            }
        }

        private void btn_Reset_Click(object sender, RoutedEventArgs e)
        {
            passB_ClaveUsuario.Clear();
            txtB_NombreUsuario.Clear();

            txtB_NombreUsuario.Focus();
        }

        private void txtB_NombreUsuario_LostFocus(object sender, RoutedEventArgs e)
        {
            if (txtB_NombreUsuario.Text.Length == 0)
            {
                txtB_NombreUsuario.Foreground = Brushes.Gray;
                txtB_NombreUsuario.Text = "Tu usuario";
            }
        }

        private void txtB_NombreUsuario_GotFocus(object sender, RoutedEventArgs e)
        {
            txtB_NombreUsuario.Clear();
            txtB_NombreUsuario.Foreground = Brushes.Black;
        }

        private void passB_ClaveUsuario_GotFocus(object sender, RoutedEventArgs e)
        {
            passB_ClaveUsuario.Clear();
        }
    }
}


text:
#ifndef __ANALYSIS_H__
#define __ANALYSIS_H__

//#define EXPERIMENTAL

#include <iostream>
#include "classad/classad_distribution.h"
#include "condor_classad.h"
#include "condor_attributes.h"
#include "boolExpr.h"
#include "resourceGroup.h"
//#include "classadList.h"
#include "explain.h"
#include "interval.h"
#include "boolValue.h"
#include "conversion.h"

#include "result.h"

/// The analyzer object
class ClassAdAnalyzer
{
 public:

		/** Default Constructor */
	ClassAdAnalyzer( bool result_as_struct = false );

		/** Destructor */
	~ClassAdAnalyzer( );

	classad_analysis::job::result GetResult() { return (result_as_struct && m_result) ? *m_result : classad_analysis::job::result(); }
	bool GetErrors(bool clear_errs=true, std::string * perrs = NULL) {
		bool had_errors = ! errstm.str().empty();
		if (perrs) *perrs = errstm.str();
		if (clear_errs) errstm.clear();
		return had_errors;
	}

		/** Analyze a job ClassAd requirements expression.
		 *	@param request The job ClassAd
		 *	@param offers A list of machine ClassAds
		 *	@param buffer The results of the analysis
		 *  @return true on success false on failure
		 */
	bool AnalyzeJobReqToBuffer( ClassAd *request, ClassAdList &offers,
								std::string &buffer, std::string &pretty_req);

#if defined( COLLECTIONS )
		/** Analyze a job ClassAd requirements expression.
		 *	@param request The job ClassAd
		 *	@param offers A collection of machine ClassAds
		 *	@param buffer The results of the analysis
		 *	@return true on success false on failure
		 */
	bool AnalyzeJobReqToBuffer( classad::ClassAd *request,
								classad::ClassAdCollectionServer &offers,
								std::string &buffer );
#endif

		/** Analyze job ClassAd attributes.
		 *	@param request The job ClassAd
		 *	@param offers A list of machine ClassAds
		 *	@param buffer The results of the analysis
		 *	@return true on success false on failure
		 */
	bool AnalyzeJobAttrsToBuffer( ClassAd *request, ClassAdList &offers,
								  std::string &buffer );

		/** Analyze an arbitrary expression.
		 *	@param mainAd The ClassAd contaning the expression
		 *	@param contextAd The target ClassAd
		 *	@param attr The attribute corresponding to the expression
		 *	@param buffer The results of the analysis
		 *	@return true on success false on failure
		 */
	bool AnalyzeExprToBuffer( classad::ClassAd *mainAd,
							  classad::ClassAd *contextAd,
							  std::string &attr, std::string &buffer );

 private:
	bool result_as_struct;
	classad_analysis::job::result *m_result;

	MultiProfile *jobReq;
	classad::MatchClassAd mad;

	ExprTree* std_rank_condition;
	ExprTree* preempt_rank_condition;
	ExprTree* preempt_prio_condition;
	ExprTree* preemption_req;

	std::stringstream errstm;

	void ensure_result_initialized(classad::ClassAd *request);

	// wrapper functions to add information to the result only if we're generating one
	void result_add_suggestion(classad_analysis::suggestion s);
	void result_add_explanation(classad_analysis::matchmaking_failure_kind mfk, classad::ClassAd resource);
	void result_add_explanation(classad_analysis::matchmaking_failure_kind mfk, ClassAd *resource);
	void result_add_machine(classad::ClassAd resource);

	bool AnalyzeJobReqToBuffer( classad::ClassAd *request, ResourceGroup &offers, std::string &buffer, std::string &pretty_req );
	bool AnalyzeJobAttrsToBuffer( classad::ClassAd *request, ResourceGroup &offers, std::string &buffer );

	bool BuildBoolTable( MultiProfile *, ResourceGroup &, BoolTable &result );
	bool BuildBoolTable( Profile *, ResourceGroup &, BoolTable &result );

	bool MakeResourceGroup( ClassAdList &, ResourceGroup &result );

#if defined( COLLECTIONS )
	bool MakeResourceGroup( classad::ClassAdCollectionServer &, ResourceGroup &result );
#endif

	bool NeedsBasicAnalysis( ClassAd *request );
	void BasicAnalyze(ClassAd* request, ClassAd* offer);

	bool SuggestCondition( MultiProfile *, ResourceGroup & );
	bool SuggestConditionRemove( Profile *, ResourceGroup & );
	bool SuggestConditionModify( Profile *, ResourceGroup & );

	bool FindConflicts( MultiProfile *, ResourceGroup & );
	bool FindConflicts( Profile *, ResourceGroup & );

	bool AnalyzeAttributes( classad::ClassAd *, ResourceGroup &,
							ClassAdExplain &result );

	bool EqualsIgnoreCase( const std::string &, const std::string & );
	bool DefinedLiteralValue( classad::Value & );
	bool AddConstraint( ValueRange *&, Condition * );
	bool AddDefaultConstraint( ValueRange *&vr );

	bool PruneDisjunction( classad::ExprTree *, classad::ExprTree *& result );
	bool PruneConjunction( classad::ExprTree *, classad::ExprTree *& result );
	bool PruneAtom( classad::ExprTree *, classad::ExprTree *& result );

		// unsupported
//	bool InDNF( classad::ExprTree * );
//	bool IsAtomicBooleanFormula( classad::Operation * );
//	bool PropagateNegation( classad::ExprTree *, classad::ExprTree *&result );
//	bool ToDNF( classad::ExprTree *, classad::ExprTree *&result );

};

#endif // __ANALYSIS_H__


text:
// Copyright 2014 Codehack http://codehack.com
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package relax

import (
	"mime"
	"net/http"
	"strings"
)

const (
	defaultMediatype = "application/vnd.codehack.relax"

	defaultVersion = "current"

	defaultLanguage = "en-US"
)

/*
Content does content negotiation to select the supported representations
for the request and response. The default representation uses media type
"application/json". If new media types are available to the service, a client
can request it via the Accept header. The format of the Accept header uses
the following vendor extension:

	Accept: application/vnd.relax+{subtype}; version={version}; lang={language}

The values for {subtype}, {version} and {language} are optional. They correspond
in order; to media subtype, content version and, language. If any value is missing
or unsupported the default values are used. If a request Accept header is not
using the vendor extension, the default values are used:

	Accept: application/vnd.relax+json; version="current"; lang="en"

By decoupling version and lang from the media type, it allows us to have separate
versions for the same resource and with individual language coverage.

When Accept indicates all media types "*&#5C;*", the media subtype can be requested
through the URL path's extension. If the service doesn't support the media encoding,
then it will respond with an HTTP error code.

	GET /api/v1/tickets.xml
	GET /company/users/123.json

Note that the extension should be appended to a collection or a resource item.
The extension is removed before the request is dispatched to the routing engine.

If the request header Accept-Language is found, the value for content language
is automatically set to that. The underlying application should use this to
construct a proper respresentation in that language.

Content passes down the following info to filters:

	ctx.Get("content.encoding") // media type used for encoding
	ctx.Get("content.decoding") // Type used in payload requests POST/PUT/PATCH
	ctx.Get("content.version")  // requested version, or "current"
	ctx.Get("content.language") // requested language, or "en-US"

Requests and responses can use mixed representations if the service supports the
media types.

See also, http://tools.ietf.org/html/rfc5646; tags to identify languages.
*/
var Content struct {
	// MediaType is the vendor extended media type used by this framework.
	// Default: application/vnd.codehack.relax
	Mediatype string
	// Version is the version used when no content version is requested.
	// Default: current
	Version string
	// Language is the language used when no content language is requested.
	// Default: en-US
	Language string
}

// content is the function that does the actual content-negotiation described above.
func (svc *Service) content(next HandlerFunc) HandlerFunc {
	// JSON is our default representation.
	json := svc.encoders["application/json"]

	return func(ctx *Context) {
		ctx.Encode = json.Encode
		ctx.Decode = json.Decode

		encoder := json

		version := acceptVersion(ctx.Request.Header.Get("Accept-Version"))

		language := acceptLanguage(ctx.Request.Header.Get("Accept-Language"))

		accept := ctx.Request.Header.Get("Accept")
		if accept == "*/*" {
			// Check if subtype is in the requested URL path's extension.
			// Path: /api/v1/users.xml
			if ext := PathExt(ctx.Request.URL.Path); ext != "" {
				// remove extension from path.
				ctx.Request.URL.Path = strings.TrimSuffix(ctx.Request.URL.Path, ext)
				// create vendor media type and fallthrough
				accept = Content.Mediatype + "+" + ext[1:]
			}
		}

		// We check our vendor media type for requests of a specific subtype.
		// Everything else will default to "application/json" (see above).
		if strings.HasPrefix(accept, Content.Mediatype) {
			// Accept: application/vnd.relax+{subtype}; version={version}; lang={lang}
			mt, op, err := mime.ParseMediaType(accept)
			if err != nil {
				ctx.Header().Set("Content-Type", json.ContentType())
				ctx.Error(http.StatusBadRequest, err.Error())
				return
			}
			// check for media subtype (encoding) request.
			if idx := strings.Index(mt, "+"); idx != -1 {
				tbe := mime.TypeByExtension("." + mt[idx+1:])
				enc, ok := svc.encoders[tbe]
				if !ok {
					ctx.Header().Set("Content-Type", json.ContentType())
					ctx.Error(http.StatusNotAcceptable,
						"That media type is not supported for response.",
						"You may use type '"+json.Accept()+"'")
					return
				}
				encoder = enc
				ctx.Encode = encoder.Encode
			}

			// If version or language were specified they are preferred over Accept-* headers.
			if v, ok := op["version"]; ok {
				version = v
			}
			if v, ok := op["lang"]; ok {
				language = v
			}
		}

		// At this point we know the response media type.
		ctx.Header().Set("Content-Type", encoder.ContentType())

		// Pass the info down to other handlers.
		ctx.Set("content.encoding", encoder.Accept())
		ctx.Set("content.version", version)
		ctx.Set("content.language", language)

		// Now check for payload representation for unsafe methods: POST PUT PATCH.
		if ctx.Request.Method[0] == 'P' {
			// Content-Type: application/{subtype}
			ct, _, err := mime.ParseMediaType(ctx.Request.Header.Get("Content-Type"))
			if err != nil {
				ctx.Error(http.StatusBadRequest, err.Error())
				return
			}
			decoder, ok := svc.encoders[ct]
			if !ok {
				ctx.Error(http.StatusUnsupportedMediaType,
					"That media type is not supported for transfer.",
					"You may use type '"+json.Accept()+"'")
				return
			}
			ctx.Decode = decoder.Decode
			ctx.Set("content.decoding", ct)
		}

		next(ctx)
	}
}

// acceptVersion checks for specific version in Accept-Version HTTP header.
// returns the version requested or Content.Version if none is set.
//
// Accept-Version: v1
func acceptVersion(version string) string {
	if version == "" {
		return Content.Version
	}
	return version
}

// acceptLanguage checks for language preferences in Accept-Language header.
// It returns the language code with highest quality. If none are set, returns
// Content.Language global default.
//
// Accept-Language: da, jp;q=0.8, en;q=0.9
func acceptLanguage(value string) string {
	if value == "" {
		return Content.Language
	}

	langcode := Content.Language

	prefs, err := ParsePreferences(value)
	// If language parsing fails, continue with request.
	// See https://tools.ietf.org/html/rfc7231#section-5.3.5
	if err == nil {
		// If langcode is not listed, give it a competitive value for sanity.
		// The value most likely is still "en" (English).
		if _, ok := prefs[langcode]; !ok {
			prefs[langcode] = 0.85
		}
		for code, value := range prefs {
			if value > prefs[langcode] {
				langcode = code
			}
		}
	}
	return langcode
}

func init() {
	// Set content defaults
	Content.Mediatype = defaultMediatype
	Content.Version = defaultVersion
	Content.Language = defaultLanguage

	// just in case
	_ = mime.AddExtensionType(".json", "application/json")
	_ = mime.AddExtensionType(".xml", "application/xml")
}


text:
package utils;

public interface MoreMethods {

    void methodA();
    void methodC();
    void methodD();
    Long methodE();
}