text:
.class final Lcom/android/server/am/ServiceRecord;
.super Landroid/os/Binder;
.source "ServiceRecord.java"

# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/android/server/am/ServiceRecord$StartItem;
    }
.end annotation

# static fields
.field static final MAX_DELIVERY_COUNT:I = 0x3

.field static final MAX_DONE_EXECUTING_COUNT:I = 0x6

# instance fields
.field final ams:Lcom/android/server/am/ActivityManagerService;

.field app:Lcom/android/server/am/ProcessRecord;

.field final appInfo:Landroid/content/pm/ApplicationInfo;

.field final baseDir:Ljava/lang/String;

.field final bindings:Landroid/util/ArrayMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Landroid/util/ArrayMap",
            "<",
            "Landroid/content/Intent$FilterComparison;",
            "Lcom/android/server/am/IntentBindRecord;",
            ">;"
        }
    .end annotation
.end field

.field callStart:Z

.field final connections:Landroid/util/ArrayMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Landroid/util/ArrayMap",
            "<",
            "Landroid/os/IBinder;",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/android/server/am/ConnectionRecord;",
            ">;>;"
        }
    .end annotation
.end field

.field crashCount:I

.field final createTime:J

.field createdFromFg:Z

.field final dataDir:Ljava/lang/String;

.field delayed:Z

.field delayedStop:Z

.field final deliveredStarts:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/android/server/am/ServiceRecord$StartItem;",
            ">;"
        }
    .end annotation
.end field

.field executeFg:Z

.field executeNesting:I

.field executingStart:J

.field final exported:Z

.field foregroundId:I

.field foregroundNoti:Landroid/app/Notification;

.field final intent:Landroid/content/Intent$FilterComparison;

.field isForeground:Z

.field isolatedProc:Lcom/android/server/am/ProcessRecord;

.field lastActivity:J

.field private lastStartId:I

.field final name:Landroid/content/ComponentName;

.field nextRestartTime:J

.field final packageName:Ljava/lang/String;

.field final pendingStarts:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/android/server/am/ServiceRecord$StartItem;",
            ">;"
        }
    .end annotation
.end field

.field final permission:Ljava/lang/String;

.field final processName:Ljava/lang/String;

.field final resDir:Ljava/lang/String;

.field restartCount:I

.field restartDelay:J

.field restartTime:J

.field final restarter:Ljava/lang/Runnable;

.field final serviceInfo:Landroid/content/pm/ServiceInfo;

.field final shortName:Ljava/lang/String;

.field startRequested:Z

.field startingBgTimeout:J

.field final stats:Lcom/android/internal/os/BatteryStatsImpl$Uid$Pkg$Serv;

.field stopIfKilled:Z

.field stringName:Ljava/lang/String;

.field totalRestartCount:I

.field tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

.field final userId:I

# direct methods
.method constructor <init>(Lcom/android/server/am/ActivityManagerService;Lcom/android/internal/os/BatteryStatsImpl$Uid$Pkg$Serv;Landroid/content/ComponentName;Landroid/content/Intent$FilterComparison;Landroid/content/pm/ServiceInfo;ZLjava/lang/Runnable;)V
    .registers 10
    .param p1    # Lcom/android/server/am/ActivityManagerService;
    .param p2    # Lcom/android/internal/os/BatteryStatsImpl$Uid$Pkg$Serv;
    .param p3    # Landroid/content/ComponentName;
    .param p4    # Landroid/content/Intent$FilterComparison;
    .param p5    # Landroid/content/pm/ServiceInfo;
    .param p6    # Z
    .param p7    # Ljava/lang/Runnable;

    invoke-direct {p0}, Landroid/os/Binder;-><init>()V

    new-instance v0, Landroid/util/ArrayMap;

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

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->bindings:Landroid/util/ArrayMap;

    new-instance v0, Landroid/util/ArrayMap;

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

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->connections:Landroid/util/ArrayMap;

    new-instance v0, Ljava/util/ArrayList;

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

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    new-instance v0, Ljava/util/ArrayList;

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

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->pendingStarts:Ljava/util/ArrayList;

    iput-object p1, p0, Lcom/android/server/am/ServiceRecord;->ams:Lcom/android/server/am/ActivityManagerService;

    iput-object p2, p0, Lcom/android/server/am/ServiceRecord;->stats:Lcom/android/internal/os/BatteryStatsImpl$Uid$Pkg$Serv;

    iput-object p3, p0, Lcom/android/server/am/ServiceRecord;->name:Landroid/content/ComponentName;

    invoke-virtual {p3}, Landroid/content/ComponentName;->flattenToShortString()Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->shortName:Ljava/lang/String;

    iput-object p4, p0, Lcom/android/server/am/ServiceRecord;->intent:Landroid/content/Intent$FilterComparison;

    iput-object p5, p0, Lcom/android/server/am/ServiceRecord;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v0, p5, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->appInfo:Landroid/content/pm/ApplicationInfo;

    iget-object v0, p5, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget-object v0, v0, Landroid/content/pm/ApplicationInfo;->packageName:Ljava/lang/String;

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->packageName:Ljava/lang/String;

    iget-object v0, p5, Landroid/content/pm/ServiceInfo;->processName:Ljava/lang/String;

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->processName:Ljava/lang/String;

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

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->permission:Ljava/lang/String;

    iget-object v0, p5, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget-object v0, v0, Landroid/content/pm/ApplicationInfo;->sourceDir:Ljava/lang/String;

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->baseDir:Ljava/lang/String;

    iget-object v0, p5, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget-object v0, v0, Landroid/content/pm/ApplicationInfo;->publicSourceDir:Ljava/lang/String;

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->resDir:Ljava/lang/String;

    iget-object v0, p5, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget-object v0, v0, Landroid/content/pm/ApplicationInfo;->dataDir:Ljava/lang/String;

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->dataDir:Ljava/lang/String;

    iget-boolean v0, p5, Landroid/content/pm/ServiceInfo;->exported:Z

    iput-boolean v0, p0, Lcom/android/server/am/ServiceRecord;->exported:Z

    iput-object p7, p0, Lcom/android/server/am/ServiceRecord;->restarter:Ljava/lang/Runnable;

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

    move-result-wide v0

    iput-wide v0, p0, Lcom/android/server/am/ServiceRecord;->createTime:J

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

    move-result-wide v0

    iput-wide v0, p0, Lcom/android/server/am/ServiceRecord;->lastActivity:J

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->appInfo:Landroid/content/pm/ApplicationInfo;

    iget v0, v0, Landroid/content/pm/ApplicationInfo;->uid:I

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

    move-result v0

    iput v0, p0, Lcom/android/server/am/ServiceRecord;->userId:I

    iput-boolean p6, p0, Lcom/android/server/am/ServiceRecord;->createdFromFg:Z

    return-void
.end method

# virtual methods
.method public cancelNotification()V
    .registers 5

    iget v2, p0, Lcom/android/server/am/ServiceRecord;->foregroundId:I

    if-eqz v2, :cond_14

    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->packageName:Ljava/lang/String;

    iget v0, p0, Lcom/android/server/am/ServiceRecord;->foregroundId:I

    iget-object v2, p0, Lcom/android/server/am/ServiceRecord;->ams:Lcom/android/server/am/ActivityManagerService;

    iget-object v2, v2, Lcom/android/server/am/ActivityManagerService;->mHandler:Landroid/os/Handler;

    new-instance v3, Lcom/android/server/am/ServiceRecord$2;

    invoke-direct {v3, p0, v1, v0}, Lcom/android/server/am/ServiceRecord$2;-><init>(Lcom/android/server/am/ServiceRecord;Ljava/lang/String;I)V

    invoke-virtual {v2, v3}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    :cond_14
    return-void
.end method

.method public clearDeliveredStartsLocked()V
    .registers 3

    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v1}, Ljava/util/ArrayList;->size()I

    move-result v1

    add-int/lit8 v0, v1, -0x1

    :goto_8
    if-ltz v0, :cond_18

    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v1, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/android/server/am/ServiceRecord$StartItem;

    invoke-virtual {v1}, Lcom/android/server/am/ServiceRecord$StartItem;->removeUriPermissionsLocked()V

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

    goto :goto_8

    :cond_18
    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v1}, Ljava/util/ArrayList;->clear()V

    return-void
.end method

.method dump(Ljava/io/PrintWriter;Ljava/lang/String;)V
    .registers 24
    .param p1    # Ljava/io/PrintWriter;
    .param p2    # Ljava/lang/String;

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "intent={"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->intent:Landroid/content/Intent$FilterComparison;

    invoke-virtual {v3}, Landroid/content/Intent$FilterComparison;->getIntent()Landroid/content/Intent;

    move-result-object v3

    const/4 v4, 0x0

    const/4 v5, 0x1

    const/4 v6, 0x0

    const/4 v9, 0x1

    invoke-virtual {v3, v4, v5, v6, v9}, Landroid/content/Intent;->toShortString(ZZZZ)Ljava/lang/String;

    move-result-object v3

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const/16 v3, 0x7d

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(C)V

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "packageName="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->packageName:Ljava/lang/String;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "processName="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->processName:Ljava/lang/String;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->permission:Ljava/lang/String;

    if-eqz v3, :cond_65

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "permission="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->permission:Ljava/lang/String;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    :cond_65
    invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

    move-result-wide v7

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

    move-result-wide v19

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "baseDir="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->baseDir:Ljava/lang/String;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->resDir:Ljava/lang/String;

    move-object/from16 v0, p0

    iget-object v4, v0, Lcom/android/server/am/ServiceRecord;->baseDir:Ljava/lang/String;

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

    move-result v3

    if-nez v3, :cond_a1

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "resDir="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->resDir:Ljava/lang/String;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    :cond_a1
    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "dataDir="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->dataDir:Ljava/lang/String;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "app="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->app:Lcom/android/server/am/ProcessRecord;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->isolatedProc:Lcom/android/server/am/ProcessRecord;

    if-eqz v3, :cond_e0

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "isolatedProc="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->isolatedProc:Lcom/android/server/am/ProcessRecord;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    :cond_e0
    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->delayed:Z

    if-eqz v3, :cond_f9

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "delayed="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->delayed:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Z)V

    :cond_f9
    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->isForeground:Z

    if-nez v3, :cond_105

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->foregroundId:I

    if-eqz v3, :cond_138

    :cond_105
    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "isForeground="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->isForeground:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Z)V

    const-string v3, " foregroundId="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->foregroundId:I

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(I)V

    const-string v3, " foregroundNoti="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->foregroundNoti:Landroid/app/Notification;

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    :cond_138
    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "createTime="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->createTime:J

    move-wide/from16 v0, v19

    move-object/from16 v2, p1

    invoke-static {v3, v4, v0, v1, v2}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    const-string v3, " startingBgTimeout="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->startingBgTimeout:J

    move-object/from16 v0, p1

    invoke-static {v3, v4, v7, v8, v0}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    invoke-virtual/range {p1 .. p1}, Ljava/io/PrintWriter;->println()V

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "lastActivity="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->lastActivity:J

    move-object/from16 v0, p1

    invoke-static {v3, v4, v7, v8, v0}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    const-string v3, " restartTime="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->restartTime:J

    move-object/from16 v0, p1

    invoke-static {v3, v4, v7, v8, v0}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    const-string v3, " createdFromFg="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->createdFromFg:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Z)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->startRequested:Z

    if-nez v3, :cond_1a5

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->delayedStop:Z

    if-nez v3, :cond_1a5

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    if-eqz v3, :cond_1f8

    :cond_1a5
    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "startRequested="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->startRequested:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Z)V

    const-string v3, " delayedStop="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->delayedStop:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Z)V

    const-string v3, " stopIfKilled="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->stopIfKilled:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Z)V

    const-string v3, " callStart="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->callStart:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Z)V

    const-string v3, " lastStartId="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(I)V

    :cond_1f8
    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->executeNesting:I

    if-eqz v3, :cond_234

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "executeNesting="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->executeNesting:I

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(I)V

    const-string v3, " executeFg="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-boolean v3, v0, Lcom/android/server/am/ServiceRecord;->executeFg:Z

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Z)V

    const-string v3, " executingStart="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->executingStart:J

    move-object/from16 v0, p1

    invoke-static {v3, v4, v7, v8, v0}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    invoke-virtual/range {p1 .. p1}, Ljava/io/PrintWriter;->println()V

    :cond_234
    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->crashCount:I

    if-nez v3, :cond_254

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->restartCount:I

    if-nez v3, :cond_254

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->restartDelay:J

    const-wide/16 v5, 0x0

    cmp-long v3, v3, v5

    if-nez v3, :cond_254

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->nextRestartTime:J

    const-wide/16 v5, 0x0

    cmp-long v3, v3, v5

    if-eqz v3, :cond_297

    :cond_254
    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "restartCount="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->restartCount:I

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(I)V

    const-string v3, " restartDelay="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->restartDelay:J

    move-object/from16 v0, p1

    invoke-static {v3, v4, v7, v8, v0}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    const-string v3, " nextRestartTime="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-wide v3, v0, Lcom/android/server/am/ServiceRecord;->nextRestartTime:J

    move-object/from16 v0, p1

    invoke-static {v3, v4, v7, v8, v0}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    const-string v3, " crashCount="

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget v3, v0, Lcom/android/server/am/ServiceRecord;->crashCount:I

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(I)V

    :cond_297
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v3

    if-lez v3, :cond_2b8

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "Delivered Starts:"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v6, v0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    move-object/from16 v3, p0

    move-object/from16 v4, p1

    move-object/from16 v5, p2

    invoke-virtual/range {v3 .. v8}, Lcom/android/server/am/ServiceRecord;->dumpStartList(Ljava/io/PrintWriter;Ljava/lang/String;Ljava/util/List;J)V

    :cond_2b8
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->pendingStarts:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v3

    if-lez v3, :cond_2db

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "Pending Starts:"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/server/am/ServiceRecord;->pendingStarts:Ljava/util/ArrayList;

    const-wide/16 v13, 0x0

    move-object/from16 v9, p0

    move-object/from16 v10, p1

    move-object/from16 v11, p2

    invoke-virtual/range {v9 .. v14}, Lcom/android/server/am/ServiceRecord;->dumpStartList(Ljava/io/PrintWriter;Ljava/lang/String;Ljava/util/List;J)V

    :cond_2db
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->bindings:Landroid/util/ArrayMap;

    invoke-virtual {v3}, Landroid/util/ArrayMap;->size()I

    move-result v3

    if-lez v3, :cond_353

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "Bindings:"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    const/16 v18, 0x0

    :goto_2f1
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->bindings:Landroid/util/ArrayMap;

    invoke-virtual {v3}, Landroid/util/ArrayMap;->size()I

    move-result v3

    move/from16 v0, v18

    if-ge v0, v3, :cond_353

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->bindings:Landroid/util/ArrayMap;

    move/from16 v0, v18

    invoke-virtual {v3, v0}, Landroid/util/ArrayMap;->valueAt(I)Ljava/lang/Object;

    move-result-object v15

    check-cast v15, Lcom/android/server/am/IntentBindRecord;

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "* IntentBindRecord{"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    invoke-static {v15}, Ljava/lang/System;->identityHashCode(Ljava/lang/Object;)I

    move-result v3

    invoke-static {v3}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;

    move-result-object v3

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    invoke-virtual {v15}, Lcom/android/server/am/IntentBindRecord;->collectFlags()I

    move-result v3

    and-int/lit8 v3, v3, 0x1

    if-eqz v3, :cond_32f

    const-string v3, " CREATE"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->append(Ljava/lang/CharSequence;)Ljava/io/PrintWriter;

    :cond_32f
    const-string v3, "}:"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    new-instance v3, Ljava/lang/StringBuilder;

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

    move-object/from16 v0, p2

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)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

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

    move-result-object v3

    move-object/from16 v0, p1

    invoke-virtual {v15, v0, v3}, Lcom/android/server/am/IntentBindRecord;->dumpInService(Ljava/io/PrintWriter;Ljava/lang/String;)V

    add-int/lit8 v18, v18, 0x1

    goto :goto_2f1

    :cond_353
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->connections:Landroid/util/ArrayMap;

    invoke-virtual {v3}, Landroid/util/ArrayMap;->size()I

    move-result v3

    if-lez v3, :cond_3a8

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "All Connections:"

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    const/16 v17, 0x0

    :goto_369
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->connections:Landroid/util/ArrayMap;

    invoke-virtual {v3}, Landroid/util/ArrayMap;->size()I

    move-result v3

    move/from16 v0, v17

    if-ge v0, v3, :cond_3a8

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/server/am/ServiceRecord;->connections:Landroid/util/ArrayMap;

    move/from16 v0, v17

    invoke-virtual {v3, v0}, Landroid/util/ArrayMap;->valueAt(I)Ljava/lang/Object;

    move-result-object v16

    check-cast v16, Ljava/util/ArrayList;

    const/16 v18, 0x0

    :goto_383
    invoke-virtual/range {v16 .. v16}, Ljava/util/ArrayList;->size()I

    move-result v3

    move/from16 v0, v18

    if-ge v0, v3, :cond_3a5

    invoke-virtual/range {p1 .. p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "  "

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    move-object/from16 v0, v16

    move/from16 v1, v18

    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v3

    move-object/from16 v0, p1

    invoke-virtual {v0, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    add-int/lit8 v18, v18, 0x1

    goto :goto_383

    :cond_3a5
    add-int/lit8 v17, v17, 0x1

    goto :goto_369

    :cond_3a8
    return-void
.end method

.method dumpStartList(Ljava/io/PrintWriter;Ljava/lang/String;Ljava/util/List;J)V
    .registers 11
    .param p1    # Ljava/io/PrintWriter;
    .param p2    # Ljava/lang/String;
    .param p4    # J
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/io/PrintWriter;",
            "Ljava/lang/String;",
            "Ljava/util/List",
            "<",
            "Lcom/android/server/am/ServiceRecord$StartItem;",
            ">;J)V"
        }
    .end annotation

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

    move-result v0

    const/4 v1, 0x0

    :goto_5
    if-ge v1, v0, :cond_b1

    invoke-interface {p3, v1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/android/server/am/ServiceRecord$StartItem;

    invoke-virtual {p1, p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "#"

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    invoke-virtual {p1, v1}, Ljava/io/PrintWriter;->print(I)V

    const-string v3, " id="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->id:I

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(I)V

    const-wide/16 v3, 0x0

    cmp-long v3, p4, v3

    if-eqz v3, :cond_32

    const-string v3, " dur="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-wide v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->deliveredTime:J

    invoke-static {v3, v4, p4, p5, p1}, Landroid/util/TimeUtils;->formatDuration(JJLjava/io/PrintWriter;)V

    :cond_32
    iget v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->deliveryCount:I

    if-eqz v3, :cond_40

    const-string v3, " dc="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->deliveryCount:I

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(I)V

    :cond_40
    iget v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->doneExecutingCount:I

    if-eqz v3, :cond_4e

    const-string v3, " dxc="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->doneExecutingCount:I

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(I)V

    :cond_4e
    const-string v3, ""

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    invoke-virtual {p1, p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "  intent="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->intent:Landroid/content/Intent;

    if-eqz v3, :cond_ab

    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->intent:Landroid/content/Intent;

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

    move-result-object v3

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    :goto_68
    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->neededGrants:Lcom/android/server/am/ActivityManagerService$NeededUriGrants;

    if-eqz v3, :cond_79

    invoke-virtual {p1, p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "  neededGrants="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->neededGrants:Lcom/android/server/am/ActivityManagerService$NeededUriGrants;

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    :cond_79
    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->uriPermissions:Lcom/android/server/am/UriPermissionOwner;

    if-eqz v3, :cond_a7

    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->uriPermissions:Lcom/android/server/am/UriPermissionOwner;

    iget-object v3, v3, Lcom/android/server/am/UriPermissionOwner;->readUriPermissions:Ljava/util/HashSet;

    if-eqz v3, :cond_92

    invoke-virtual {p1, p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "  readUriPermissions="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->uriPermissions:Lcom/android/server/am/UriPermissionOwner;

    iget-object v3, v3, Lcom/android/server/am/UriPermissionOwner;->readUriPermissions:Ljava/util/HashSet;

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    :cond_92
    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->uriPermissions:Lcom/android/server/am/UriPermissionOwner;

    iget-object v3, v3, Lcom/android/server/am/UriPermissionOwner;->writeUriPermissions:Ljava/util/HashSet;

    if-eqz v3, :cond_a7

    invoke-virtual {p1, p2}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    const-string v3, "  writeUriPermissions="

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->print(Ljava/lang/String;)V

    iget-object v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->uriPermissions:Lcom/android/server/am/UriPermissionOwner;

    iget-object v3, v3, Lcom/android/server/am/UriPermissionOwner;->writeUriPermissions:Ljava/util/HashSet;

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/Object;)V

    :cond_a7
    add-int/lit8 v1, v1, 0x1

    goto/16 :goto_5

    :cond_ab
    const-string v3, "null"

    invoke-virtual {p1, v3}, Ljava/io/PrintWriter;->println(Ljava/lang/String;)V

    goto :goto_68

    :cond_b1
    return-void
.end method

.method public findDeliveredStart(IZ)Lcom/android/server/am/ServiceRecord$StartItem;
    .registers 7
    .param p1    # I
    .param p2    # Z

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v0

    const/4 v1, 0x0

    :goto_7
    if-ge v1, v0, :cond_20

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v3, v1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/android/server/am/ServiceRecord$StartItem;

    iget v3, v2, Lcom/android/server/am/ServiceRecord$StartItem;->id:I

    if-ne v3, p1, :cond_1d

    if-eqz p2, :cond_1c

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->deliveredStarts:Ljava/util/ArrayList;

    invoke-virtual {v3, v1}, Ljava/util/ArrayList;->remove(I)Ljava/lang/Object;

    :cond_1c
    :goto_1c
    return-object v2

    :cond_1d
    add-int/lit8 v1, v1, 0x1

    goto :goto_7

    :cond_20
    const/4 v2, 0x0

    goto :goto_1c
.end method

.method public forceClearTracker()V
    .registers 3

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    if-eqz v0, :cond_d

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    const/4 v1, 0x1

    invoke-virtual {v0, p0, v1}, Lcom/android/internal/app/ProcessStats$ServiceState;->clearCurrentOwner(Ljava/lang/Object;Z)V

    const/4 v0, 0x0

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    :cond_d
    return-void
.end method

.method public getLastStartId()I
    .registers 2

    iget v0, p0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    return v0
.end method

.method public getTracker()Lcom/android/internal/app/ProcessStats$ServiceState;
    .registers 6

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    if-eqz v0, :cond_7

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    :goto_6
    return-object v0

    :cond_7
    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v0, v0, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget v0, v0, Landroid/content/pm/ApplicationInfo;->flags:I

    and-int/lit8 v0, v0, 0x8

    if-nez v0, :cond_32

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->ams:Lcom/android/server/am/ActivityManagerService;

    iget-object v0, v0, Lcom/android/server/am/ActivityManagerService;->mProcessStats:Lcom/android/server/am/ProcessStatsService;

    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->serviceInfo:Landroid/content/pm/ServiceInfo;

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

    iget-object v2, p0, Lcom/android/server/am/ServiceRecord;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v2, v2, Landroid/content/pm/ServiceInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    iget v2, v2, Landroid/content/pm/ApplicationInfo;->uid:I

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->serviceInfo:Landroid/content/pm/ServiceInfo;

    iget-object v3, v3, Landroid/content/pm/ServiceInfo;->processName:Ljava/lang/String;

    iget-object v4, p0, Lcom/android/server/am/ServiceRecord;->serviceInfo:Landroid/content/pm/ServiceInfo;

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

    invoke-virtual {v0, v1, v2, v3, v4}, Lcom/android/server/am/ProcessStatsService;->getServiceStateLocked(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)Lcom/android/internal/app/ProcessStats$ServiceState;

    move-result-object v0

    iput-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    invoke-virtual {v0, p0}, Lcom/android/internal/app/ProcessStats$ServiceState;->applyNewOwner(Ljava/lang/Object;)V

    :cond_32
    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->tracker:Lcom/android/internal/app/ProcessStats$ServiceState;

    goto :goto_6
.end method

.method public hasAutoCreateConnections()Z
    .registers 5

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->connections:Landroid/util/ArrayMap;

    invoke-virtual {v3}, Landroid/util/ArrayMap;->size()I

    move-result v3

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

    :goto_8
    if-ltz v0, :cond_2d

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->connections:Landroid/util/ArrayMap;

    invoke-virtual {v3, v0}, Landroid/util/ArrayMap;->valueAt(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/util/ArrayList;

    const/4 v2, 0x0

    :goto_13
    invoke-virtual {v1}, Ljava/util/ArrayList;->size()I

    move-result v3

    if-ge v2, v3, :cond_2a

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Lcom/android/server/am/ConnectionRecord;

    iget v3, v3, Lcom/android/server/am/ConnectionRecord;->flags:I

    and-int/lit8 v3, v3, 0x1

    if-eqz v3, :cond_27

    const/4 v3, 0x1

    :goto_26
    return v3

    :cond_27
    add-int/lit8 v2, v2, 0x1

    goto :goto_13

    :cond_2a
    add-int/lit8 v0, v0, -0x1

    goto :goto_8

    :cond_2d
    const/4 v3, 0x0

    goto :goto_26
.end method

.method public makeNextStartId()I
    .registers 3

    const/4 v1, 0x1

    iget v0, p0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    iget v0, p0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    if-ge v0, v1, :cond_d

    iput v1, p0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    :cond_d
    iget v0, p0, Lcom/android/server/am/ServiceRecord;->lastStartId:I

    return v0
.end method

.method public postNotification()V
    .registers 9

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->appInfo:Landroid/content/pm/ApplicationInfo;

    iget v4, v0, Landroid/content/pm/ApplicationInfo;->uid:I

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->app:Lcom/android/server/am/ProcessRecord;

    iget v5, v0, Lcom/android/server/am/ProcessRecord;->pid:I

    iget v0, p0, Lcom/android/server/am/ServiceRecord;->foregroundId:I

    if-eqz v0, :cond_23

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->foregroundNoti:Landroid/app/Notification;

    if-eqz v0, :cond_23

    iget-object v3, p0, Lcom/android/server/am/ServiceRecord;->packageName:Ljava/lang/String;

    iget v6, p0, Lcom/android/server/am/ServiceRecord;->foregroundId:I

    iget-object v2, p0, Lcom/android/server/am/ServiceRecord;->foregroundNoti:Landroid/app/Notification;

    iget-object v0, p0, Lcom/android/server/am/ServiceRecord;->ams:Lcom/android/server/am/ActivityManagerService;

    iget-object v7, v0, Lcom/android/server/am/ActivityManagerService;->mHandler:Landroid/os/Handler;

    new-instance v0, Lcom/android/server/am/ServiceRecord$1;

    move-object v1, p0

    invoke-direct/range {v0 .. v6}, Lcom/android/server/am/ServiceRecord$1;-><init>(Lcom/android/server/am/ServiceRecord;Landroid/app/Notification;Ljava/lang/String;III)V

    invoke-virtual {v7, v0}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    :cond_23
    return-void
.end method

.method public resetRestartCounter()V
    .registers 4

    const-wide/16 v1, 0x0

    const/4 v0, 0x0

    iput v0, p0, Lcom/android/server/am/ServiceRecord;->restartCount:I

    iput-wide v1, p0, Lcom/android/server/am/ServiceRecord;->restartDelay:J

    iput-wide v1, p0, Lcom/android/server/am/ServiceRecord;->restartTime:J

    return-void
.end method

.method public retrieveAppBindingLocked(Landroid/content/Intent;Lcom/android/server/am/ProcessRecord;)Lcom/android/server/am/AppBindRecord;
    .registers 8
    .param p1    # Landroid/content/Intent;
    .param p2    # Lcom/android/server/am/ProcessRecord;

    new-instance v2, Landroid/content/Intent$FilterComparison;

    invoke-direct {v2, p1}, Landroid/content/Intent$FilterComparison;-><init>(Landroid/content/Intent;)V

    iget-object v4, p0, Lcom/android/server/am/ServiceRecord;->bindings:Landroid/util/ArrayMap;

    invoke-virtual {v4, v2}, Landroid/util/ArrayMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Lcom/android/server/am/IntentBindRecord;

    if-nez v3, :cond_19

    new-instance v3, Lcom/android/server/am/IntentBindRecord;

    invoke-direct {v3, p0, v2}, Lcom/android/server/am/IntentBindRecord;-><init>(Lcom/android/server/am/ServiceRecord;Landroid/content/Intent$FilterComparison;)V

    iget-object v4, p0, Lcom/android/server/am/ServiceRecord;->bindings:Landroid/util/ArrayMap;

    invoke-virtual {v4, v2, v3}, Landroid/util/ArrayMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    :cond_19
    iget-object v4, v3, Lcom/android/server/am/IntentBindRecord;->apps:Landroid/util/ArrayMap;

    invoke-virtual {v4, p2}, Landroid/util/ArrayMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/android/server/am/AppBindRecord;

    if-eqz v0, :cond_25

    move-object v1, v0

    :goto_24
    return-object v1

    :cond_25
    new-instance v0, Lcom/android/server/am/AppBindRecord;

    invoke-direct {v0, p0, v3, p2}, Lcom/android/server/am/AppBindRecord;-><init>(Lcom/android/server/am/ServiceRecord;Lcom/android/server/am/IntentBindRecord;Lcom/android/server/am/ProcessRecord;)V

    iget-object v4, v3, Lcom/android/server/am/IntentBindRecord;->apps:Landroid/util/ArrayMap;

    invoke-virtual {v4, p2, v0}, Landroid/util/ArrayMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    move-object v1, v0

    goto :goto_24
.end method

.method public toString()Ljava/lang/String;
    .registers 4

    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->stringName:Ljava/lang/String;

    if-eqz v1, :cond_7

    iget-object v1, p0, Lcom/android/server/am/ServiceRecord;->stringName:Ljava/lang/String;

    :goto_6
    return-object v1

    :cond_7
    new-instance v0, Ljava/lang/StringBuilder;

    const/16 v1, 0x80

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

    const-string v1, "ServiceRecord{"

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

    move-result-object v1

    invoke-static {p0}, Ljava/lang/System;->identityHashCode(Ljava/lang/Object;)I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;

    move-result-object v2

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

    move-result-object v1

    const-string v2, " u"

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

    move-result-object v1

    iget v2, p0, Lcom/android/server/am/ServiceRecord;->userId:I

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

    move-result-object v1

    const/16 v2, 0x20

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

    move-result-object v1

    iget-object v2, p0, Lcom/android/server/am/ServiceRecord;->shortName:Ljava/lang/String;

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

    move-result-object v1

    const/16 v2, 0x7d

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

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

    move-result-object v1

    iput-object v1, p0, Lcom/android/server/am/ServiceRecord;->stringName:Ljava/lang/String;

    goto :goto_6
.end method

redpajama_set_name: RedPajamaGithub


text:
/// <reference types="node" />
import { ClientRequest } from 'http';
import type { Request } from '../types';
/**
 * Fix proxied body if bodyParser is involved.
 */
export declare function fixRequestBody(proxyReq: ClientRequest, req: Request): void;


text:
sap.ui.define([
		"sap/m/routing/Router"
	], function (Router) {
	"use strict";

	return Router.extend("sap.ui.demo.mdtemplate.Router", {

		constructor : function() {
			sap.m.routing.Router.apply(this, arguments);
		}

	});

}, /* bExport= */ true);


text:
"""
When the test runner finds and executes tests within this directory,
this file will be loaded to setup the test environment.

configuration comes in through os.environ, see config below

"""
import os
import sys
import urllib2
import httplib
import cookielib
import re
from unittest import TestCase
try:
    import simplejson
except ImportError:
    import json as simplejson
import urllib
from urllib2 import Request
import string
import types
import socket
# global socket timeout, seemed to help with a weird connection reset issue in appengine
socket.setdefaulttimeout(60)

__all__ = ['TestClass', 'tag']

here_dir = os.path.dirname(os.path.abspath(__file__))
conf_file = here_dir + '/test.ini'

def setup_context():
    """
    Test modules/packages can import this function and call it to
    ensure their tests have a valid context.

    """

def setup_package():
    setup_context()

def teardown_package():
    pass

class AcreRedirectHandler(urllib2.HTTPRedirectHandler):
    """
    A subclass of the default HTTPRedirectHandler which handles 301 and 302 status codes.
    """
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        result = urllib2.HTTPRedirectHandler()
        print "Redirect handler caught error.\ncode: %s\nmsg: %s\nheaders: %s\nnewurl: %s\n" % (code, msg, headers, newurl);
        print "Now throwing catchable HTTPError";
        raise urllib2.HTTPError(newurl, code, msg, headers, fp)

class ExtraAsserts(TestCase):

    def assertIn(self, array, value, msg=None):
        self.assert_(value in array, msg or "value %s not in %r" % (value, array))

    def assertNotIn(self, array, value, msg=None):
        self.assert_(not value in array, msg or "value %s is in %r" % (value, array))

    def assert_(self, cond, msg=None):
        return self.assertTrue(cond, msg)

def tag(**kwds):
   """ decorator that sets attributes on a function

   usage:
       @tag(key1=v1, key2='something else')
       def fn(...):
           ....
   """
   def inner(f):
       for k,v in kwds.iteritems():
           setattr(f, k, v)
       return f
   return inner

class DevNull():
    def __init__(self):
        self.lines = []

    def write(self, s):
        self.lines.append(s)

class TestClass(ExtraAsserts):

    def tearDown(self):
        sys.stdout = self.real_stdout

    def setUp(self, *args, **kwargs):
        # supress prints
        verbose = False
        if verbose is False:
            self.real_stdout = sys.stdout
            sys.stdout = DevNull()

        self.cookiefile = "./cookies.lwp",
        self.cookiejar = cookielib.LWPCookieJar("./cookies.lwp")

        # Install cookie and redirect handlers.
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejar))
        urllib2.install_opener(self.opener)

        # set test url
        self.data = None;
        self.method = "GET";
        self.headers = None

        config = os.environ
        self.server_base = config.get("ACRE_HOST_BASE")
        self.server_host = "dev." + self.server_base
        self.server_name = "api.qatests.apps.freebase." + self.server_host
        self.script_namespace = "/freebase/apps/qatests/api"

        self.port = int(config.get("ACRE_PORT"))
        self.server_url = 'http://' + self.server_name
        if self.port != 80:
            self.server_url += ':%d' % self.port

        self.host = self.server_url;
        self.username = config.get("TEST_USERNAME")
        self.password = config.get("TEST_PASSWORD")

        base_addr = config.get("ACRE_METAWEB_BASE_ADDR")
        port_str = config.get("ACRE_FREEBASE_SITE_ADDR_PORT")
        if port_str:
            port_str = ":" + port_str
        else:
            port_str = ":80"
        if base_addr:
            self.freebase_api_service = "http://api." + base_addr + port_str
            self.freebase_service = "http://api." + base_addr
            self.appeditor_host = "http://www." + base_addr + port_str
        else:
            print "tests are going nowhere with the env var: ACRE_METAWEB_BASE_ADDR"
            sys.exit(1)

        self.appeditor_service_url = None
        if self.appeditor_host:
            self.appeditor_service_url = self.appeditor_host + "/appeditor/services"

        self.auth_host = self.freebase_service
        self.data_path = "data"
        self.data_path = here_dir + '/' + self.data_path

    def set_acre_script(self, acre_script, data="", headers=None, domain=None):
        self.acre_script = acre_script
        if domain is not None:
            self.server_name = domain+"."+  self.server_host
        self.server_url = 'http://'+self.server_name;

        if self.port != 80 and not re.compile( ":%s$" % self.port ).search(self.server_url):
            self.server_url += ':%s' % self.port

        self.acre_url = self.server_url+"/"+ acre_script

        if (isinstance(data, basestring)):
            self.data = data
        else:
            self.data = self.encode_data(data)

    def get_url(self, url, data=None):
        """GET a non-Acre url"""
        from urllib2 import Request

        if data is not None:
            request = Request( url +"?" + data);
        else:
            request = Request( url )
        self.cookiejar.add_cookie_header(request)
        try:
            response = urllib2.urlopen(request)
            cookies = self.cookiejar.make_cookies(response, request)
            #for c in cookies:
            #    print "Got cookie: %s" % c;

            return response
        except:
            raise

    def get(self,headers={}):
        """Http GET the test acre url, by default set the x-acre-enable-log header and store the logs in the response headers"""
        from urllib2 import Request
        self.log = None
        if self.method == "GET":
            if ('%s' % self.data).rstrip().lstrip():
                print "self.data is %s\n" % self.data;
                print "getting url: " + self.acre_url + "?" + self.data
                self.request = Request(self.acre_url +"?"+ self.data, headers=headers)
            else:
                print "getting url: " + self.acre_url
                self.request = Request(self.acre_url, headers=headers)
        else:
            print "POSTing request: %s with data %s" % (self.acre_url, self.data);
            headers['Content-Type'] = "application/x-www-form-urlencoded"

            self.request = Request( self.acre_url, data=self.data, headers=headers )

        try:
            self.cookiejar.add_cookie_header(self.request)
            self.response = urllib2.urlopen(self.request)

            cookies = self.cookiejar.make_cookies(self.response, self.request);
            print "TID: %s" % self.response.headers['X-Metaweb-TID'];
            for c in cookies:
                print "Cookie: %s" % c;

            return self.response
        except urllib2.HTTPError, e:
            print "TID: %s" % e.hdrs['X-Metaweb-TID'];
            raise

    def get_response_headers(self, response=None):
        p = re.compile("[\r\n]+");
        if response is None:
            response = self.response;
        _headers = p.split( "%s" % response.info());
        headers = {};

        for _h in _headers:
            p = re.compile(":");
            if p.search("%s" % _h):
                _key = p.split("%s" % _h, maxsplit=1);
                key =  _key[0].strip();
                value = _key[1].strip();

                if headers.has_key(key):
                    if  isinstance (headers[key], list):
                        headers[key].append(value)
                    else:
                        headers[key] = [headers[key], value];
                else:
                    headers[key] = value;

        self.response_headers = headers;

        return self.response_headers;

    def sleep(self, seconds):
        from time import sleep
        sleep(seconds);

    def app_login(self, domain=None, username=None, password=None):
        self.cookiefile = "./cookies.lwp";
        self.cookiejar = cookielib.LWPCookieJar();
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejar));
        urllib2.install_opener(self.opener);
        data = urllib.urlencode({ "username":username, "password":password, 'mw_cookie_scope':'domain' });
	if domain is None:
	     url = "http://%s" % self.server_host;
	else:
	    url = "http://%s.%s" % (domain, self.server_host);

	if self.port != 80:
	    url = "%s:%s" % ( url, self.port );

        url = "%s/acre/login?%s" % (url, data);
        print "Logging in: %s" % url

        try:
            request = urllib2.Request(url)
	    self.cookiejar.add_cookie_header(request)
            respobj = urllib2.urlopen(request);
            respdata = respobj.read();
            respurl  = respobj.geturl();
            resphead = respobj.info();

            #print "Got response: %s" % respdata;
            cookies = self.cookiejar.make_cookies(respobj, request);
            for c in cookies:
                print "Cookie: %s" % c;

        except urllib2.HTTPError, e:
            print "Login failed: %s " % e;
            print e.fp.read();
            raise;

        except Exception, e:
            print "Login failed: %s " % e;
            raise;

    def app_touch(self, domain=None):
        from time import sleep
        sleep(2);
        print "Calling acre  touch service";
	if domain is None:
            touch_url = 'http://' + self.server_base;
	else:
	    touch_url = "http://%s.%s" % (domain, self.server_host);

        if self.port != 80:
            touch_url += ':%d' % self.port
        self.request_url( "%s/acre/touch" % (touch_url))

    def freebase_touch(self):
        from time import sleep
        sleep(2);
        print "Calling freebase touch service";
        self.request_url( "%s/api/service/touch" % (self.freebase_api_service))

    def touch(self, host=None):
        from time import sleep
        sleep(2);
        print "Calling touch service";
        if host is None:
            host = 'http://' + self.server_base
            if self.port != 80:
                host += ':%d' % self.port
        self.request_url( "%s/acre/touch" % (host))

    def acre_touch(self):
        from time import sleep
        sleep(2);
        print "Calling touch service";
        self.request_url( "%s/acre/touch" % (self.appeditor_host))

    def get_dataset(self, data_type, data_start):
        files = os.listdir(os.path.join(self.data_path, data_type))
        return [ a for a in files if a.startswith(data_start) ]

    def get_data(self, data_type, data_file):
        return file(os.path.join(self.data_path, data_type, data_file)).read()

    def print_exception_msg(self, error):
        print "Got error: %s" % error;
        body = "";
        if (re.match("HTTP Error", "%s" % error)):
            tid = self.get_tid_from_error(error);
            body = error.fp.read();
        elif (self.response):
            if (self.response.headers):
                tid = self.get_tid();
            else:
                tid = None
        else:
             print "No response object found - no TID available.";

        self.assert_(False, "An unexpected error occurred.\nTest: %s?%s\nTID:%s\nMessage:\n%s\n%s" % (self.acre_url, self.data, tid, error, body));

    def get_tid_from_error(self, error):
        _headers = error.hdrs;
        tid = ""
        p = re.compile('x-metaweb-tid', re.I )
        for h in _headers:
             if p.match( h ):
                 tid = _headers[h]
        if tid == "":
            self.assert_(False, "No X-Metaweb-TID header found in Acre response.")
        return tid;

    #WILL: def get_log_messages_from_error(self, error, format="json", callback=None): #HACK: I don't think this is required anymore?

    def get_tid( self ):
        try:
            if self.response.headers['X-Metaweb-TID']:
                return self.response.headers['X-Metaweb-TID']
            else:
               self.assert_(False, "No X-Metaweb-TID found in Acre response.");
        except Exception, e:
            print "Caught unexpected exception %s: %s " % (e, self.response.headers)

    def parse_headers(self, headers=None):
        #print self.response.info();
        p = re.compile("[\r\n]+")
        if headers is None:
            headers = p.split("%s" % self.response.info())
        else:
            headers = p.split("%s" % headers);
        #print "headers: %s " % headers;
        sep = re.compile('[a-zA-Z\-]+:[\s]*')
        for h in headers:
            #print "header line: " + h
            h = sep.split(h)
            if len(h) > 1:
                field = h.pop(0)
                value = h.pop()
                value = (value.rstrip()).lstrip()
                self.response.headers[field] = value
                #print "field: " + field + " value: " + value;

    def verify_log_message(self, expected_msg, expected_level=None):

        if not self.log or not len(self.log):
            self.assert_(False,'Log is empty, could not find %s' % (expected_msg))

        if not expected_level:
            expected_level = "LOG"

        found_log = False
        for msg in self.log:
            metadata = msg[0]
            con_args = msg[1]
            if isinstance(con_args, types.StringTypes):
                message = con_args
            elif isinstance(con_args, types.ListType):
                message = con_args[0] #HACK only the first arg
            else:
                print type(con_args)
                break

            if message and isinstance(message, types.StringTypes):
                if (hasattr(expected_msg, 'search') and expected_msg.search(message)) or (expected_msg == message):
                    found_log = True
                    self.assert_(expected_level == metadata['Type'], "Did not find expected log level in message. Expected: %s. Actual: %s" %(expected_level, metadata['Type']))
                    break

        if not found_log:
            self.assert_(False, "Did not find expected message in the log. Expected: %s Actual %s" % (expected_msg, self.log))

    def check_for_failures(self):
        self.assert_(re.match('OK', self.response.read(), re.I|re.M), self.response.read())

    def encode_data(self, data):
        import urllib

        # clean up any values that look like they're supposed to be JSON
        # XXX/nix this is still kind of unpredictable.
        if isinstance(data, dict):
            for k,v in data.items():
                if not isinstance(v, basestring):
                    data[k] = simplejson.dumps(v)
                    print " --> %r" % data[k]

        self.data = urllib.urlencode(data)
        #print "encoded data: " + self.data
        return self.data

    def validate_html(self, response):
        # only import this stuff if we need it!
        from html5lib.html5parser import HTMLParser
        from html5lib.filters.validator import HTMLConformanceChecker
        import pprint

        p = HTMLParser()
        p.parse(response.body)

        if (p.errors and
            not (len(p.errors) == 1 and p.errors[0][1] == 'unknown-doctype')):

            lines = response.body.splitlines()
            for (line, col), error, vars in p.errors:
                print "----------------------------------"
                print "Error: %s on line %s, column %s" % (error, line, col)
                print "%5d: %s" % (line, lines[line-1])
                print "      %s^" % (" " * col,)

            self.assert_(False)

    def check( self ):
        r = self.response.read()
        #print("response body:" + r)
        self.assert_(re.compile('ok', re.I|re.M).search(r), "Did not find OK in acre response.")

    def login(self, username=None, password=None):
        self.freebase_login(username, password);
        if ( self.freebase_service != self.appeditor_host ):
            self.acre_login(username, password);

    def freebase_login(self, username=None, password=None, host=None):
        if host is None:
            host = self.freebase_service;
        self.cookiefile = "./cookies.lwp";
        self.cookiejar = cookielib.LWPCookieJar();
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejar));
        urllib2.install_opener(self.opener);
        data = urllib.urlencode({ "username":username, "password":password, 'mw_cookie_scope':'domain' });
        url = "%s/api/account/login?%s" % (host, data);
        print "Logging in: %s" % url

        try:
            request = urllib2.Request(url)
	    self.cookiejar.add_cookie_header(request)
            respobj = urllib2.urlopen(request);
            respdata = respobj.read();
            respurl  = respobj.geturl();
            resphead = respobj.info();
            cookies = self.cookiejar.make_cookies(respobj, request);
            for c in cookies:
                print "Cookie: %s" % c;

            #print "Got response: %s" % respdata;

        except urllib2.HTTPError, e:
            print "Login failed: %s " % e;
            print e.fp.read();
            raise;

        except Exception, e:
            print "Login failed: %s " % e;
            raise;

    def  acre_login(self, username=None, password=None, host=None):
        if host is None:
            host = self.freebase_service;

        self.cookiefile = "./cookies.lwp";
        self.cookiejar = cookielib.LWPCookieJar();
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejar));
        urllib2.install_opener(self.opener);
        data = urllib.urlencode({ "username":username, "password":password, 'mw_cookie_scope':'domain' });
        url = "%s/api/account/login?%s" % (host, data);
        print "Logging in: %s" % url

        try:
            request = urllib2.Request(url)
	    self.cookiejar.add_cookie_header(request)
            respobj = urllib2.urlopen(request);
            respdata = respobj.read();
            respurl  = respobj.geturl();
            resphead = respobj.info();

            print "Got response: %s" % respdata;
            cookies = self.cookiejar.make_cookies(respobj, request);
            for c in cookies:
                print "Got cookie: %s" % c;

        except urllib2.HTTPError, e:
            print "Login failed: %s " % e;
            print e.fp.read();
            raise;

        except Exception, e:
            print "Login failed: %s " % e;
            raise;

    def logout(self):
        self.freebase_logout();
        if ( self.freebase_service != self.auth_host ):
            self.acre_logout();

    def freebase_logout(self):
        data = urllib.urlencode({ 'mw_cookie_scope':'domain' });
        logout_url = "%s/api/account/logout?%s" % (self.freebase_service, data);
        headers = { "X-Metaweb-Request" : 1 }
        response = self.request_url(logout_url );

    def acre_logout(self):
        data = urllib.urlencode({ 'mw_cookie_scope':'domain' });
        logout_url = "%s/api/account/logout?%s" % (self.appeditor_host, data);
        headers = { "X-Metaweb-Request" : 1 }
        response = self.request_url(logout_url );

    def assertController(self, response, controller_name):
        """ Easy way to assert that a given controller was run

        Uses routes' parsed controller, which handles internal redirects

        """

        # chop leading '/' because routes doesn't give it to us

        if controller_name[0] == '/':
            controller_name = controller_name[1:]

        environ = response.req.environ
        self.assertEquals(environ['wsgiorg.routing_args'][1]['controller'],
                          controller_name)

    def request_url( self, url, port=None, path=None, args=None, data=None, headers={}, method=None, code=None ):

        #print "ARGS IS: %s DATA: %s" % (args, data)

        if port is not None and port != 80:
            url = "%s:%s" % (url, port);

        if path is not None:
            url = "%s/%s" % (url, path);

        if args is not None:
            url = "%s?%s" % (url, args);

        if data is not None:
            data = urllib.urlencode(data);

        try:
            print "\nRequesting url %s\n" % url
            print "     Adding headers: %s\n" % headers

            # by default, if data is provided, we POST IT unless method==GET
            if data is not None and (method=="POST" or method==None):
                headers['Content-Type'] = "application/x-www-form-urlencoded"
                print "     Posting data: %s\n" % data
                self.request = urllib2.Request(url, data=data, headers=headers);
            elif data is not None and method == "GET":
	        url = "%s?%s" % ( url, data );
                self.request = urllib2.Request(url, headers=headers);

            else:
                self.request = urllib2.Request(url, headers=headers);

            self.cookiejar.add_cookie_header(self.request);
            self.response = self.opener.open(self.request);

            body_result = None;
            body_message = None;
            body_json = None;
            body = self.response.read();

            try:
                body_json = simplejson.loads(body);
                if body_json.has_key("result"):
                    body_result = body_json['result'];
                if body_json.has_key("messages"):
                    body_messsage = body_json['messages'][0]['message'];
            except Exception, e:
                if url.find("api/trans") > -1:
                    print "Warn: request did not return a JSON object: %s" %  e;

            result = { "request_url": url,
                     "body": body,
                     "body_json": body_json,
                     "body_result": body_result,
                     "body_message": body_message,
                     "response": self.response,
                     "response_url" : self.response.geturl(),
                     "headers": self.get_response_headers()
            }
            print "    URL: %s" % (url);
            if result['headers'].has_key('X-Metaweb-TID'):
                print "    TID: %s" % result['headers']['X-Metaweb-TID'];
            else:
                print "    Headers: %s" % result['headers'];

            if result['headers'].has_key('X-Metaweb-Cost'):
                print "    Cost: %s" % result['headers']['X-Metaweb-Cost'];

            cookies = self.cookiejar.make_cookies(self.response, self.request);
            for c in cookies:
                print "    Got cookie: %s" % c;

            if result.has_key('body_result'):
                print "    Result: %s" % result['body_result'];
            elif result.has_key('body_json'):
                print "    Result: %s" % result['body_json'];
            else:
                print "    Result: %s" % result['body'];

            print "\n";

            return result;

        except urllib2.HTTPError, e:
            result = { "body": e.fp.read(),
                       "response": e,
                       "headers": e.hdrs,
                       "code": e.code,
                       "info": e.info,
                       "msg":  e.msg,
                       "newurl": e.url,
                       "request_url": url }

            print "    URL: %s?%s" % (url, data);
            if result['headers'].has_key('X-Metaweb-TID'):
                print "    TID: %s" % result['headers']['X-Metaweb-TID'];
            else:
                print "    Headers: %s" % result['headers'];
            if result['headers'].has_key('X-Metaweb-Cost'):
                print "    Cost: %s" % result['headers']['X-Metaweb-Cost'];
            print "    Result: %s" % result['body'];

            print "\n";

            if code is not None:
                self.assert_ (e.code == code, "Did not get expected HTTP Error code.  Expected: %s Got: %s" % ( code, e.code ));

            if result['code'] == 302 or result['code'] == 301:
                print "    Got redirect.\n"
                print "    Redirecting to %s\n" % result['newurl']
                return self.request_url(result['newurl']);

            else:
                print "    Got code %s\n%s\n" % (e.code, result['body'] );

            return result;

        except Exception, e:
            print "    Caught unexpected error %s\n" % e;
            for p in e:
                print "    %s" % p;
            self.assert_(False, "threw unexpected error:\n%s" % e);

    def mqlread(self, query, headers={}, host=None):
        if host is None:
            host = self.freebase_api_service;
        url = "%s/api/service/mqlread" % host;
        data = { "query": simplejson.dumps( query ) }
        headers['X-Metaweb-Request'] = 1;
        print "Sending MqlRead query: %s/%s" % (url, query);
        response = self.request_url( url, data=data, headers=headers );
        return response;

    def mqlwrite(self, query, headers={}, username=None, password=None, host=None):
        if username is None:
            username = self.username;
        if username is password:
            username = self.password;
        if host is None:
            host = self.freebase_api_service;
        #self.freebase_login(host=host);
        url = "%s/api/service/mqlwrite" % host;
        data = { "query": simplejson.dumps( query ) }
        headers['X-Metaweb-Request'] = 1;
        print "Sending MqlWrite query: %s/%s" % (url, query);
        return self.request_url( url, data=data, headers=headers );

    def create_timestamp(self):
        import time;
        time.sleep(1);
        dt = time.localtime();
        year = dt[0];
        if dt[1] < 10:
            month = "0%s" % dt[1]
        else:
            month =  dt[1];
        if dt[2] < 10:
            day   = "0%s" % dt[2];
        else:
            day=dt[2];
        if dt[3] < 10:
            hour = "0%s" % dt[3]
        else:
            hour =  dt[3];
        if dt[4] < 10:
            min = "0%s" % dt[4];
        else:
            min = dt[4];
        if dt[5] < 10:
            sec = "0%s" % dt[5]
        else:
            sec = dt[5];

        app_name = "%s%s%s-%s%s%s" % (year, month, day, hour, min, sec)

        print "timestamp created: %s" % app_name
        return app_name;


text:
@extends(Config::get('entrust-gui.layout'))

@section('heading', 'Create User')

@section('content')
<form action="{{ route('entrust-gui::users.store') }}" method="post" role="form">
    @include('entrust-gui::users.partials.form')
    <button type="submit" id="create" class="btn btn-labeled btn-primary">{{ trans('entrust-gui::button.create') }}</button>
    {{ trans('entrust-gui::button.cancel') }}
</form>
@endsection


text:
<TITLE>Review for Bounce (2000)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Bounce (2000)

reviewed by
Scott Renshaw

BOUNCE
(Miramax)
Starring:  Ben Affleck, Gwyneth Paltrow, Joe Morton, Tony Goldwyn, Natasha
Henstridge, Johnny Galecki, Alex D. Linz.
Screenplay:  Don Roos.
Producers:  Steve Golin and Michael Besman.
Director:  Don Roos.
MPAA Rating:  PG-13 (profanity, adult themes)
Running Time:  105 minutes.
Reviewed by Scott Renshaw.

     This just in: The sincere romantic drama is not extinct. Make no
mistake, it's on the endangered species list; in this oh-so-ironic era,
sincerity sightings have been akin to those blurry shots of the Loch Ness
Monster and hubcap-like flying saucers. You don't expect mainstream movies
to deliver romantic stories that seem grounded in genuine feelings, and
you certainly don't expect it from Don Roos, who wrote and directed the
attitude-laden THE OPPOSITE OF SEX. Nevertheless, here comes BOUNCE
offering that rarest of Y2K big-screen commodities: an adult relationship
with some real emotion.

     It starts out, however, like a typical high-concept trifle. Buddy
Amaral (Ben Affleck), a cocky advertising executive, is on his way back to
L.A. from a business trip to Chicago when he meets Greg Janello (Tony
Goldwyn) in an O'Hare Airport bar. Greg is trying to get home to his
family on a snowy night with plenty of flight delays; Buddy is looking for
an excuse to stay the night with a woman he just met. Doing his version of
a good deed, Buddy hands Greg his boarding pass for his L.A.-bound flight.
Tragically, that flight crashes, leaving Buddy with a serious case of
survivor guilt. After a bout with the bottle, Buddy decides that the
closure he needs involves checking in on Greg's widow Abby (Gwyneth
Paltrow) a year after the crash to make sure she's doing all right.

     Naturally, a relationship grows between Buddy and Abby, complicated
by Buddy's unwillingness to admit to Abby that he was the person
responsible for Greg being on the ill-fated plane. The surprise is that
the relationship never feels like a wacky contrivance. Roos is a smart
writer with a nose for full characterizations, and the story development
as a whole rarely feels manipulated for the convenience of the plot (see
below for notable exception). He steps back as a director from some of the
most potentially exploitative moments, and injects his sharp wit in places
where it works organically (particularly in the person of Johnny Galecki
as Buddy's assistant). Though it's a romance with some humor, it never
ignores the basic sadness in both Buddy and Abby's lives that gives
resonance to their connection. Though it's a romance with tragic elements,
it never wallows in the tragedy so much that it turns into melodrama.

     BOUNCE could have been a true gem of a film if the leads had been
more evenly matched as actors. Gwyneth Paltrow is one of those performers
who appears doomed to be scorned and underappreciated for her talent as
long as she is still young and attractive, but let's get this straight:
She's a damned good actress. In BOUNCE, she's once again wonderful,
capturing Abby's strength and vulnerability. Affleck, on the other hand,
still has some growing to do as an actor. He's not a bad actor, but he
still carries himself on screen primarily with a swagger, even when he's
supposed to be emotionally wounded. Buddy the charming cad is a role
Affleck can make appealing in his sleep. Buddy the tormented alcoholic,
huddled in a shower with a drink in his hand, is too heavy a character for
Affleck to clean-and-jerk.

     Roos takes an unfortunately large mis-step during BOUNCE's third act,
when he introduces a sub-plot involving a court battle. Not only does it
once again place Affleck in the unfortunate position of getting all
mega-serious on us, it's also the only time BOUNCE starts to feel like
something that could only happen in a movie. There's nothing inherently
wrong with romantic dramas that take on that AN AFFAIR TO REMEMBER-style
sense of heightened tragedy. It's just so unusual when a film gives you
the opportunity to explore romantic complications more simply. BOUNCE
makes it's share of mistakes, but it's always clear that its heart is in
the right place. How refreshing to spend time with a film willing to show
you its heart at all.

     On the Renshaw scale of 0 to 10 soulful survivors:  7.

                   Visit Scott Renshaw's Screening Room
                    http://www.inconnect.com/~renshaw/
                                   ***
             Subscribe to receive new reviews directly by email!
 See the Screening Room for details, or reply to this message with subject
                               "Subscribe".

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
<?php

namespace app\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\CategoryLinks;

/**
 * CategoryLinksSearch represents the model behind the search form about `app\models\CategoryLinks`.
 */
class CategoryLinksSearch extends CategoryLinks
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'category_id', 'product_id'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = CategoryLinks::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'category_id' => $this->category_id,
            'product_id' => $this->product_id,
        ]);

        return $dataProvider;
    }
}


