text:
.class Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;
.super Ljava/lang/Object;
.source "NotificationManagerCompat.java"

# interfaces
.implements Landroid/content/ServiceConnection;
.implements Landroid/os/Handler$Callback;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/support/v4/app/NotificationManagerCompat;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0xa
    name = "SideChannelManager"
.end annotation

.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;
    }
.end annotation

# static fields
.field private static final KEY_BINDER:Ljava/lang/String; = "binder"

.field private static final MSG_QUEUE_TASK:I = 0x0

.field private static final MSG_RETRY_LISTENER_QUEUE:I = 0x3

.field private static final MSG_SERVICE_CONNECTED:I = 0x1

.field private static final MSG_SERVICE_DISCONNECTED:I = 0x2

# instance fields
.field private mCachedEnabledPackages:Ljava/util/Set;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Set",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private final mContext:Landroid/content/Context;

.field private final mHandler:Landroid/os/Handler;

.field private final mHandlerThread:Landroid/os/HandlerThread;

.field private final mRecordMap:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Landroid/content/ComponentName;",
            "Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;",
            ">;"
        }
    .end annotation
.end field

# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 2
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 281
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 277
    new-instance v0, Ljava/util/HashMap;

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

    iput-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    .line 279
    new-instance v0, Ljava/util/HashSet;

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

    iput-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mCachedEnabledPackages:Ljava/util/Set;

    .line 282
    iput-object p1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mContext:Landroid/content/Context;

    .line 283
    new-instance v0, Landroid/os/HandlerThread;

    const-string v1, "NotificationManagerCompat"

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

    iput-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandlerThread:Landroid/os/HandlerThread;

    .line 284
    iget-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandlerThread:Landroid/os/HandlerThread;

    invoke-virtual {v0}, Landroid/os/HandlerThread;->start()V

    .line 285
    new-instance v0, Landroid/os/Handler;

    iget-object v1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandlerThread:Landroid/os/HandlerThread;

    invoke-virtual {v1}, Landroid/os/HandlerThread;->getLooper()Landroid/os/Looper;

    move-result-object v1

    invoke-direct {v0, v1, p0}, Landroid/os/Handler;-><init>(Landroid/os/Looper;Landroid/os/Handler$Callback;)V

    iput-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    .line 286
    return-void
.end method

