APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:CarSet
版本号:1.017
包名称:com.kyhero.car.myhost

MD5 校验值:5756fdbe0a23430a0d6b1f0e70235766

反编译源代码说明

ActivityManagerProxy.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.didi.virtualapk.delegate;

import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import com.didi.virtualapk.PluginManager;
import com.didi.virtualapk.internal.utils.PluginUtil;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ActivityManagerProxy implements InvocationHandler {
    public static final int INTENT_SENDER_ACTIVITY = 2;
    public static final int INTENT_SENDER_ACTIVITY_RESULT = 3;
    public static final int INTENT_SENDER_BROADCAST = 1;
    public static final int INTENT_SENDER_SERVICE = 4;
    private static final String TAG = "VA.IActivityManagerProxy";
    private IActivityManager mActivityManager;
    private PluginManager mPluginManager;

    public ActivityManagerProxy(PluginManager pluginManager, IActivityManager activityManager) {
        this.mPluginManager = pluginManager;
        this.mActivityManager = activityManager;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        IBinder ams;
        if ("startService".equals(method.getName())) {
            try {
                return startService(proxy, method, args);
            } catch (Throwable e) {
                Log.e(TAG, "Start service error", e);
            }
        } else if ("stopService".equals(method.getName())) {
            try {
                return stopService(proxy, method, args);
            } catch (Throwable e2) {
                Log.e(TAG, "Stop Service error", e2);
            }
        } else if ("stopServiceToken".equals(method.getName())) {
            try {
                return stopServiceToken(proxy, method, args);
            } catch (Throwable e3) {
                Log.e(TAG, "Stop service token error", e3);
            }
        } else if ("bindService".equals(method.getName())) {
            try {
                return bindService(proxy, method, args);
            } catch (Throwable e4) {
                Log.w(TAG, e4);
            }
        } else if ("unbindService".equals(method.getName())) {
            try {
                return unbindService(proxy, method, args);
            } catch (Throwable e5) {
                Log.w(TAG, e5);
            }
        } else if ("getIntentSender".equals(method.getName())) {
            try {
                getIntentSender(method, args);
            } catch (Exception e6) {
                Log.w(TAG, e6);
            }
        } else if ("overridePendingTransition".equals(method.getName())) {
            try {
                overridePendingTransition(method, args);
            } catch (Exception e7) {
                Log.w(TAG, e7);
            }
        }
        try {
            return method.invoke(this.mActivityManager, args);
        } catch (Throwable th) {
            Throwable c = th.getCause();
            if (c != null && (c instanceof DeadObjectException) && (ams = ServiceManager.getService("activity")) != null) {
                IActivityManager am = ActivityManagerNative.asInterface(ams);
                this.mActivityManager = am;
            }
            Throwable cause = th;
            while (!(cause instanceof RemoteException)) {
                cause = cause.getCause();
                if (cause == null) {
                    if (c != null) {
                        throw c;
                    }
                    throw th;
                }
            }
            throw cause;
        }
    }

    protected Object startService(Object proxy, Method method, Object[] args) throws Throwable {
        Intent target = (Intent) args[1];
        ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
        return (resolveInfo == null || resolveInfo.serviceInfo == null) ? method.invoke(this.mActivityManager, args) : startDelegateServiceForTarget(target, resolveInfo.serviceInfo, null, 1);
    }

    protected Object stopService(Object proxy, Method method, Object[] args) throws Throwable {
        Intent target = (Intent) args[1];
        ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
        if (resolveInfo == null || resolveInfo.serviceInfo == null) {
            return method.invoke(this.mActivityManager, args);
        }
        startDelegateServiceForTarget(target, resolveInfo.serviceInfo, null, 2);
        return 1;
    }

    protected Object stopServiceToken(Object proxy, Method method, Object[] args) throws Throwable {
        ComponentName component = (ComponentName) args[0];
        Intent target = new Intent().setComponent(component);
        ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
        if (resolveInfo == null || resolveInfo.serviceInfo == null) {
            return method.invoke(this.mActivityManager, args);
        }
        startDelegateServiceForTarget(target, resolveInfo.serviceInfo, null, 2);
        return true;
    }

    protected Object bindService(Object proxy, Method method, Object[] args) throws Throwable {
        Intent target = (Intent) args[2];
        ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
        if (resolveInfo == null || resolveInfo.serviceInfo == null) {
            return method.invoke(this.mActivityManager, args);
        }
        Bundle bundle = new Bundle();
        PluginUtil.putBinder(bundle, "sc", (IBinder) args[4]);
        startDelegateServiceForTarget(target, resolveInfo.serviceInfo, bundle, 3);
        this.mPluginManager.getComponentsHandler().remberIServiceConnection((IBinder) args[4], target);
        return 1;
    }

    protected Object unbindService(Object proxy, Method method, Object[] args) throws Throwable {
        IBinder iServiceConnection = (IBinder) args[0];
        Intent target = this.mPluginManager.getComponentsHandler().forgetIServiceConnection(iServiceConnection);
        if (target == null) {
            return method.invoke(this.mActivityManager, args);
        }
        ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
        startDelegateServiceForTarget(target, resolveInfo.serviceInfo, null, 4);
        return true;
    }

    protected ComponentName startDelegateServiceForTarget(Intent target, ServiceInfo serviceInfo, Bundle extras, int command) {
        Intent wrapperIntent = wrapperTargetIntent(target, serviceInfo, extras, command);
        return this.mPluginManager.getHostContext().startService(wrapperIntent);
    }

    protected Intent wrapperTargetIntent(Intent target, ServiceInfo serviceInfo, Bundle extras, int command) {
        target.setComponent(new ComponentName(serviceInfo.packageName, serviceInfo.name));
        String pluginLocation = this.mPluginManager.getLoadedPlugin(target.getComponent()).getLocation();
        boolean local = PluginUtil.isLocalService(serviceInfo);
        Class delegate = local ? LocalService.class : RemoteService.class;
        Intent intent = new Intent();
        intent.setClass(this.mPluginManager.getHostContext(), delegate);
        intent.putExtra(LocalService.EXTRA_TARGET, target);
        intent.putExtra(LocalService.EXTRA_COMMAND, command);
        intent.putExtra(LocalService.EXTRA_PLUGIN_LOCATION, pluginLocation);
        if (extras != null) {
            intent.putExtras(extras);
        }
        return intent;
    }

    protected void getIntentSender(Method method, Object[] args) {
        String hostPackageName = this.mPluginManager.getHostContext().getPackageName();
        args[1] = hostPackageName;
        Intent target = ((Intent[]) args[5])[0];
        int intentSenderType = ((Integer) args[0]).intValue();
        if (intentSenderType == 2) {
            this.mPluginManager.getComponentsHandler().transformIntentToExplicitAsNeeded(target);
            this.mPluginManager.getComponentsHandler().markIntentIfNeeded(target);
        } else {
            if (intentSenderType == 4) {
                ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
                if (resolveInfo != null && resolveInfo.serviceInfo != null) {
                    Intent wrapperIntent = wrapperTargetIntent(target, resolveInfo.serviceInfo, null, 1);
                    ((Intent[]) args[5])[0] = wrapperIntent;
                    return;
                }
                return;
            }
            if (intentSenderType == 1) {
            }
        }
    }

    protected void overridePendingTransition(Method method, Object[] args) {
        String hostPackageName = this.mPluginManager.getHostContext().getPackageName();
        args[1] = hostPackageName;
    }
}