当前位置: 首页>>代码示例>>Java>>正文


Java AndroidAppHelper类代码示例

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


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

示例1: getLollipopRecentTask

import android.app.AndroidAppHelper; //导入依赖的package包/类
private String getLollipopRecentTask() {
    /** @hide Process is hosting the current top activities.  Note that this covers
     * all activities that are visible to the user. */
    final int PROCESS_STATE_TOP = 2;
    try {
        Field processStateField = ActivityManager.RunningAppProcessInfo.class.getDeclaredField("processState");
        List<ActivityManager.RunningAppProcessInfo> processes = ((ActivityManager) AndroidAppHelper.currentApplication().getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses();
        for (ActivityManager.RunningAppProcessInfo process : processes) {
            if (process.importance <= ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && process.importanceReasonCode == 0) {
                int state = processStateField.getInt(process);
                if (state == PROCESS_STATE_TOP) {
                    String[] packname = process.pkgList;
                    return packname[0];
                }
            }
        }
    } catch (Exception e) {
        XposedBridge.log(e);
    }
    return "";
}
 
开发者ID:ryuunoakaihitomi,项目名称:Screenshot-Hookbox,代码行数:22,代码来源:X.java

示例2: modifySensor

import android.app.AndroidAppHelper; //导入依赖的package包/类
@Override
public void modifySensor(final XC_LoadPackage.LoadPackageParam lpparam) {
    XposedHelpers.findAndHookMethod(
            "android.hardware.SystemSensorManager$ListenerDelegate",
            lpparam.classLoader, "onSensorChangedLocked", Sensor.class,
            float[].class, long[].class, int.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) {
                    Sensor sensor = (Sensor) param.args[0];
                    Context context = AndroidAppHelper.currentApplication();
                    //Use processName here always. Not packageName.
                    if (!isPackageAllowedToSeeTrueSensor(lpparam.processName, sensor, context) && getSensorStatus(sensor, context) == Constants.SENSOR_STATUS_MOCK_VALUES) {
                        // Get the mock values from the settings.
                        float[] values = getSensorValues(sensor, context);

                        //noinspection SuspiciousSystemArraycopy
                        System.arraycopy(values, 0, param.args[1], 0, values.length);
                    }
                }
            }
    );
}
 
开发者ID:wardellbagby,项目名称:Sensor-Disabler,代码行数:23,代码来源:MockSensorValuesModificationMethod.java

示例3: modifySensor

import android.app.AndroidAppHelper; //导入依赖的package包/类
@Override
public void modifySensor(final XC_LoadPackage.LoadPackageParam lpparam) {
    XposedHelpers.findAndHookMethod("android.hardware.SystemSensorManager", lpparam.classLoader, "getFullSensorList", new XC_MethodHook() {
        @Override
        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            //Without this, you'd never be able to edit the values for a removed sensor! Aaah!
            if (!lpparam.packageName.equals(BuildConfig.APPLICATION_ID)) {
                //Create a new list so we don't modify the original list.
                @SuppressWarnings("unchecked") List<Sensor> fullSensorList = new ArrayList<>((Collection<? extends Sensor>) param.getResult());
                Iterator<Sensor> iterator = fullSensorList.iterator();
                Context context = AndroidAppHelper.currentApplication();
                while (iterator.hasNext()) {
                    Sensor sensor = iterator.next();
                    if (!isPackageAllowedToSeeTrueSensor(lpparam.processName, sensor, context) && getSensorStatus(sensor, context) == Constants.SENSOR_STATUS_REMOVE_SENSOR) {
                        iterator.remove();
                    }
                }
                param.setResult(fullSensorList);
            }
        }
    });
}
 
开发者ID:wardellbagby,项目名称:Sensor-Disabler,代码行数:23,代码来源:RemoveSensorModificationMethod.java

示例4: createInstance

