GeneralUtils.java 5.48 KB
package com.arellomobile.android.push.utils;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.util.TypedValue;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.UUID;

public class GeneralUtils
{
  public static final String[] SUPPORTED_AUDIO_FORMATS = { ".mp3", ".3gp", ".mp4", ".m4a", ".aac", ".flac", ".ogg", ".wav" };
  private static List<String> a;
  
  static
  {
    ArrayList localArrayList = new ArrayList();
    a = localArrayList;
    localArrayList.add("9774d56d682e549c");
  }
  
  public static void checkNotNull(Object paramObject, String paramString)
  {
    if (paramObject == null) {
      throw new IllegalArgumentException(String.format("Please set the %1$s constant and recompile the app.", new Object[] { paramString }));
    }
  }
  
  public static void checkNotNullOrEmpty(String paramString1, String paramString2)
  {
    checkNotNull(paramString1, paramString2);
    if (paramString1.length() == 0) {
      throw new IllegalArgumentException(String.format("Please set the %1$s constant and recompile the app.", new Object[] { paramString2 }));
    }
  }
  
  public static boolean checkStickyBroadcastPermissions(Context paramContext)
  {
    return paramContext.getPackageManager().checkPermission("android.permission.BROADCAST_STICKY", paramContext.getPackageName()) == 0;
  }
  
  @SuppressLint({"WorldWriteableFiles"})
  public static String getDeviceUUID(Context paramContext)
  {
    Object localObject1 = Settings.Secure.getString(paramContext.getContentResolver(), "android_id");
    if ((localObject1 != null) && (!a.contains(localObject1))) {}
    do
    {
      for (;;)
      {
        return (String)localObject1;
        try
        {
          localObject2 = ((TelephonyManager)paramContext.getSystemService("phone")).getDeviceId();
          localObject1 = localObject2;
          if (localObject2 != null) {}
        }
        catch (RuntimeException localRuntimeException)
        {
          Object localObject2;
          for (;;) {}
        }
      }
      localObject2 = paramContext.getSharedPreferences("com.arellomobile.android.push.deviceid", 2);
      paramContext = ((SharedPreferences)localObject2).getString("deviceid", null);
      localObject1 = paramContext;
    } while (paramContext != null);
    paramContext = UUID.randomUUID().toString();
    localObject1 = ((SharedPreferences)localObject2).edit();
    ((SharedPreferences.Editor)localObject1).putString("deviceid", paramContext);
    ((SharedPreferences.Editor)localObject1).commit();
    return paramContext;
  }
  
  public static ArrayList<String> getRawResourses(Context paramContext)
  {
    localArrayList = new ArrayList();
    try
    {
      Field[] arrayOfField = Class.forName(paramContext.getPackageName() + ".R$raw").getFields();
      int i = 0;
      while (i < arrayOfField.length)
      {
        String str = arrayOfField[i].getName();
        int j = paramContext.getResources().getIdentifier(str, "raw", paramContext.getPackageName());
        TypedValue localTypedValue = new TypedValue();
        paramContext.getResources().getValue(j, localTypedValue, true);
        if (isSound(localTypedValue.string.toString())) {
          localArrayList.add(str);
        }
        i += 1;
      }
      return localArrayList;
    }
    catch (ClassNotFoundException paramContext) {}
  }
  
  public static boolean isAmazonDevice()
  {
    try
    {
      Class.forName("com.amazon.device.messaging.ADM");
      return true;
    }
    catch (ClassNotFoundException localClassNotFoundException) {}
    return false;
  }
  
  public static boolean isAppOnForeground(Context paramContext)
  {
    Object localObject = ((ActivityManager)paramContext.getSystemService("activity")).getRunningAppProcesses();
    if (localObject == null) {
      return false;
    }
    paramContext = paramContext.getPackageName();
    localObject = ((List)localObject).iterator();
    while (((Iterator)localObject).hasNext())
    {
      ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo)((Iterator)localObject).next();
      if ((localRunningAppProcessInfo.importance == 100) && (localRunningAppProcessInfo.processName.equals(paramContext))) {
        return true;
      }
    }
    return false;
  }
  
  protected static boolean isSound(String paramString)
  {
    boolean bool2 = false;
    int i = 0;
    for (;;)
    {
      boolean bool1 = bool2;
      if (i < SUPPORTED_AUDIO_FORMATS.length)
      {
        String str = SUPPORTED_AUDIO_FORMATS[i];
        if (paramString.toLowerCase(Locale.US).endsWith(str)) {
          bool1 = true;
        }
      }
      else
      {
        return bool1;
      }
      i += 1;
    }
  }
  
  @SuppressLint({"InlinedApi"})
  public static boolean isTablet(Context paramContext)
  {
    return (paramContext.getResources().getConfiguration().screenLayout & 0x4) == 4;
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/utils/GeneralUtils.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */