检查安装和卸载是否阻止(辅助功能)

时间:2017-01-28 06:30:16

标签: java android

AppLocker无法进入删除和安装屏幕?可行性非常好。我究竟做错了什么?此外,当我安装apk时,它不起作用。我想我在最后一部分犯了错误。 Stackoverflow说这正是我正在寻找的,但是......

private Runnable checkDataRunnable = new Runnable() {

        @Override
            public void run() {

            // TODO Auto-generated method stub
            LogUtil.e("colin", "run");
            ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
            CommLockInfoService commLockInfoService = new CommLockInfoService(
                    getApplicationContext());
            commLockInfoService.getCommLockInfoDaoInstance();
            String lastLoadPackageName = "";
            String packgeName = "";
            String className = "";
            LogUtil.e("demo3", "run1");
            while (!threadIsTerminate) {
                try {
                    if (Build.VERSION.SDK_INT >= 21) {
                        packgeName = LockService.getForegroundApp();
                    } else {
                        ComponentName topActivity = activityManager.getRunningTasks(1).get(0).topActivity;
                        if (topActivity != null) {
                            className = topActivity.getClassName();
                            packgeName = topActivity.getPackageName();
                        }
                    }
                    if (packgeName.equals(BuildConfig.FLAVOR) || packgeName == null) {
                        packgeName = lastLoadPackageName;
                    }
                    if (!(!LockService.lockState || LockService.this.inWhiteList(packgeName) || packgeName.equals(lastLoadPackageName))) {
                        lastLoadPackageName = packgeName;
                        if (LockService.allowedLeaveAment && LockService.lastUnlockTimeSeconds != 0 && new Date().getTime() - LockService.lastUnlockTimeSeconds < LockService.leaverTime) {
                            LogUtil.e("colin", "");
                        } else if (commLockInfoService.isLockedPackageName(packgeName)) {
                            LockService.this.passwordLock(packgeName);
                        }else if ("com.android.packageinstaller".equals(packgeName)) {
                            LockService.this.passwordLock(packgeName);
                        }else if ("com.android.packageinstaller.UninstallerActivity".equals(className)){
                            LockService.this.passwordLock(className);
                        }

                    }
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    };

0 个答案:

没有答案