text:
<?php

namespace Neton\FrameworkBundle\Controller;

use Neton\DirectBundle\Annotation\Form;
use Neton\DirectBundle\Annotation\Remote;

use Neton\FrameworkBundle\Entity\Bundle;
use Neton\FrameworkBundle\Helper\BundleHelper;

class BundleController extends SessionController
{
    /**
     * Retorna os bundles cadastrados no sistema.
     *
     * @remote
     * @param Array $params
     * @return Array
     */
    public function listAction($params)
    {
        $em = $this->getDoctrine()->getManager();

        $list = $em->getRepository('NetonFrameworkBundle:Bundle')->getList($params);

        return $this->createStoreResult($list['results'], $list['total']);
    }

    /**
     * Reordena os bundles da aplicação.
     *
     * @remote
     * @param array $params
     */
    public function reorderAction($params)
    {
        $em = $this->getDoctrine()->getManager();

        foreach ($params as $item){
            $bundle = $em->getRepository('NetonFrameworkBundle:Bundle')->find($item['id']);
            $bundle->setOrderIndex($item['order']);
        }

        $em->flush();

        return true;
    }

    /**
     * Habilita/Desabilita os bundles da aplicação.
     *
     * @remote
     * @param array $params
     */
    public function setEnabledAction($params)
    {
        $em = $this->getDoctrine()->getManager();

        foreach ($params['ids'] as $id){
            $bundle = $em->getRepository('NetonFrameworkBundle:Bundle')->find($id);

            if ($bundle->getName() != 'frameworkbundle')
                $bundle->setEnabled($params['enabled']);
        }

        $em->flush();

        return true;
    }

