资源简介
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语言程序设计模拟试题
相关资源
- httputil工具类
- MQ工具类java
- PayCommonUtil
- XDA签名工具
- wifi杀手工具
- Java证书打印工具类
- platform.pk8和platform.x509.pem以及Signapk工
- android动态添加权限工具包,方便快捷
- jar打包工具 jar
- uiautomatorviewer工具更新优化适配Andro
- 生成二维码Jar包工具
- 安卓手机读IC卡工具
- JAVA时间工具类计算法定工作日工时等
- Android QQ聊天工具客户端源代码
- Android 实用工具 备忘录
- 获取微信所需签名工具
- Quartz 2.2.1 工具类
- JAVA简易画图工具
- []commons-net-3.3.jar
- Android、Java、Web三端通用的RSA和AES工具
- java写的最简单的lan聊天工具
- NLPIR2016分词工具包
- JDBC线程安全的Druid数据库连接池工具
- apkutil解析apk安装包的工具
- pinyin4j-2.5.0.jar附带Util工具类
- 根据配置文件自动构造Bean类
- java连接数据库工具类--DBConnection(j
- 一个Java实现的基于内容的图像检索工
- FTPSUploadUtils 上传工具
- hadoop-2.6.0 win工具包 hadoop.dll winutils
评论
共有 条评论