import android.app.AndroidAppHelper; //导入依赖的package包/类
public static ModuleResources createInstance(String modulePath, XResources origRes)
{
  if(modulePath == null)
    throw new IllegalArgumentException("modulePath must not be null");

  AssetManager assets = (AssetManager)newInstance(AssetManager.class);
  callMethod(assets, "addAssetPath", modulePath);
  
  ModuleResources res;
  if(origRes != null)
    res = new ModuleResources(assets, origRes.getDisplayMetrics(), origRes.getConfiguration());
  else
    res = new ModuleResources(assets, null, null);

  AndroidAppHelper.addActiveResource(modulePath, res.hashCode(), false, res);
  return res;
}
 
开发者ID:greg2001,项目名称:GemXperiaXposed,代码行数:18,代码来源:ModuleResources.java

示例5: createInstance

import android.app.AndroidAppHelper; //导入依赖的package包/类
/**
 * Usually called with the automatically injected {@code MODULE_PATH} constant of the first parameter
 * and the resources received in the callback for {@link XposedBridge#hookInitPackageResources} (or
 * {@code null} for system-wide replacements.
 */
public static XModuleResources createInstance(String modulePath, XResources origRes) {
	if (modulePath == null)
		throw new IllegalArgumentException("modulePath must not be null");

	AssetManager assets = new AssetManager();
	assets.addAssetPath(modulePath);

	XModuleResources res;
	if (origRes != null)
		res = new XModuleResources(assets, origRes.getDisplayMetrics(),	origRes.getConfiguration());
	else
		res = new XModuleResources(assets, null, null);

	AndroidAppHelper.addActiveResource(modulePath, res.hashCode(), false, res);
	return res;
}
 
开发者ID:sunwayforever,项目名称:xposed-art,代码行数:22,代码来源:XModuleResources.java

示例6: selectCallType

import android.app.AndroidAppHelper; //导入依赖的package包/类
private static void selectCallType(final XC_MethodHook.MethodHookParam param) {
    Resources res = AndroidAppHelper.currentApplication().getResources();
    String callWithHangouts = res.getString(
            res.getIdentifier(HANGOUTS_STR_CALL_WITH_HANGOUTS, "string", HANGOUTS_RES_PKG_NAME));
    String callWithCellular = res.getString(
            res.getIdentifier(HANGOUTS_STR_CALL_WITH_PSTN, "string", HANGOUTS_RES_PKG_NAME));

    CharSequence options[] = new CharSequence[]{callWithHangouts, callWithCellular};
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("");
    builder.setItems(options, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case 0:
                    hangoutsCall(param);
                    break;
                case 1:
                    cellularCall();
                    break;
            }
        }
    });
    builder.show();
}
 
开发者ID:kmark,项目名称:XHangouts,代码行数:26,代码来源:UiCallButtons.java

示例7: getCrashTip

import android.app.AndroidAppHelper; //导入依赖的package包/类
private static String getCrashTip() {

        Context context = null;
        try {
            context = AndroidAppHelper.currentApplication().createPackageContext(PACKAGE_NAME, Context.CONTEXT_IGNORE_SECURITY);
            return context.getString(R.string.crash_tip) + ": ";
        } catch (PackageManager.NameNotFoundException e) {
            return "";
        }
    }
 
开发者ID:Kuanghusing,项目名称:NeverCrash,代码行数:11,代码来源:x.java

示例8: handleLoadPackage

import android.app.AndroidAppHelper; //导入依赖的package包/类
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
    if (!lpparam.packageName.equals("zebpay.Application"))
        return;
    findAndHookMethod("zebpay.Application.activity.SplashActivity", lpparam.classLoader, "b", new XC_MethodReplacement() {
        @Override
        protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
            String warning = "App has been hooked by third party app, but ignored by Zebpay Unblock. HODL!";
            Context context = AndroidAppHelper.currentApplication();
            Toast toast = Toast.makeText(context, warning, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
            return true;
        }
    });
}
 
开发者ID:theapu,项目名称:Zebpay-Unblock,代码行数:16,代码来源:ZebpayUnblocker.java

示例9: getShotObject

import android.app.AndroidAppHelper; //导入依赖的package包/类
private String getShotObject() {
    String ret = getLollipopRecentTask();
    if (ret.isEmpty())
        if (BoolConfigIO.get(REC))
            return "RecentTasksList";
        else
            return "unknown";
    else if (((KeyguardManager) AndroidAppHelper.currentApplication().getSystemService(Context.KEYGUARD_SERVICE)).inKeyguardRestrictedInputMode())
        return "LockScreen";
    else {
        Log.d(TAG, "getShotObject:" + ret);
        return ret;
    }
}
 
开发者ID:ryuunoakaihitomi,项目名称:Screenshot-Hookbox,代码行数:15,代码来源:X.java

示例10: connect

import android.app.AndroidAppHelper; //导入依赖的package包/类
public boolean connect(Context context) {
    if (isConnected()) {
        return true;
    }
    ComponentName cn;
    if (context == null) {
        // only valid from Xposed context in hooked app
        context = AndroidAppHelper.currentApplication();
        cn = new ComponentName(THIS_APP, THIS_APP + ".JoystickService");
    } else {
        cn = new ComponentName(context, JoystickService.class);
    }

    if (context != null) {
        if (messenger == null) {
            messenger = new Messenger(incomingHandler);
        }

        Intent intent = new Intent();
        intent.setComponent(cn);
        if (!context.bindService(intent, this, Context.BIND_AUTO_CREATE)) {
            Toast.makeText(AndroidAppHelper.currentApplication(), "Unable to start service! Did you reboot after updating?", Toast.LENGTH_SHORT).show();
        }
        return true;
    }
    return false;
}
 
开发者ID:spezifisch,项目名称:ThreeStepsAhead,代码行数:28,代码来源:IPC.java

示例11: initZygote

import android.app.AndroidAppHelper; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {
	prefs = AndroidAppHelper.getSharedPreferencesForPackage(MY_PACKAGE_NAME,
			Common.PREFS, Context.MODE_PRIVATE);
	//prefs = new XSharedPreferences(MY_PACKAGE_NAME, Common.PREFS).makeWorldReadable();
	MODULE_PATH = startupParam.modulePath;
	mDebugMode = prefs.getBoolean(Common.PREF_DEBUG_MODE, false);
}
 
开发者ID:Nephiel,项目名称:NFCLockScreenOffEnablerMM,代码行数:10,代码来源:NFCLockScreenOffEnabler.java

示例12: modifySensor

import android.app.AndroidAppHelper; //导入依赖的package包/类
@Override
public void modifySensor(final XC_LoadPackage.LoadPackageParam lpparam) {
    XC_MethodHook mockSensorHook = new XC_MethodHook() {
        @SuppressWarnings("unchecked")
        @Override
        protected void beforeHookedMethod(MethodHookParam param)
                throws Throwable {

            Object systemSensorManager = XposedHelpers.getObjectField(param.thisObject, "mManager");
            SparseArray<Sensor> sensors = getSensors(systemSensorManager);

            // params.args[] is an array that holds the arguments that dispatchSensorEvent received, which are a handle pointing to a sensor
            // in sHandleToSensor and a float[] of values that should be applied to that sensor.
            int handle = (Integer) (param.args[0]); // This tells us which sensor was currently called.
            Sensor sensor = sensors.get(handle);
            Context context = AndroidAppHelper.currentApplication();
            if (!isPackageAllowedToSeeTrueSensor(lpparam.processName, sensor, context) && getSensorStatus(sensor, context) == Constants.SENSOR_STATUS_MOCK_VALUES) {
                float[] values = getSensorValues(sensor, context);
                    /*The SystemSensorManager compares the array it gets with the array from the a SensorEvent,
                    and some sensors (looking at you, Proximity) only use one index in the array
                    but still send along a length 3 array, so we copy here instead of replacing it
                    outright. */

                //noinspection SuspiciousSystemArraycopy
                System.arraycopy(values, 0, param.args[1], 0, values.length);
            }
        }
    };
    XposedHelpers.findAndHookMethod("android.hardware.SystemSensorManager$SensorEventQueue", lpparam.classLoader, "dispatchSensorEvent", int.class, float[].class, int.class, long.class, mockSensorHook);
}
 
