这段android代码是做什么用的,好像是个?

云原生 发布于 2014/10/29 15:48
阅读 394
收藏 0
package mm.purchasesdk.iapservice;

import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import java.util.HashMap;
import mm.purchasesdk.core.IPurchase;
import mm.purchasesdk.core.protocol.MessengerInfo;
import mm.purchasesdk.core.utils.LogUtil;
import mm.purchasesdk.fingerprint.IdentifyApp;

public class PurchaseService extends Service
{
  private static String TAG = "ap PurchaseService";
  private final Messenger jdField_a_of_type_AndroidOsMessenger = new Messenger(new a());
  private IPurchase mPurchaseCore;
  private String mPackageName = null;
  private static HashMap jdField_a_of_type_JavaUtilHashMap = new HashMap();
  private static HashMap jdField_b_of_type_JavaUtilHashMap = new HashMap();
  private Messenger jdField_b_of_type_AndroidOsMessenger;
  private Messenger c;
  private String jdField_b_of_type_JavaLangString;

  public IBinder onBind(Intent paramIntent)
  {
    LogUtil.readDebugConfig();
    this.mPurchaseCore = ((IPurchase)IdentifyApp.load(this, ""));
    if (this.mPurchaseCore == null)
      LogUtil.e(TAG, "动态加载失败返回null");
    else
      LogUtil.e(TAG, "动态加载成功");
    return this.jdField_a_of_type_AndroidOsMessenger.getBinder();
  }

  public void onCreate()
  {
    super.onCreate();
  }

