PushEventsTransmitter.java 3.76 KB
package com.arellomobile.android.push;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import com.arellomobile.android.push.utils.GeneralUtils;
import java.io.PrintStream;
import java.lang.reflect.Method;

public class PushEventsTransmitter
{
  static void a(Context paramContext, String paramString)
  {
    if (a(paramContext))
    {
      a(paramContext, paramString, "REGISTER_EVENT");
      return;
    }
    a(paramContext, paramString, "REGISTER_EVENT", null);
  }
  
  static void a(Context paramContext, String paramString, Bundle paramBundle)
  {
    a(paramContext, paramString, "PUSH_RECEIVE_EVENT", paramBundle);
  }
  
  private static void a(Context paramContext, String paramString1, String paramString2)
  {
    String str = paramContext.getPackageName();
    Intent localIntent = new Intent(str + ".com.arellomobile.android.push.REGISTER_BROAD_CAST_ACTION");
    localIntent.putExtra(paramString2, paramString1);
    localIntent.setPackage(str);
    if (GeneralUtils.checkStickyBroadcastPermissions(paramContext))
    {
      paramContext.sendStickyBroadcast(localIntent);
      return;
    }
    Log.w(PushEventsTransmitter.class.getSimpleName(), "No android.permission.BROADCAST_STICKY. Reverting to simple broadcast");
    paramContext.sendBroadcast(localIntent);
  }
  
  private static void a(Context paramContext, String paramString1, String paramString2, Bundle paramBundle)
  {
    Intent localIntent = new Intent(paramContext, MessageActivity.class);
    if (paramBundle != null) {
      localIntent.putExtras(paramBundle);
    }
    localIntent.putExtra(paramString2, paramString1);
    localIntent.setFlags(268435456);
    try
    {
      paramString1 = Class.forName("com.arellomobile.android.push.PushwooshProxy");
      if (paramString1 != null)
      {
        paramString2 = paramString1.getMethod("getInstanceOrNull", new Class[0]).invoke(null, null);
        if (paramString2 != null) {
          paramString1.getMethod("checkMessage", new Class[] { Intent.class }).invoke(paramString2, new Object[] { localIntent });
        }
      }
    }
    catch (Exception paramString1)
    {
      for (;;) {}
    }
    paramContext.startActivity(localIntent);
  }
  
  private static boolean a(Context paramContext)
  {
    try
    {
      paramContext = paramContext.getPackageManager().getApplicationInfo(paramContext.getApplicationContext().getPackageName(), 128);
      if (paramContext.metaData != null)
      {
        boolean bool = paramContext.metaData.getBoolean("PW_BROADCAST_REGISTRATION", true);
        System.out.println("Using broadcast registration: " + bool);
        return bool;
      }
      return true;
    }
    catch (Exception paramContext)
    {
      paramContext.printStackTrace();
    }
    return true;
  }
  
  static void b(Context paramContext, String paramString)
  {
    if (a(paramContext))
    {
      a(paramContext, paramString, "REGISTER_ERROR_EVENT");
      return;
    }
    a(paramContext, paramString, "REGISTER_ERROR_EVENT", null);
  }
  
  static void c(Context paramContext, String paramString)
  {
    if (a(paramContext))
    {
      a(paramContext, paramString, "UNREGISTER_EVENT");
      return;
    }
    a(paramContext, paramString, "UNREGISTER_EVENT", null);
  }
  
  static void d(Context paramContext, String paramString)
  {
    if (a(paramContext))
    {
      a(paramContext, paramString, "UNREGISTER_ERROR_EVENT");
      return;
    }
    a(paramContext, paramString, "UNREGISTER_ERROR_EVENT", null);
  }
}


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