    /**
     * Salva o registro de um bundle.
     *
     * @remote
     * @param array $params
     */
    public function saveAction($params)
    {
        $em = $this->getDoctrine()->getManager();

        if ($params['id'] != 0){
            $bundle = $em->getRepository('NetonFrameworkBundle:Bundle')->find($params['id']);
        } else {
            $bundle = new Bundle();
        }

        if ($params['isDefault'] == '1'){
            $this->resetDefault();
        }

        // seta os campos da tabela
        $bundle->setTitle($params['title']);
        $bundle->setName($params['name']);
        $bundle->setEnabled($params['enabled']);
        $bundle->setIconCls($params['iconCls']);
        $bundle->setIsDefault($params['isDefault']);
        $bundle->setOrderIndex($params['orderIndex']);

        $em->persist($bundle);
        $em->flush();

        $this->buildBundle($params['name'], $params['title']);

        return true;
    }

    /**
     * Remove os registros de bundles.
     *
     * @remote
     * @param array $params
     */
    public function removeAction($params)
    {
        $em = $this->getDoctrine()->getManager();
        $bundles = array();

        foreach ($params['bundles'] as $id){
            $bundle = $em->getRepository('NetonFrameworkBundle:Bundle')->find($id);
            $bundles[] = $bundle->getName();

            $em->remove($bundle);
        }

        try{
            $em->flush();

            foreach ($bundles as $bundle){
                $this->destroyBundle($bundle);
            }

        }catch(\Exception $e){
            //echo $e->getMessage();
            return false;
        }

        return true;
    }

