package com.jaredrummler.android.processes.models;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.jaredrummler.android.processes.ProcessManager;
import java.io.File;
import java.io.IOException;

public class AndroidAppProcess
  extends AndroidProcess
{
  public static final Parcelable.Creator<AndroidAppProcess> CREATOR = new Parcelable.Creator()
  {
    public AndroidAppProcess createFromParcel(Parcel paramAnonymousParcel)
    {
      return new AndroidAppProcess(paramAnonymousParcel);
    }
    
    public AndroidAppProcess[] newArray(int paramAnonymousInt)
    {
      return new AndroidAppProcess[paramAnonymousInt];
    }
  };
  private static final boolean SYS_SUPPORTS_SCHEDGROUPS = new File("/dev/cpuctl/tasks").exists();
  public final boolean foreground;
  public final int uid;
  
  public AndroidAppProcess(int paramInt)
    throws IOException, AndroidAppProcess.NotAndroidAppProcessException
  {
    super(paramInt);
    int i;
    if (SYS_SUPPORTS_SCHEDGROUPS)
    {
      localObject2 = cgroup();
      localObject1 = ((Cgroup)localObject2).getGroup("cpuacct");
      localObject2 = ((Cgroup)localObject2).getGroup("cpu");
      if (Build.VERSION.SDK_INT >= 21)
      {
        if ((localObject2 == null) || (localObject1 == null) || (!((ControlGroup)localObject1).group.contains("pid_"))) {
          throw new NotAndroidAppProcessException(paramInt);
        }
        if (!((ControlGroup)localObject2).group.contains("bg_non_interactive")) {
          bool = true;
        }
      }
      for (;;)
      {
        try
        {
          i = Integer.parseInt(localObject1.group.split("/")[1].replace("uid_", ""));
          ProcessManager.log("name=%s, pid=%d, uid=%d, foreground=%b, cpuacct=%s, cpu=%s", new Object[] { this.name, Integer.valueOf(paramInt), Integer.valueOf(i), Boolean.valueOf(bool), ((ControlGroup)localObject1).toString(), ((ControlGroup)localObject2).toString() });
          this.foreground = bool;
          this.uid = i;
          return;
          bool = false;
          continue;
        }
        catch (Exception localException1)
        {
          i = status().getUid();
          continue;
        }
        if ((localObject2 == null) || (localObject1 == null) || (!((ControlGroup)localObject2).group.contains("apps"))) {
          throw new NotAndroidAppProcessException(paramInt);
        }
        if (!((ControlGroup)localObject2).group.contains("bg_non_interactive")) {
          bool = true;
        }
        try
        {
          for (;;)
          {
            i = Integer.parseInt(((ControlGroup)localObject1).group.substring(((ControlGroup)localObject1).group.lastIndexOf("/") + 1));
            ProcessManager.log("name=%s, pid=%d, uid=%d foreground=%b, cpuacct=%s, cpu=%s", new Object[] { this.name, Integer.valueOf(paramInt), Integer.valueOf(i), Boolean.valueOf(bool), ((ControlGroup)localObject1).toString(), ((ControlGroup)localObject2).toString() });
            break;
            bool = false;
          }
        }
        catch (Exception localException2)
        {
          for (;;)
          {
            i = status().getUid();
          }
        }
      }
    }
    if ((this.name.startsWith("/")) || (!new File("/data/data", getPackageName()).exists())) {
      throw new NotAndroidAppProcessException(paramInt);
    }
    Object localObject1 = stat();
    Object localObject2 = status();
    if (((Stat)localObject1).policy() == 0) {}
    for (boolean bool = true;; bool = false)
    {
      i = ((Status)localObject2).getUid();
      ProcessManager.log("name=%s, pid=%d, uid=%d foreground=%b", new Object[] { this.name, Integer.valueOf(paramInt), Integer.valueOf(i), Boolean.valueOf(bool) });
      break;
    }
  }
  
  protected AndroidAppProcess(Parcel paramParcel)
  {
    super(paramParcel);
    if (paramParcel.readByte() != 0) {}
    for (boolean bool = true;; bool = false)
    {
      this.foreground = bool;
      this.uid = paramParcel.readInt();
      return;
    }
  }
  
  public PackageInfo getPackageInfo(Context paramContext, int paramInt)
    throws PackageManager.NameNotFoundException
  {
    return paramContext.getPackageManager().getPackageInfo(getPackageName(), paramInt);
  }
  
  public String getPackageName()
  {
    return this.name.split(":")[0];
  }
  
  public void writeToParcel(Parcel paramParcel, int paramInt)
  {
    super.writeToParcel(paramParcel, paramInt);
    if (this.foreground) {}
    for (paramInt = 1;; paramInt = 0)
    {
      paramParcel.writeByte((byte)paramInt);
      paramParcel.writeInt(this.uid);
      return;
    }
  }
  
  public static final class NotAndroidAppProcessException
    extends Exception
  {
    public NotAndroidAppProcessException(int paramInt)
    {
      super();
    }
  }
}


/* Location:              /home/enzo/Documents/hacking/malwares/viking-horde/classes.jar!/com/jaredrummler/android/processes/models/AndroidAppProcess.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */