package com.google.android.m4b.maps.am;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.os.Process;
import com.google.android.m4b.maps.aa.g;
import com.google.android.m4b.maps.ac.a;
import com.google.android.m4b.maps.ak.r.a;
import com.google.android.m4b.maps.cl.af;
import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

public final class c
  implements r.a
{
  private a a;
  private boolean b;
  private String c;
  private Context d;

  public c(Context paramContext)
  {
    this.d = paramContext;
    String str1 = a(paramContext);
    int i;
    String str2;
    if (str1 != null)
    {
      i = str1.indexOf(':');
      if ((i == -1) || (i >= str1.length()))
        str2 = "";
    }
    while (true)
    {
      this.c = ("event_store_v2" + str2);
      File localFile = paramContext.getFileStreamPath("event_store" + str2);
      if ((localFile != null) && (localFile.exists()))
        localFile.delete();
      return;
      str2 = "_" + str1.substring(i + 1);
      continue;
      str2 = "";
    }
  }

  @VisibleForTesting
  private static String a(Context paramContext)
  {
    ActivityManager localActivityManager = (ActivityManager)paramContext.getSystemService("activity");
    int i = Process.myPid();
    Iterator localIterator = localActivityManager.getRunningAppProcesses().iterator();
    while (localIterator.hasNext())
    {
      ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo)localIterator.next();
      if (localRunningAppProcessInfo.pid == i)
        return localRunningAppProcessInfo.processName;
    }
    return null;
  }

  private void c()
  {
    FileInputStream localFileInputStream = null;
    try
    {
      String str = this.c;
      if (str != null);
      try
      {
        localFileInputStream = this.d.openFileInput(this.c);
        if (localFileInputStream != null)
        {
          this.a = new a(af.a);
          this.a.a(g.a(localFileInputStream));
          localFileInputStream.close();
        }
        while (true)
        {
          this.b = true;
          return;
          this.a = null;
        }
      }
      catch (IOException localIOException)
      {
        while (true)
        {
          this.a = null;
          g.b(localFileInputStream);
          this.d.deleteFile(this.c);
        }
      }
    }
    finally
    {
    }
  }

  public final a a()
  {
    try
    {
      if (!this.b)
        c();
      a locala = this.a;
      return locala;
    }
    finally
    {
    }
  }

  public final void a(a parama)
  {
    try
    {
      this.a = parama;
      this.b = true;
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public final void b()
  {
    FileOutputStream localFileOutputStream = null;
    try
    {
      if (this.c != null)
      {
        if (this.a != null)
          break label43;
        this.d.deleteFile(this.c);
      }
      while (true)
      {
        this.a = null;
        this.b = false;
        return;
        try
        {
          label43: localFileOutputStream = this.d.openFileOutput(this.c, 0);
          localFileOutputStream.write(this.a.d());
          localFileOutputStream.close();
        }
        catch (IOException localIOException)
        {
          g.a(localFileOutputStream);
          this.d.deleteFile(this.c);
        }
      }
    }
    finally
    {
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.google.android.m4b.maps.am.c
 * JD-Core Version:    0.6.2
 */