开发者ID:wardellbagby,项目名称:Sensor-Disabler,代码行数:31,代码来源:MockSensorValuesModificationMethodApi18.java

示例13: initZygote

import android.app.AndroidAppHelper; //导入依赖的package包/类
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
    loadPrefs();

    try {
        XposedHelpers.findAndHookMethod(
                Resources.class, "updateConfiguration",
                Configuration.class, DisplayMetrics.class, "android.content.res.CompatibilityInfo",
                new XC_MethodHook() {
                    @Override
                    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                        if (param.args[0] == null) {
                            return;
                        }

                        String packageName;
                        Resources res = ((Resources) param.thisObject);
                        if (res instanceof XResources) {
                            packageName = ((XResources) res).getPackageName();
                        } else if (res instanceof XModuleResources) {
                            return;
                        } else {
                            try {
                                packageName = XResources.getPackageNameDuringConstruction();
                            } catch (IllegalStateException e) {
                                return;
                            }
                        }

                        String hostPackageName = AndroidAppHelper.currentPackageName();
                        boolean isActiveApp = hostPackageName.equals(packageName);

                        Configuration newConfig = null;

                        if (packageName != null) {
                            Locale loc = getPackageSpecificLocale(packageName);
                            if (loc != null) {
                                newConfig = new Configuration((Configuration) param.args[0]);

                                setConfigurationLocale(newConfig, loc);

                                if (isActiveApp) {
                                    Locale.setDefault(loc);
                                }
                            }
                        }

                        if (newConfig != null) {
                            param.args[0] = newConfig;
                        }
                    }
                }
        );
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
开发者ID:jiefoxi,项目名称:XposedAppLocale,代码行数:58,代码来源:XposedMod.java

示例14: initZygote

import android.app.AndroidAppHelper; //导入依赖的package包/类
@Override
public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {

    installPackageHook = new XC_MethodHook() {
        @Override
        public void beforeHookedMethod(MethodHookParam param) throws Throwable {
            mContext = AndroidAppHelper.currentApplication();
            mContext = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
            boolean isInstallStage = "installStage".equals(param.method.getName());
            int flags = 0;
            int id = 0;

            if (isInstallStage) {
                try {
                    id = 4;
                    flags = (Integer) XposedHelpers.getObjectField(param.args[id], "installFlags");
                    XposedBridge.log("PreventADBInstall: Hook Flags Success!");
                } catch (Exception e) {
                    XposedBridge.log(e);
                }
            } else {
                try {
                    id = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? 2 : 1;
                    flags = (Integer) param.args[id];
                    XposedBridge.log("PreventADBInstall: Hook Flags Success!");
                } catch (Exception e) {
                    XposedBridge.log(e);
                }
            }

            if (isInstallStage) {
                Object sessions = param.args[id];
                XposedHelpers.setIntField(sessions, "installFlags", flags);
                param.args[id] = sessions;
            } else {
                param.args[id] = flags;
            }

            if ((getCallingUid() == 2000) || (getCallingUid() == 0)) {
                param.setResult(null);
                XposedBridge.log("PreventADBInstall: Block Success!");
                Looper.prepare();
                Toast.makeText(mContext, "拦截 ADB 安装成功!", Toast.LENGTH_LONG).show();
                Looper.loop();
                return;
            }
        }
    };
}
 
开发者ID:aviraxp,项目名称:PreventADBInstall,代码行数:50,代码来源:HookMain.java

示例15: getContext

import android.app.AndroidAppHelper; //导入依赖的package包/类
private static Context getContext() {
  return (Context) AndroidAppHelper.currentApplication();
}
 
开发者ID:gavinhungry,项目名称:Xposed-ShowSimOperator,代码行数:4,代码来源:ShowSimOperator.java


注:本文中的android.app.AndroidAppHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。