• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DexMaker类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.google.dexmaker.DexMaker的典型用法代码示例。如果您正苦于以下问题:Java DexMaker类的具体用法?Java DexMaker怎么用?Java DexMaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DexMaker类属于com.google.dexmaker包,在下文中一共展示了DexMaker类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: declareFields

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareFields(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType,
		String pluginId,String pkgName) {
	FieldId<D, String> _pluginId = generatedType.getField(TypeId.STRING,
			"_pluginId");
	dexMaker.declare(_pluginId, PRIVATE | STATIC | FINAL, pluginId);
	FieldId<D, String> _pkg = generatedType.getField(TypeId.STRING,
			"_pkg");
	dexMaker.declare(_pkg, PRIVATE | STATIC | FINAL, pkgName);
	
	TypeId<AssetManager> AssetManager = TypeId.get(AssetManager.class);
	TypeId<Resources> Resources = TypeId.get(Resources.class);
	FieldId<D, AssetManager> asm = generatedType.getField(AssetManager,
			FIELD_ASSERTMANAGER);
	dexMaker.declare(asm, PRIVATE, null);
	FieldId<D, Resources> res = generatedType.getField(Resources, FIELD_RESOURCES);
	dexMaker.declare(res, PRIVATE, null);
	FieldId<D, Boolean> beforeOnCreate = generatedType.getField(TypeId.BOOLEAN, FIELD_mOnCreated);
	dexMaker.declare(beforeOnCreate, PRIVATE, null);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:21,
代码来源:ActivityClassGenerator.java

示例2: declareMethod_getComponentName

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getComponentName(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType,String superClassName) {
	TypeId<ComponentName> ComponentName = TypeId.get(ComponentName.class);
	MethodId<D, ComponentName> method = generatedType.getMethod(ComponentName,
			"getComponentName");
	Code methodCode = dexMaker.declare(method, PROTECTED);
	Local<String> pkg =  methodCode.newLocal(TypeId.STRING);
	Local<String> cls =  methodCode.newLocal(TypeId.STRING);
	Local<ComponentName> localComp =  methodCode.newLocal(ComponentName);
	{
		FieldId<D, String> fieldPkg = generatedType.getField(TypeId.STRING,
				"_pkg");
		methodCode.sget(fieldPkg, pkg);
	}
	methodCode.loadConstant(cls, superClassName);
	
	MethodId<ComponentName, Void> comp_constructor = ComponentName.getConstructor(
			TypeId.STRING,TypeId.STRING);
	methodCode.newInstance(localComp, comp_constructor, pkg, cls);
	methodCode.returnValue(localComp);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:22,
代码来源:ActivityClassGenerator.java

示例3: declareMethod_getResources

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getResources(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	TypeId<Resources> Resources = TypeId.get(Resources.class);
	MethodId<D, Resources> getResources = generatedType.getMethod(
			Resources, "getResources");
	Code code = dexMaker.declare(getResources, PUBLIC);
	Local<D> localThis = code.getThis(generatedType);
	Local<Resources> localRes = code.newLocal(Resources);
	Local<Resources> nullV = code.newLocal(Resources);
	code.loadConstant(nullV, null);
	FieldId<D, Resources> res = generatedType.getField(Resources, FIELD_RESOURCES);
	code.iget(res, localRes, localThis);
	//
	Label localResIsNull = new Label();
	code.compare(Comparison.NE, localResIsNull, localRes, nullV);
	MethodId<S, Resources> superGetResources = superType.getMethod(
			Resources, "getResources");
	code.invokeSuper(superGetResources, localRes, localThis);
	code.mark(localResIsNull);
	//
	code.returnValue(localRes);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:23,
代码来源:ActivityClassGenerator.java

示例4: declareMethod_getAssets

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getAssets(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	TypeId<AssetManager> AssetManager = TypeId.get(AssetManager.class);
	MethodId<D, AssetManager> getAssets = generatedType.getMethod(
			AssetManager, "getAssets");
	Code code = dexMaker.declare(getAssets, PUBLIC);
	Local<D> localThis = code.getThis(generatedType);
	Local<AssetManager> localAsm = code.newLocal(AssetManager);
	Local<AssetManager> nullV = code.newLocal(AssetManager);
	code.loadConstant(nullV, null);
	FieldId<D, AssetManager> res = generatedType.getField(AssetManager,
			FIELD_ASSERTMANAGER);
	code.iget(res, localAsm, localThis);
	Label localAsmIsNull = new Label();
	code.compare(Comparison.NE, localAsmIsNull, localAsm, nullV);
	MethodId<S, AssetManager> superGetAssetManager = superType.getMethod(
			AssetManager, "getAssets");
	code.invokeSuper(superGetAssetManager, localAsm, localThis);
	code.mark(localAsmIsNull);
	code.returnValue(localAsm);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:22,
代码来源:ActivityClassGenerator.java

示例5: declareMethod_startService

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_startService(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	TypeId<ComponentName> returnType = TypeId.get(ComponentName.class);
	TypeId<Intent> Intent = TypeId.get(Intent.class);
	MethodId<D, ComponentName> method = generatedType.getMethod(returnType,
			"startService",Intent);
	MethodId<ActivityOverider, ComponentName> methodOveride = ActivityOverider
			.getMethod(returnType, "overrideStartService"
					,TypeId.get(Activity.class),TypeId.STRING
					,Intent);
	Code methodCode = dexMaker.declare(method, PUBLIC);
	// locals
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<ComponentName> localComponentName = methodCode.newLocal(returnType);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	
	methodCode.invokeStatic(methodOveride,
			localComponentName//
			,localThis, pluginId
			, methodCode.getParameter(0, Intent)
			);
	methodCode.returnValue(localComponentName);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:26,
代码来源:ActivityClassGenerator.java

示例6: declareMethod_unbindService

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_unbindService(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	//void unbindService( conn);
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	TypeId<ServiceConnection> Conn = TypeId.get(ServiceConnection.class);
	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			"unbindService",Conn);
	MethodId<ActivityOverider, Void> methodOveride = ActivityOverider
			.getMethod(TypeId.VOID, "overrideUnbindService"
					,TypeId.get(Activity.class),TypeId.STRING
					,Conn);
	Code methodCode = dexMaker.declare(method, PUBLIC);
	// locals
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	
	methodCode.invokeStatic(methodOveride,
			null//
			,localThis, pluginId
			, methodCode.getParameter(0, Conn)
			);
	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:25,
代码来源:ActivityClassGenerator.java

示例7: declareLifeCyleMethod

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareLifeCyleMethod(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType,
		String methodName) {
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			methodName);
	Code methodCode = dexMaker.declare(method, PROTECTED);
	// locals
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
			methodName);
	methodCode.invokeSuper(superMethod, null, localThis);

	MethodId<ActivityOverider, Void> methodOveride = ActivityOverider
			.getMethod(TypeId.VOID, "callback_" + methodName,
					TypeId.STRING, TypeId.get(Activity.class));
	methodCode.invokeStatic(methodOveride, null, pluginId, localThis);
	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:22,
代码来源:ActivityClassGenerator.java

示例8: generateConstructorAndFields

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates class field that holds a reference to the associated
 * {@link view_inspector.probe.Interceptor} instance and the {@link View} constructor.
 */
private static <T, G extends T> void generateConstructorAndFields(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);
  dexMaker.declare(interceptorField, PRIVATE, null);

  final TypeId<?>[] types = classArrayToTypeArray(CONSTRUCTOR_ARG_TYPES);
  final MethodId<?, ?> constructor = generatedType.getConstructor(types);
  final Code constructorCode = dexMaker.declare(constructor, PUBLIC);

  final Local<?>[] params = new Local[types.length];
  for (int i = 0; i < params.length; ++i) {
    params[i] = constructorCode.getParameter(i, types[i]);
  }

  final MethodId<T, ?> superConstructor = baseType.getConstructor(types);
  final Local<G> thisRef = constructorCode.getThis(generatedType);
  constructorCode.invokeDirect(superConstructor, null, thisRef, params);
  constructorCode.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:25,
代码来源:DexProxyBuilder.java

示例9: generateSetMeasuredDimension

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#setMeasuredDimension(int, int)} method for
 * the proxy class.
 */
private static <T, G extends T> void generateSetMeasuredDimension(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final String methodName = ViewMethod.SET_MEASURED_DIMENSION.getName();

  final MethodId<T, Void> superMethod =
      baseType.getMethod(VOID_TYPE, methodName, TypeId.INT, TypeId.INT);

  final MethodId<G, Void> callsSuperMethod =
      generatedType.getMethod(VOID_TYPE, ViewMethod.SET_MEASURED_DIMENSION.getInvokeName(),
          TypeId.INT, TypeId.INT);

  final Code code = dexMaker.declare(callsSuperMethod, PUBLIC);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Integer> localWidth = code.getParameter(0, TypeId.INT);
  final Local<Integer> localHeight = code.getParameter(1, TypeId.INT);
  code.invokeSuper(superMethod, null, localThis, localWidth, localHeight);
  code.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:24,
代码来源:DexProxyBuilder.java

示例10: generateSetInterceptor

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#setMeasuredDimension(int, int)} method for
 * the proxy class.
 */
private static <T, G extends T> void generateSetInterceptor(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

  final String methodName = ViewMethod.SET_INTERCEPTOR.getName();

  final MethodId<G, Void> methodId =
      generatedType.getMethod(VOID_TYPE, methodName, INTERCEPTOR_TYPE);
  final Code code = dexMaker.declare(methodId, PUBLIC);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Interceptor> localInterceptor = code.getParameter(0, INTERCEPTOR_TYPE);
  code.iput(interceptorField, localThis, localInterceptor);
  code.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:21,
代码来源:DexProxyBuilder.java

示例11: declareMethod_getResources

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getResources(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    TypeId<Resources> Resources = TypeId.get(Resources.class);
    MethodId<D, Resources> getResources = generatedType.getMethod(
            Resources, "getResources");
    Code code = dexMaker.declare(getResources, PUBLIC);
    Local<D> localThis = code.getThis(generatedType);
    Local<Resources> localRes = code.newLocal(Resources);
    Local<Resources> nullV = code.newLocal(Resources);
    code.loadConstant(nullV, null);
    FieldId<D, Resources> res = generatedType.getField(Resources,
            FIELD_RESOURCES);
    code.iget(res, localRes, localThis);
    //
    Label localResIsNull = new Label();
    code.compare(Comparison.NE, localResIsNull, localRes, nullV);
    MethodId<S, Resources> superGetResources = superType.getMethod(
            Resources, "getResources");
    code.invokeSuper(superGetResources, localRes, localThis);
    code.mark(localResIsNull);
    //
    code.returnValue(localRes);
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:24,
代码来源:ActivityClassGenerator.java

示例12: declareMethod_getAssets

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getAssets(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    TypeId<AssetManager> AssetManager = TypeId.get(AssetManager.class);
    MethodId<D, AssetManager> getAssets = generatedType.getMethod(
            AssetManager, "getAssets");
    Code code = dexMaker.declare(getAssets, PUBLIC);
    Local<D> localThis = code.getThis(generatedType);
    Local<AssetManager> localAsm = code.newLocal(AssetManager);
    Local<AssetManager> nullV = code.newLocal(AssetManager);
    code.loadConstant(nullV, null);
    FieldId<D, AssetManager> res = generatedType.getField(AssetManager,
            FIELD_ASSERTMANAGER);
    code.iget(res, localAsm, localThis);
    Label localAsmIsNull = new Label();
    code.compare(Comparison.NE, localAsmIsNull, localAsm, nullV);
    MethodId<S, AssetManager> superGetAssetManager = superType.getMethod(
            AssetManager, "getAssets");
    code.invokeSuper(superGetAssetManager, localAsm, localThis);
    code.mark(localAsmIsNull);
    code.returnValue(localAsm);
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:22,
代码来源:ActivityClassGenerator.java

示例13: declareMethod_startService

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_startService(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    TypeId<ComponentName> returnType = TypeId.get(ComponentName.class);
    TypeId<Intent> Intent = TypeId.get(Intent.class);
    MethodId<D, ComponentName> method = generatedType.getMethod(returnType,
            "startService", Intent);
    MethodId<ActivityOverider, ComponentName> methodOveride = ActivityOverider
            .getMethod(returnType, "overrideStartService",
                    TypeId.get(Activity.class), TypeId.STRING, Intent);
    Code methodCode = dexMaker.declare(method, PUBLIC);
    // locals
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<ComponentName> localComponentName = methodCode
            .newLocal(returnType);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);

    methodCode.invokeStatic(methodOveride, localComponentName//
            , localThis, pluginId, methodCode.getParameter(0, Intent));
    methodCode.returnValue(localComponentName);
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:23,
代码来源:ActivityClassGenerator.java

示例14: declareMethod_unbindService

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_unbindService(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    // void unbindService( conn);
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    TypeId<ServiceConnection> Conn = TypeId.get(ServiceConnection.class);
    MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
            "unbindService", Conn);
    MethodId<ActivityOverider, Void> methodOveride = ActivityOverider
            .getMethod(TypeId.VOID, "overrideUnbindService",
                    TypeId.get(Activity.class), TypeId.STRING, Conn);
    Code methodCode = dexMaker.declare(method, PUBLIC);
    // locals
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);

    methodCode.invokeStatic(methodOveride, null//
            , localThis, pluginId, methodCode.getParameter(0, Conn));
    methodCode.returnVoid();
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:21,
代码来源:ActivityClassGenerator.java

示例15: declareMethod_stopService

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_stopService(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    // boolean stopService(intent);
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    TypeId<Boolean> returnType = TypeId.BOOLEAN;
    TypeId<Intent> Intent = TypeId.get(Intent.class);
    //
    MethodId<D, Boolean> method = generatedType.getMethod(returnType,
            "stopService", Intent);
    MethodId<ActivityOverider, Boolean> methodOveride = ActivityOverider
            .getMethod(returnType, "overrideStopService",
                    TypeId.get(Activity.class), TypeId.STRING, Intent);
    Code methodCode = dexMaker.declare(method, PUBLIC);
    // locals
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<Boolean> localBool = methodCode.newLocal(returnType);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);

    methodCode.invokeStatic(methodOveride, localBool//
            , localThis, pluginId, methodCode.getParameter(0, Intent));
    methodCode.returnValue(localBool);
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:24,
代码来源:ActivityClassGenerator.java

示例16: declareLifeCyleMethod

点赞 3

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareLifeCyleMethod(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType,
        String methodName) {
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
            methodName);
    Code methodCode = dexMaker.declare(method, PROTECTED);
    // locals
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);
    MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
            methodName);
    methodCode.invokeSuper(superMethod, null, localThis);

    MethodId<ActivityOverider, Void> methodOveride = ActivityOverider
            .getMethod(TypeId.VOID, "callback_" + methodName,
                    TypeId.STRING, TypeId.get(Activity.class));
    methodCode.invokeStatic(methodOveride, null, pluginId, localThis);
    methodCode.returnVoid();
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:22,
代码来源:ActivityClassGenerator.java

示例17: declareMethod_getIntent

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getIntent(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	TypeId<Intent> Intent = TypeId.get(Intent.class);
	TypeId<ComponentName> ComponentName = TypeId.get(ComponentName.class);
	String methodName = "getIntent";
	MethodId<D, Intent> method = generatedType
			.getMethod(Intent, methodName);
	MethodId<S, Intent> superMethod = superType
			.getMethod(Intent, methodName);
	
	Code code = dexMaker.declare(method, PUBLIC);
	Local<D> localThis = code.getThis(generatedType);
	Local<Intent> i = code.newLocal(Intent);
	Local<ComponentName> localComp =  code.newLocal(ComponentName);
	
	MethodId<D, ComponentName> getComponent = generatedType
			.getMethod(ComponentName, "getComponentName");
	
	code.invokeVirtual(getComponent, localComp, localThis);
	
	MethodId<Intent, Intent> setComponent = Intent
			.getMethod(Intent, "setComponent",ComponentName);
	
    code.invokeSuper(superMethod, i, localThis);
    code.invokeVirtual(setComponent, i, i, localComp);
    code.returnValue(i);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:28,
代码来源:ActivityClassGenerator.java

示例18: declareMethod_getPackageName

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_getPackageName(DexMaker dexMaker, TypeId<D> generatedType, String pkgName){
	MethodId<D, String> method = generatedType.getMethod(TypeId.STRING,
			"getPackageName");
	Code methodCode = dexMaker.declare(method, PROTECTED);
	Local<String> pkg = methodCode.newLocal(TypeId.STRING);
	methodCode.loadConstant(pkg, pkgName);
	methodCode.returnValue(pkg);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:9,
代码来源:ActivityClassGenerator.java

示例19: declareMethod_onCreate

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_onCreate(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	//
	// 声明 方法:onCreate
	TypeId<Bundle> Bundle = TypeId.get(Bundle.class);
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);

	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			"onCreate", Bundle);
	Code methodCode = dexMaker.declare(method, PROTECTED);
	// locals 
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Bundle> lcoalBundle = methodCode.getParameter(0, Bundle);
	Local<Boolean> lcoalCreated = methodCode.newLocal(TypeId.BOOLEAN);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	// this.mOnCreated = true;
	FieldId<D, Boolean> beforeOnCreate = generatedType.getField(TypeId.BOOLEAN, FIELD_mOnCreated);
	methodCode.loadConstant(lcoalCreated, true);
	methodCode.iput(beforeOnCreate, localThis, lcoalCreated);
	
	MethodId<ActivityOverider, Void> method_call_onCreate = ActivityOverider
			.getMethod(TypeId.VOID, "callback_onCreate", TypeId.STRING,
					TypeId.get(Activity.class));
	methodCode
			.invokeStatic(method_call_onCreate, null, pluginId, localThis);
	
	// super.onCreate()
	MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID, "onCreate",
			Bundle);
	methodCode.invokeSuper(superMethod, null, localThis, lcoalBundle);

	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:35,
代码来源:ActivityClassGenerator.java

示例20: declare_constructor

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declare_constructor(DexMaker dexMaker,
		TypeId<D> generatedType, TypeId<S> superType) {
	MethodId<D, Void> method = generatedType.getConstructor();
	Code constructorCode = dexMaker.declare(method, PUBLIC);
	Local<D> localThis = constructorCode.getThis(generatedType);
	MethodId<S, Void> superConstructor = superType.getConstructor();
	constructorCode.invokeDirect(superConstructor, null, localThis);
	constructorCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:10,
代码来源:ActivityClassGenerator.java

示例21: declareMethod_onBackPressed

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * 生成以下代码: <br/>
 * 
 * <pre>
 * public void onBackPressed() {
 * 	if (ActivityOverider.overrideOnbackPressed(this, pluginId)) {
 * 		super.onBackPressed();
 * 	}
 * }
 * </pre>
 * 
 * @param dexMaker
 * @param generatedType
 * @param superType
 */

private static <S, D extends S> void declareMethod_onBackPressed(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			"onBackPressed");
	Code methodCode = dexMaker.declare(method, PUBLIC);
	// locals -- 一个方法内的本地变量必须提前声明在所有操作之前
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Boolean> localBool = methodCode.newLocal(TypeId.BOOLEAN);
	Local<Boolean> localFalse = methodCode.newLocal(TypeId.BOOLEAN);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);

	methodCode.loadConstant(localFalse, false);

	MethodId<ActivityOverider, Boolean> methodOveride = ActivityOverider
			.getMethod(TypeId.BOOLEAN, "overrideOnbackPressed"
					, TypeId.get(Activity.class), TypeId.STRING);
	methodCode.invokeStatic(methodOveride, localBool, localThis, pluginId);
	// codeBlock: if start
	Label localBool_isInvokeSuper = new Label();
	methodCode.compare(Comparison.EQ, localBool_isInvokeSuper, localBool,
			localFalse);
	MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
			"onBackPressed");
	methodCode.invokeSuper(superMethod, null, localThis);
	methodCode.mark(localBool_isInvokeSuper);
	// codeBlock: if end
	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:47,
代码来源:ActivityClassGenerator.java

示例22: declareMethod_bindService

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_bindService(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	//boolean bindService(intent, conn, flags);
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	TypeId<Boolean> returnType = TypeId.BOOLEAN;
	TypeId<Intent> Intent = TypeId.get(Intent.class);
	TypeId<ServiceConnection> Conn = TypeId.get(ServiceConnection.class);
	MethodId<D, Boolean> method = generatedType.getMethod(returnType,
			"bindService",Intent,Conn,TypeId.INT);
	MethodId<ActivityOverider, Boolean> methodOveride = ActivityOverider
			.getMethod(returnType, "overrideBindService"
					,TypeId.get(Activity.class),TypeId.STRING
					,Intent,Conn,TypeId.INT);
	Code methodCode = dexMaker.declare(method, PUBLIC);
	// locals
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Boolean> localBool = methodCode.newLocal(returnType);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	
	methodCode.invokeStatic(methodOveride,
			localBool//
			,localThis, pluginId
			, methodCode.getParameter(0, Intent)
			, methodCode.getParameter(1, Conn)
			, methodCode.getParameter(2, TypeId.INT)
			);
	methodCode.returnValue(localBool);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:30,
代码来源:ActivityClassGenerator.java

示例23: declareMethod_stopService

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_stopService(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	//boolean stopService(intent);
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	TypeId<Boolean> returnType = TypeId.BOOLEAN;
	TypeId<Intent> Intent = TypeId.get(Intent.class);
	//
	MethodId<D, Boolean> method = generatedType.getMethod(returnType,
			"stopService",Intent);
	MethodId<ActivityOverider, Boolean> methodOveride = ActivityOverider
			.getMethod(returnType, "overrideStopService"
					,TypeId.get(Activity.class),TypeId.STRING
					,Intent);
	Code methodCode = dexMaker.declare(method, PUBLIC);
	// locals
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Boolean> localBool = methodCode.newLocal(returnType);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	
	methodCode.invokeStatic(methodOveride,
			localBool//
			,localThis, pluginId
			, methodCode.getParameter(0, Intent)
			);
	methodCode.returnValue(localBool);
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:28,
代码来源:ActivityClassGenerator.java

示例24: declareFields

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareFields(DexMaker dexMaker,
        TypeId<D> generatedType, TypeId<S> superType, String pluginId) {
    FieldId<D, String> _pluginId = generatedType.getField(TypeId.STRING,
            "_pluginId");
    dexMaker.declare(_pluginId, PRIVATE | STATIC | FINAL, pluginId);

    TypeId<AssetManager> AssetManager = TypeId.get(AssetManager.class);
    TypeId<Resources> Resources = TypeId.get(Resources.class);
    FieldId<D, AssetManager> asm = generatedType.getField(AssetManager,
            FIELD_ASSERTMANAGER);
    dexMaker.declare(asm, PRIVATE, null);
    FieldId<D, Resources> res = generatedType.getField(Resources,
            FIELD_RESOURCES);
    dexMaker.declare(res, PRIVATE, null);
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:16,
代码来源:ActivityClassGenerator.java

示例25: declare_constructor

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declare_constructor(DexMaker dexMaker,
        TypeId<D> generatedType, TypeId<S> superType) {
    MethodId<D, Void> method = generatedType.getConstructor();
    Code constructorCode = dexMaker.declare(method, PUBLIC);
    Local<D> localThis = constructorCode.getThis(generatedType);
    MethodId<S, Void> superConstructor = superType.getConstructor();
    constructorCode.invokeDirect(superConstructor, null, localThis);
    constructorCode.returnVoid();// void 方法也必须显式的声明返回void
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:10,
代码来源:ActivityClassGenerator.java

示例26: declareMethod_onBackPressed

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * 生成以下代码: <br/>
 * 
 * <pre>
 * public void onBackPressed() {
 *     if (ActivityOverider.overrideOnbackPressed(this, pluginId)) {
 *         super.onBackPressed();
 *     }
 * }
 * </pre>
 * 
 * @param dexMaker
 * @param generatedType
 * @param superType
 */

private static <S, D extends S> void declareMethod_onBackPressed(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
            "onBackPressed");
    Code methodCode = dexMaker.declare(method, PUBLIC);
    // locals -- 一个方法内的本地变量必须提前声明在所有操作之前
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<Boolean> localBool = methodCode.newLocal(TypeId.BOOLEAN);
    Local<Boolean> localFalse = methodCode.newLocal(TypeId.BOOLEAN);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);

    methodCode.loadConstant(localFalse, false);

    MethodId<ActivityOverider, Boolean> methodOveride = ActivityOverider
            .getMethod(TypeId.BOOLEAN, "overrideOnbackPressed",
                    TypeId.get(Activity.class), TypeId.STRING);
    methodCode.invokeStatic(methodOveride, localBool, localThis, pluginId);
    // codeBlock: if start
    Label localBool_isInvokeSuper = new Label();
    methodCode.compare(Comparison.EQ, localBool_isInvokeSuper, localBool,
            localFalse);
    MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
            "onBackPressed");
    methodCode.invokeSuper(superMethod, null, localThis);
    methodCode.mark(localBool_isInvokeSuper);
    // codeBlock: if end
    methodCode.returnVoid();
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:47,
代码来源:ActivityClassGenerator.java

示例27: declareMethod_bindService

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_bindService(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    // boolean bindService(intent, conn, flags);
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    TypeId<Boolean> returnType = TypeId.BOOLEAN;
    TypeId<Intent> Intent = TypeId.get(Intent.class);
    TypeId<ServiceConnection> Conn = TypeId.get(ServiceConnection.class);
    MethodId<D, Boolean> method = generatedType.getMethod(returnType,
            "bindService", Intent, Conn, TypeId.INT);
    MethodId<ActivityOverider, Boolean> methodOveride = ActivityOverider
            .getMethod(returnType, "overrideBindService",
                    TypeId.get(Activity.class), TypeId.STRING, Intent,
                    Conn, TypeId.INT);
    Code methodCode = dexMaker.declare(method, PUBLIC);
    // locals
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<Boolean> localBool = methodCode.newLocal(returnType);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);

    methodCode.invokeStatic(
            methodOveride,
            localBool//
            , localThis, pluginId, methodCode.getParameter(0, Intent),
            methodCode.getParameter(1, Conn),
            methodCode.getParameter(2, TypeId.INT));
    methodCode.returnValue(localBool);
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:29,
代码来源:ActivityClassGenerator.java

示例28: createActivityDex

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * 
 * @param superClassName
 * @param targetClassName
 * @param pluginId
 * @param pkgName
 * @return
 */
public static <S, D extends S> byte[] createActivityDex(
		final String superClassName, final String targetClassName,
		final String pluginId, String pkgName) {

	DexMaker dexMaker = new DexMaker();

	TypeId<D> generatedType = TypeId.get('L' + targetClassName.replace('.',
			'/') + ';');

	TypeId<S> superType = TypeId
			.get('L' + superClassName.replace('.', '/') + ';');
	// 声明类
	dexMaker.declare(generatedType, "", PUBLIC | FINAL, superType);
	// 定义字段
	//private static final String _pluginId = @param{pluginId};
	// private AssetManager asm;
	// private Resources res;
	declareFields(dexMaker, generatedType, superType, pluginId,pkgName);
	// 声明 默认构造方法
	declare_constructor(dexMaker, generatedType, superType);

	// 声明 方法:onCreate
	declareMethod_onCreate(dexMaker, generatedType, superType);
	// 声明 方法:public AssetManager getAssets()
	declareMethod_getAssets(dexMaker, generatedType, superType);
	// 声明 方法:public Resources getResources()
	declareMethod_getResources(dexMaker, generatedType, superType);
	/*
	 * 声明 方法:startActivityForResult(Intent intent, int requestCode, Bundle
	 * options)
	 */
	declareMethod_startActivityForResult(dexMaker, generatedType,superType);
	// 声明 方法:public void onBackPressed()
	declareMethod_onBackPressed(dexMaker, generatedType, superType);
	
	declareMethod_startService(dexMaker, generatedType, superType);
	declareMethod_bindService(dexMaker, generatedType, superType);
	declareMethod_unbindService(dexMaker, generatedType, superType);
	declareMethod_stopService(dexMaker, generatedType, superType);
	// Create life Cycle methods
	declareLifeCyleMethod(dexMaker, generatedType, superType, "onResume");
	declareLifeCyleMethod(dexMaker, generatedType, superType, "onStart");
	declareLifeCyleMethod(dexMaker, generatedType, superType, "onRestart");
	declareLifeCyleMethod(dexMaker, generatedType, superType, "onPause");
	declareLifeCyleMethod(dexMaker, generatedType, superType, "onStop");
	declareLifeCyleMethod(dexMaker, generatedType, superType, "onDestroy");

	declareMethod_attachBaseContext(dexMaker, generatedType, superType);
	
	declareMethod_getComponentName(dexMaker, generatedType, superType, superClassName);
	declareMethod_getPackageName(dexMaker, generatedType, pkgName);
	declareMethod_getIntent(dexMaker, generatedType, superType);
	declareMethod_setTheme(dexMaker, generatedType, superType);
	// Create the dex Content
	byte[] dex = dexMaker.generate();
	return dex;
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:66,
代码来源:ActivityClassGenerator.java

示例29: declareMethod_setTheme

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_setTheme(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	// Types
	final String methodName = "setTheme";
	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			methodName, TypeId.INT);
	
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	// static int ActivityOverider::getPlugActivityTheme(Activity fromAct,String pluginId)
	MethodId<ActivityOverider, Integer> methodOveride = ActivityOverider
			.getMethod(TypeId.INT, "getPlugActivityTheme", TypeId.get(Activity.class),
					TypeId.STRING);
	// locals 
	Code methodCode = dexMaker.declare(method, PROTECTED);
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Integer> resId = methodCode.getParameter(0, TypeId.INT);
	Local<Integer> int0 = methodCode.newLocal(TypeId.INT);
	Local<Boolean> lcoalonCreate = methodCode.newLocal(TypeId.BOOLEAN);
	Local<Boolean> localFalse = methodCode.newLocal(TypeId.BOOLEAN);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	/* int resId = paramThemeId;
	 * if( !OnCreated ){
	 *    resId = ActivityOverider.getPlugActivityTheme(this,pluginId);
	 * }
	 * if(resId!=0){
	 *   super.setTheme(resId);
	 * } 
	 */
	FieldId<D, Boolean> onCreated = generatedType.getField(TypeId.BOOLEAN, FIELD_mOnCreated);
	methodCode.iget(onCreated, lcoalonCreate, localThis);
	{
		Label ifBeforeOncreate = new Label();
		methodCode.loadConstant(localFalse, false);
		methodCode.compare(Comparison.NE, ifBeforeOncreate, lcoalonCreate, localFalse);
		methodCode.invokeStatic(methodOveride, resId, localThis,pluginId);
		methodCode.mark(ifBeforeOncreate);
	}
	//
	Label if_resId = new Label();
	methodCode.loadConstant(int0, 0);
	methodCode.compare(Comparison.EQ, if_resId, resId, int0);
	MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID, methodName, TypeId.INT);
	methodCode.invokeSuper(superMethod, null, localThis, resId);
	methodCode.mark(if_resId);
	
	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:49,
代码来源:ActivityClassGenerator.java

示例30: declareMethod_attachBaseContext

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_attachBaseContext(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	// Types
	TypeId<Context> Context = TypeId.get(Context.class);
	TypeId<AssetManager> AssetManager = TypeId.get(AssetManager.class);
	TypeId<Resources> Resources = TypeId.get(Resources.class);
	FieldId<D, AssetManager> assertManager = generatedType.getField(AssetManager,
			FIELD_ASSERTMANAGER);
	FieldId<D, Resources> resources = generatedType.getField(Resources, FIELD_RESOURCES);
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	TypeId<DisplayMetrics> DisplayMetrics = TypeId
			.get(DisplayMetrics.class);
	TypeId<Configuration> Configuration = TypeId.get(Configuration.class);
	
	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			"attachBaseContext", Context);
	Code methodCode = dexMaker.declare(method, PROTECTED);
	TypeId<Object[]> ObjArr = TypeId.get(Object[].class);
	// locals -- 一个方法内的本地变量必须提前声明在所有操作之前
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Object[]> rsArr = methodCode.newLocal(ObjArr);
	Local<Object> rsArr0 = methodCode.newLocal(TypeId.OBJECT);
	Local<Object> rsArr1 = methodCode.newLocal(TypeId.OBJECT);
	Local<Context> base = methodCode.getParameter(0, Context);
	Local<Context> newbase = methodCode.newLocal(Context);
	Local<Integer> index0 = methodCode.newLocal(TypeId.INT);
	Local<Integer> index1 = methodCode.newLocal(TypeId.INT);
	Local<AssetManager> localAsm = methodCode.newLocal(AssetManager);
	Local<Resources> superRes = methodCode.newLocal(Resources);
	Local<DisplayMetrics> mtrc = methodCode.newLocal(DisplayMetrics);
	Local<Configuration> cfg = methodCode.newLocal(Configuration);
	Local<Resources> resLocal = methodCode.newLocal(Resources);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	methodCode.loadConstant(index0, 0);
	methodCode.loadConstant(index1, 1);
	// codes:
	//  Object [] rs = ActivitiOverrider.overrideAttachBaseContext(_pluginId, activity, base);
	MethodId<ActivityOverider, Object[]> methodOverride = ActivityOverider.getMethod(ObjArr,
			"overrideAttachBaseContext",TypeId.STRING,TypeId.get(Activity.class),Context);
	methodCode.invokeStatic(methodOverride, rsArr, pluginId,localThis,base);
	methodCode.aget(rsArr0, rsArr, index0);
	methodCode.aget(rsArr1, rsArr, index1);
	methodCode.cast(newbase, rsArr0);// base = rs[0];
	methodCode.cast(localAsm, rsArr1);// localAsm = rs[1];
	
	
	methodCode.iput(assertManager, localThis, localAsm);
	// superRes = base.getResources();
	MethodId<Context, Resources> methodGetResources = Context.getMethod(Resources,
			"getResources");
	methodCode.invokeVirtual(methodGetResources, superRes, base);

	//
	// superRes.getDisplayMetrics()
	MethodId<Resources, DisplayMetrics> getDisplayMetrics = Resources
			.getMethod(DisplayMetrics, "getDisplayMetrics");
	methodCode.invokeVirtual(getDisplayMetrics, mtrc, superRes);
	//
	// superRes.getConfiguration()
	MethodId<Resources, Configuration> getConfiguration = Resources
			.getMethod(Configuration, "getConfiguration");
	methodCode.invokeVirtual(getConfiguration, cfg, superRes);
	//
	// res = new Resources(asm, superRes.getDisplayMetrics(), superRes.getConfiguration());

	MethodId<Resources, Void> res_constructor = Resources.getConstructor(
			AssetManager, DisplayMetrics, Configuration);
	methodCode.newInstance(resLocal, res_constructor, localAsm, mtrc, cfg);
	methodCode.iput(resources, localThis, resLocal);
	
	MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
			"attachBaseContext", Context);
	methodCode.invokeSuper(superMethod, null, localThis, newbase);
	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:77,
代码来源:ActivityClassGenerator.java

示例31: declareMethod_startActivityForResult

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_startActivityForResult(
		DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
	TypeId<Intent> intent = TypeId.get(Intent.class);
	TypeId<Integer> requestCode = TypeId.INT;
	TypeId<Bundle> bundle = TypeId.get(Bundle.class);
	
	TypeId<?>[] params;
	String methodName = "startActivityForResult";
	final boolean isNewSdk = android.os.Build.VERSION.SDK_INT > 10;
	if (isNewSdk) {
		params = new TypeId[] { intent, requestCode, bundle };
	} else {
		params = new TypeId[] { intent, requestCode };
	}
	MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
			methodName, params);
	MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
			methodName, params);
	Code methodCode = dexMaker.declare(method, PUBLIC);
	TypeId<ActivityOverider> ActivityOverider = TypeId
			.get(ActivityOverider.class);
	MethodId<ActivityOverider, Intent> methodOveride = ActivityOverider
			.getMethod(intent, "overrideStartActivityForResult",
					TypeId.get(Activity.class),TypeId.STRING,
					intent, requestCode, bundle);
	// locals
	Local<D> localThis = methodCode.getThis(generatedType);
	Local<Intent> newIntent = methodCode.newLocal(intent);
	Local<Bundle> nullParamBundle = methodCode.newLocal(bundle);
	Local<String> pluginId = get_pluginId(generatedType, methodCode);
	methodCode.loadConstant(nullParamBundle, null);
	Local<?> args[];
	if (isNewSdk) {
		args = new Local[] {localThis
				, pluginId
				, methodCode.getParameter(0, intent)//
				, methodCode.getParameter(1, requestCode)//
				, methodCode.getParameter(2, bundle)//
				};
		methodCode.invokeStatic(methodOveride, newIntent, args);
		// super.startActivityForResult(...)
		
		methodCode.invokeSuper(superMethod, null,
				localThis//
				, newIntent//
				, methodCode.getParameter(1, requestCode)//
				, methodCode.getParameter(2, bundle) //
				);
	} else {
		args = new Local[] {localThis
				, pluginId
				, methodCode.getParameter(0, intent)//
				, methodCode.getParameter(1, requestCode)//
				,nullParamBundle
				};
		methodCode.invokeStatic(methodOveride, newIntent, args);
		methodCode.invokeSuper(superMethod, null,
				localThis//
				, newIntent//
				, methodCode.getParameter(1, requestCode)//
				);
	}
	methodCode.returnVoid();
}
 

开发者ID:frankswu,
项目名称:android-saf-plugin-demo,
代码行数:65,
代码来源:ActivityClassGenerator.java

示例32: generateOnMeasureMethod

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#onMeasure(int, int)} method for the proxy class.
 */
private static <T, G extends T> void generateOnMeasureMethod(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

  final String methodName = ViewMethod.ON_MEASURE.getName();

  final MethodId<T, Void> superMethod =
      baseType.getMethod(VOID_TYPE, methodName, TypeId.INT, TypeId.INT);
  final MethodId<Interceptor, Void> onMeasureMethod =
      INTERCEPTOR_TYPE.getMethod(VOID_TYPE, methodName, VIEW_TYPE, TypeId.INT, TypeId.INT);

  final MethodId<G, Void> methodId =
      generatedType.getMethod(VOID_TYPE, methodName, TypeId.INT, TypeId.INT);
  final Code code = dexMaker.declare(methodId, PUBLIC);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Interceptor> nullInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Interceptor> localInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Integer> localWidth = code.getParameter(0, TypeId.INT);
  final Local<Integer> localHeight = code.getParameter(1, TypeId.INT);

  code.iget(interceptorField, localInterceptor, localThis);
  code.loadConstant(nullInterceptor, null);

  // Interceptor is not null, call it.
  final Label interceptorNullCase = new Label();
  code.compare(Comparison.EQ, interceptorNullCase, nullInterceptor, localInterceptor);
  code.invokeVirtual(onMeasureMethod, null, localInterceptor, localThis, localWidth, localHeight);
  code.returnVoid();

  // Interceptor is null, call super method.
  code.mark(interceptorNullCase);
  code.invokeSuper(superMethod, null, localThis, localWidth, localHeight);
  code.returnVoid();

  final MethodId<G, Void> callsSuperMethod =
      generatedType.getMethod(VOID_TYPE, ViewMethod.ON_MEASURE.getInvokeName(), TypeId.INT,
          TypeId.INT);

  final Code superCode = dexMaker.declare(callsSuperMethod, PUBLIC);

  final Local<G> superThis = superCode.getThis(generatedType);
  final Local<Integer> superLocalWidth = superCode.getParameter(0, TypeId.INT);
  final Local<Integer> superLocalHeight = superCode.getParameter(1, TypeId.INT);
  superCode.invokeSuper(superMethod, null, superThis, superLocalWidth, superLocalHeight);
  superCode.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:52,
代码来源:DexProxyBuilder.java

示例33: generateOnLayoutMethod

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#onLayout(boolean, int, int, int, int)} method
 * for the proxy class.
 */
private static <T, G extends T> void generateOnLayoutMethod(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

  final String methodName = ViewMethod.ON_LAYOUT.getName();

  final MethodId<T, Void> superMethod =
      baseType.getMethod(VOID_TYPE, methodName, TypeId.BOOLEAN, TypeId.INT, TypeId.INT,
          TypeId.INT, TypeId.INT);
  final MethodId<Interceptor, Void> onLayoutMethod =
      INTERCEPTOR_TYPE.getMethod(VOID_TYPE, methodName, VIEW_TYPE, TypeId.BOOLEAN, TypeId.INT,
          TypeId.INT, TypeId.INT, TypeId.INT);

  final MethodId<G, Void> methodId =
      generatedType.getMethod(VOID_TYPE, methodName, TypeId.BOOLEAN, TypeId.INT, TypeId.INT,
          TypeId.INT, TypeId.INT);
  final Code code = dexMaker.declare(methodId, PUBLIC);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Interceptor> nullInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Interceptor> localInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Boolean> localChanged = code.getParameter(0, TypeId.BOOLEAN);
  final Local<Integer> localLeft = code.getParameter(1, TypeId.INT);
  final Local<Integer> localTop = code.getParameter(2, TypeId.INT);
  final Local<Integer> localRight = code.getParameter(3, TypeId.INT);
  final Local<Integer> localBottom = code.getParameter(4, TypeId.INT);

  code.iget(interceptorField, localInterceptor, localThis);
  code.loadConstant(nullInterceptor, null);

  // Interceptor is not null, call it.
  final Label interceptorNullCase = new Label();
  code.compare(Comparison.EQ, interceptorNullCase, nullInterceptor, localInterceptor);
  code.invokeVirtual(onLayoutMethod, null, localInterceptor, localThis, localChanged, localLeft,
      localTop, localRight, localBottom);
  code.returnVoid();

  // Interceptor is null, call super method.
  code.mark(interceptorNullCase);
  code.invokeSuper(superMethod, null, localThis, localChanged, localLeft, localTop, localRight,
      localBottom);
  code.returnVoid();

  final MethodId<G, Void> callsSuperMethod =
      generatedType.getMethod(VOID_TYPE, ViewMethod.ON_LAYOUT.getInvokeName(), TypeId.BOOLEAN,
          TypeId.INT, TypeId.INT, TypeId.INT, TypeId.INT);

  final Code superCode = dexMaker.declare(callsSuperMethod, PUBLIC);

  final Local<G> superThis = superCode.getThis(generatedType);
  final Local<Boolean> superLocalChanged = superCode.getParameter(0, TypeId.BOOLEAN);
  final Local<Integer> superLocalLeft = superCode.getParameter(1, TypeId.INT);
  final Local<Integer> superLocalTop = superCode.getParameter(2, TypeId.INT);
  final Local<Integer> superLocalRight = superCode.getParameter(3, TypeId.INT);
  final Local<Integer> superLocalBottom = superCode.getParameter(4, TypeId.INT);
  superCode.invokeSuper(superMethod, null, superThis, superLocalChanged, superLocalLeft,
      superLocalTop, superLocalRight, superLocalBottom);
  superCode.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:65,
代码来源:DexProxyBuilder.java

示例34: generateDrawMethod

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#draw(Canvas)} method for the proxy class.
 */
private static <T, G extends T> void generateDrawMethod(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType, ViewMethod viewMethod, int modifier) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

  final String methodName = viewMethod.getName();

  final MethodId<T, Void> superMethod = baseType.getMethod(VOID_TYPE, methodName, CANVAS_TYPE);
  final MethodId<Interceptor, Void> drawMethod =
      INTERCEPTOR_TYPE.getMethod(VOID_TYPE, methodName, VIEW_TYPE, CANVAS_TYPE);

  final MethodId<G, Void> methodId = generatedType.getMethod(VOID_TYPE, methodName, CANVAS_TYPE);
  final Code code = dexMaker.declare(methodId, modifier);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Interceptor> nullInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Interceptor> localInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Canvas> localCanvas = code.getParameter(0, CANVAS_TYPE);

  code.iget(interceptorField, localInterceptor, localThis);
  code.loadConstant(nullInterceptor, null);

  // Interceptor is not null, call it.
  final Label interceptorNullCase = new Label();
  code.compare(Comparison.EQ, interceptorNullCase, nullInterceptor, localInterceptor);
  code.invokeVirtual(drawMethod, null, localInterceptor, localThis, localCanvas);
  code.returnVoid();

  // Interceptor is null, call super method.
  code.mark(interceptorNullCase);
  code.invokeSuper(superMethod, null, localThis, localCanvas);
  code.returnVoid();

  final MethodId<G, Void> callsSuperMethod =
      generatedType.getMethod(VOID_TYPE, viewMethod.getInvokeName(), CANVAS_TYPE);

  final Code superCode = dexMaker.declare(callsSuperMethod, PUBLIC);

  final Local<G> superThis = superCode.getThis(generatedType);
  final Local<Canvas> superLocalCanvas = superCode.getParameter(0, CANVAS_TYPE);
  superCode.invokeSuper(superMethod, null, superThis, superLocalCanvas);
  superCode.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:47,
代码来源:DexProxyBuilder.java

示例35: generateDrawMethods

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#onDraw(Canvas)} method for the proxy class.
 */
private static <T, G extends T> void generateDrawMethods(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  generateDrawMethod(dexMaker, generatedType, baseType, ViewMethod.DRAW, PUBLIC);
  generateDrawMethod(dexMaker, generatedType, baseType, ViewMethod.ON_DRAW, PUBLIC);
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:9,
代码来源:DexProxyBuilder.java

示例36: generateRequestLayoutMethod

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#requestLayout()} method for the proxy class.
 */
private static <T, G extends T> void generateRequestLayoutMethod(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

  final String methodName = ViewMethod.REQUEST_LAYOUT.getName();

  final MethodId<T, Void> superMethod = baseType.getMethod(VOID_TYPE, methodName);
  final MethodId<Interceptor, Void> requestLayoutMethod =
      INTERCEPTOR_TYPE.getMethod(VOID_TYPE, methodName, VIEW_TYPE);

  final MethodId<?, ?> methodId = generatedType.getMethod(VOID_TYPE, methodName);
  final Code code = dexMaker.declare(methodId, PUBLIC);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Interceptor> nullInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Interceptor> localInterceptor = code.newLocal(INTERCEPTOR_TYPE);

  code.iget(interceptorField, localInterceptor, localThis);
  code.loadConstant(nullInterceptor, null);

  // Interceptor is not null, call it.
  final Label interceptorNullCase = new Label();
  code.compare(Comparison.EQ, interceptorNullCase, nullInterceptor, localInterceptor);
  code.invokeVirtual(requestLayoutMethod, null, localInterceptor, localThis);
  code.returnVoid();

  // Interceptor is null, call super method.
  code.mark(interceptorNullCase);
  code.invokeSuper(superMethod, null, localThis);
  code.returnVoid();

  final MethodId<G, Void> callsSuperMethod =
      generatedType.getMethod(VOID_TYPE, ViewMethod.REQUEST_LAYOUT.getInvokeName());

  final Code superCode = dexMaker.declare(callsSuperMethod, PUBLIC);

  final Local<G> superThis = superCode.getThis(generatedType);
  superCode.invokeSuper(superMethod, null, superThis);
  superCode.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:45,
代码来源:DexProxyBuilder.java

示例37: generateForceLayoutMethod

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * Generates the {@link View#forceLayout()} method for the proxy class.
 */
private static <T, G extends T> void generateForceLayoutMethod(DexMaker dexMaker,
    TypeId<G> generatedType, TypeId<T> baseType) {
  final FieldId<G, Interceptor> interceptorField =
      generatedType.getField(INTERCEPTOR_TYPE, FIELD_NAME_INTERCEPTOR);

  final String methodName = ViewMethod.FORCE_LAYOUT.getName();

  final MethodId<T, Void> superMethod = baseType.getMethod(VOID_TYPE, methodName);
  final MethodId<Interceptor, Void> forceLayoutMethod =
      INTERCEPTOR_TYPE.getMethod(VOID_TYPE, methodName, VIEW_TYPE);

  final MethodId<?, ?> methodId = generatedType.getMethod(VOID_TYPE, methodName);
  final Code code = dexMaker.declare(methodId, PUBLIC);

  final Local<G> localThis = code.getThis(generatedType);
  final Local<Interceptor> nullInterceptor = code.newLocal(INTERCEPTOR_TYPE);
  final Local<Interceptor> localInterceptor = code.newLocal(INTERCEPTOR_TYPE);

  code.iget(interceptorField, localInterceptor, localThis);
  code.loadConstant(nullInterceptor, null);

  // Interceptor is not null, call it.
  final Label interceptorNullCase = new Label();
  code.compare(Comparison.EQ, interceptorNullCase, nullInterceptor, localInterceptor);
  code.invokeVirtual(forceLayoutMethod, null, localInterceptor, localThis);
  code.returnVoid();

  // Interceptor is null, call super method.
  code.mark(interceptorNullCase);
  code.invokeSuper(superMethod, null, localThis);
  code.returnVoid();

  final MethodId<G, Void> callsSuperMethod =
      generatedType.getMethod(VOID_TYPE, ViewMethod.FORCE_LAYOUT.getInvokeName());

  final Code superCode = dexMaker.declare(callsSuperMethod, PUBLIC);

  final Local<G> superThis = superCode.getThis(generatedType);
  superCode.invokeSuper(superMethod, null, superThis);
  superCode.returnVoid();
}
 

开发者ID:xfumihiro,
项目名称:ViewInspector,
代码行数:45,
代码来源:DexProxyBuilder.java

示例38: createActivityDex

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
/**
 * 
 * @param superClassName
 * @param targetClassName
 * @param pluginId
 * @param pkgName
 * @return
 */
public static <S, D extends S> byte[] createActivityDex(
        final String superClassName, final String targetClassName,
        final String pluginId, String pkgName) {

    DexMaker dexMaker = new DexMaker();

    TypeId<D> generatedType = TypeId.get('L' + targetClassName.replace('.',
            '/') + ';');

    TypeId<S> superType = TypeId
            .get('L' + superClassName.replace('.', '/') + ';');
    // 声明类
    dexMaker.declare(generatedType, "", PUBLIC | FINAL, superType);
    // 定义字段
    // private static final String _pluginId = @param{pluginId};
    // private AssetManager asm;
    // private Resources res;
    declareFields(dexMaker, generatedType, superType, pluginId);
    // 声明 默认构造方法
    declare_constructor(dexMaker, generatedType, superType);

    // 声明 方法:onCreate
    declareMethod_onCreate(dexMaker, generatedType, superType);
    // 声明 方法:public AssetManager getAssets()
    declareMethod_getAssets(dexMaker, generatedType, superType);
    // 声明 方法:public Resources getResources()
    declareMethod_getResources(dexMaker, generatedType, superType);
    /*
     * 声明 方法:startActivityForResult(Intent intent, int requestCode, Bundle
     * options)
     */
    declareMethod_startActivityForResult(dexMaker, generatedType, superType);
    // 声明 方法:public void onBackPressed()
    declareMethod_onBackPressed(dexMaker, generatedType, superType);

    declareMethod_startService(dexMaker, generatedType, superType);
    declareMethod_bindService(dexMaker, generatedType, superType);
    declareMethod_unbindService(dexMaker, generatedType, superType);
    declareMethod_stopService(dexMaker, generatedType, superType);
    // declareMethod_getPackageName(dexMaker, generatedType, superType,
    // pkgName);
    // Create the dex Content
    declareLifeCyleMethod(dexMaker, generatedType, superType, "onResume");
    declareLifeCyleMethod(dexMaker, generatedType, superType, "onStart");
    declareLifeCyleMethod(dexMaker, generatedType, superType, "onRestart");
    declareLifeCyleMethod(dexMaker, generatedType, superType, "onPause");
    declareLifeCyleMethod(dexMaker, generatedType, superType, "onStop");
    declareLifeCyleMethod(dexMaker, generatedType, superType, "onDestroy");

    byte[] dex = dexMaker.generate();
    return dex;
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:61,
代码来源:ActivityClassGenerator.java

示例39: declareMethod_onCreate

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private static <S, D extends S> void declareMethod_onCreate(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    TypeId<AssetManager> AssetManager = TypeId.get(AssetManager.class);
    TypeId<Resources> Resources = TypeId.get(Resources.class);
    // TypeId<Theme> Theme = TypeId.get(Theme.class);
    FieldId<D, AssetManager> assertManager = generatedType.getField(
            AssetManager, FIELD_ASSERTMANAGER);
    FieldId<D, Resources> resources = generatedType.getField(Resources,
            FIELD_RESOURCES);
    //
    // 声明 方法:onCreate
    TypeId<Bundle> Bundle = TypeId.get(Bundle.class);
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    TypeId<DisplayMetrics> DisplayMetrics = TypeId
            .get(DisplayMetrics.class);
    TypeId<Configuration> Configuration = TypeId.get(Configuration.class);

    MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
            "onCreate", Bundle);
    Code methodCode = dexMaker.declare(method, PROTECTED);
    // locals -- 一个方法内的本地变量必须提前声明在所有操作之前
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<Bundle> lcoalBundle = methodCode.getParameter(0, Bundle);
    Local<AssetManager> localAsm = methodCode.newLocal(AssetManager);
    Local<Resources> superRes = methodCode.newLocal(Resources);
    Local<DisplayMetrics> mtrc = methodCode.newLocal(DisplayMetrics);
    Local<Configuration> cfg = methodCode.newLocal(Configuration);
    Local<Resources> resLocal = methodCode.newLocal(Resources);
    // Local<Theme> localTheme = methodCode.newLocal(Theme);
    // Local<Theme> superTheme = methodCode.newLocal(Theme);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);
    // ActivityOverider:
    // public static AssetManager getAssetManager(String,Activity)
    MethodId<ActivityOverider, AssetManager> methodOveride = ActivityOverider
            .getMethod(AssetManager, "getAssetManager", TypeId.STRING,
                    TypeId.get(Activity.class));
    //
    methodCode.invokeStatic(methodOveride, localAsm, pluginId, localThis);
    methodCode.iput(assertManager, localThis, localAsm);
    MethodId methodGetResources = superType.getMethod(Resources,
            "getResources");
    methodCode.invokeSuper(methodGetResources, superRes, localThis);

    //
    // superRes.getDisplayMetrics()
    MethodId<Resources, DisplayMetrics> getDisplayMetrics = Resources
            .getMethod(DisplayMetrics, "getDisplayMetrics");
    methodCode.invokeVirtual(getDisplayMetrics, mtrc, superRes);
    //
    // superRes.getConfiguration()
    MethodId<Resources, Configuration> getConfiguration = Resources
            .getMethod(Configuration, "getConfiguration");
    methodCode.invokeVirtual(getConfiguration, cfg, superRes);
    //
    // res = new Resources(asm, superRes.getDisplayMetrics(),
    // superRes.getConfiguration());

    MethodId<Resources, Void> res_constructor = Resources.getConstructor(
            AssetManager, DisplayMetrics, Configuration);
    methodCode.newInstance(resLocal, res_constructor, localAsm, mtrc, cfg);
    methodCode.iput(resources, localThis, resLocal);

    MethodId<ActivityOverider, Void> method_call_onCreate = ActivityOverider
            .getMethod(TypeId.VOID, "callback_onCreate", TypeId.STRING,
                    TypeId.get(Activity.class));
    methodCode
            .invokeStatic(method_call_onCreate, null, pluginId, localThis);

    // super.onCreate()
    MethodId superMethod = superType.getMethod(TypeId.VOID, "onCreate",
            Bundle);
    methodCode.invokeSuper(superMethod, null, localThis, lcoalBundle);

    methodCode.returnVoid();
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:78,
代码来源:ActivityClassGenerator.java

示例40: declareMethod_startActivityForResult

点赞 2

import com.google.dexmaker.DexMaker; //导入依赖的package包/类
private static <S, D extends S> void declareMethod_startActivityForResult(
        DexMaker dexMaker, TypeId<D> generatedType, TypeId<S> superType) {
    TypeId<Intent> intent = TypeId.get(Intent.class);
    TypeId<Integer> requestCode = TypeId.INT;
    TypeId<Bundle> bundle = TypeId.get(Bundle.class);

    TypeId<?>[] params;
    String methodName = "startActivityForResult";
    final boolean isNewSdk = android.os.Build.VERSION.SDK_INT > 10;
    if (isNewSdk) {
        params = new TypeId[] { intent, requestCode, bundle };
    } else {
        params = new TypeId[] { intent, requestCode };
    }
    MethodId<D, Void> method = generatedType.getMethod(TypeId.VOID,
            methodName, params);
    MethodId<S, Void> superMethod = superType.getMethod(TypeId.VOID,
            methodName, params);
    Code methodCode = dexMaker.declare(method, PUBLIC);
    TypeId<ActivityOverider> ActivityOverider = TypeId
            .get(ActivityOverider.class);
    MethodId<ActivityOverider, Intent> methodOveride = ActivityOverider
            .getMethod(intent, "overrideStartActivityForResult",
                    TypeId.get(Activity.class), TypeId.STRING, intent,
                    requestCode, bundle);
    // locals
    Local<D> localThis = methodCode.getThis(generatedType);
    Local<Intent> newIntent = methodCode.newLocal(intent);
    Local<Bundle> nullParamBundle = methodCode.newLocal(bundle);
    Local<String> pluginId = get_pluginId(generatedType, methodCode);

    methodCode.loadConstant(nullParamBundle, null);
    Local<?> args[];
    if (isNewSdk) {
        args = new Local[] { localThis, pluginId,
                methodCode.getParameter(0, intent)//
                , methodCode.getParameter(1, requestCode)//
                , methodCode.getParameter(2, bundle) //
        };
        methodCode.invokeStatic(methodOveride, newIntent, args);
        // super.startActivityForResult(...)
        methodCode.invokeSuper(superMethod, null, localThis//
                , newIntent//
                , methodCode.getParameter(1, requestCode)//
                , methodCode.getParameter(2, bundle) //
                );
    } else {
        args = new Local[] { localThis, pluginId,
                methodCode.getParameter(0, intent)//
                , methodCode.getParameter(1, requestCode)//
                , nullParamBundle };
        methodCode.invokeStatic(methodOveride, newIntent, args);
        methodCode.invokeSuper(superMethod, null, localThis//
                , newIntent//
                , methodCode.getParameter(1, requestCode)//
                );
    }
    methodCode.returnVoid();
}
 

开发者ID:achellies,
项目名称:AndroidPlugin,
代码行数:60,
代码来源:ActivityClassGenerator.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)