text:
.class public Lcom/android/internal/content/PackageHelper;
.super Ljava/lang/Object;
.source "PackageHelper.java"

# static fields
.field public static final APP_INSTALL_AUTO:I = 0x0

.field public static final APP_INSTALL_EXTERNAL:I = 0x2

.field public static final APP_INSTALL_INTERNAL:I = 0x1

.field public static final RECOMMEND_FAILED_ALREADY_EXISTS:I = -0x4

.field public static final RECOMMEND_FAILED_INSUFFICIENT_STORAGE:I = -0x1

.field public static final RECOMMEND_FAILED_INVALID_APK:I = -0x2

.field public static final RECOMMEND_FAILED_INVALID_LOCATION:I = -0x3

.field public static final RECOMMEND_FAILED_INVALID_URI:I = -0x6

.field public static final RECOMMEND_FAILED_VERSION_DOWNGRADE:I = -0x7

.field public static final RECOMMEND_INSTALL_EXTERNAL:I = 0x2

.field public static final RECOMMEND_INSTALL_INTERNAL:I = 0x1

.field public static final RECOMMEND_MEDIA_UNAVAILABLE:I = -0x5

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

.field private static final localLOGV:Z

# direct methods
.method public constructor <init>()V
    .locals 0

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

    return-void
.end method

.method public static calculateInstalledSize(Landroid/content/pm/PackageParser$PackageLite;Lcom/android/internal/content/NativeLibraryHelper$Handle;ZLjava/lang/String;)J
    .locals 8
    .param p0, "pkg"    # Landroid/content/pm/PackageParser$PackageLite;
    .param p1, "handle"    # Lcom/android/internal/content/NativeLibraryHelper$Handle;
    .param p2, "isForwardLocked"    # Z
    .param p3, "abiOverride"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 471
    const-wide/16 v4, 0x0

    .line 474
    .local v4, "sizeBytes":J
    invoke-virtual {p0}, Landroid/content/pm/PackageParser$PackageLite;->getAllCodePaths()Ljava/util/List;

    move-result-object v3

    invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v2

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

    move-result v3

    if-eqz v3, :cond_1

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

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    .line 475
    .local v1, "codePath":Ljava/lang/String;
    new-instance v0, Ljava/io/File;

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

    .line 476
    .local v0, "codeFile":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->length()J

    move-result-wide v6

    add-long/2addr v4, v6

    .line 478
    if-eqz p2, :cond_0

    .line 479
    const/4 v3, 0x0

    invoke-static {v0, v3}, Lcom/android/internal/content/PackageHelper;->extractPublicFiles(Ljava/io/File;Ljava/io/File;)J

    move-result-wide v6

    add-long/2addr v4, v6

    goto :goto_0

    .line 484
    .end local v0    # "codeFile":Ljava/io/File;
    .end local v1    # "codePath":Ljava/lang/String;
    :cond_1
    invoke-static {p1, p3}, Lcom/android/internal/content/NativeLibraryHelper;->sumNativeBinariesWithOverride(Lcom/android/internal/content/NativeLibraryHelper$Handle;Ljava/lang/String;)J

    move-result-wide v6

    add-long/2addr v4, v6

    .line 486
    return-wide v4
.end method

.method public static calculateInstalledSize(Landroid/content/pm/PackageParser$PackageLite;ZLjava/lang/String;)J
    .locals 4
    .param p0, "pkg"    # Landroid/content/pm/PackageParser$PackageLite;
    .param p1, "isForwardLocked"    # Z
    .param p2, "abiOverride"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

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

    .line 462
    .local v0, "handle":Lcom/android/internal/content/NativeLibraryHelper$Handle;
    :try_start_0
    invoke-static {p0}, Lcom/android/internal/content/NativeLibraryHelper$Handle;->create(Landroid/content/pm/PackageParser$PackageLite;)Lcom/android/internal/content/NativeLibraryHelper$Handle;

    move-result-object v0

    .line 463
    invoke-static {p0, v0, p1, p2}, Lcom/android/internal/content/PackageHelper;->calculateInstalledSize(Landroid/content/pm/PackageParser$PackageLite;Lcom/android/internal/content/NativeLibraryHelper$Handle;ZLjava/lang/String;)J
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-wide v2

    .line 465
    invoke-static {v0}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    return-wide v2

    :catchall_0
    move-exception v1

    invoke-static {v0}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    throw v1
.end method