    /**
     * Constrói os arquivos e registros do bundle na UI.
     *
     * @param string $bundleName
     * @param string $title
     */
    private function buildBundle($bundleName, $title)
    {
        // cria o helper de bundles
        $helper = new BundleHelper($this->get('kernel'), $bundleName, $title);

        // se os arquivos do bundle não existirem
        if (!$helper->bundleExists()){
            $helper->build();
        }
    }

    /**
     * Destrói as referências do bundle arquivos e entradas.
     *
     * @param string $bundleName
     */
    private function destroyBundle($bundleName)
    {
        // cria o helper de bundles
        $helper = new BundleHelper($this->get('kernel'), $bundleName);

        $helper->destroy();
    }

    /**
     * Reseta o estado da opção default dos bundles.
     */
    private function resetDefault()
    {
        $em = $this->getDoctrine()->getManager();

        $bundles = $em->getRepository('NetonFrameworkBundle:Bundle')->findAll();

        foreach ($bundles as $bundle){
            $bundle->setIsDefault('0');
        }
    }

}


text:
//#define LOG_NDEBUG 0

#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <system/audio.h>
#include <audio_utils/resampler.h>
#include <speex/speex_resampler.h>

#include "hal-log.h"

struct resampler {
    struct resampler_itfe itfe;
    SpeexResamplerState *speex_resampler;       // handle on speex resampler
    struct resampler_buffer_provider *provider; // buffer provider installed by client
    uint32_t in_sample_rate;                    // input sampling rate in Hz
    uint32_t out_sample_rate;                   // output sampling rate in Hz
    uint32_t channel_count;                     // number of channels (interleaved)
    int16_t *in_buf;                            // input buffer
    size_t in_buf_size;                         // input buffer size
    size_t frames_in;                           // number of frames in input buffer
    size_t frames_rq;                           // cached number of output frames
    size_t frames_needed;                       // minimum number of input frames to produce
                                                // frames_rq output frames
    int32_t speex_delay_ns;                     // delay introduced by speex resampler in ns
};