  private void a(Message paramMessage, MessengerInfo paramMessengerInfo)
  {
    try
    {
      this.mPurchaseCore.service_unsubscribe(this, paramMessengerInfo.getPaycode(), paramMessage, paramMessengerInfo);
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private void b(Message paramMessage, MessengerInfo paramMessengerInfo)
  {
    LogUtil.d(TAG, "query:" + paramMessengerInfo.toString() + "/" + paramMessage.toString());
    try
    {
      this.mPurchaseCore.service_query(this, paramMessengerInfo.getPaycode(), paramMessengerInfo.getTradeID(), paramMessage, paramMessengerInfo);
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private void c(Message paramMessage, MessengerInfo paramMessengerInfo)
  {
    LogUtil.d(TAG, "bill:" + paramMessengerInfo.toString() + "/" + paramMessage.toString());
    Message localMessage = Message.obtain(null, 3, 0, 0);
    try
    {
      this.c = ((Messenger)jdField_b_of_type_JavaUtilHashMap.get(paramMessengerInfo.getTaskID()));
      localMessage.setData(paramMessengerInfo.writeToBundle());
      localMessage.replyTo = this.jdField_a_of_type_AndroidOsMessenger;
      this.c.send(localMessage);
      jdField_b_of_type_JavaUtilHashMap.remove(paramMessengerInfo.getTaskID());
      this.jdField_b_of_type_JavaLangString = "";
    }
    catch (RemoteException localRemoteException)
    {
      localRemoteException.printStackTrace();
    }
  }

  private void d(Message paramMessage, MessengerInfo paramMessengerInfo)
  {
    LogUtil.d(TAG, "bill:" + paramMessengerInfo.toString() + "/" + paramMessage.toString());
    Message localMessage = Message.obtain(null, 11, 0, 0);
    try
    {
      this.c = ((Messenger)jdField_b_of_type_JavaUtilHashMap.get(paramMessengerInfo.getTaskID()));
      localMessage.setData(paramMessengerInfo.writeToBundle());
      localMessage.replyTo = this.jdField_a_of_type_AndroidOsMessenger;
      this.c.send(localMessage);
      jdField_b_of_type_JavaUtilHashMap.remove(paramMessengerInfo.getTaskID());
      this.jdField_b_of_type_JavaLangString = "";
    }
    catch (RemoteException localRemoteException)
    {
      localRemoteException.printStackTrace();
    }
  }

  private void e(Message paramMessage, MessengerInfo paramMessengerInfo)
  {
    LogUtil.d(TAG, "auth:" + paramMessengerInfo.toString() + "/" + paramMessage.toString());
    this.mPackageName = paramMessengerInfo.getPackageName();
  }

  private void f(Message paramMessage, MessengerInfo paramMessengerInfo)
  {
    LogUtil.d(TAG, "init:" + paramMessengerInfo.toString() + "/" + paramMessage.toString());
    try
    {
      this.mPurchaseCore.service_init(this, paramMessage, paramMessengerInfo);
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  class a extends Handler
  {
    a()
    {
    }

    public void handleMessage(Message paramMessage)
    {
      LogUtil.d(PurchaseService.b(), "handleMessage what:" + paramMessage.what + ":" + paramMessage.toString());
      super.handleMessage(paramMessage);
      PurchaseService.a(PurchaseService.this).setMessage(paramMessage);
      PurchaseService.a(PurchaseService.this).setMessenger(paramMessage.replyTo);
      MessengerInfo localMessengerInfo = new MessengerInfo();
      Bundle localBundle = paramMessage.getData();
      localMessengerInfo.readBundle(localBundle);
      PurchaseService.a(PurchaseService.this).setClasseSha1(localMessengerInfo.getClasseSha1());
      String str1 = localBundle.getString("PAYCODE");
      String str2 = localBundle.getString("TIMESTAMP");
      if (paramMessage.arg2 == 0)
      {
        LogUtil.d(PurchaseService.b(), "info.getTaskID() = " + localMessengerInfo.getTaskID());
        PurchaseService.a().put(localMessengerInfo.getTaskID(), paramMessage.replyTo);
      }
      else if (paramMessage.arg2 == 1)
      {
        PurchaseService.a(PurchaseService.this, paramMessage.replyTo);
        LogUtil.d(PurchaseService.b(), " IncomingHandler info.getTaskID() = " + localMessengerInfo.getTaskID());
        PurchaseService.b().put(localMessengerInfo.getTaskID(), paramMessage.replyTo);
      }
      switch (paramMessage.what)
      {
      case 1:
        PurchaseService.a(PurchaseService.this, paramMessage, localMessengerInfo);
        break;
      case 2:
        PurchaseService.b(PurchaseService.this, paramMessage, localMessengerInfo);
        break;
      case 6:
        a(localMessengerInfo, 2);
        break;
      case 3:
        PurchaseService.c(PurchaseService.this, paramMessage, localMessengerInfo);
        break;
      case 4:
        PurchaseService.d(PurchaseService.this, paramMessage, localMessengerInfo);
        break;
      case 5:
        PurchaseService.e(PurchaseService.this, paramMessage, localMessengerInfo);
        break;
      case 7:
        Message localMessage = Message.obtain(null, 3, 0, 0);
        try
        {
          LogUtil.d(PurchaseService.b(), "MSG_BILLFINISH info = " + localMessengerInfo);
          LogUtil.d(PurchaseService.b(), "MSG_BILLFINISH info.getTaskID() = " + localMessengerInfo.getTaskID());
          PurchaseService.b(PurchaseService.this, (Messenger)PurchaseService.a().get(localMessengerInfo.getTaskID()));
          LogUtil.d(PurchaseService.b(), "MSG_BILLFINISH mMessengerFC = " + PurchaseService.a(PurchaseService.this));
          localMessage.setData(localMessengerInfo.writeToBundle());
          localMessage.replyTo = PurchaseService.b(PurchaseService.this);
          PurchaseService.a(PurchaseService.this).send(localMessage);
          PurchaseService.a().remove(localMessengerInfo.getTaskID());
        }
        catch (RemoteException localRemoteException)
        {
          localRemoteException.printStackTrace();
        }
        if (PurchaseService.a().size() > 0)
          break;
        PurchaseService.a(PurchaseService.this, null);
        break;
      case 9:
        localMessengerInfo.setPackageName(PurchaseService.a(PurchaseService.this));
        a(localMessengerInfo, 9);
        break;
      case 11:
        PurchaseService.f(PurchaseService.this, paramMessage, localMessengerInfo);
      case 8:
      case 10:
      }
    }

    private void a(MessengerInfo paramMessengerInfo, int paramInt)
    {
      String str = paramMessengerInfo.getIDToken();
      if ((str != null) && (paramInt != 9))
      {
        localObject = IdentifyApp.IdTokenService(str.getBytes(), paramMessengerInfo.getTimeStamp(), "" + paramMessengerInfo.getResult());
        paramMessengerInfo.setIdtoken_verf((String)localObject);
      }
      LogUtil.d(PurchaseService.b(), "sendToClient Server " + paramInt);
      Object localObject = Message.obtain(null, paramInt, 0, 0);
      try
      {
        PurchaseService.b(PurchaseService.this, (Messenger)PurchaseService.a().get(paramMessengerInfo.getTaskID()));
        ((Message)localObject).setData(paramMessengerInfo.writeToBundle());
        ((Message)localObject).replyTo = PurchaseService.b(PurchaseService.this);
        if (PurchaseService.a(PurchaseService.this) != null)
          PurchaseService.a(PurchaseService.this).send((Message)localObject);
        if (PurchaseService.a() != null)
          PurchaseService.a().remove(paramMessengerInfo.getTaskID());
      }
      catch (RemoteException localRemoteException)
      {
        localRemoteException.printStackTrace();
      }
    }
  }
}



加载中
返回顶部
顶部