资源简介
android5.0及以上,通过包名判断是否在运行,不需要用户授权

代码片段和文件信息
/*
* Copyright (C) 2015. Jared Rummler
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.lstn.protect2_1.runningProcess;
import java.io.File;
import java.io.IOException;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Parcel;
public class AndroidAppProcess extends AndroidProcess {
private static final boolean SYS_SUPPORTS_SCHEDGROUPS = new File(“/dev/cpuctl/tasks“).exists();
/**
* {@code true} if the process is in the foreground
*/
public final boolean foreground;
/**
* The user id of this process.
*/
public final int uid;
public AndroidAppProcess(int pid) throws IOException NotAndroidAppProcessException {
super(pid);
final boolean foreground;
int uid;
if (SYS_SUPPORTS_SCHEDGROUPS) {
Cgroup cgroup = cgroup();
ControlGroup cpuacct = cgroup.getGroup(“cpuacct“);
ControlGroup cpu = cgroup.getGroup(“cpu“);
if (Build.VERSION.SDK_INT >= 21) {//Build.VERSION_CODES.LOLLIPOP
if (cpu == null || cpuacct == null || !cpuacct.group.contains(“pid_“)) {
throw new NotAndroidAppProcessException(pid);
}
foreground = !cpu.group.contains(“bg_non_interactive“);
try {
uid = Integer.parseInt(cpuacct.group.split(“/“)[1].replace(“uid_“ ““));
} catch (Exception e) {
uid = status().getUid();
}
ProcessManager.log(“name=%s pid=%d uid=%d foreground=%b cpuacct=%s cpu=%s“
name pid uid foreground cpuacct.toString() cpu.toString());
} else {
if (cpu == null || cpuacct == null || !cpu.group.contains(“apps“)) {
throw new NotAndroidAppProcessException(pid);
}
foreground = !cpu.group.contains(“bg_non_interactive“);
try {
uid = Integer.parseInt(cpuacct.group.substring(cpuacct.group.lastIndexOf(“/“) + 1));
} catch (Exception e) {
uid = status().getUid();
}
ProcessManager.log(“name=%s pid=%d uid=%d foreground=%b cpuacct=%s cpu=%s“
name pid uid foreground cpuacct.toString() cpu.toString());
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-07 16:09 protect-2.1-src\
文件 6181 2017-02-07 15:22 protect-2.1-src\AndroidAppProcess.java
文件 27461 2017-02-07 15:14 protect-2.1-src\AndroidProcess.java
文件 2993 2017-02-07 15:14 protect-2.1-src\Cgroup.java
文件 2041 2017-02-07 15:14 protect-2.1-src\ControlGroup.java
文件 9438 2017-02-07 15:22 protect-2.1-src\ProcessManager.java
文件 2431 2017-02-07 15:14 protect-2.1-src\ProcFile.java
文件 22572 2017-02-07 15:14 protect-2.1-src\Stat.java
文件 2644 2017-02-07 15:14 protect-2.1-src\Statm.java
文件 6970 2017-02-07 15:14 protect-2.1-src\Status.java
文件 23930 2019-03-30 10:08 protect-2.1.jar
文件 14964 2019-03-30 10:31 使用.docx
- 上一篇:jsp登陆界面模板
- 下一篇:重庆大学java语言程序设计模拟试题
相关资源
- Android手机工具ADB.exe
- Android分区工具包
- 进制转换器(java)
- Java串口调试工具源码
- android图片压缩工具类分享
- 安全测试工具ysoserial
- 顺丰丰桥接口开发详细教程源码含下
- JAVA util工具包
- mac版adb工具
- 精简的jre的精简工具
- 批量去除 bom 工具
- 小工具,解决oschina码云svn文件夹不能
- 一款Java的MySqlWeb管理工具
- 去掉代码注释的工具java \\ c\\c++、ph
- 命令行工具在VasDolly.jar文件夹下获取
- DbVisualizer 10.0.14 破解jar包
- 文件加密工具带jar包
- Android iperf 工具
- Java字节码转换工具—Retrotranslato
- mysql-connector-java-5.0.8 jar包
- Android Parted GPT分区工具包
- MongoDB的Java访问实现包括文件存储
- jsp中国移动计费系统
- 最新数据验证工具类java,身份证、手
- Android BigNews 曾量更新 生成 patch.patc
- 敏感信息脱敏源码和jar包
- 基于Java开发的免费网络拓扑软件-Su
- Airkiss一键配网小工具
- Rabbitmq工具类,java工具类RabbitmqUtil
- java字节码文件查看工具查看class文件
评论
共有 条评论