.method private ensureServiceBound(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)Z
    .locals 4
    .param p1, "record"    # Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .prologue
    .line 421
    iget-boolean v1, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->bound:Z

    if-eqz v1, :cond_0

    .line 422
    const/4 v1, 0x1

    .line 432
    :goto_0
    return v1

    .line 424
    :cond_0
    new-instance v1, Landroid/content/Intent;

    const-string v2, "android.support.BIND_NOTIFICATION_SIDE_CHANNEL"

    invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

    invoke-virtual {v1, v2}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;

    move-result-object v0

    .line 425
    .local v0, "intent":Landroid/content/Intent;
    iget-object v1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mContext:Landroid/content/Context;

    # getter for: Landroid/support/v4/app/NotificationManagerCompat;->SIDE_CHANNEL_BIND_FLAGS:I
    invoke-static {}, Landroid/support/v4/app/NotificationManagerCompat;->access$000()I

    move-result v2

    invoke-virtual {v1, v0, p0, v2}, Landroid/content/Context;->bindService(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z

    move-result v1

    iput-boolean v1, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->bound:Z

    .line 426
    iget-boolean v1, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->bound:Z

    if-eqz v1, :cond_1

    .line 427
    const/4 v1, 0x0

    iput v1, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

    .line 432
    :goto_1
    iget-boolean v1, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->bound:Z

    goto :goto_0

    .line 429
    :cond_1
    const-string v1, "NotifManCompat"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "Unable to bind to listener "

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

    move-result-object v2

    iget-object v3, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

    invoke-virtual {v2, v3}, 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;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 430
    iget-object v1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mContext:Landroid/content/Context;

    invoke-virtual {v1, p0}, Landroid/content/Context;->unbindService(Landroid/content/ServiceConnection;)V

    goto :goto_1
.end method

.method private ensureServiceUnbound(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V
    .locals 1
    .param p1, "record"    # Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .prologue
    .line 439
    iget-boolean v0, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->bound:Z

    if-eqz v0, :cond_0

    .line 440
    iget-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mContext:Landroid/content/Context;

    invoke-virtual {v0, p0}, Landroid/content/Context;->unbindService(Landroid/content/ServiceConnection;)V

    .line 441
    const/4 v0, 0x0

    iput-boolean v0, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->bound:Z

    .line 443
    :cond_0
    const/4 v0, 0x0

    iput-object v0, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->service:Landroid/support/v4/app/INotificationSideChannel;

    .line 444
    return-void
.end method

.method private handleQueueTask(Landroid/support/v4/app/NotificationManagerCompat$Task;)V
    .locals 3
    .param p1, "task"    # Landroid/support/v4/app/NotificationManagerCompat$Task;

    .prologue
    .line 317
    invoke-direct {p0}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->updateListenerMap()V

    .line 318
    iget-object v2, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

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

    move-result-object v0

    .local v0, "i$":Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

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

    move-result-object v1

    check-cast v1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .line 319
    .local v1, "record":Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;
    iget-object v2, v1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v2, p1}, Ljava/util/LinkedList;->add(Ljava/lang/Object;)Z

    .line 320
    invoke-direct {p0, v1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->processListenerQueue(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    goto :goto_0

    .line 322
    .end local v1    # "record":Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;
    :cond_0
    return-void
.end method

.method private handleRetryListenerQueue(Landroid/content/ComponentName;)V
    .locals 2
    .param p1, "componentName"    # Landroid/content/ComponentName;

    .prologue
    .line 341
    iget-object v1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    invoke-interface {v1, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .line 342
    .local v0, "record":Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;
    if-eqz v0, :cond_0

    .line 343
    invoke-direct {p0, v0}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->processListenerQueue(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    .line 345
    :cond_0
    return-void
.end method

.method private handleServiceConnected(Landroid/content/ComponentName;Landroid/os/IBinder;)V
    .locals 2
    .param p1, "componentName"    # Landroid/content/ComponentName;
    .param p2, "iBinder"    # Landroid/os/IBinder;

    .prologue
    .line 325
    iget-object v1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    invoke-interface {v1, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .line 326
    .local v0, "record":Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;
    if-eqz v0, :cond_0

    .line 327
    invoke-static {p2}, Landroid/support/v4/app/INotificationSideChannel$Stub;->asInterface(Landroid/os/IBinder;)Landroid/support/v4/app/INotificationSideChannel;

    move-result-object v1

    iput-object v1, v0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->service:Landroid/support/v4/app/INotificationSideChannel;

    .line 328
    const/4 v1, 0x0

    iput v1, v0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

    .line 329
    invoke-direct {p0, v0}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->processListenerQueue(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    .line 331
    :cond_0
    return-void
.end method

.method private handleServiceDisconnected(Landroid/content/ComponentName;)V
    .locals 2
    .param p1, "componentName"    # Landroid/content/ComponentName;

    .prologue
    .line 334
    iget-object v1, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    invoke-interface {v1, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .line 335
    .local v0, "record":Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;
    if-eqz v0, :cond_0

    .line 336
    invoke-direct {p0, v0}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->ensureServiceUnbound(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    .line 338
    :cond_0
    return-void
.end method

.method private processListenerQueue(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V
    .locals 6
    .param p1, "record"    # Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .prologue
    const/4 v5, 0x3

    .line 475
    const-string v2, "NotifManCompat"

    invoke-static {v2, v5}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 476
    const-string v2, "NotifManCompat"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Processing component "

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

    move-result-object v3

    iget-object v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

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

    move-result-object v3

    const-string v4, ", "

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

    move-result-object v3

    iget-object v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v4}, Ljava/util/LinkedList;->size()I

    move-result v4

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

    move-result-object v3

    const-string v4, " queued tasks"

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

    move-result-object v3

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

    move-result-object v3

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

    .line 479
    :cond_0
    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v2}, Ljava/util/LinkedList;->isEmpty()Z

    move-result v2

    if-eqz v2, :cond_2

    .line 513
    :cond_1
    :goto_0
    return-void

    .line 482
    :cond_2
    invoke-direct {p0, p1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->ensureServiceBound(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)Z

    move-result v2

    if-eqz v2, :cond_3

    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->service:Landroid/support/v4/app/INotificationSideChannel;

    if-nez v2, :cond_6

    .line 484
    :cond_3
    invoke-direct {p0, p1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->scheduleListenerRetry(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    goto :goto_0

    .line 494
    .local v1, "task":Landroid/support/v4/app/NotificationManagerCompat$Task;
    :cond_4
    :try_start_0
    const-string v2, "NotifManCompat"

    const/4 v3, 0x3

    invoke-static {v2, v3}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v2

    if-eqz v2, :cond_5

    .line 495
    const-string v2, "NotifManCompat"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Sending task "

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

    move-result-object v3

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

    move-result-object v3

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

    move-result-object v3

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

    .line 497
    :cond_5
    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->service:Landroid/support/v4/app/INotificationSideChannel;

    invoke-interface {v1, v2}, Landroid/support/v4/app/NotificationManagerCompat$Task;->send(Landroid/support/v4/app/INotificationSideChannel;)V

    .line 498
    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v2}, Ljava/util/LinkedList;->remove()Ljava/lang/Object;
    :try_end_0
    .catch Landroid/os/DeadObjectException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_1

    .line 489
    .end local v1    # "task":Landroid/support/v4/app/NotificationManagerCompat$Task;
    :cond_6
    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v2}, Ljava/util/LinkedList;->peek()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/support/v4/app/NotificationManagerCompat$Task;

    .line 490
    .restart local v1    # "task":Landroid/support/v4/app/NotificationManagerCompat$Task;
    if-nez v1, :cond_4

    .line 509
    :cond_7
    :goto_1
    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v2}, Ljava/util/LinkedList;->isEmpty()Z

    move-result v2

    if-nez v2, :cond_1

    .line 511
    invoke-direct {p0, p1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->scheduleListenerRetry(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    goto :goto_0

    .line 499
    :catch_0
    move-exception v0

    .line 500
    .local v0, "e":Landroid/os/DeadObjectException;
    const-string v2, "NotifManCompat"

    invoke-static {v2, v5}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v2

    if-eqz v2, :cond_7

    .line 501
    const-string v2, "NotifManCompat"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Remote service has died: "

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

    move-result-object v3

    iget-object v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

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

    move-result-object v3

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

    move-result-object v3

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

    goto :goto_1

    .line 504
    .end local v0    # "e":Landroid/os/DeadObjectException;
    :catch_1
    move-exception v0

    .line 505
    .local v0, "e":Landroid/os/RemoteException;
    const-string v2, "NotifManCompat"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "RemoteException communicating with "

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

    move-result-object v3

    iget-object v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

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

    move-result-object v3

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

    move-result-object v3

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

    goto :goto_1
.end method

.method private scheduleListenerRetry(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V
    .locals 6
    .param p1, "record"    # Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    .prologue
    const/4 v5, 0x3

    .line 452
    iget-object v2, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    iget-object v3, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

    invoke-virtual {v2, v5, v3}, Landroid/os/Handler;->hasMessages(ILjava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 468
    :goto_0
    return-void

    .line 455
    :cond_0
    iget v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

    add-int/lit8 v2, v2, 0x1

    iput v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

    .line 456
    iget v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

    const/4 v3, 0x6

    if-le v2, v3, :cond_1

    .line 457
    const-string v2, "NotifManCompat"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Giving up on delivering "

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

    move-result-object v3

    iget-object v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v4}, Ljava/util/LinkedList;->size()I

    move-result v4

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

    move-result-object v3

    const-string v4, " tasks to "

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

    move-result-object v3

    iget-object v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

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

    move-result-object v3

    const-string v4, " after "

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

    move-result-object v3

    iget v4, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

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

    move-result-object v3

    const-string v4, " retries"

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

    move-result-object v3

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

    move-result-object v3

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

    .line 459
    iget-object v2, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->taskQueue:Ljava/util/LinkedList;

    invoke-virtual {v2}, Ljava/util/LinkedList;->clear()V

    goto :goto_0

    .line 462
    :cond_1
    const/4 v2, 0x1

    iget v3, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->retryCount:I

    add-int/lit8 v3, v3, -0x1

    shl-int/2addr v2, v3

    mul-int/lit16 v0, v2, 0x3e8

    .line 463
    .local v0, "delayMs":I
    const-string v2, "NotifManCompat"

    invoke-static {v2, v5}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v2

    if-eqz v2, :cond_2

    .line 464
    const-string v2, "NotifManCompat"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Scheduling retry for "

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

    move-result-object v3

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

    move-result-object v3

    const-string v4, " ms"

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

    move-result-object v3

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

    move-result-object v3

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

    .line 466
    :cond_2
    iget-object v2, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    iget-object v3, p1, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;->componentName:Landroid/content/ComponentName;

    invoke-virtual {v2, v5, v3}, Landroid/os/Handler;->obtainMessage(ILjava/lang/Object;)Landroid/os/Message;

    move-result-object v1

    .line 467
    .local v1, "msg":Landroid/os/Message;
    iget-object v2, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    int-to-long v4, v0

    invoke-virtual {v2, v1, v4, v5}, Landroid/os/Handler;->sendMessageDelayed(Landroid/os/Message;J)Z

    goto/16 :goto_0
.end method

.method private updateListenerMap()V
    .locals 12

    .prologue
    const/4 v11, 0x3

    .line 370
    iget-object v8, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mContext:Landroid/content/Context;

    invoke-static {v8}, Landroid/support/v4/app/NotificationManagerCompat;->getEnabledListenerPackages(Landroid/content/Context;)Ljava/util/Set;

    move-result-object v2

    .line 371
    .local v2, "enabledPackages":Ljava/util/Set;, "Ljava/util/Set<Ljava/lang/String;>;"
    iget-object v8, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mCachedEnabledPackages:Ljava/util/Set;

    invoke-virtual {v2, v8}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

    move-result v8

    if-eqz v8, :cond_1

    .line 414
    :cond_0
    return-void

    .line 375
    :cond_1
    iput-object v2, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mCachedEnabledPackages:Ljava/util/Set;

    .line 376
    iget-object v8, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mContext:Landroid/content/Context;

    invoke-virtual {v8}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v8

    new-instance v9, Landroid/content/Intent;

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

    const-string v10, "android.support.BIND_NOTIFICATION_SIDE_CHANNEL"

    invoke-virtual {v9, v10}, Landroid/content/Intent;->setAction(Ljava/lang/String;)Landroid/content/Intent;

    move-result-object v9

    const/4 v10, 0x4

    invoke-virtual {v8, v9, v10}, Landroid/content/pm/PackageManager;->queryIntentServices(Landroid/content/Intent;I)Ljava/util/List;

    move-result-object v7

    .line 378
    .local v7, "resolveInfos":Ljava/util/List;, "Ljava/util/List<Landroid/content/pm/ResolveInfo;>;"
    new-instance v1, Ljava/util/HashSet;

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

    .line 379
    .local v1, "enabledComponents":Ljava/util/Set;, "Ljava/util/Set<Landroid/content/ComponentName;>;"
    invoke-interface {v7}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    .local v4, "i$":Ljava/util/Iterator;
    :cond_2
    :goto_0
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v8

    if-eqz v8, :cond_4

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

    move-result-object v6

    check-cast v6, Landroid/content/pm/ResolveInfo;

    .line 380
    .local v6, "resolveInfo":Landroid/content/pm/ResolveInfo;
    iget-object v8, v6, Landroid/content/pm/ResolveInfo;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v8, v8, Landroid/content/pm/ServiceInfo;->packageName:Ljava/lang/String;

    invoke-interface {v2, v8}, Ljava/util/Set;->contains(Ljava/lang/Object;)Z

    move-result v8

    if-eqz v8, :cond_2

    .line 383
    new-instance v0, Landroid/content/ComponentName;

    iget-object v8, v6, Landroid/content/pm/ResolveInfo;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v8, v8, Landroid/content/pm/ServiceInfo;->packageName:Ljava/lang/String;

    iget-object v9, v6, Landroid/content/pm/ResolveInfo;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v9, v9, Landroid/content/pm/ServiceInfo;->name:Ljava/lang/String;

    invoke-direct {v0, v8, v9}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 385
    .local v0, "componentName":Landroid/content/ComponentName;
    iget-object v8, v6, Landroid/content/pm/ResolveInfo;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v8, v8, Landroid/content/pm/ServiceInfo;->permission:Ljava/lang/String;

    if-eqz v8, :cond_3

    .line 386
    const-string v8, "NotifManCompat"

    new-instance v9, Ljava/lang/StringBuilder;

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

    const-string v10, "Permission present on component "

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

    move-result-object v9

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

    move-result-object v9

    const-string v10, ", not adding listener record."

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

    move-result-object v9

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

    move-result-object v9

    invoke-static {v8, v9}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    .line 390
    :cond_3
    invoke-interface {v1, v0}, Ljava/util/Set;->add(Ljava/lang/Object;)Z

    goto :goto_0

    .line 393
    .end local v0    # "componentName":Landroid/content/ComponentName;
    .end local v6    # "resolveInfo":Landroid/content/pm/ResolveInfo;
    :cond_4
    invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :cond_5
    :goto_1
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v8

    if-eqz v8, :cond_7

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

    move-result-object v0

    check-cast v0, Landroid/content/ComponentName;

    .line 394
    .restart local v0    # "componentName":Landroid/content/ComponentName;
    iget-object v8, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    invoke-interface {v8, v0}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z

    move-result v8

    if-nez v8, :cond_5

    .line 395
    const-string v8, "NotifManCompat"

    invoke-static {v8, v11}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v8

    if-eqz v8, :cond_6

    .line 396
    const-string v8, "NotifManCompat"

    new-instance v9, Ljava/lang/StringBuilder;

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

    const-string v10, "Adding listener record for "

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

    move-result-object v9

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

    move-result-object v9

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

    move-result-object v9

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

    .line 398
    :cond_6
    iget-object v8, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    new-instance v9, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    invoke-direct {v9, v0}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;-><init>(Landroid/content/ComponentName;)V

    invoke-interface {v8, v0, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_1

    .line 402
    .end local v0    # "componentName":Landroid/content/ComponentName;
    :cond_7
    iget-object v8, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mRecordMap:Ljava/util/Map;

    invoke-interface {v8}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v8

    invoke-interface {v8}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v5

    .line 404
    .local v5, "it":Ljava/util/Iterator;, "Ljava/util/Iterator<Ljava/util/Map$Entry<Landroid/content/ComponentName;Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;>;>;"
    :cond_8
    :goto_2
    invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z

    move-result v8

    if-eqz v8, :cond_0

    .line 405
    invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/util/Map$Entry;

    .line 406
    .local v3, "entry":Ljava/util/Map$Entry;, "Ljava/util/Map$Entry<Landroid/content/ComponentName;Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;>;"
    invoke-interface {v3}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v8

    invoke-interface {v1, v8}, Ljava/util/Set;->contains(Ljava/lang/Object;)Z

    move-result v8

    if-nez v8, :cond_8

    .line 407
    const-string v8, "NotifManCompat"

    invoke-static {v8, v11}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v8

    if-eqz v8, :cond_9

    .line 408
    const-string v8, "NotifManCompat"

    new-instance v9, Ljava/lang/StringBuilder;

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

    const-string v10, "Removing listener record for "

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

    move-result-object v9

    invoke-interface {v3}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v10

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

    move-result-object v9

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

    move-result-object v9

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

    .line 410
    :cond_9
    invoke-interface {v3}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;

    invoke-direct {p0, v8}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->ensureServiceUnbound(Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager$ListenerRecord;)V

    .line 411
    invoke-interface {v5}, Ljava/util/Iterator;->remove()V

    goto :goto_2
.end method

# virtual methods
.method public handleMessage(Landroid/os/Message;)Z
    .locals 4
    .param p1, "msg"    # Landroid/os/Message;

    .prologue
    const/4 v2, 0x1

    .line 298
    iget v1, p1, Landroid/os/Message;->what:I

    packed-switch v1, :pswitch_data_0

    .line 313
    const/4 v1, 0x0

    :goto_0
    return v1

    .line 300
    :pswitch_0
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/support/v4/app/NotificationManagerCompat$Task;

    invoke-direct {p0, v1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->handleQueueTask(Landroid/support/v4/app/NotificationManagerCompat$Task;)V

    move v1, v2

    .line 301
    goto :goto_0

    .line 303
    :pswitch_1
    iget-object v0, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v0, Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;

    .line 304
    .local v0, "event":Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;
    iget-object v1, v0, Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;->componentName:Landroid/content/ComponentName;

    iget-object v3, v0, Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;->iBinder:Landroid/os/IBinder;

    invoke-direct {p0, v1, v3}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->handleServiceConnected(Landroid/content/ComponentName;Landroid/os/IBinder;)V

    move v1, v2

    .line 305
    goto :goto_0

    .line 307
    .end local v0    # "event":Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;
    :pswitch_2
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/content/ComponentName;

    invoke-direct {p0, v1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->handleServiceDisconnected(Landroid/content/ComponentName;)V

    move v1, v2

    .line 308
    goto :goto_0

    .line 310
    :pswitch_3
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/content/ComponentName;

    invoke-direct {p0, v1}, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->handleRetryListenerQueue(Landroid/content/ComponentName;)V

    move v1, v2

    .line 311
    goto :goto_0

    .line 298
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_1
        :pswitch_2
        :pswitch_3
    .end packed-switch
.end method

.method public onServiceConnected(Landroid/content/ComponentName;Landroid/os/IBinder;)V
    .locals 3
    .param p1, "componentName"    # Landroid/content/ComponentName;
    .param p2, "iBinder"    # Landroid/os/IBinder;

    .prologue
    .line 349
    const-string v0, "NotifManCompat"

    const/4 v1, 0x3

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

    move-result v0

    if-eqz v0, :cond_0

    .line 350
    const-string v0, "NotifManCompat"

    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v2, "Connected to service "

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

    move-result-object v1

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

    move-result-object v1

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

    move-result-object v1

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

    .line 352
    :cond_0
    iget-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    const/4 v1, 0x1

    new-instance v2, Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;

    invoke-direct {v2, p1, p2}, Landroid/support/v4/app/NotificationManagerCompat$ServiceConnectedEvent;-><init>(Landroid/content/ComponentName;Landroid/os/IBinder;)V

    invoke-virtual {v0, v1, v2}, Landroid/os/Handler;->obtainMessage(ILjava/lang/Object;)Landroid/os/Message;

    move-result-object v0

    invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V

    .line 355
    return-void
.end method

.method public onServiceDisconnected(Landroid/content/ComponentName;)V
    .locals 3
    .param p1, "componentName"    # Landroid/content/ComponentName;

    .prologue
    .line 359
    const-string v0, "NotifManCompat"

    const/4 v1, 0x3

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

    move-result v0

    if-eqz v0, :cond_0

    .line 360
    const-string v0, "NotifManCompat"

    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v2, "Disconnected from service "

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

    move-result-object v1

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

    move-result-object v1

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

    move-result-object v1

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

    .line 362
    :cond_0
    iget-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    const/4 v1, 0x2

    invoke-virtual {v0, v1, p1}, Landroid/os/Handler;->obtainMessage(ILjava/lang/Object;)Landroid/os/Message;

    move-result-object v0

    invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V

    .line 363
    return-void
.end method

.method public queueTask(Landroid/support/v4/app/NotificationManagerCompat$Task;)V
    .locals 2
    .param p1, "task"    # Landroid/support/v4/app/NotificationManagerCompat$Task;

    .prologue
    .line 293
    iget-object v0, p0, Landroid/support/v4/app/NotificationManagerCompat$SideChannelManager;->mHandler:Landroid/os/Handler;

    const/4 v1, 0x0

    invoke-virtual {v0, v1, p1}, Landroid/os/Handler;->obtainMessage(ILjava/lang/Object;)Landroid/os/Message;

    move-result-object v0

    invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V

    .line 294
    return-void
.end method


text:
using System.Threading.Tasks;
using Marten;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace CoreTests.Examples;

public class EnvironmentChecks
{

#if NET6_0_OR_GREATER

        #region sample_use_environment_check_in_hosted_service

        public static async Task use_environment_check()
        {
            using var host = await Host.CreateDefaultBuilder()
                .ConfigureServices(services =>
                {
                    // Do this, or your environment check assertion failures below
                    // is just swallowed and logged on startup
                    services.Configure<HostOptions>(options =>
                    {
                        options.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.StopHost;
                    });

                    services.AddMarten("connection string")
                        .AssertDatabaseMatchesConfigurationOnStartup();
                })
                .StartAsync();
        }

        #endregion
#endif
}

redpajama_set_name: RedPajamaGithub


text:
package com.soleccy.games.tictactoe.my;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Arrays;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class MiniMaxPlayerEvaluateTest {

	@Parameters(name = "{index}: {0} :: {2}")
	public static Iterable<Object[]> data() {
		return Arrays.asList(new Object[][] {
				{ "ppp", new Player[] { player, player, player }, 100, },
				{ "ppo", new Player[] { player, player, oponent }, 0 },
				{ "ppe", new Player[] { player, player, empty }, 10 },
				{ "pop", new Player[] { player, oponent, player }, 0 },
				{ "poo", new Player[] { player, oponent, oponent }, 0 },
				{ "poe", new Player[] { player, oponent, empty }, 0 },
				{ "pep", new Player[] { player, empty, player }, 10 },
				{ "peo", new Player[] { player, empty, oponent }, -1 },
				{ "pee", new Player[] { player, empty, empty }, 1 },
				{ "ppp", new Player[] { oponent, player, player }, 0, },
				{ "ppo", new Player[] { oponent, player, oponent }, 0 },
				{ "ppe", new Player[] { oponent, player, empty }, 0 },
				{ "pop", new Player[] { oponent, oponent, player }, 0 },
				{ "poo", new Player[] { oponent, oponent, oponent }, -100 },
				{ "poe", new Player[] { oponent, oponent, empty }, -10 },
				{ "pep", new Player[] { oponent, empty, player }, 0 },
				{ "peo", new Player[] { oponent, empty, oponent }, -10 },
				{ "pee", new Player[] { oponent, empty, empty }, -1 },
				{ "ppp", new Player[] { empty, player, player }, 10, },
				{ "ppo", new Player[] { empty, player, oponent }, -1 },
				{ "ppe", new Player[] { empty, player, empty }, 1 },
				{ "pop", new Player[] { empty, oponent, player }, 0 },
				{ "poo", new Player[] { empty, oponent, oponent }, -10 },
				{ "poe", new Player[] { empty, oponent, empty }, -1 },
				{ "pep", new Player[] { empty, empty, player }, 1 },
				{ "peo", new Player[] { empty, empty, oponent }, -1 },
				{ "eee", new Player[] { empty, empty, empty }, 0 } });
	}

	private static Player player = new DefaultPlayer("X");
	private static Player oponent = new DefaultPlayer("O");
	private static Player empty = Player.NO_PLAYER;

	private Board board;

	private Player[] players;
	private int score;

	public MiniMaxPlayerEvaluateTest(String title, Player[] players, int score) {
		this.players = players;
		this.score = score;
	}

	@Before
	public void setUp() throws Exception {
		board = new Board(3);
	}

	@Test
	public void testEvaluateLine() {

		// Given
		board.getTile(0, 0).setPlayer(players[0]);
		board.getTile(0, 1).setPlayer(players[1]);
		board.getTile(0, 2).setPlayer(players[2]);

		// When
		int actualScore = MiniMaxPlayer.evaluateLine(0, 0, 0, 1, 0, 2, board,
				player);

		// Then
		assertThat(actualScore, equalTo(score));

	}
}


text:
<?php

namespace spec\GrumPHP\Formatter;

use GrumPHP\Formatter\PhpCsFixerFormatter;
use GrumPHP\Formatter\ProcessFormatterInterface;
use PhpSpec\ObjectBehavior;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessUtils;

class PhpCsFixerFormatterSpec extends ObjectBehavior
{
    function it_is_initializable()
    {
        $this->shouldHaveType(PhpCsFixerFormatter::class);
    }

    function it_is_a_process_formatter()
    {
        $this->shouldHaveType(ProcessFormatterInterface::class);
    }

    function it_handles_command_exceptions(Process $process)
    {
        $process->getOutput()->willReturn('');
        $process->getErrorOutput()->willReturn('stderr');
        $this->format($process)->shouldReturn('stderr');
    }

    function it_handles_invalid_json(Process $process)
    {
        $process->getOutput()->willReturn('invalid');
        $this->format($process)->shouldReturn('invalid');
    }

    function it_handles_invalid_file_formats(Process $process)
    {
        $json = $this->parseJson(['invalid']);
        $process->getOutput()->willReturn($json);
        $this->format($process)->shouldStartWith('Invalid file: ');
    }

    function it_formats_php_cs_fixer_json_output_for_single_file(Process $process)
    {
        $json = $this->parseJson([
            ['name' => 'name1',],
        ]);
        $process->getOutput()->willReturn($json);
        $this->format($process)->shouldBe('1) name1');
    }

    function it_formats_php_cs_fixer_json_output_for_multiple_files(Process $process)
    {
        $json = $this->parseJson([
            ['name' => 'name1',],
            ['name' => 'name2', 'appliedFixers' => ['fixer1', 'fixer2']],
        ]);
        $process->getOutput()->willReturn($json);
        $this->format($process)->shouldBe('1) name1' . PHP_EOL . '2) name2 (fixer1, fixer2)');
    }

    function it_formats_php_cs_fixer_json_output_for_diff(Process $process)
    {
        $json = $this->parseJson([
            ['name' => 'name1', 'diff' => 'diff1'],
        ]);
        $process->getOutput()->willReturn($json);
        $this->format($process)->shouldBe('1) name1' . PHP_EOL . PHP_EOL . 'diff1');
    }

    function it_should_be_possible_to_reset_the_counter(Process $process)
    {
        $json = $this->parseJson([['name' => 'name1']]);
        $process->getOutput()->willReturn($json);

        $this->format($process)->shouldBe('1) name1');
        $this->resetCounter();
        $this->format($process)->shouldBe('1) name1');
    }

    function it_formats_suggestions(Process $process)
    {
        $dryRun = ProcessUtils::escapeArgument('--dry-run');
        $formatJson = ProcessUtils::escapeArgument('--format=json');

        $command = sprintf('phpcsfixer %s %s .', $dryRun, $formatJson);

        $process->getCommandLine()->willReturn($command);
        $this->formatSuggestion($process)->shouldReturn('phpcsfixer .');
    }

    function it_formats_the_error_message()
    {
        $this->formatErrorMessage(['message1'], ['message2'])->shouldBeString();
    }

    /**
     * @param $files
     *
     * @return string
     */
    private function parseJson(array $files)
    {
        return json_encode(['files' => $files]);
    }
}


text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<feed><tipo>Rua</tipo><logradouro>Caramuru</logradouro><bairro>São Tomé</bairro><cidade>Viamão</cidade><uf>RS</uf><cep>94460350</cep></feed>


text:
<!DOCTYPE html>

  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <link rel="stylesheet" href="/css/main.css">
  <link rel="icon" href="/images/favicon.png">
  <title>Music | Vigor</title>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
  <meta property="og:url" content="https://manatran.github.io/" />
  <meta property="og:title" content="Vigor" />
  <meta property="og:image" content="https://i.imgur.com/Wr6l4gc.png" />
  <meta property="og:description" content="The path to a healthy lifestyle starts with us." />

    menu

Music

username

      Log out

          homeHomepage

          directions_runExercise

          restaurant_menuRestaurants

          music_noteMusic

          settingsSettings

          groupSocial

    keyboard_arrow_up

  <form class="inline_form">
    search
    <input id="music_search" type="text" placeholder="Search music" class="validate">
  </form>

Your selection

Please search for music in the searchbar above.


text:
package org.apache.ambari.server.actionmanager;

import com.google.inject.assistedinject.Assisted;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.ExecuteActionRequest;
import org.apache.ambari.server.orm.entities.RequestEntity;

import java.util.Collection;

public interface RequestFactory {

  Request createNew(long requestId, @Assisted("clusterId") Long clusterName) throws AmbariException;

  Request createNewFromStages(Collection<Stage> stages);

  Request createNewFromStages(Collection<Stage> stages, ExecuteActionRequest actionRequest);

  Request createExisting(RequestEntity entity);

}


text:
**After every change to your formulae, perform the following** from the root of the Git repository (not from `support/build/_docker/`):

    $ docker build --pull --tag heroku-php-build-cedar-14 --file $(pwd)/support/build/_docker/cedar-14.Dockerfile .

## Configuration

File `env.default` contains a list of required env vars, some with default values. You can modify it with the values you desire, or pass them to `docker run` using `--env`.

Out of the box, you'll likely want to change `S3_BUCKET` and `S3_PREFIX` to match your info. Instead of setting `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in that file, it is recommended to pass them to `docker run` through the environment, or explicitly using `--env`, in order to prevent accidental commits of credentials.

## Using the Image

From the root of the Git repository (not from `support/build/_docker/`):

    docker run --rm --tty --interactive --env-file=support/build/_docker/env.default heroku-php-build-cedar-14 /bin/bash

That runs with values from `env.default`; if you need to pass e.g. `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` because they are not already in your environment, do either:

    AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... docker run --rm --tty --interactive --env-file=support/build/_docker/env.default heroku-php-build-cedar-14 /bin/bash

or

    docker run --rm --tty --interactive --env-file=support/build/_docker/env.default -e AWS_ACCESS_KEY_ID=... -e AWS_SECRET_ACCESS_KEY=... heroku-php-build-cedar-14 /bin/bash

You then have a shell where you can run `bob build`, `deploy.sh` and so forth.

The `support/build/_util/` directory is on `$PATH` in the image.


text:
      <button id="button-animated" dropdownToggle type="button" class="btn dropdown-toggle"
        aria-controls="dropdown-animated">
        <mat-icon aria-label="drop down menu">menu</mat-icon>
      </button>

        <app-nav></app-nav>

      {{ localData.website }}{{ pageTitle }}

    <app-nav></app-nav>

    <router-outlet></router-outlet>

        Image by Freepik fromwww.flaticon.com

          {{ localData.strapline }}

          {{ localAPI }}

          {{ localData.website }} 2020


text:
var mmmagic = require('mmmagic');
var magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);

magic.detectFile('./kitten.jpg', function(err, result) {
  if (err) throw err;

  // image/jpeg
  console.log('kitten.jpg', result);
});

magic.detectFile('./kitten.png', function(err, result) {
  if (err) throw err;

  // also `image/jpeg` even though extension is PNG
  console.log('kitten.png', result);
});


text:
"""
Use eapi to retrieve 'show ip route' from your arista switch.
From the returned data structure retrieve the prefixes, the output interfaces,
and the next hops (if available).

Print these routes and the associated information to stdout.
"""
from pprint import pprint
import pyeapi

def main():
    """
    Use eapi to retrieve 'show ip route' from your arista switch.
    From the returned data structure retrieve the prefixes, the output
    interfaces, and the next hops (if available).

    Print these routes and the associated information to stdout.
    """
    pynet_sw = pyeapi.connect_to("pynet-sw2")
    output = pynet_sw.enable("show ip route")

    # Strip off unneeded information
    output = output[0]
    output = output['result']['vrfs']['default']

    # Get the routes
    routes = output['routes']
    print "\n{:>15} {:>15} {:>15}".format("prefix", "interface", "next_hop")
    filler = "-" * 15
    print "{:>15} {:>15} {:>15}".format(filler, filler, filler)
    for prefix, attr in routes.items():
        intf_nexthop = attr['vias'][0]
        interface = intf_nexthop.get('interface', 'N/A')
        next_hop = intf_nexthop.get('nexthopAddr', 'N/A')
        print "{:>15} {:>15} {:>15}".format(prefix, interface, next_hop)
    print

if __name__ == "__main__":
    main()


text:
ALTER TABLE grant_claim_maximum
ADD COLUMN funding_rules ENUM('STATE_AID', 'SUBSIDY_CONTROL', 'NOT_AID') NULL;

ALTER TABLE application_finance
ADD COLUMN northern_ireland_declaration BOOLEAN NULL;

ALTER TABLE project_finance
ADD COLUMN northern_ireland_declaration BOOLEAN NULL;


text:
from __future__ import absolute_import, unicode_literals

from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
from wagtail.images import get_image_model

from wagtailaltgenerator.providers import get_current_provider
from wagtailaltgenerator.utils import translate_description_result
from wagtailaltgenerator import app_settings
from wagtailaltgenerator.app_settings import get_setting

image_cls = get_image_model()

@receiver(
    post_save,
    sender=image_cls,
    dispatch_uid="wagtailaltgenerator.signals.apply_image_alt",
)
def apply_image_alt(sender, instance, **kwargs):
    # Only run on new images
    if not kwargs["created"]:
        return

    provider = get_current_provider()()
    image_url = instance.file.url

    result = provider.describe(instance)

    if get_setting("ALT_GENERATOR_TRANSLATE_TO_LOCAL_LANG"):
        result = translate_description_result(result)

    if image_url[-4:] == instance.title[-4:]:
        _apply_title(instance, result.description)

    if get_setting("ALT_GENERATOR_USE_TAGS"):
        _apply_tags(instance, result.tags)

    instance.save()

def _apply_title(instance, description):
    if not description:
        return

    instance.title = description

def _apply_tags(instance, tags):
    if not tags:
        return

    if app_settings.ALT_GENERATOR_MAX_TAGS != -1:
        tags = tags[: app_settings.ALT_GENERATOR_MAX_TAGS]

    instance.tags.add(*tags)


text:
package io.dropwizard.testing.junit5;

/**
 * {@link DropwizardExtensionsSupport} class uses this interface to find fields fields in test class instance and test
 * class
 */
public interface DropwizardExtension {

    /**
     * Executed before test method or class.
     */
    void before() throws Throwable;

    /**
     * Executed after test method or class.
     */
    void after() throws Throwable;
}


text:
[![NPM](https://nodei.co/npm/apostrophe-instagram.png?downloads=true&stars=true)](https://nodei.co/npm/apostrophe-instagram/)

apostrophe-instagram is a widget for the [Apostrophe](http://github.com/punkave/apostrophe) content management system. Apostrophe Instagram lets you display a feed of images from a users Instagram feed.

## TO-DO
- [x] Build it
- [x] Publish to NPM
- [ ] Build some nice basic styles
- [ ] Write some tests?


text:
using System;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.SessionState;

using Clifton.Core.ExtensionMethods;

namespace Clifton.WebInterfaces
{
	public class HttpRequestWrapper : IRequest
	{
		public NameValueCollection QueryString { get { return request.QueryString; } }
		public Uri Url { get { return request.Url; } }
		public Stream InputStream { get { return request.InputStream; } }
		public Encoding ContentEncoding { get { return request.ContentEncoding; } }
        public bool AcceptEncoding { get { return request.Headers["Accept-Encoding"] != null; } }
		public IPEndPoint RemoteEndPoint { get
			{
				string ip = request.UserHostAddress;

				if (request.UserHostAddress == "::1")
				{
					ip = "127.0.0.1";
				}

				return new IPEndPoint(new IPAddress(ip.Split('.').Select(s => Convert.ToByte(s)).ToArray()), 0);
			}
		}

		protected HttpRequest request;

		public HttpRequestWrapper(HttpRequest request)
		{
			this.request = request;
		}
	}

	public class HttpResponseWrapper : IResponse
	{
		public int StatusCode { get { return response.StatusCode; } set { response.StatusCode = value; } }
		public string ContentType { get { return response.ContentType; } set { response.ContentType = value; } }
		public Encoding ContentEncoding { get { return response.ContentEncoding; } set { response.ContentEncoding = value; } }
		public long ContentLength64 { get { return contentLength; } set { contentLength = value; } }
		public Stream OutputStream { get { return response.OutputStream; } }

		protected HttpResponse response;
		protected long contentLength;

		public HttpResponseWrapper(HttpResponse response)
		{
			this.response = response;
		}

		public void Close()
		{
			// Never close the response from IIS.
			// response.End();
		}

		public void Write(string data, string contentType = "text/text", int statusCode = 200)
		{
			// IIS will fire the EndRequest event twice, the second time, setting header information will throw an exception.
			// This is handled by the IISService, testing for context.Response.HeadersWritten to prevent processing of the second
			// request.
			StatusCode = statusCode;
			ContentType = contentType;
			ContentEncoding = Encoding.UTF8;
			byte[] byteData = data.to_Utf8();
			response.OutputStream.Write(byteData, 0, byteData.Length);
			Close();
		}

        public void WriteCompressed(string data, string contentType = "text/text", int statusCode = 200)
        {
            StatusCode = statusCode;
            ContentType = contentType;
            response.AddHeader("Content-Encoding", "gzip");
            byte[] byteData = data.GZip();
            response.OutputStream.Write(byteData, 0, byteData.Length);
            Close();
        }

        public void Write(byte[] data, string contentType = "text/text", int statusCode = 200)
		{
			StatusCode = statusCode;
			ContentType = contentType;
			ContentEncoding = Encoding.UTF8;
			response.OutputStream.Write(data, 0, data.Length);
			Close();
		}
	}

	public class HttpContextWrapper : IContext
	{
		public IRequest Request { get { return request; } }
		public IResponse Response { get { return response; } }
		public HttpSessionState Session { get { return context.Session; } }
		public bool IsLocal { get { return context.Request.IsLocal; } }
		public bool IsSecureConnection { get { return context.Request.IsSecureConnection; } }

		protected HttpRequestWrapper request;
		protected HttpContext context;
		protected IResponse response;

		public HttpContextWrapper(HttpContext context)
		{
			this.context = context;
			response = new HttpResponseWrapper(context.Response);
			request = new HttpRequestWrapper(context.Request);
		}

		public IPAddress EndpointAddress()
		{
			return context.EndpointAddress();
		}

		public HttpVerb Verb()
		{
			return context.Verb();
		}

		public UriPath Path()
		{
			return context.Path();
		}

		public UriExtension Extension()
		{
			return context.Extension();
		}

		public void Redirect(string url)
		{
			context.Redirect(url);
		}
	}
}


text:
class Object
  def mikan_test
    p 1
  end
end


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/scan_flashlight_pressed" android:state_pressed="true" />
    <item android:drawable="@drawable/scan_flashlight_pressed" android:state_checked="true" />
    <item android:drawable="@drawable/scan_flashlight_normal" />

</selector>


text:
package ch.heigvd.amt.gamy.model;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;

/**
 * This class is used to manage all accounts in our application. An account is
 * defined by an email which is used as login identifier, a first name and
 * last name. Each user must have an hashed password.
 *
 * An Account could have some roles (See details in Role.java) and an account
 * could have too some applications.
 *
 * We added a query for the login which the user could be connect using
 * is email address. Another query is use to count the number of user account
 * created in our application.
 */
@Entity
@NamedQueries({
  @NamedQuery(name = "Account.findByAccountEmail", query = "SELECT a FROM Account a WHERE a.email = :email"),
  @NamedQuery(name = "Account.findCount", query = "SELECT count(a) FROM Account a"),
})
public class Account extends AbstractDomainModelEntity<Long> {

   /*
    * Emais is an attribute that must be unique and not null because it used for
    * the login.
    */
   @Column(unique = true, nullable = false)
   private String email;

   /*
    * First and last name of the user.
    */
   private String firstName;
   private String lastName;

   /*
    * hash of the password from the user.
    */
   @Column(nullable = false)
   private byte[] hash;

   /*
    * Creation date of this account.
    */
   @Temporal(javax.persistence.TemporalType.DATE)
   private Date creationDate;

   /*
    * List of role of the user on this application.
    */
   @ManyToMany
   private List<Role> roles = new LinkedList<>();

   /*
    * List of application that an user created. An user could have N apps but
    * each apps must be attached to only one user.
    * The association beetween "Application and Account is bi-directionnal.
    */
   @OneToMany(mappedBy = "account")
   private List<Application> applications = new LinkedList<>();

   /**
    * All JPA must have an empty constructor.
    */
   public Account() {}

   /**
    * Constructor of Account class. Set all parameter used by an account.
    *
    * @param email is the email address use by the user for the login.
    * @param firstName is first name of the user.
    * @param lastName is last name of the user.
    * @param hash is the hash of the password.
    */
   public Account(String email,
           String firstName,
           String lastName,
           byte[] hash) {

      this.email = email;
      this.firstName = firstName;
      this.lastName = lastName;
      this.hash = hash;
      this.creationDate = new Date ();
   }

   /* Setter */

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   public void setLastName(String lastName) {
      this.lastName = lastName;
   }

   public void setHash(byte[] hash) {
      this.hash = hash;
   }

   /* Getter */

   public String getEmail() {
      return email;
   }

   public String getFirstName() {
      return firstName;
   }

   public String getLastName() {
      return lastName;
   }

   public byte[] getHash() {
      return hash;
   }

   public Date getCreationDate() {
      return creationDate;
   }

   public List<Role> getRoles() {
      return roles;
   }

   public List<Application> getApplications() {
      return applications;
   }

   /* ToString */

   @Override
   public String toString() {
      return "Account{" + "email=" + email + ", firstName=" + firstName + ", lastName=" + lastName + ", hash=" + hash + ", creationDate=" + creationDate + ", roles=" + roles + ", applications=" + applications + '}';
   }

   /* Syncronisation list */

   public void addRole(Role role) {
      if (!roles.contains(role))
         roles.add(role);
   }

   public void addApplication(Application app) {
      if(!applications.contains(app))
         applications.add(app);
   }
}


text:
For the following problems I worked alone using only the course materials from this term.
Owen Trueblood

$\pagebreak$

L03

-----

# Problem 1

_Collaboration:_ On problem 1, I collaborated with no one, and received help from no one.

----------

_Proof._

By induction.

Define:

$r(x) = \text{set of all numbers where } \\
	\text{1) the digits are equal to one another AND } \\
	\text{2) the number of digits is x}$

_for example:_ $r(3) = \{ 111, 222, 333, 444, 555, 666, 777, 888, 999 \}$

The induction hypothesis is $P(n) ::= \{n \in \mathfrak{N}, Q \in r(3^n) \mid 3^n \text{ divides evenly into Q} \}$

In the base case $P(0)$, $3^n \implies 3^0 \implies 1$. Because 1 divides every number with no remainder, $P(0)$ is true.

If X stands in for the digit (1, 2, ..., or 9) repeated in Q, then

$\sum_{i=1}^{3^n} X = (3^n)X \hfill (1)$

Because $3 \text{ divides a number evenly } \text{IFF} \text{ it divides the sum of its digits}$, and the previous equation shows that the sum of the digits has $3^n$ as a factor, $P(n+1) = 3^{n+1} | Q$ will always be true. Expounding on that argument, $3^n$ as a factor forces the truth of $P(n+1)$ because for n > 0 it has 3 as a factor. The base case is true, and $P(n) \implies P(n+1)$ is true, so by induction P(n) is proven. $\diamond$


text:
package es.tid.pce.pcep.objects.tlvs;

public class OverloadedDurationTLV extends PCEPTLV {

	public OverloadedDurationTLV(){

	}

	public OverloadedDurationTLV(byte[] bytes, int offset){
		super(bytes,offset);
	}

	public void encode() {
		// TODO Auto-generated method stub

	}

	public void decode() {
		// TODO Auto-generated method stub

	}

}


text:
var path = require('path');
var express = require('express');
var bodyParser = require('body-parser');
var nunjucks = require('nunjucks');
var config = require('./config');

var app = express();

var TEMPLATES_DIRECTORY = path.join(__dirname, 'templates');

app.set('views', TEMPLATES_DIRECTORY);
nunjucks.configure(TEMPLATES_DIRECTORY, { express: app });

app.listen(config.get('PORT'), function() {
    console.log('the-machine is now running at localhost:'
        + config.get('PORT'));
});

var STATIC_DIRECTORY = path.join(__dirname, 'static');
var SERVICE_WORKER_PATH = path.join(__dirname, 'static',
    'javascripts', 'service-worker.js');
var MANIFEST_PATH = path.join(__dirname, 'manifest.json');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use('/static', express.static(STATIC_DIRECTORY));
app.use('/service-worker.js', express.static(SERVICE_WORKER_PATH));
app.use('/manifest.json', express.static(MANIFEST_PATH));
app.use('/', require('./routes'));


text:
<?php

namespace Victoire\Bundle\CoreBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * This is the class that validates and merges configuration from your app/config files.
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('victoire_core');

        $rootNode
            ->children()
                ->scalarNode('user_class')
                    ->defaultNull()
                ->end()
            ->end()
            ->children()
                ->arrayNode('domain_name')
                    ->prototype('scalar')->end()
                ->end()
            ->end()
            ->children()
                ->scalarNode('cache_dir')
                    ->defaultValue('%kernel.cache_dir%/victoire')
                ->end()
            ->end()
            ->children()
                ->scalarNode('business_entity_debug')
                    ->defaultValue('%kernel.debug%')
                ->end()
            ->end()
            ->children()
                ->variableNode('base_paths')
                    ->defaultValue([
                        '%kernel.root_dir%/../src',
                        '%kernel.root_dir%/../vendor/victoire',
                        '%kernel.root_dir%/../vendor/friendsofvictoire',
                    ])
                ->end()
            ->end()
            ->children()
                ->variableNode('businessTemplates')
                    ->defaultNull()
                    ->treatNullLike([])
                ->end()
            ->end()
            ->children()
                ->variableNode('templates')
                    ->defaultValue(['layout' => 'VictoireCoreBundle:Layout:layout.html.twig'])
                ->end()
            ->end()
            ->children()
                ->variableNode('layouts')
                    ->defaultValue([])
                ->end()
            ->end()
            ->children()
                ->variableNode('modal_layouts')
                    ->defaultValue(['modal'])
                ->end()
            ->end()
            ->children()
                ->arrayNode('widgets')
                    ->useAttributeAsKey(true)
                    ->prototype('array')
                        ->children()
                            ->scalarNode('class')->end()
                            ->scalarNode('name')->end()
                            ->scalarNode('cache')->defaultTrue()->end()
                            ->scalarNode('cache_timeout')->defaultValue(7 * 24 * 60 * 1000)->end() //one week
                        ->end()
                    ->end()
                ->defaultValue([])
                ->end()
            ->end()
            ->children()
                ->arrayNode('slots')
                    ->useAttributeAsKey(true)
                    ->prototype('array')
                    ->children()
                        ->integerNode('position')->end()
                        ->integerNode('max')->end()
                        ->variableNode('widgets')->end()
                        ->scalarNode('class')->end()
                    ->end()
                ->end()
            ->end();

        return $treeBuilder;
    }
}


text:
require 'minitest/unit'
require '../lib/Game.rb'

MiniTest::Unit.autorun

DEAD = 0
ALIVE = 1

class GameTest < MiniTest::Unit::TestCase
  def test_game
    code = 'def print_state; end'
    Game.class_eval code
    assert_equal(true, Game.start_game)
  end
end


text:
<?php declare(strict_types=1);

namespace Propel\Generator\Behavior\AggregateField\Component\RelatedRepository;

use Propel\Generator\Behavior\AggregateField\AggregateFieldRelationBehavior;
use Propel\Generator\Builder\Om\Component\BuildComponent;
use Propel\Generator\Builder\Om\Component\NamingTrait;
use Propel\Generator\Builder\Om\Component\RelationTrait;

/**
 *
 *
 * @author Marc J. Schmidt <marc@marcjschmidt.de>
 */
class FindRelatedMethod extends BuildComponent
{
    use NamingTrait;
    use RelationTrait;

    public function process()
    {
        /** @var AggregateFieldRelationBehavior $behavior */
        $behavior = $this->getBehavior();

        $relation = $behavior->getRelation();
        $relationName = $behavior->getRelationName();
        $refRelationName = $this->getRefRelationPhpName($relation);
        $aggregateName = $behavior->getParameter('aggregate_name');
        $foreignEntity = $behavior->getForeignEntity();

        $variableName = $relationName . ucfirst($behavior->getParameter('aggregate_name'));
        $foreignEntityClassName = $foreignEntity->getFullName();
        $foreignClass = $this->getQueryClassNameForEntity($foreignEntity, true);

        $body = "
\$criteria = \$this->createQuery();
\$repository = \$this->getConfiguration()->getRepository('$foreignEntityClassName');
/** @var \\$foreignClass \$query */
\$query = \$repository->createQuery();
\$this->afCache{$variableName} = \$query
    ->use{$refRelationName}Query()
        ->filterByPrimaryKeys(\$this->getEntityMap()->getOriginPKs(\$event->getEntities()))
    ->endUse()
    ->find();
";
        $name = 'findRelated' . $relationName . ucfirst($aggregateName);

        $this->addMethod($name)
            ->setDescription("[AggregateField-related] Finds the related {$foreignEntity->getName()} objects and keep them for later.")
            ->addSimpleDescParameter('event', '\Propel\Runtime\Event\UpdateEvent', 'update event')
            ->setBody($body);
    }
}


text:
/**
* pulldown to refresh data
* @author febody.com
*/
'use strict';

var React = require('react-native');
var {
    Image,
    ListView,
    TouchableHighlight,
    StyleSheet,
    Text,
    View,
    PanResponder,
    ToastAndroid,
    Dimensions,
    ScrollView,
    ActivityIndicatorIOS,
    Animated
} = React;
var TimerMixin = require('react-timer-mixin');
var deviceWidth = Dimensions.get('window').width;

var MIN_PULLDOWN_DISTANCE = 20;
var SCROLL_HEIGHT = 150;
var SCROLL_EVENT_THROTTLE =100;
var SCROLL_ACC = 5;
var ListViewSimpleExample = React.createClass({
    mixins: [TimerMixin],
    getInitialState: function() {
        var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
        return {
            dataSource: ds,
            refreshing: false,
            scrollY: 0,
            touching: false,
            ignoreInertialScroll:true,
            refreshState : '',
        };
    },
    getDefaultProps() {
        return {
            minPulldownDistance: MIN_PULLDOWN_DISTANCE,
            scrollEventThrottle: SCROLL_EVENT_THROTTLE,
            ignoreInertialScroll: true,
        }
    },
    _handlePanResponderGrant: function(e: Object, gestureState: Object) {
        console.log('_handlePanResponderGrant');
        return true;
    },
    _handlePanResponderMove: function(e: Object, gestureState: Object) {
        console.log('_handlePanResponderMove');
        return true;
    },
    _handlePanResponderEnd: function(e: Object, gestureState: Object) {
        console.log('_handlePanResponderEnd');
    },
    componentWillMount: function() {
        this._genRows();
        var that = this;
        this._panResponder = PanResponder.create({
        // Ask to be the responder:
        onStartShouldSetPanResponder: (evt, gestureState) => {
        return !that.state.refreshing;
        },
        onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
        onMoveShouldSetPanResponder: (evt, gestureState) => true,
        onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,

        onPanResponderGrant: (evt, gestureState) => {
        this.setState({touching: true});
        console.log('onPanResponderGrant');
        },

        onPanResponderMove: (evt, gestureState) => {

            if(that.scrollY > 0 || that.state.refreshing) {
                return ;
            }
            var dy = that.dy = gestureState.dy * SCROLL_ACC;
            if(dy > MIN_PULLDOWN_DISTANCE && that.state.touching && !that.state.refreshing) {
                that.setState({scrollY:dy});
                that._genRows();
                that.onRefresh(dy);
                console.log(dy);
            }
            console.log('onPanResponderMove');
        },
        onPanResponderTerminationRequest: (evt, gestureState) => true,
        onPanResponderRelease: (evt, gestureState) => {
            console.log('onPanResponderRelease');
        },
        onPanResponderEnd: (evt, gestureState) => {
            that.onRelease();
            that.setState({touching: false});
            console.log('onPanResponderEnd');
        },
        onPanResponderTerminate: (evt, gestureState) => {
        console.log('onPanResponderTerminate');
        },
        onShouldBlockNativeResponder: (evt, gestureState) => {
            console.log('onShouldBlockNativeResponder');
            return true;
        },
    });

},

    onRelease () {
        var dy = this.dy ;
        var hander ;
        if(this.state.refreshing && this.dy > 3 && dy < SCROLL_HEIGHT) {
            hander = setInterval(()=>{
                if(dy + 20 < SCROLL_HEIGHT){
                    dy = dy + 20;
                    this.setState({scrollY: dy});
                }else{
                    this.dy = SCROLL_HEIGHT ;
                    clearInterval(hander);
                    this.setState({scrollY:SCROLL_HEIGHT});
                }
            },30);
        }
    },
    onRefresh (dy) {
        this.setState({scrollY:dy > SCROLL_HEIGHT ? SCROLL_HEIGHT: dy});
    },
    componentDidMount () {
    },
    listViewScroll (e) {
        this.scrollY =  e.nativeEvent.contentOffset.y;
    },
    renderHeader () {
        return (
            <View style={[styles.header,styles.content]}>
            <Text>下来刷新数据</Text>
            </View>
        );
    },
    renderIndicator () {

        return(
            <View  style={[styles.indicator,{height: this.state.scrollY/3}]}>
            <Text style={{color:'blue'}}>正在刷新纪录...</Text>
            </View>
        )
    },
    render: function() {
        var pageStyle = {
            backgroundColor:'red',
            alignItems: 'center',
            padding: 20,
        };

        var listStyle = {
            translateY: this.state.scrollY,
        };
        return (

        <ScrollView key='1' onScroll = {this.listViewScroll}
            {...this._panResponder.panHandlers}
        scrollEventThrottle={200}>
            {this.renderIndicator()}
            <ListView
            ref={listview => { this.listview = listview; }}
            dataSource={this.state.dataSource}
            renderRow={this._renderRow}
            automaticallyAdjustContentInsets={false}
            keyboardDismissMode="on-drag"
            scrollRenderAheadDistance= {100}
            keyboardShouldPersistTaps={false}
            showsVerticalScrollIndicator={true}
            initialListSize={12}
            onEndReachedThreshold={50}
            pageSize={6}
            style={[styles.list,listStyle]}
            />
        </ScrollView>

        );
    },

    _renderRow: function(rowData: string, sectionID: number, rowID: number) {
        return (
            <View style={{height:80}}>
            <Text>{rowData + ' !'}</Text>
            </View>
        );
    },

    _genRows: function(pressData: {[key: number]: boolean}): Array<string> {

    if(this.state.refreshing) return;
    var number = Math.round(Math.random()*30);
    var data = [];
    number =20;
    for(var i = 0;i < number; i++) {
        if(i == 0 || i == 1 || i == 2) {
            data.push(Math.random());
        } else {
            data.push(data[i-1] + data[i-2])
        }
    }
    this.setState({refreshing:true});
    var that = this;
    this.setTimeout(function(){
        that.setState({refreshing: false});
        that.setState({dataSource: that.state.dataSource.cloneWithRows(data.reverse())});

        var hander  = setInterval(()=>{
            if(that.state.scrollY - 20 > 0 ){
            that.setState({scrollY:that.state.scrollY-20})
            } else {
            clearInterval(hander);
            that.setState({scrollY:0})
            }
        },40);
    },1000)
    },

    _pressRow: function(rowID: number) {
        this._pressData[rowID] = !this._pressData[rowID];
        this.setState({dataSource: this.state.dataSource.cloneWithRows(
            this._genRows(this._pressData)
        )});
    },
});

var styles = StyleSheet.create({
    row: {
        flexDirection: 'row',
        justifyContent: 'center',
        padding: 10,
        backgroundColor: '#F6F6F6',
    },
    separator: {
        height: 1,
        backgroundColor: '#CCCCCC',
    },
    thumb: {
        width: 64,
        height: 64,
    },
    text: {
        flex: 1,
    },
    header: {
        flex: 1,
        justifyContent: 'space-around',
        alignItems: 'center',
    },
    content: {
        marginTop: 10,
    }
,
    list: {
        translateX:0,
        backgroundColor:'red',
        width:deviceWidth
    },
    indicator:{
        flex: 1,
        justifyContent:'center',
        alignItems:'center',
        backgroundColor:'green',
        position:'absolute',
        top:0,
        left:0,
        width:deviceWidth
    }
});

module.exports = ListViewSimpleExample;


text:
public class J1_callstaticmethods {

  public J1_callstaticmethods() {}

  public static int test() {
    java.lang.System.gc();
    return 123;
  }
}