//------------------------------------------------------------------------------
// speex based resampler
//------------------------------------------------------------------------------

static void resampler_reset(struct resampler_itfe *resampler)
{
    struct resampler *rsmp = (struct resampler *)resampler;

    rsmp->frames_in = 0;
    rsmp->frames_rq = 0;

    if (rsmp != NULL && rsmp->speex_resampler != NULL) {
        speex_resampler_reset_mem(rsmp->speex_resampler);
    }
}

static int32_t resampler_delay_ns(struct resampler_itfe *resampler)
{
    struct resampler *rsmp = (struct resampler *)resampler;

    int32_t delay = (int32_t)((1000000000 * (int64_t)rsmp->frames_in) / rsmp->in_sample_rate);
    delay += rsmp->speex_delay_ns;

    return delay;
}

// outputs a number of frames less or equal to *outFrameCount and updates *outFrameCount
// with the actual number of frames produced.
static int resampler_resample_from_provider(struct resampler_itfe *resampler,
                       int16_t *out,
                       size_t *outFrameCount)
{
    struct resampler *rsmp = (struct resampler *)resampler;
    size_t framesRq;
    size_t framesWr;
    size_t inFrames;

    if (rsmp == NULL || out == NULL || outFrameCount == NULL) {
        return -EINVAL;
    }
    if (rsmp->provider == NULL) {
        *outFrameCount = 0;
        return -ENOSYS;
    }

    framesRq = *outFrameCount;
    // update and cache the number of frames needed at the input sampling rate to produce
    // the number of frames requested at the output sampling rate
    if (framesRq != rsmp->frames_rq) {
        rsmp->frames_needed = (framesRq * rsmp->in_sample_rate) / rsmp->out_sample_rate + 1;
        rsmp->frames_rq = framesRq;
    }

    framesWr = 0;
    inFrames = 0;
    while (framesWr < framesRq) {
        size_t outFrames;
        if (rsmp->frames_in < rsmp->frames_needed) {
            struct resampler_buffer buf;
            // make sure that the number of frames present in rsmp->in_buf (rsmp->frames_in) is at
            // least the number of frames needed to produce the number of frames requested at
            // the output sampling rate
            if (rsmp->in_buf_size < rsmp->frames_needed) {
                rsmp->in_buf_size = rsmp->frames_needed;
                rsmp->in_buf = (int16_t *)realloc(rsmp->in_buf,
                                        rsmp->in_buf_size * rsmp->channel_count * sizeof(int16_t));
            }
            buf.frame_count = rsmp->frames_needed - rsmp->frames_in;
            rsmp->provider->get_next_buffer(rsmp->provider, &buf);
            if (buf.raw == NULL) {
                break;
            }
            memcpy(rsmp->in_buf + rsmp->frames_in * rsmp->channel_count,
                    buf.raw,
                    buf.frame_count * rsmp->channel_count * sizeof(int16_t));
            rsmp->frames_in += buf.frame_count;
            rsmp->provider->release_buffer(rsmp->provider, &buf);
        }

        outFrames = framesRq - framesWr;
        inFrames = rsmp->frames_in;
        if (rsmp->channel_count == 1) {
            speex_resampler_process_int(rsmp->speex_resampler,
                                        0,
                                        rsmp->in_buf,
                                        (void *) &inFrames,
                                        out + framesWr,
                                        (void *) &outFrames);
        } else {
            speex_resampler_process_interleaved_int(rsmp->speex_resampler,
                                        rsmp->in_buf,
                                        (void *) &inFrames,
                                        out + framesWr * rsmp->channel_count,
                                        (void *) &outFrames);
        }
        framesWr += outFrames;
        rsmp->frames_in -= inFrames;

        if ((framesWr != framesRq) && (rsmp->frames_in != 0))
            warn("ReSampler::resample() remaining %zd frames in and %zd out",
                rsmp->frames_in, (framesRq - framesWr));
    }
    if (rsmp->frames_in) {
        memmove(rsmp->in_buf,
                rsmp->in_buf + inFrames * rsmp->channel_count,
                rsmp->frames_in * rsmp->channel_count * sizeof(int16_t));
    }
    *outFrameCount = framesWr;

    return 0;
}

static int resampler_resample_from_input(struct resampler_itfe *resampler,
                                  int16_t *in,
                                  size_t *inFrameCount,
                                  int16_t *out,
                                  size_t *outFrameCount)
{
    struct resampler *rsmp = (struct resampler *)resampler;

    if (rsmp == NULL || in == NULL || inFrameCount == NULL ||
            out == NULL || outFrameCount == NULL) {
        return -EINVAL;
    }
    if (rsmp->provider != NULL) {
        *outFrameCount = 0;
        return -ENOSYS;
    }

    if (rsmp->channel_count == 1) {
        speex_resampler_process_int(rsmp->speex_resampler,
                                    0,
                                    in,
                                    (void *) inFrameCount,
                                    out,
                                    (void *) outFrameCount);
    } else {
        speex_resampler_process_interleaved_int(rsmp->speex_resampler,
                                                in,
                                                (void *) inFrameCount,
                                                out,
                                                (void *) outFrameCount);
    }

    DBG("resampler_resample_from_input() DONE in %zd out %zd", *inFrameCount, *outFrameCount);

    return 0;
}

int create_resampler(uint32_t inSampleRate,
                    uint32_t outSampleRate,
                    uint32_t channelCount,
                    uint32_t quality,
                    struct resampler_buffer_provider* provider,
                    struct resampler_itfe **resampler)
{
    int error;
    struct resampler *rsmp;
    int frames;

    DBG("create_resampler() In SR %d Out SR %d channels %d",
         inSampleRate, outSampleRate, channelCount);

    if (resampler == NULL) {
        return -EINVAL;
    }

    *resampler = NULL;

    if (quality <= RESAMPLER_QUALITY_MIN || quality >= RESAMPLER_QUALITY_MAX) {
        return -EINVAL;
    }

    rsmp = (struct resampler *)calloc(1, sizeof(struct resampler));

    rsmp->speex_resampler = speex_resampler_init(channelCount,
                                      inSampleRate,
                                      outSampleRate,
                                      quality,
                                      &error);
    if (rsmp->speex_resampler == NULL) {
        error("ReSampler: Cannot create speex resampler: %s", speex_resampler_strerror(error));
        free(rsmp);
        return -ENODEV;
    }

    rsmp->itfe.reset = resampler_reset;
    rsmp->itfe.resample_from_provider = resampler_resample_from_provider;
    rsmp->itfe.resample_from_input = resampler_resample_from_input;
    rsmp->itfe.delay_ns = resampler_delay_ns;

    rsmp->provider = provider;
    rsmp->in_sample_rate = inSampleRate;
    rsmp->out_sample_rate = outSampleRate;
    rsmp->channel_count = channelCount;
    rsmp->in_buf = NULL;
    rsmp->in_buf_size = 0;

    resampler_reset(&rsmp->itfe);

    frames = speex_resampler_get_input_latency(rsmp->speex_resampler);
    rsmp->speex_delay_ns = (int32_t)((1000000000 * (int64_t)frames) / rsmp->in_sample_rate);
    frames = speex_resampler_get_output_latency(rsmp->speex_resampler);
    rsmp->speex_delay_ns += (int32_t)((1000000000 * (int64_t)frames) / rsmp->out_sample_rate);

    *resampler = &rsmp->itfe;
    DBG("create_resampler() DONE rsmp %p &rsmp->itfe %p speex %p",
         rsmp, &rsmp->itfe, rsmp->speex_resampler);
    return 0;
}

void release_resampler(struct resampler_itfe *resampler)
{
    struct resampler *rsmp = (struct resampler *)resampler;

    if (rsmp == NULL) {
        return;
    }

    free(rsmp->in_buf);

    if (rsmp->speex_resampler != NULL) {
        speex_resampler_destroy(rsmp->speex_resampler);
    }
    free(rsmp);
}