.method private static copyZipEntry(Ljava/util/zip/ZipEntry;Ljava/util/zip/ZipFile;Ljava/util/zip/ZipOutputStream;)V
    .locals 5
    .param p0, "zipEntry"    # Ljava/util/zip/ZipEntry;
    .param p1, "inZipFile"    # Ljava/util/zip/ZipFile;
    .param p2, "outZipStream"    # Ljava/util/zip/ZipOutputStream;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 298
    const/16 v4, 0x1000

    new-array v0, v4, [B

    .line 302
    .local v0, "buffer":[B
    invoke-virtual {p0}, Ljava/util/zip/ZipEntry;->getMethod()I

    move-result v4

    if-nez v4, :cond_0

    .line 304
    new-instance v2, Ljava/util/zip/ZipEntry;

    invoke-direct {v2, p0}, Ljava/util/zip/ZipEntry;-><init>(Ljava/util/zip/ZipEntry;)V

    .line 309
    .local v2, "newEntry":Ljava/util/zip/ZipEntry;
    :goto_0
    invoke-virtual {p2, v2}, Ljava/util/zip/ZipOutputStream;->putNextEntry(Ljava/util/zip/ZipEntry;)V

    .line 311
    invoke-virtual {p1, p0}, Ljava/util/zip/ZipFile;->getInputStream(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;

    move-result-object v1

    .line 313
    .local v1, "data":Ljava/io/InputStream;
    :goto_1
    :try_start_0
    invoke-virtual {v1, v0}, Ljava/io/InputStream;->read([B)I

    move-result v3

    .local v3, "num":I
    if-lez v3, :cond_1

    .line 314
    const/4 v4, 0x0

    invoke-virtual {p2, v0, v4, v3}, Ljava/util/zip/ZipOutputStream;->write([BII)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_1

    .line 318
    .end local v3    # "num":I
    :catchall_0
    move-exception v4

    invoke-static {v1}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    throw v4

    .line 307
    .end local v1    # "data":Ljava/io/InputStream;
    .end local v2    # "newEntry":Ljava/util/zip/ZipEntry;
    :cond_0
    new-instance v2, Ljava/util/zip/ZipEntry;

    invoke-virtual {p0}, Ljava/util/zip/ZipEntry;->getName()Ljava/lang/String;

    move-result-object v4

    invoke-direct {v2, v4}, Ljava/util/zip/ZipEntry;-><init>(Ljava/lang/String;)V

    .restart local v2    # "newEntry":Ljava/util/zip/ZipEntry;
    goto :goto_0

    .line 316
    .restart local v1    # "data":Ljava/io/InputStream;
    .restart local v3    # "num":I
    :cond_1
    :try_start_1
    invoke-virtual {p2}, Ljava/util/zip/ZipOutputStream;->flush()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 318
    invoke-static {v1}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    .line 320
    return-void
.end method

.method public static createSdDir(JLjava/lang/String;Ljava/lang/String;IZ)Ljava/lang/String;
    .locals 12
    .param p0, "sizeBytes"    # J
    .param p2, "cid"    # Ljava/lang/String;
    .param p3, "sdEncKey"    # Ljava/lang/String;
    .param p4, "uid"    # I
    .param p5, "isExternal"    # Z

    .prologue
    .line 86
    const-wide/32 v4, 0x100000

    add-long/2addr v4, p0

    const-wide/32 v10, 0x100000

    div-long/2addr v4, v10

    long-to-int v1, v4

    add-int/lit8 v2, v1, 0x1

    .line 88
    .local v2, "sizeMb":I
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v0

    .line 93
    .local v0, "mountService":Landroid/os/storage/IMountService;
    const-string v3, "ext4"

    move-object v1, p2

    move-object v4, p3

    move/from16 v5, p4

    move/from16 v6, p5

    invoke-interface/range {v0 .. v6}, Landroid/os/storage/IMountService;->createSecureContainer(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;IZ)I

    move-result v9

    .line 95
    .local v9, "rc":I
    if-eqz v9, :cond_0

    .line 96
    const-string v1, "PackageHelper"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Failed to create secure container "

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

    move-result-object v3

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

    move-result-object v3

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

    move-result-object v3

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

    .line 97
    const/4 v7, 0x0

    .line 106
    .end local v0    # "mountService":Landroid/os/storage/IMountService;
    .end local v9    # "rc":I
    :goto_0
    return-object v7

    .line 99
    .restart local v0    # "mountService":Landroid/os/storage/IMountService;
    .restart local v9    # "rc":I
    :cond_0
    invoke-interface {v0, p2}, Landroid/os/storage/IMountService;->getSecureContainerPath(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v7

    .line 102
    .local v7, "cachePath":Ljava/lang/String;
    goto :goto_0

    .line 103
    .end local v0    # "mountService":Landroid/os/storage/IMountService;
    .end local v7    # "cachePath":Ljava/lang/String;
    .end local v9    # "rc":I
    :catch_0
    move-exception v8

    .line 104
    .local v8, "e":Landroid/os/RemoteException;
    const-string v1, "PackageHelper"

    const-string v3, "MountService running?"

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

    .line 106
    const/4 v7, 0x0

    goto :goto_0
.end method

.method public static destroySdDir(Ljava/lang/String;)Z
    .locals 6
    .param p0, "cid"    # Ljava/lang/String;

    .prologue
    const/4 v3, 0x1

    const/4 v2, 0x0

    .line 211
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v4

    const/4 v5, 0x1

    invoke-interface {v4, p0, v5}, Landroid/os/storage/IMountService;->destroySecureContainer(Ljava/lang/String;Z)I

    move-result v1

    .line 212
    .local v1, "rc":I
    if-eqz v1, :cond_0

    .line 213
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to destroy container "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 221
    .end local v1    # "rc":I
    :goto_0
    return v2

    .restart local v1    # "rc":I
    :cond_0
    move v2, v3

    .line 216
    goto :goto_0

    .line 217
    .end local v1    # "rc":I
    :catch_0
    move-exception v0

    .line 218
    .local v0, "e":Landroid/os/RemoteException;
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to destroy container "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " with exception "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

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

    goto :goto_0
.end method

.method public static extractPublicFiles(Ljava/io/File;Ljava/io/File;)J
    .locals 12
    .param p0, "apkFile"    # Ljava/io/File;
    .param p1, "publicZipFile"    # Ljava/io/File;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 251
    if-nez p1, :cond_2

    .line 252
    const/4 v0, 0x0

    .line 253
    .local v0, "fstr":Ljava/io/FileOutputStream;
    const/4 v3, 0x0

    .line 260
    .local v3, "publicZipOutStream":Ljava/util/zip/ZipOutputStream;
    :goto_0
    const-wide/16 v4, 0x0

    .line 263
    .local v4, "size":J
    :try_start_0
    new-instance v2, Ljava/util/zip/ZipFile;

    invoke-virtual {p0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v8

    invoke-direct {v2, v8}, Ljava/util/zip/ZipFile;-><init>(Ljava/lang/String;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    .line 266
    .local v2, "privateZip":Ljava/util/zip/ZipFile;
    :try_start_1
    invoke-virtual {v2}, Ljava/util/zip/ZipFile;->entries()Ljava/util/Enumeration;

    move-result-object v8

    invoke-static {v8}, Ljava/util/Collections;->list(Ljava/util/Enumeration;)Ljava/util/ArrayList;

    move-result-object v8

    invoke-virtual {v8}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v1

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

    move-result v8

    if-eqz v8, :cond_3

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

    move-result-object v6

    check-cast v6, Ljava/util/zip/ZipEntry;

    .line 267
    .local v6, "zipEntry":Ljava/util/zip/ZipEntry;
    invoke-virtual {v6}, Ljava/util/zip/ZipEntry;->getName()Ljava/lang/String;

    move-result-object v7

    .line 268
    .local v7, "zipEntryName":Ljava/lang/String;
    const-string v8, "AndroidManifest.xml"

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

    move-result v8

    if-nez v8, :cond_1

    const-string/jumbo v8, "resources.arsc"

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

    move-result v8

    if-nez v8, :cond_1

    const-string/jumbo v8, "res/"

    invoke-virtual {v7, v8}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v8

    if-eqz v8, :cond_0

    .line 271
    :cond_1
    invoke-virtual {v6}, Ljava/util/zip/ZipEntry;->getSize()J

    move-result-wide v8

    add-long/2addr v4, v8

    .line 272
    if-eqz p1, :cond_0

    .line 273
    invoke-static {v6, v2, v3}, Lcom/android/internal/content/PackageHelper;->copyZipEntry(Ljava/util/zip/ZipEntry;Ljava/util/zip/ZipFile;Ljava/util/zip/ZipOutputStream;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1

    .line 278
    .end local v1    # "i$":Ljava/util/Iterator;
    .end local v6    # "zipEntry":Ljava/util/zip/ZipEntry;
    .end local v7    # "zipEntryName":Ljava/lang/String;
    :catchall_0
    move-exception v8

    :try_start_2
    invoke-virtual {v2}, Ljava/util/zip/ZipFile;->close()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    :goto_2
    :try_start_3
    throw v8
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 290
    .end local v2    # "privateZip":Ljava/util/zip/ZipFile;
    :catchall_1
    move-exception v8

    invoke-static {v3}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    throw v8

    .line 255
    .end local v0    # "fstr":Ljava/io/FileOutputStream;
    .end local v3    # "publicZipOutStream":Ljava/util/zip/ZipOutputStream;
    .end local v4    # "size":J
    :cond_2
    new-instance v0, Ljava/io/FileOutputStream;

    invoke-direct {v0, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 256
    .restart local v0    # "fstr":Ljava/io/FileOutputStream;
    new-instance v3, Ljava/util/zip/ZipOutputStream;

    invoke-direct {v3, v0}, Ljava/util/zip/ZipOutputStream;-><init>(Ljava/io/OutputStream;)V

    .line 257
    .restart local v3    # "publicZipOutStream":Ljava/util/zip/ZipOutputStream;
    const-string v8, "PackageHelper"

    new-instance v9, Ljava/lang/StringBuilder;

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

    const-string v10, "Extracting "

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

    move-result-object v9

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

    move-result-object v9

    const-string v10, " to "

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

    move-result-object v9

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

    move-result-object v9

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

    move-result-object v9

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

    goto/16 :goto_0

    .line 278
    .restart local v1    # "i$":Ljava/util/Iterator;
    .restart local v2    # "privateZip":Ljava/util/zip/ZipFile;
    .restart local v4    # "size":J
    :cond_3
    :try_start_4
    invoke-virtual {v2}, Ljava/util/zip/ZipFile;->close()V
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 281
    :goto_3
    if-eqz p1, :cond_4

    .line 282
    :try_start_5
    invoke-virtual {v3}, Ljava/util/zip/ZipOutputStream;->finish()V

    .line 283
    invoke-virtual {v3}, Ljava/util/zip/ZipOutputStream;->flush()V

    .line 284
    invoke-static {v0}, Landroid/os/FileUtils;->sync(Ljava/io/FileOutputStream;)Z

    .line 285
    invoke-virtual {v3}, Ljava/util/zip/ZipOutputStream;->close()V

    .line 286
    invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v8

    const/16 v9, 0x1a4

    const/4 v10, -0x1

    const/4 v11, -0x1

    invoke-static {v8, v9, v10, v11}, Landroid/os/FileUtils;->setPermissions(Ljava/lang/String;III)I
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_1

    .line 290
    :cond_4
    invoke-static {v3}, Llibcore/io/IoUtils;->closeQuietly(Ljava/lang/AutoCloseable;)V

    .line 293
    return-wide v4

    .line 278
    :catch_0
    move-exception v8

    goto :goto_3

    .end local v1    # "i$":Ljava/util/Iterator;
    :catch_1
    move-exception v9

    goto :goto_2
.end method

.method public static finalizeSdDir(Ljava/lang/String;)Z
    .locals 6
    .param p0, "cid"    # Ljava/lang/String;

    .prologue
    const/4 v2, 0x0

    .line 195
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v3

    invoke-interface {v3, p0}, Landroid/os/storage/IMountService;->finalizeSecureContainer(Ljava/lang/String;)I

    move-result v1

    .line 196
    .local v1, "rc":I
    if-eqz v1, :cond_0

    .line 197
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to finalize container "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 205
    .end local v1    # "rc":I
    :goto_0
    return v2

    .line 200
    .restart local v1    # "rc":I
    :cond_0
    const/4 v2, 0x1

    goto :goto_0

    .line 201
    .end local v1    # "rc":I
    :catch_0
    move-exception v0

    .line 202
    .local v0, "e":Landroid/os/RemoteException;
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to finalize container "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " with exception "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

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

    goto :goto_0
.end method

.method public static fixSdPermissions(Ljava/lang/String;ILjava/lang/String;)Z
    .locals 6
    .param p0, "cid"    # Ljava/lang/String;
    .param p1, "gid"    # I
    .param p2, "filename"    # Ljava/lang/String;

    .prologue
    const/4 v2, 0x0

    .line 324
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v3

    invoke-interface {v3, p0, p1, p2}, Landroid/os/storage/IMountService;->fixPermissionsSecureContainer(Ljava/lang/String;ILjava/lang/String;)I

    move-result v1

    .line 325
    .local v1, "rc":I
    if-eqz v1, :cond_0

    .line 326
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to fixperms container "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 333
    .end local v1    # "rc":I
    :goto_0
    return v2

    .line 329
    .restart local v1    # "rc":I
    :cond_0
    const/4 v2, 0x1

    goto :goto_0

    .line 330
    .end local v1    # "rc":I
    :catch_0
    move-exception v0

    .line 331
    .local v0, "e":Landroid/os/RemoteException;
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to fixperms container "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " with exception "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

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

    goto :goto_0
.end method

.method public static getMountService()Landroid/os/storage/IMountService;
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 74
    const-string/jumbo v1, "mount"

    invoke-static {v1}, Landroid/os/ServiceManager;->getService(Ljava/lang/String;)Landroid/os/IBinder;

    move-result-object v0

    .line 75
    .local v0, "service":Landroid/os/IBinder;
    if-eqz v0, :cond_0

    .line 76
    invoke-static {v0}, Landroid/os/storage/IMountService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/os/storage/IMountService;

    move-result-object v1

    return-object v1

    .line 78
    :cond_0
    const-string v1, "PackageHelper"

    const-string v2, "Can\'t get mount service"

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

    .line 79
    new-instance v1, Landroid/os/RemoteException;

    const-string v2, "Could not contact mount service"

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

    throw v1
.end method

.method public static getSdDir(Ljava/lang/String;)Ljava/lang/String;
    .locals 4
    .param p0, "cid"    # Ljava/lang/String;

    .prologue
    .line 175
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v1

    invoke-interface {v1, p0}, Landroid/os/storage/IMountService;->getSecureContainerPath(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 180
    :goto_0
    return-object v1

    .line 176
    :catch_0
    move-exception v0

    .line 177
    .local v0, "e":Landroid/os/RemoteException;
    const-string v1, "PackageHelper"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "Failed to get container path for "

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

    move-result-object v2

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

    move-result-object v2

    const-string v3, " with exception "

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

    move-result-object v2

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

    move-result-object v2

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

    move-result-object v2

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

    .line 180
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static getSdFilesystem(Ljava/lang/String;)Ljava/lang/String;
    .locals 4
    .param p0, "cid"    # Ljava/lang/String;

    .prologue
    .line 185
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v1

    invoke-interface {v1, p0}, Landroid/os/storage/IMountService;->getSecureContainerFilesystemPath(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 190
    :goto_0
    return-object v1

    .line 186
    :catch_0
    move-exception v0

    .line 187
    .local v0, "e":Landroid/os/RemoteException;
    const-string v1, "PackageHelper"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "Failed to get container path for "

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

    move-result-object v2

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

    move-result-object v2

    const-string v3, " with exception "

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

    move-result-object v2

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

    move-result-object v2

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

    move-result-object v2

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

    .line 190
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static getSecureContainerList()[Ljava/lang/String;
    .locals 4

    .prologue
    .line 226
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v1

    invoke-interface {v1}, Landroid/os/storage/IMountService;->getSecureContainerList()[Ljava/lang/String;
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 231
    .local v0, "e":Landroid/os/RemoteException;
    :goto_0
    return-object v1

    .line 227
    .end local v0    # "e":Landroid/os/RemoteException;
    :catch_0
    move-exception v0

    .line 228
    .restart local v0    # "e":Landroid/os/RemoteException;
    const-string v1, "PackageHelper"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "Failed to get secure container list with exception"

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

    move-result-object v2

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

    move-result-object v2

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

    move-result-object v2

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

    .line 231
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static isContainerMounted(Ljava/lang/String;)Z
    .locals 4
    .param p0, "cid"    # Ljava/lang/String;

    .prologue
    .line 236
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v1

    invoke-interface {v1, p0}, Landroid/os/storage/IMountService;->isSecureContainerMounted(Ljava/lang/String;)Z
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v1

    .line 240
    :goto_0
    return v1

    .line 237
    :catch_0
    move-exception v0

    .line 238
    .local v0, "e":Landroid/os/RemoteException;
    const-string v1, "PackageHelper"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "Failed to find out if container "

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

    move-result-object v2

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

    move-result-object v2

    const-string v3, " mounted"

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

    move-result-object v2

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

    move-result-object v2

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

    .line 240
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static isSdMounted()Z
    .locals 2

    .prologue
    .line 503
    invoke-static {}, Landroid/os/Environment;->hasRemovableStorageSlot()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 504
    const-string/jumbo v0, "mounted"

    invoke-static {}, Landroid/os/Environment;->getRemovableStorageState()Ljava/lang/String;

    move-result-object v1

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

    move-result v0

    if-eqz v0, :cond_0

    .line 505
    const/4 v0, 0x1

    .line 508
    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public static mountSdDir(Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;
    .locals 1
    .param p0, "cid"    # Ljava/lang/String;
    .param p1, "key"    # Ljava/lang/String;
    .param p2, "ownerUid"    # I

    .prologue
    .line 126
    const/4 v0, 0x1

    invoke-static {p0, p1, p2, v0}, Lcom/android/internal/content/PackageHelper;->mountSdDir(Ljava/lang/String;Ljava/lang/String;IZ)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public static mountSdDir(Ljava/lang/String;Ljava/lang/String;IZ)Ljava/lang/String;
    .locals 6
    .param p0, "cid"    # Ljava/lang/String;
    .param p1, "key"    # Ljava/lang/String;
    .param p2, "ownerUid"    # I
    .param p3, "readOnly"    # Z

    .prologue
    const/4 v2, 0x0

    .line 131
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v3

    invoke-interface {v3, p0, p1, p2, p3}, Landroid/os/storage/IMountService;->mountSecureContainer(Ljava/lang/String;Ljava/lang/String;IZ)I

    move-result v1

    .line 132
    .local v1, "rc":I
    if-eqz v1, :cond_0

    .line 133
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to mount container "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " rc : "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

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

    .line 140
    .end local v1    # "rc":I
    :goto_0
    return-object v2

    .line 136
    .restart local v1    # "rc":I
    :cond_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v3

    invoke-interface {v3, p0}, Landroid/os/storage/IMountService;->getSecureContainerPath(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    goto :goto_0

    .line 137
    .end local v1    # "rc":I
    :catch_0
    move-exception v0

    .line 138
    .local v0, "e":Landroid/os/RemoteException;
    const-string v3, "PackageHelper"

    const-string v4, "MountService running?"

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

    goto :goto_0
.end method

.method public static renameSdDir(Ljava/lang/String;Ljava/lang/String;)Z
    .locals 6
    .param p0, "oldId"    # Ljava/lang/String;
    .param p1, "newId"    # Ljava/lang/String;

    .prologue
    const/4 v2, 0x0

    .line 159
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v3

    invoke-interface {v3, p0, p1}, Landroid/os/storage/IMountService;->renameSecureContainer(Ljava/lang/String;Ljava/lang/String;)I

    move-result v1

    .line 160
    .local v1, "rc":I
    if-eqz v1, :cond_0

    .line 161
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to rename "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " to "

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

    move-result-object v4

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

    move-result-object v4

    const-string/jumbo v5, "with rc "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 170
    .end local v1    # "rc":I
    :goto_0
    return v2

    .line 165
    .restart local v1    # "rc":I
    :cond_0
    const/4 v2, 0x1

    goto :goto_0

    .line 166
    .end local v1    # "rc":I
    :catch_0
    move-exception v0

    .line 167
    .local v0, "e":Landroid/os/RemoteException;
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed ot rename  "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " to "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " with exception : "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

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

    goto :goto_0
.end method

.method public static replaceEnd(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 4
    .param p0, "str"    # Ljava/lang/String;
    .param p1, "before"    # Ljava/lang/String;
    .param p2, "after"    # Ljava/lang/String;

    .prologue
    .line 490
    invoke-virtual {p0, p1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 491
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v2, "Expected "

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

    move-result-object v1

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

    move-result-object v1

    const-string v2, " to end with "

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

    move-result-object v1

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

    move-result-object v1

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

    move-result-object v1

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

    throw v0

    .line 494
    :cond_0
    new-instance v0, Ljava/lang/StringBuilder;

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

    const/4 v1, 0x0

    invoke-virtual {p0}, Ljava/lang/String;->length()I

    move-result v2

    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v3

    sub-int/2addr v2, v3

    invoke-virtual {p0, v1, v2}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v1

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

    move-result-object v0

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

    move-result-object v0

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

    move-result-object v0

    return-object v0
.end method

.method public static resizeSdDir(JLjava/lang/String;Ljava/lang/String;)Z
    .locals 8
    .param p0, "sizeBytes"    # J
    .param p2, "cid"    # Ljava/lang/String;
    .param p3, "sdEncKey"    # Ljava/lang/String;

    .prologue
    const-wide/32 v6, 0x100000

    .line 111
    add-long v4, p0, v6

    div-long/2addr v4, v6

    long-to-int v4, v4

    add-int/lit8 v3, v4, 0x1

    .line 113
    .local v3, "sizeMb":I
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v1

    .line 114
    .local v1, "mountService":Landroid/os/storage/IMountService;
    invoke-interface {v1, p2, v3, p3}, Landroid/os/storage/IMountService;->resizeSecureContainer(Ljava/lang/String;ILjava/lang/String;)I
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v2

    .line 115
    .local v2, "rc":I
    if-nez v2, :cond_0

    .line 116
    const/4 v4, 0x1

    .line 122
    .end local v1    # "mountService":Landroid/os/storage/IMountService;
    .end local v2    # "rc":I
    :goto_0
    return v4

    .line 118
    :catch_0
    move-exception v0

    .line 119
    .local v0, "e":Landroid/os/RemoteException;
    const-string v4, "PackageHelper"

    const-string v5, "MountService running?"

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

    .line 121
    .end local v0    # "e":Landroid/os/RemoteException;
    :cond_0
    const-string v4, "PackageHelper"

    new-instance v5, Ljava/lang/StringBuilder;

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

    const-string v6, "Failed to create secure container "

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

    move-result-object v5

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

    move-result-object v5

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

    move-result-object v5

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

    .line 122
    const/4 v4, 0x0

    goto :goto_0
.end method

.method public static resolveInstallLocation(Landroid/content/Context;Ljava/lang/String;IJI)I
    .locals 17
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "packageName"    # Ljava/lang/String;
    .param p2, "installLocation"    # I
    .param p3, "sizeBytes"    # J
    .param p5, "installFlags"    # I

    .prologue
    .line 342
    const/4 v7, 0x0

    .line 344
    .local v7, "existingInfo":Landroid/content/pm/ApplicationInfo;
    :try_start_0
    invoke-virtual/range {p0 .. p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v13

    const/16 v14, 0x2000

    move-object/from16 v0, p1

    invoke-virtual {v13, v0, v14}, Landroid/content/pm/PackageManager;->getApplicationInfo(Ljava/lang/String;I)Landroid/content/pm/ApplicationInfo;
    :try_end_0
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v7

    .line 351
    :goto_0
    and-int/lit8 v13, p5, 0x10

    if-eqz v13, :cond_4

    .line 352
    const/4 v10, 0x1

    .line 353
    .local v10, "prefer":I
    const/4 v5, 0x0

    .line 380
    .local v5, "checkBoth":Z
    :goto_1
    invoke-static {}, Landroid/os/Environment;->isExternalStorageEmulated()Z

    move-result v6

    .line 381
    .local v6, "emulated":Z
    invoke-static/range {p0 .. p0}, Landroid/os/storage/StorageManager;->from(Landroid/content/Context;)Landroid/os/storage/StorageManager;

    move-result-object v11

    .line 383
    .local v11, "storage":Landroid/os/storage/StorageManager;
    invoke-static {}, Landroid/os/Environment;->hasRemovableStorageSlot()Z

    move-result v4

    .line 384
    .local v4, "bSdSlot":Z
    if-eqz v4, :cond_b

    const-string/jumbo v13, "mounted"

    invoke-static {}, Landroid/os/Environment;->getRemovableStorageState()Ljava/lang/String;

    move-result-object v14

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

    move-result v13

    if-eqz v13, :cond_b

    const/4 v3, 0x1

    .line 385
    .local v3, "bSdMounted":Z
    :goto_2
    if-eqz v6, :cond_c

    if-eqz v3, :cond_c

    const/4 v2, 0x1

    .line 388
    .local v2, "bSdAsExteranl":Z
    :goto_3
    const/4 v9, 0x0

    .line 389
    .local v9, "fitsOnInternal":Z
    if-nez v5, :cond_0

    const/4 v13, 0x1

    if-ne v10, v13, :cond_1

    .line 390
    :cond_0
    invoke-static {}, Landroid/os/Environment;->getDataDirectory()Ljava/io/File;

    move-result-object v12

    .line 391
    .local v12, "target":Ljava/io/File;
    invoke-virtual {v11, v12}, Landroid/os/storage/StorageManager;->getStorageBytesUntilLow(Ljava/io/File;)J

    move-result-wide v14

    cmp-long v13, p3, v14

    if-gtz v13, :cond_d

    const/4 v9, 0x1

    .line 394
    .end local v12    # "target":Ljava/io/File;
    :cond_1
    :goto_4
    const/4 v8, 0x0

    .line 395
    .local v8, "fitsOnExternal":Z
    if-nez v6, :cond_f

    if-nez v5, :cond_2

    const/4 v13, 0x2

    if-ne v10, v13, :cond_f

    .line 396
    :cond_2
    new-instance v13, Landroid/os/Environment$UserEnvironment;

    const/4 v14, 0x0

    invoke-direct {v13, v14}, Landroid/os/Environment$UserEnvironment;-><init>(I)V

    invoke-virtual {v13}, Landroid/os/Environment$UserEnvironment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v12

    .line 399
    .restart local v12    # "target":Ljava/io/File;
    const-wide/16 v14, 0x0

    cmp-long v13, p3, v14

    if-lez v13, :cond_3

    .line 400
    invoke-virtual {v11, v12}, Landroid/os/storage/StorageManager;->getStorageBytesUntilLow(Ljava/io/File;)J

    move-result-wide v14

    cmp-long v13, p3, v14

    if-gtz v13, :cond_e

    const/4 v8, 0x1

    .line 410
    .end local v12    # "target":Ljava/io/File;
    :cond_3
    :goto_5
    const/4 v13, 0x1

    if-ne v10, v13, :cond_12

    .line 411
    if-eqz v9, :cond_14

    .line 412
    const/4 v13, 0x1

    .line 454
    :goto_6
    return v13

    .line 354
    .end local v2    # "bSdAsExteranl":Z
    .end local v3    # "bSdMounted":Z
    .end local v4    # "bSdSlot":Z
    .end local v5    # "checkBoth":Z
    .end local v6    # "emulated":Z
    .end local v8    # "fitsOnExternal":Z
    .end local v9    # "fitsOnInternal":Z
    .end local v10    # "prefer":I
    .end local v11    # "storage":Landroid/os/storage/StorageManager;
    :cond_4
    and-int/lit8 v13, p5, 0x8

    if-eqz v13, :cond_5

    .line 355
    const/4 v10, 0x2

    .line 356
    .restart local v10    # "prefer":I
    const/4 v5, 0x0

    .restart local v5    # "checkBoth":Z
    goto :goto_1

    .line 357
    .end local v5    # "checkBoth":Z
    .end local v10    # "prefer":I
    :cond_5
    const/4 v13, 0x1

    move/from16 v0, p2

    if-ne v0, v13, :cond_6

    .line 358
    const/4 v10, 0x1

    .line 359
    .restart local v10    # "prefer":I
    const/4 v5, 0x0

    .restart local v5    # "checkBoth":Z
    goto :goto_1

    .line 360
    .end local v5    # "checkBoth":Z
    .end local v10    # "prefer":I
    :cond_6
    const/4 v13, 0x2

    move/from16 v0, p2

    if-ne v0, v13, :cond_7

    .line 361
    const/4 v10, 0x2

    .line 362
    .restart local v10    # "prefer":I
    const/4 v5, 0x1

    .restart local v5    # "checkBoth":Z
    goto :goto_1

    .line 363
    .end local v5    # "checkBoth":Z
    .end local v10    # "prefer":I
    :cond_7
    if-nez p2, :cond_a

    .line 365
    if-eqz v7, :cond_9

    .line 366
    iget v13, v7, Landroid/content/pm/ApplicationInfo;->flags:I

    const/high16 v14, 0x40000

    and-int/2addr v13, v14

    if-eqz v13, :cond_8

    .line 367
    const/4 v10, 0x2

    .line 374
    .restart local v10    # "prefer":I
    :goto_7
    const/4 v5, 0x1

    .restart local v5    # "checkBoth":Z
    goto :goto_1

    .line 369
    .end local v5    # "checkBoth":Z
    .end local v10    # "prefer":I
    :cond_8
    const/4 v10, 0x1

    .restart local v10    # "prefer":I
    goto :goto_7

    .line 372
    .end local v10    # "prefer":I
    :cond_9
    const/4 v10, 0x1

    .restart local v10    # "prefer":I
    goto :goto_7

    .line 376
    .end local v10    # "prefer":I
    :cond_a
    const/4 v10, 0x1

    .line 377
    .restart local v10    # "prefer":I
    const/4 v5, 0x0

    .restart local v5    # "checkBoth":Z
    goto/16 :goto_1

    .line 384
    .restart local v4    # "bSdSlot":Z
    .restart local v6    # "emulated":Z
    .restart local v11    # "storage":Landroid/os/storage/StorageManager;
    :cond_b
    const/4 v3, 0x0

    goto :goto_2

    .line 385
    .restart local v3    # "bSdMounted":Z
    :cond_c
    const/4 v2, 0x0

    goto :goto_3

    .line 391
    .restart local v2    # "bSdAsExteranl":Z
    .restart local v9    # "fitsOnInternal":Z
    .restart local v12    # "target":Ljava/io/File;
    :cond_d
    const/4 v9, 0x0

    goto :goto_4

    .line 400
    .restart local v8    # "fitsOnExternal":Z
    :cond_e
    const/4 v8, 0x0

    goto :goto_5

    .line 404
    .end local v12    # "target":Ljava/io/File;
    :cond_f
    if-eqz v2, :cond_3

    if-nez v5, :cond_10

    const/4 v13, 0x2

    if-ne v10, v13, :cond_3

    .line 405
    :cond_10
    invoke-static {}, Landroid/os/Environment;->getRemovableStorageDirectory()Ljava/io/File;

    move-result-object v12

    .line 406
    .restart local v12    # "target":Ljava/io/File;
    invoke-virtual {v11, v12}, Landroid/os/storage/StorageManager;->getStorageBytesUntilLow(Ljava/io/File;)J

    move-result-wide v14

    cmp-long v13, p3, v14

    if-gtz v13, :cond_11

    const/4 v8, 0x1

    :goto_8
    goto :goto_5

    :cond_11
    const/4 v8, 0x0

    goto :goto_8

    .line 414
    .end local v12    # "target":Ljava/io/File;
    :cond_12
    if-nez v6, :cond_13

    const/4 v13, 0x2

    if-ne v10, v13, :cond_13

    .line 415
    if-eqz v8, :cond_14

    .line 416
    const/4 v13, 0x2

    goto :goto_6

    .line 420
    :cond_13
    if-eqz v2, :cond_14

    const/4 v13, 0x2

    if-ne v10, v13, :cond_14

    .line 421
    if-eqz v8, :cond_14

    .line 422
    const/4 v13, 0x2

    goto :goto_6

    .line 427
    :cond_14
    if-eqz v5, :cond_17

    .line 428
    if-eqz v9, :cond_15

    .line 429
    const/4 v13, 0x1

    goto :goto_6

    .line 430
    :cond_15
    if-nez v6, :cond_16

    if-eqz v8, :cond_16

    .line 431
    const/4 v13, 0x2

    goto :goto_6

    .line 434
    :cond_16
    if-eqz v2, :cond_17

    if-eqz v8, :cond_17

    .line 435
    const/4 v13, 0x2

    goto :goto_6

    .line 445
    :cond_17
    if-nez v6, :cond_19

    if-nez v5, :cond_18

    const/4 v13, 0x2

    if-ne v10, v13, :cond_19

    :cond_18
    const-string/jumbo v13, "mounted"

    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v14

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

    move-result v13

    if-nez v13, :cond_19

    .line 447
    const/4 v13, -0x5

    goto/16 :goto_6

    .line 449
    :cond_19
    if-eqz v6, :cond_1a

    if-eqz v4, :cond_1a

    const/4 v13, 0x2

    if-ne v10, v13, :cond_1a

    if-nez v3, :cond_1a

    .line 451
    const/4 v13, -0x5

    goto/16 :goto_6

    .line 454
    :cond_1a
    const/4 v13, -0x1

    goto/16 :goto_6

    .line 346
    .end local v2    # "bSdAsExteranl":Z
    .end local v3    # "bSdMounted":Z
    .end local v4    # "bSdSlot":Z
    .end local v5    # "checkBoth":Z
    .end local v6    # "emulated":Z
    .end local v8    # "fitsOnExternal":Z
    .end local v9    # "fitsOnInternal":Z
    .end local v10    # "prefer":I
    .end local v11    # "storage":Landroid/os/storage/StorageManager;
    :catch_0
    move-exception v13

    goto/16 :goto_0
.end method

.method public static unMountSdDir(Ljava/lang/String;)Z
    .locals 6
    .param p0, "cid"    # Ljava/lang/String;

    .prologue
    const/4 v3, 0x1

    const/4 v2, 0x0

    .line 145
    :try_start_0
    invoke-static {}, Lcom/android/internal/content/PackageHelper;->getMountService()Landroid/os/storage/IMountService;

    move-result-object v4

    const/4 v5, 0x1

    invoke-interface {v4, p0, v5}, Landroid/os/storage/IMountService;->unmountSecureContainer(Ljava/lang/String;Z)I

    move-result v1

    .line 146
    .local v1, "rc":I
    if-eqz v1, :cond_0

    .line 147
    const-string v3, "PackageHelper"

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Failed to unmount "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, " with rc "

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

    move-result-object v4

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v3, v4}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    .line 154
    .end local v1    # "rc":I
    :goto_0
    return v2

    .restart local v1    # "rc":I
    :cond_0
    move v2, v3

    .line 150
    goto :goto_0

    .line 151
    .end local v1    # "rc":I
    :catch_0
    move-exception v0

    .line 152
    .local v0, "e":Landroid/os/RemoteException;
    const-string v3, "PackageHelper"

    const-string v4, "MountService running?"

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

    goto :goto_0
.end method


text:
author: jeffatwood
comments: true
date: 2008-12-23 09:55:47+00:00
layout: post
redirect_from: /2008/12/vote-fraud-and-you
hero:
slug: vote-fraud-and-you
title: Vote Fraud and You
wordpress_id: 170
tags:
- company
- design
---

As we discovered in the [Stack Overflow podcast with the Reddit guys](http://blog.stackoverflow.com/2008/10/podcast-27/), they have a hidden mechanism for detecting and defeating **revenge voting patterns**. I suppose it's a measure of how naive we are, but this wasn't even on our radar.

Well, now it is.

If you irritate another user, they might be having a bad day and decide to take it out on you by **methodically going through and downvoting every post you've made**. The impact of this is pretty limited on Stack Overflow, as you only get 30 votes per day, and upvotes are +10 while downvotes are only -2 (and -1 to the votee).

(As an aside, if you're regularly pissing off a lot of other users, consider taking part of [our FAQ](http://stackoverflow.com/faq) to heart: be nice! We're all here to learn from and share with each other. This is in no way an excuse for bad behavior, of course, but realize that people tend to respond in kind. When in doubt, always treat people with the same respect and decorum you'd want them to treat you. Even if they don't deserve it.)

Still, it's unacceptable behavior, and I've been getting several reports of this sort of revenge downvoting now, enough that we needed to take action to combat it.

[![Poll Faults](http://www.coxandforkum.com/archives/06.11.07.PollFaults-X.gif)](http://www.coxandforkum.com/archives/000973.html)

I was pleasantly surprised to find that the vast, vast majority of Stack Overflow users do _not_ engage in revenge downvoting. Unfortunately, for those users that do, the pattern was quite clear. As of today, **we have several queries that look for unusual downvote patterns**. If we discover these patterns in a given user's voting history, we view all their downvotes for that user as suspect. They're all silently deleted, and any lost reputation is restored to the unfortunate target of these downvotes.

While working on this code, I also realized that we should be checking for the inverse of this behavior -- unusual _upvote_ patterns. To game the reputation system, unscrupulous users might create alternate user accounts that vote up their main account. Again, this is a bit tougher on Stack Overflow than other sites, because we don't allow any user account to upvote at all until they've earned 15 reputation first. And then of course there's the aforementioned 30 vote per day limit.

I reformulated my queries, and I found that there were **many, many more suspicious upvote patterns** than downvote patterns. More than five times as many! I guess I shouldn't be surprised, since the value of a single +10 upvote is fairly high. In parallel with the downvote validation, we now use several daily heuristics to detect strange user upvoting patterns; if we decide the upvotes are questionable, they will _all_ be removed.

Anyway, if you find that your reputation has changed overnight, it might be because we now check for, and remove, any suspicious upvote or downvote patterns.

I thought about doling out reputation penalties to the users involved, but I figured it's better to err on the side of forgiveness. I want to be clear that the "problem" voters are a very, _very_ small part of the Stack Overflow community. Most people use the voting system the way it was intended. Our policy on this is simple: we'll silently remove any vote fraud we detect. Please don't do it. In the long run, it will be **easier to earn reputation by posting great answers and questions than gaming the system.**

redpajama_set_name: RedPajamaGithub


text:
@interface MSSearchMenuItem : MSMenuItemData

@end


text:
'use strict';

var Bookshelf = require('bookshelf');

module.exports = Bookshelf.initialize(Underscoreboard.config.db);


text:
/**
 *
 */
package de.zalando.platform.awsutilizationmonitor.stats;

/**
 * @author jloeffler
 *
 */
public enum AwsResourceType {
	CloudFront, CloudSearch, CloudWatch, DynamoDB, EC2, ElastiCache, ElasticMapReduce, ElasticTranscoder, Glacier, Kinesis, RDS, Redshift, S3, SimpleDB, SNS, SQS, Unknown
}


text:
<?php

namespace PM\CharacterBundle\Service;

use Doctrine\ORM\EntityManager;
use Symfony\Component\Security\Core\SecurityContext;
use PM\CharacterBundle\Entity\CharacterSkill;
use PM\MonsterBundle\Entity\MonsterSkillInstance;

class skillAction
{
    protected $em;
    protected $security;

    public function __construct(EntityManager $EntityManager, SecurityContext $security_context)
    {
        $this->em = $EntityManager;
        $this->security = $security_context;
    }

    public function deleteSkill($skill)
    {
        /* A supprimer avec une compétence :
         *  -> Skill : Entité competence
         *  -> A voir pour le reste
         */

        $this->em->remove($skill);
        $this->em->flush();
    }

    public function getSkillforCharacters($skill)
    {
        $current_user = $this->security->getUser();

        $repository = $this->em->getRepository('PMCharacterBundle:CharacterUsed');
        $characterUseds = $repository->findAll();

        foreach ($characterUseds as $characterUsed) {
            $characterSkill = new CharacterSkill;
            $characterSkill->setCreateUser($current_user);
            $characterSkill->setCharacterUsed($characterUsed);
            $characterSkill->setSkill($skill);
            $characterSkill->setRanks(0);

            $this->em->persist($characterSkill);
        }

        $this->em->flush();
    }

    public function getSkillforMonsters($skill)
    {
        $current_user = $this->security->getUser();

        $repository = $this->em->getRepository('PMMonsterBundle:Monster');
        $monsters = $repository->findAll();

        foreach ($monsters as $monster) {
            $monsterSkillInstance = new MonsterSkillInstance;
            $monsterSkillInstance->setCreateUser($current_user);
            $monsterSkillInstance->setMonster($monster);
            $monsterSkillInstance->setSkill($skill);
            $monsterSkillInstance->setRanks(0);

            $this->em->persist($monsterSkillInstance);
        }

        $this->em->flush();
    }
}


text:
/*      ... OS include files
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <syslog.h>

/*      ... System include files
*/

/*      ... Library include files
*/

/*      ... Local include files
*/
#include <raddebug.h>

/*      ... global memory declarations
*/

/*      ... global memory referenced
*/

/*      ... static (local) memory declarations
*/

void radDEBUGPrint (int waitForInput, char *format, ...)
{
    va_list     argList;
    char        temp1[256];

    /*  ... print the var arg stuff to the message
    */
    va_start (argList, format);
    vsprintf (temp1, format, argList);
    va_end   (argList);

    if (waitForInput != 0)
    {
        printf ("<ENTER>: %s\n", temp1);
        getchar ();
    }
    else
    {
        printf ("%s\n", temp1);
    }

    return;
}


text:
<?php
/**
 * Migration from Jetpack's Image Widget to WordPress' Core Image Widget.
 *
 * @since 4.9
 *
 * @package Jetpack
 */

/**
 * Migrates all active instances of Jetpack's image widget to Core's media image widget.
 */
function jetpack_migrate_image_widget() {
	// Only trigger the migration from wp-admin
	if ( ! is_admin() ) {
		return;
	}

	// Only migrate if the new widget is available and we haven't yet migrated
	if ( ! class_exists( 'WP_Widget_Media_Image' ) || Jetpack_Options::get_option( 'image_widget_migration' ) ) {
		return;
	}

	$default_data = array(
		'attachment_id' => 0,
		'url' => '',
		'title' => '',
		'size' => 'custom',
		'width' => 0,
		'height' => 0,
		'align' => 'none',
		'caption' => '',
		'alt' => '',
		'link_type' => '',
		'link_url' => '',
		'image_classes' => '',
		'link_classes' => '',
		'link_rel' => '',
		'image_title' => '',
		'link_target_blank' => false,
		'conditions' => null,
	);

	$old_widgets = get_option( 'widget_image', array() );
	$media_image = get_option( 'widget_media_image', array() );
	$sidebars_widgets = wp_get_sidebars_widgets();

	// Persist old and current widgets in backup table.
	jetpack_store_migration_data( 'widget_image', maybe_serialize( $old_widgets ) );
	if ( jetpack_get_migration_data( 'widget_image' ) !== $old_widgets ) {
		return false;
	}

	jetpack_store_migration_data( 'sidebars_widgets', maybe_serialize( $sidebars_widgets ) );
	if ( jetpack_get_migration_data( 'sidebars_widgets' ) !== $sidebars_widgets ) {
		return false;
	}

	// Array to store legacy widget ids in to unregister on success.
	$widgets_to_unregister = array();

	foreach ( $old_widgets as $id => $widget ) {
		if ( is_string( $id ) ) {
			continue;
		}

		// Can be caused by instanciating but not populating a widget in the Customizer.
		if ( empty( $widget ) ) {
			continue;
		}

		// Ensure widget has no keys other than those expected.
		// Not all widgets have conditions, so lets add it in.
		$widget_copy = array_merge( array( 'conditions' => null ), $widget );
		$non_allowed_keys = array_diff_key(
			$widget_copy,
			array(
				'title'             => '',
				'img_url'           => '',
				'alt_text'          => '',
				'img_title'         => '',
				'caption'           => '',
				'align'             => '',
				'img_width'         => '',
				'img_height'        => '',
				'link'              => '',
				'link_target_blank' => '',
				'conditions'        => '',
			)
		);

		if ( count( $non_allowed_keys ) > 0 ) {
			// skipping the widget in question
			continue;
		}

		$media_image[ $id ] = array_merge( $default_data, $widget, array(
			'alt'         => $widget['alt_text'],
			'height'      => $widget['img_height'],
			'image_classes' => ! empty( $widget['align'] ) ? 'align' . $widget['align'] : '',
			'image_title' => $widget['img_title'],
			'link_url'    => $widget['link'],
			'url'         => $widget['img_url'],
			'width'       => $widget['img_width'],
		) );

		// Unsetting old widget fields
		$media_image[ $id ] = array_diff_key( $media_image[ $id ], array(
			'align' => false,
			'alt_text' => false,
			'img_height' => false,
			'img_title' => false,
			'img_url' => false,
			'img_width' => false,
			'link' => false,
		) );

		// Check if the image is in the media library.
		$image_basename = basename( $widget['img_url'] );

		if ( empty( $image_basename ) ) {
			continue;
		}

		$attachment_ids = get_posts( array(
			'fields'      => 'ids',
			'meta_query'  => array(
				array(
					'value'   => basename( $image_basename ),
					'compare' => 'LIKE',
					'key'     => '_wp_attachment_metadata',
				),
			),
			'post_status' => 'inherit',
			'post_type'   => 'attachment',
			'suppress_filters' => false,
		) );

		foreach ( $attachment_ids as $attachment_id ) {
			$image_meta = wp_get_attachment_metadata( $attachment_id );

			// Is it a full size image?
			$image_path_pieces = explode( '/', $image_meta['file'] );
			if ( $image_basename === array_pop( $image_path_pieces ) ) {
				$media_image[ $id ]['attachment_id'] = $attachment_id;

				// Set correct size if dimensions fit.
				if (
					$media_image[ $id ]['width']  == $image_meta['width'] ||
					$media_image[ $id ]['height'] == $image_meta['height']
				) {
					$media_image[ $id ]['size'] = 'full';
				}
				break;
			}

			// Is it a down-sized image?
			foreach ( $image_meta['sizes'] as $size => $image ) {
				if ( false !== array_search( $image_basename, $image ) ) {
					$media_image[ $id ]['attachment_id'] = $attachment_id;

					// Set correct size if dimensions fit.
					if (
						$media_image[ $id ]['width']  == $image['width'] ||
						$media_image[ $id ]['height'] == $image['height']
					) {
						$media_image[ $id ]['size'] = $size;
					}
					break 2;
				}
			}
		}

		if ( ! empty( $widget['link'] ) ) {
			$media_image[ $id ]['link_type'] = $widget['link'] === $widget['img_url'] ? 'file' : 'custom';
		}

		foreach ( $sidebars_widgets as $sidebar => $widgets ) {
			if (
				is_array( $widgets )
				&& false !== ( $key = array_search( "image-{$id}", $widgets, true ) )
			) {
				$sidebars_widgets[ $sidebar ][ $key ] = "media_image-{$id}";
			}
		}

		$widgets_to_unregister[] = $id;
	}

	if ( update_option( 'widget_media_image', $media_image ) ) {
		delete_option( 'widget_image' );

		// Now un-register old widgets and register new.
		foreach ( $widgets_to_unregister as $id ) {
			wp_unregister_sidebar_widget( "image-${id}" );

			// register new widget.
			$media_image_widget = new WP_Widget_Media_Image();
			$media_image_widget->_set( $id );
			$media_image_widget->_register_one( $id );
		}

		wp_set_sidebars_widgets( $sidebars_widgets );

		// We need to refresh on widgets page for changes to take effect.
		add_action( 'current_screen', 'jetpack_refresh_on_widget_page' );
	} else {
		$widget_media_image = get_option( 'widget_media_image' );
		if ( is_array( $widget_media_image ) ) {
			delete_option( 'widget_image' );
		}
	}

	Jetpack_Options::update_option( 'image_widget_migration', true );
}
add_action( 'widgets_init', 'jetpack_migrate_image_widget' );

function jetpack_refresh_on_widget_page( $current ) {
	if ( 'widgets' === $current->base ) {
		wp_safe_redirect( admin_url( 'widgets.php' ) );
		exit;
	}
}


text:
CREATE TABLE IF NOT EXISTS `xxx_db` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `pass` char(32) NOT NULL,
  `ctime` datetime NOT NULL,
  `settings` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_group` (
  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_tables` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `title` varchar(128) NOT NULL,
  `comment` varchar(128) NOT NULL,
  `alias` varchar(24) NOT NULL,
  `idparent` int(10) unsigned NOT NULL,
  `isfolder` tinyint(3) unsigned NOT NULL,
  `istree` tinyint(3) unsigned NOT NULL,
  `help` varchar(128) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idparent` (`idparent`,`isfolder`,`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_users` (
  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `login` varchar(32) NOT NULL,
  `pass` binary(16) NOT NULL,
  `email` varchar(32) NOT NULL,
  `idgroup` smallint(5) unsigned NOT NULL,
  `name` varchar(64) NOT NULL,
  `lang` varchar(10) NOT NULL,
  `uptime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  KEY `login` (`login`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_columns` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `idtable` smallint(5) unsigned NOT NULL,
  `idtype` tinyint(3) unsigned NOT NULL,
  `title` varchar(96) NOT NULL,
  `comment` varchar(128) NOT NULL,
  `sort` smallint(5) unsigned NOT NULL,
  `alias` varchar(24) NOT NULL,
  `visible` tinyint(3) unsigned NOT NULL,
  `align` tinyint(3) unsigned NOT NULL,
  `extend` varchar(250) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idtable` (`idtable`,`sort`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_menu` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(64) NOT NULL,
  `sort` int(11) NOT NULL,
  `url` varchar(128) NOT NULL,
  `hint` varchar(128) NOT NULL,
  `idparent` int(10) unsigned NOT NULL,
  `isfolder` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idparent` (`idparent`,`sort`,`title`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_log` (
  `idtable` smallint(5) unsigned NOT NULL,
  `idrow` int(10) unsigned NOT NULL,
  `iduser` smallint(5) unsigned NOT NULL,
  `uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `action` set('create','edit','delete','') NOT NULL,
  KEY `uptime` (`uptime`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_sets` (
  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `_owner` smallint(5) unsigned NOT NULL,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `idset` smallint(5) unsigned NOT NULL,
  `iditem` tinyint(3) unsigned NOT NULL,
  `title` varchar(48) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idset` (`idset`,`iditem`),
  KEY `idsetname` (`idset`,`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_files` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_owner` smallint(5) unsigned NOT NULL,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `idtable` smallint(5) unsigned NOT NULL,
  `idcol` int(10) unsigned NOT NULL,
  `iditem` int(10) unsigned NOT NULL,
  `folder` tinyint(3) unsigned NOT NULL,
  `filename` varchar(128) NOT NULL,
  `size` int(10) unsigned NOT NULL,
  `comment` text NOT NULL,
  `storage` longblob NOT NULL,
  `w` mediumint(8) unsigned NOT NULL,
  `h` mediumint(8) unsigned NOT NULL,
  `sort` tinyint(3) unsigned NOT NULL,
  `preview` blob NOT NULL,
  `mime` tinyint(4) NOT NULL,
  `ispreview` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idtable` (`idtable`,`idcol`,`iditem`,`sort`),
  KEY `folder` (`idtable`,`folder`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_mimes` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `ext` varchar(64) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_access` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `idgroup` smallint(5) unsigned NOT NULL,
  `idtable` int(10) unsigned NOT NULL,
  `mask` varchar(32) NOT NULL,
  `active` tinyint(3) NOT NULL,
  `read` tinyint(3) unsigned NOT NULL,
  `create` tinyint(3) unsigned NOT NULL,
  `edit` tinyint(3) unsigned NOT NULL,
  `del` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `_uptime` (`_uptime`),
  KEY `idgroup` (`idgroup`,`idtable`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_share` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `idtable` smallint(5) unsigned NOT NULL,
  `idslice` int(10) unsigned NOT NULL,
  `idfile` int(10) unsigned NOT NULL,
  `code` int(10) unsigned NOT NULL,
  `timelimit` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `viewlimit` smallint(6) NOT NULL,
  `firstonly` tinyint(3) unsigned NOT NULL,
  `firstip` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idtable` (`idtable`,`idslice`,`idfile`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_slices` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `idtable` smallint(5) unsigned NOT NULL,
  `params` varchar(255) NOT NULL,
  `title` varchar(64) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `_owner` (`_owner`,`idtable`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_tags` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `title` varchar(64) NOT NULL,
  `color` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_taglist` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `idtable` smallint(5) unsigned NOT NULL,
  `iditem` int(10) unsigned NOT NULL,
  `idtag` smallint(5) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idtable` (`idtable`,`iditem`),
  KEY `idtag` (`idtag`,`idtable`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_onemany` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `idcolumn` smallint(5) unsigned NOT NULL,
  `iditem` int(10) unsigned NOT NULL,
  `idmulti` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idcolumn` (`idcolumn`,`iditem`),
  KEY `idcolumn_2` (`idcolumn`,`idmulti`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
##
CREATE TABLE IF NOT EXISTS `xxx_webpages` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `_uptime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `_owner` smallint(5) unsigned NOT NULL,
  `title` varchar(128) NOT NULL,
  `alias` varchar(64) NOT NULL,
  `content` text NOT NULL,
  `options` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `_uptime` (`_uptime`),
  KEY `alias` (`alias`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


text:
<?xml version="1.0" encoding="UTF-8"?>
<test_definition>
  <suite name="Usecase WebAPI">
    <set name="Multimedia &amp; Graphics" background="brand-success" icon="glyphicon-facetime-video">
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Jsenhance" purpose="Jsenhance">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="MediaSource" purpose="MediaSource">
      </testcase>
    </set>
    <set name="Networking &amp; Storage" background="brand-warning" icon="glyphicon-link">
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="FileSystem" purpose="File System">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="RawSockets" purpose="Raw Sockets">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="WebSocket" purpose="WebSocket">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="SpeechSynthesis" purpose="SpeechSynthesis">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="WebSpeech" purpose="WebSpeech">
      </testcase>
    </set>
    <set name="Security" background="brand-warning3" icon="glyphicon-warning-sign">
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="CSP" purpose="CSP" subcase="9">
      </testcase>
    </set>
    <set name="Tizen Extension APIs" background="brand-primary3" icon="glyphicon-send">
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="DataControl" purpose="DataControl">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Notification" purpose="Notification">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Package" purpose="Package">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="SSO" purpose="SSO">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Telephony" purpose="Telephony">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Time" purpose="Time">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Tizen" purpose="Tizen">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Vehicle" purpose="Vehicle">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Locale" purpose="Locale">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="ApplicationSwitching" purpose="ApplicationSwitching">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="Es6NumericLiterals" purpose="Es6NumericLiterals">
      </testcase>
      <testcase component="Crosswalk Use Cases/WebAPI" execution_type="manual" id="FileApiPersistent" purpose="FileApiPersistent">
      </testcase>
    </set>
  </suite>
</test_definition>


text:
require 'simplecov'

module SimpleCov::Configuration
  def clean_filters
    @filters = []
  end
end

SimpleCov.configure do
  clean_filters
  load_profile 'test_frameworks'
  add_filter "ruby"
end

ENV["COVERAGE"] && SimpleCov.start do
  add_filter "/.rvm/"
end
require 'rubygems'
require 'minitest/unit'
require 'minitest/mock'

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

class MiniTest::Unit::TestCase
end

MiniTest::Unit.autorun


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>app.forms.DeleteEventForm — Eventum 0.1 documentation</title>

  <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>

    <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />

    <link rel="top" title="Eventum 0.1 documentation" href="../../../index.html"/>
        <link rel="up" title="app" href="../../app.html"/>

           Eventum

  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>

Quickstart

Stack

Setup

Developing

Documentation

Testing

Organization / Structure

The Eventum App

Forms

Library Functions

Models

Routes

Module contents

Forms

Form Fields

app.forms.AddToWhitelistForm

app.forms.CreateBlogPostForm

app.forms.CreateEventForm

app.forms.CreateProfileForm

app.forms.DeleteEventForm

app.forms.EditEventForm

app.forms.EditUserForm

app.forms.UploadImageForm

app.forms.validators

Library Functions

app.lib.decorators

app.lib.error

app.lib.events

app.lib.google_calendar

app.lib.google_calendar_resource_builder

app.lib.networking

app.lib.text

Models

Model Fields

app.models.BlogPost

app.models.Event

app.models.EventSeries

app.models.Image

app.models.Post

app.models.User

app.models.Whitelist

Routes

Admin Routes

Submodules

app.routes.base

app.routes.blog

app.routes.client

        Eventum

Docs »

Module code »

app »

app.forms.DeleteEventForm

Source code for app.forms.DeleteEventForm

"""
.. module:: DeleteEventForm
    :synopsis: A form for deleting an event or event series.

.. moduleauthor:: Dan Schlosser <dan@danrs.ch>
"""

from flask.ext.wtf import Form
from wtforms import BooleanField

[docs]class DeleteEventForm(Form):
    """A form for deleting an event.

    :ivar delete_all: :class:`wtforms.fields.BooleanField` - True if the event
        is recurring and all events in the series should be deleted.
    """
    delete_all = BooleanField('Delete All', default=False)

        © Copyright 2014, Dan Schlosser.

  Built with Sphinx using a theme provided by Read the Docs.


text:
layout: page
title: "Emily Brooke Edge"
comments: true
description: "blanks"
keywords: "Emily Brooke Edge,CU,Boulder"
---
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://dl.dropboxusercontent.com/s/pc42nxpaw1ea4o9/highcharts.js?dl=0"></script>
<!-- <script src="../assets/js/highcharts.js"></script> -->
<style type="text/css">@font-face {
	font-family: "Bebas Neue";
	src: url(https://www.filehosting.org/file/details/544349/BebasNeue Regular.otf) format("opentype");
	}
	h1.Bebas {
		font-family: "Bebas Neue", Verdana, Tahoma;
	}
</style>
</head>

#### TEACHING INFORMATION

**College**: School of Journalism

**Classes taught**: JOUR 1001

#### JOUR 1001: Contemporary Media Analysis

**Terms taught**: Spring 2012, Fall 2013, Fall 2014

**Instructor rating**: 5.29

**Standard deviation in instructor rating**: 0.35

**Average grade** (4.0 scale): 3.29

**Standard deviation in grades** (4.0 scale): 0.18

**Average workload** (raw): 2.19

**Standard deviation in workload** (raw): 0.37


text:
zjs
===
A lightweight module loader for browsers.

About zjs
---------
Zjs is a modular script loader and compiler for browsers. It can be compared to
more robust options like requireJs, but differs in that it loads modules based on
namespaces (which are just javascript objects, such as 'app.foo.bar'), not filepaths.
The advantage of this is that a project can be compiled into a single file without
needing any extra code (such as 'require' wrappers); in fact, a compiled zjs project
won't have a single line of code from the zjs library.

If you need lots of AMD stuff on your projects, zjs is likely not the way to go. However,
it might be ideal for smaller apps. If you need to use popular libraries like Backbone, jQuery
or Underscore you can import them into zjs with minimal trouble.

How does it work?
-----------------
zjs uses a simple API to manage dependencies. Here is a simple way to write
a module (using the 'chaining' flavor):

```JavaScript
z('app.module')
    .imports('app.my.dependency')
    .imports('app.my.otherDependency')
    .exports(function(){

        var Foo = function(){
            return "foo";
        }

        var Bar = app.my.dependency;

        // Define what this module exports by returning
        // something.
        return {
            Foo: Foo,
            Bar: Bar
        };

    });
```

If you don't like chaining, you can also define modules via a factory callback. You can
define modules using several different "flavors" depending on the number of
arguments you pass to the `z` constructor and the `factory` callback. These
are all purely aesthetic, and function the same internally. Here are examples of each:

```JavaScript
// The 'no-dependencies' flavor, where no args are passed
// to the factory. This is good for modules with a single export.
z('foo.bar', function () {return 'foo';});

// The 'module-context' flavor, where a single arg is passed to the
// factory. This arg points to the current module, and you can
// call its imports and exports methods using chaining or individually.
z('foo.bin', function (module) {
    module
        .imports('foo.bar')
        .imports('foo.bar');
    module.exports('bar', 'bar');
});

// The 'imports-exports' flavor, where two args are passed. These
// are mapped to the current module's 'import' and 'export' methods,
// respectively. If you're not compiling your ZJS project, this method
// may result in marginally better minification.
z('foo.baz', function (imports, exports) {
    imports('foo.bar');
    imports('foo.bin');
    exports('bar', 'bar');
});

// The 'defines-module-context' flavor, similar to the 'module-context'
// flavor, but which requires you to use the 'defines' method somewhere so
// Zjs knows what to call this module. Use this if you find it asthetically
// pleasing.
z(function (module) {
    module.defines('foo.bin');

    module.imports('foo.bar');

    module.exports({
        bar: 'bar',
        foo: 'foo'
    });
});

// The 'defines-imports-exports' flavor is an alternative to the above,
// if you like using psuedo-keywords.
z(function (defines, imports, exports) {
    defines('foo.bin');

    imports('foo.bar');

    exports({
        bar: 'bar',
        foo: 'foo'
    });
});
```

This read-me will use the "module-context" flavor for the rest of the examples,
but you can use whichever one you like the best. However, you should pick a style
and stick to it for your entire project. You CAN mix and match methods without
breaking anything, but, you know, don't do that. Be consistent.

Zjs can also use plugins to import modules. The syntax is similar to
RequireJS:

```JavaScript
z('app.bar', function (module) {
    // Import using the 'txt' plugin
    module.imports('txt!app.bar.templates', {ext:'myFileType'});
    module.exports(function () {
        // Use in the same way as any other import.
        var foo = app.bar.templates;
    });
});
```

Zjs comes with a 'txt' plugin that lets you import files via AJAX. You can
add your own plugins with 'z.plugin':

```JavaScript
z.plugin('myPlugin', function(moduleName, next, error, options) {
    // Code
});
```

Take a look in the source to get an idea of how  the 'txt' plugin was implemented, it's pretty simple.

Compiling
---------
While you can use Zjs to load modules on a browser, you'll likely want to compile
everything before you deploy it. To do this, Zjs comes with a command-line tool:

```
$ npm install zjs -g
$ zjs build <path/to/main.js> <path/to/compiledApp.js>
```

The compiled file can be optimized by as well, just include the '-o' option
when building a project:

```
$ zjs build <path/to/main.js> <path/to/compiledApp.js> -o
```

Zjs requires a 'main' file to properly compile a project. This is where you'll include
all your configuration options and where you'll include your first modules. Here's an example:

```JavaScript
z.config({
    root: '/scripts',
    // You can name your main module anything you like,
    // just include the following in the config.
    // By default, zjs assumes the main module is called 'main'.
    main: 'app.main',
    // Use the shim to set up non-zjs modules.
    shim: {
        '$': {
            map: 'libs/jquery.min.js'
        },
        '_': {
            map: 'libs/underscore.js'
        },
        'Backbone': {
            map: 'libs/backbone.js',
            imports: ['_', '$'] // Including this option will ensure that backbone has underscore and jquery
        }
    },
    map: {
        // You can use patterns to map namespaces to filepaths.
        // The following will, for example, match 'foo.bar'
        // to 'libs/foo/bar.js'
        'libs/foo/*.js': 'foo.*',
        // If you want to map an entire directory, use '**'.
        // The following will, for example, match 'baz.bif.bin.bar' to 'libs/baz/bif/bin/bar.js'
        'libs/baz/**/*.js': 'baz.**.*',
        // It's also possible to tell zjs that one file
        // exports several modules.
        // Patterns will work here!
        'libs/bar.js': [
            'bar.bin',
            'bar.foo',
            'bar.fid.*'
        ]
    }
});

z('app.main', function (module) {

    module.imports('app.boot');

    module.exports(function () {
        app.boot();
    });

});
```


text:
package org.fest.swing.core.matcher;

import static org.fest.assertions.Assertions.assertThat;

import org.junit.Test;

/**
 * Tests for {@code toString} in {@link NamedComponentMatcherTemplate#ANY}.
 *
 * @author Alex Ruiz
 */
public class NamedComponentMatcherTemplate_ANY_toString_Test extends NamedComponentMatcherTemplate_TestCase {
  @Test
  public void should_implement_toString() {
    assertThat(NamedComponentMatcherTemplate.anyValue().toString()).isEqualTo("<Any>");
  }
}


text:
let commands = {

    // Glboal Prefix
    prefix: "!!",

    // Show help
    help : [ "help", " --help", " help" ],

    // Disconnect from voice chat
    dc: 'dc',

    // Post random Pics
    // Dependencies: rate, addpic
    randomPicsAlias: { 'a/': 'anime/', 'm/': 'misc/' },
    randomPics: [ 'tfw', 'god', 'bog', 'exposed', 'tsu', 'lol', 'fap', 'call', 'bullshit', 'memri', 'yousmart', 'ungabunga', 'kys', 'misc'
     ,'tekken', 'todd', 'anime-legacy', 'anime', 'beargrylls', 'indian', 'dafuq'
     ,'umaru', 'boomer', 'zoomer', 'pepe', 'bst' // requests
     ,'sfv', 'blazbluecf', 'kpop', 'games', 'movies'
     ,'nsfw' // special case, will post it to the NSFW channel
     ,"trash" // for removed items
     ,'pichesays' // for hesays command
    ],
    randomPic: 'randompic',
    folderSearch: 'fsearch',

    // Text Generation
    textgen: 'textgen',

    // Binary converter
    binaryConverter: [ 'b2d', 'd2b' ],

    // Add pic to the above folder
    addPic: 'add',
    deletePic: 'delete',
    imageSearch: 'imsearch',
    album: 'album',

    // Bog related
    quickrundown: 'quickrundown',
    bog: 'bog',

    catchyou: 'catchyou',

    // Game questions
    qs: 'qs',

    // Is something randomizer
    is: [ 'is', 'are', 'does', 'will', 'would', 'has', 'should'],

    // Did thanos kill me
    didthanoskillme: 'didthanoskillme',

    // Rate something out of 10
    rate: 'rate',

    // Youtube search
    yt: 'yt',

    // Show you how to search
    search: 'search ',

    // Space out e.g HELL -> H E L L
    spaceout: 'spaceout',

    // Convert each character to big blocks
    regional: 'regional',

    // Evaluate mathematical expression
    math: 'math',

    //hash usernames
    namehash: 'namehash',

    // My anime list by popular demand
    myanimelist: 'myanimelist',

    // Show online users
    whosonline: 'whosonline',

    // Ban phrase
    banphrase: 'banphrase',
    unbanphrase: 'unbanphrase',

    // Count phrase usage
    countusage: 'countusage',

    // 4Chan
    fourchan: '4chan',

    // Clean bot messages
    clean: 'clean',

    // Trump audio
    trump : ["trump", "hillary", "tachanka", "pafrican", "pussy",
     "haveatthemboys", "shitpostingfucks", "ohnonono", "sam", "reddit",
     "leftthechat", "blackmesa", "goblin"],

    // Play youtube
    play: 'play',

    // Movie search
    imdb: 'imdb',

    // Google API
    // Translation
    translate: 'translate',
    suggest: 'suggest',

    // Get image from instagram
    igimage: 'igimage',

    // Download user images
    igdownload: 'igdownload',

    // Search Urban Dictionary
    urban: 'urban',

    // Roll dice i.e. 1d20
    roll: 'roll',

    // Remind a user of a message in time x
    remind: 'remind',

    // Choose an option at random
    which: 'which',

    // Flip a coin
    flip: 'flip',

    // replay the last command
    replay: 'replay',

    // Games
    games: {
        rps: 'grps'
    },

    // World cup
    wcup: 'wcup',

    // Magic 8 ball
    eightball: '8ball',

    // Steam helpers
    steamurl: 'steamurl',

    // Image processing
    image: {
        gray: 'imgray',
        meme: 'immeme',
        style: 'imstyle'
    },

    // Authentication
    authorize: 'authorize',
    authGen: 'auth-gen',

    // Random password generator
    randompass: 'randompass',

    hesays: 'hesays'
};

export { commands };


text:
package org.raistlic.common.stopwatch;

import org.raistlic.common.precondition.Param;

/**
 * Default implementation for {@link StopWatch} .
 */
final class StopWatchDefault implements StopWatch {

  /**
   * The mark of "start time".
   */
  private long anchor;

  /**
   * The saved elapsed time, calculated on pausing the watch, and only used when watch is paused.
   */
  private long elapsedAmount;

  /**
   * Expiration amount, also used as a unit for moving anchor forward and backward.
   */
  private long tickNanos;

  /**
   * true indicating the watch is actively measuring time elapsed.
   */
  private boolean running;

  StopWatchDefault(long tickNanos) {

    Param.isTrue(tickNanos > 0L, "tickNanos must be greater than 0");

    this.tickNanos = tickNanos;
  }

  @Override
  public void setTick(long tickNanos) {

    Param.isTrue(tickNanos > 0L, "tickNanos must be greater than 0");

    this.tickNanos = tickNanos;
  }

  @Override
  public long getTick() {

    return this.tickNanos;
  }

  @Override
  public void tickForward(long current) {

    // assume set(?, current) will achieve the goal, then
    //
    // when running, goal is : started = started + getTick()
    // started + getTick() = current + ? - getTick() -> ? = getTick()*2 - (current - started) = getTick()*2 - readElapsed(current)
    // when saved, goal is : saved = saved - getTick()
    // getTick() - ? = saved - getTick() -> ? = getTick()*2 - saved = getTick()*2 - readElapsed(current)
    set(getTick() * 2 - readElapsed(current), current);
  }

  @Override
  public void tickBackward(long currentNanos) {

    // assume set(?, current) will achieve the goal, then
    //
    // when running, goal is : started = started - getTick()
    // started = started - getTick() -> started - getTick() = current + ? - getTick() -> ? = started - current = -readElapsed(current)
    // when saved, goal is : saved = saved + getTick()
    // saved = saved + getTick() -> getTick() - ? = saved + getTick() -> ? = -saved = -readElapsed(current)
    set(-readElapsed(currentNanos), currentNanos);
  }

  @Override
  public boolean expired(long currentNanos) {

    return readElapsed(currentNanos) >= tickNanos;
  }

  @Override
  public void set(long expiresInNanos, long currentNanos) {

    if (running) {
      // because when it expires: started + tick == current + expiresIn
      anchor = currentNanos + expiresInNanos - tickNanos;
    } else {
      // again when it expires: (current - saved) + tick == current + expiresIn
      elapsedAmount = tickNanos - expiresInNanos;
    }
  }

  @Override
  public long readElapsed(long currentNanos) {

    return running ? currentNanos - anchor : elapsedAmount;
  }

  @Override
  public long readExpired(long currentNanos) {

    return readElapsed(currentNanos) - tickNanos;
  }

  @Override
  public void reset(long currentNanos) {

    anchor = currentNanos;
    running = true;
  }

  @Override
  public void pause(long currentNanos) {

    if (running) {
      elapsedAmount = currentNanos - anchor;
      running = false;
    }
  }

  @Override
  public void resume(long currentNanos) {

    if (!running) {
      anchor = currentNanos - elapsedAmount;
      running = true;
    }
  }
}