package tv.ouya.console.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import java.util.Random;
import tv.ouya.console.internal.util.CurrentTime;

public class SerialNumber
{
  public static final String SERIAL = "serial";
  public static final String SERIAL_PREFS = "serial_prefs";
  private static SerialNumber instance;
  private Context context;
  private CurrentTime currentTime;
  private String serialNumber;
  
  @Deprecated
  public SerialNumber(Context paramContext)
  {
    this.context = paramContext;
    this.currentTime = CurrentTime.getInstance();
  }
  
  private void firstTime()
  {
    if ((!Build.SERIAL.startsWith("emulator")) && (!Build.SERIAL.equals("unknown"))) {
      this.serialNumber = Build.SERIAL;
    }
    Object localObject;
    do
    {
      return;
      localObject = null;
      try
      {
        Context localContext = this.context.createPackageContext("tv.ouya", 2);
        localObject = localContext;
        if (localContext == null)
        {
          localObject = localContext;
          localContext = this.context;
          localObject = localContext;
        }
      }
      catch (PackageManager.NameNotFoundException localNameNotFoundException)
      {
        for (;;)
        {
          localNameNotFoundException.printStackTrace();
        }
      }
      this.serialNumber = ((Context)localObject).getSharedPreferences("serial_prefs", 3).getString("serial", null);
    } while (this.serialNumber != null);
    this.serialNumber = generateSerialNumber((Context)localObject);
  }
  
  private String generateSerialNumber(Context paramContext)
  {
    String str = "" + Long.valueOf(new Random(this.currentTime.currentTimeMillis()).nextLong()).hashCode();
    paramContext = paramContext.getSharedPreferences("serial_prefs", 3).edit();
    paramContext.putString("serial", str);
    paramContext.commit();
    return str;
  }
  
  public static SerialNumber getInstance(Context paramContext)
  {
    if (instance == null) {
      instance = new SerialNumber(paramContext);
    }
    return instance;
  }
  
  @Deprecated
  public static void setInstance(SerialNumber paramSerialNumber)
  {
    instance = paramSerialNumber;
  }
  
  public String getSerialNumber()
  {
    if (this.serialNumber == null) {
      firstTime();
    }
    return this.serialNumber;
  }
}


/* Location:              /home/enzo/Documents/hacking/malwares/viking-horde/classes.jar!/tv/ouya/console/util/SerialNumber.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */