Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1602ae8f authored by Mårten Kongstad's avatar Mårten Kongstad Committed by android-build-merger
Browse files

Merge "Remove unused methods from OMS" am: fd5cdfc9 am: 55a2494d

am: 5e9775cb

Change-Id: Ie922a1a605a8b1d8d697713c919d4dd82ffff20e
parents 4f4a3414 5e9775cb
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -92,26 +92,10 @@ class IdmapManager {
        return new File(getIdmapPath(overlayPackage.applicationInfo.getBaseCodePath())).isFile();
    }

    boolean isDangerous(@NonNull final PackageInfo overlayPackage, final int userId) {
        // unused userId: see comment in OverlayManagerServiceImpl.removeIdmapIfPossible
        return isDangerous(getIdmapPath(overlayPackage.applicationInfo.getBaseCodePath()));
    }

    private String getIdmapPath(@NonNull final String baseCodePath) {
        final StringBuilder sb = new StringBuilder("/data/resource-cache/");
        sb.append(baseCodePath.substring(1).replace('/', '@'));
        sb.append("@idmap");
        return sb.toString();
    }

    private boolean isDangerous(@NonNull final String idmapPath) {
        try (DataInputStream dis = new DataInputStream(new FileInputStream(idmapPath))) {
            final int magic = dis.readInt();
            final int version = dis.readInt();
            final int dangerous = dis.readInt();
            return dangerous != 0;
        } catch (IOException e) {
            return true;
        }
    }
}