Android APP OPS移除应用程序项目的修改方法

修改文件:

packages/apps/Settings/src/com/android/settings/applications/AppOpsState.java


相关代码片段:

    private void addOp(List entries, AppOpsManager.PackageOps pkgOps,
            AppEntry appEntry, AppOpsManager.OpEntry opEntry, boolean allowMerge, int switchOrder) {
        if (allowMerge && entries.size() > 0) {
            AppOpEntry last = entries.get(entries.size()-1);
            if (last.getAppEntry() == appEntry) {
                boolean lastExe = last.getTime() != 0;
                boolean entryExe = opEntry.getTime() != 0;
                if (lastExe == entryExe) {
                    if (DEBUG) Log.d(TAG, "Add op " + opEntry.getOp() + " to package "
                            + pkgOps.getPackageName() + ": append to " + last);
                    last.addOp(opEntry);
                    return;
                }
            }
        }
        AppOpEntry entry = appEntry.getOpSwitch(opEntry.getOp());
        if (entry != null) {
            entry.addOp(opEntry);
            return;
        }
        entry = new AppOpEntry(pkgOps, opEntry, appEntry, switchOrder);
        if (DEBUG) Log.d(TAG, "Add op " + opEntry.getOp() + " to package "
                + pkgOps.getPackageName() + ": making new " + entry);
        entries.add(entry);
    }

修改位置:

在方法体中的首行进行过滤,过滤掉需要移除的应用包名。


修改方法:

例如过滤掉浏览器项目。

        if ("com.android.browser".equals(pkgOps.getPackageName())){
            return;
        }

备注:一般来讲在过CTS的时候会修改到此处。

你可能感兴趣的:(Android APP OPS移除应用程序项目的修改方法)