Info Call to External Storage API

Description

List of all external storage API calls. Insecure storage of sensitive information by setting insecure permissions or storing data without encryption might expose this information to an attacker.

Recommendation

This entry is informative, no recommendations applicable.

Technical details

Method android.support.v4.util.AtomicFile.startWrite() calling method java.io.FileOutputStream.<init>()


    public java.io.FileOutputStream startWrite()
    {
        if (this.mBaseName.exists()) {
            if (this.mBackupName.exists()) {
                this.mBaseName.delete();
            } else {
                if (!this.mBaseName.renameTo(this.mBackupName)) {
                    android.util.Log.w("AtomicFile", new StringBuilder().append("Couldn\'t rename file ").append(this.mBaseName).append(" to backup file ").append(this.mBackupName).toString());
                }
            }
        }
        try {
            java.io.FileOutputStream v3_1 = new java.io.FileOutputStream(this.mBaseName);
        } catch (java.io.FileNotFoundException v0) {
            if (this.mBaseName.getParentFile().mkdir()) {
                try {
                    v3_1 = new java.io.FileOutputStream(this.mBaseName);
                } catch (java.io.FileNotFoundException v1) {
                    throw new java.io.IOException(new StringBuilder().append("Couldn\'t create ").append(this.mBaseName).toString());
                }
            } else {
                throw new java.io.IOException(new StringBuilder().append("Couldn\'t create directory ").append(this.mBaseName).toString());
            }
        }
        return v3_1;
    }

Method android.support.v4.print.PrintHelperKitkat$2.onWrite() calling method java.io.FileOutputStream.<init>()


    public void onWrite(android.print.PageRange[] p10, android.os.ParcelFileDescriptor p11, android.os.CancellationSignal p12, android.print.PrintDocumentAdapter$WriteResultCallback p13)
    {
        android.print.pdf.PrintedPdfDocument v4_1 = new android.print.pdf.PrintedPdfDocument(this.this$0.mContext, this.mAttributes);
        try {
            android.graphics.pdf.PdfDocument$Page v3 = v4_1.startPage(1);
            v3.getCanvas().drawBitmap(this.mBitmap, android.support.v4.print.PrintHelperKitkat.access$000(this.this$0, this.mBitmap.getWidth(), this.mBitmap.getHeight(), new android.graphics.RectF(v3.getInfo().getContentRect()), this.val$fittingMode), 0);
            v4_1.finishPage(v3);
        } catch (java.io.IOException v5_12) {
            if (v4_1 != null) {
                v4_1.close();
            }
            if (p11 != null) {
                try {
                    p11.close();
                } catch (java.io.IOException v6) {
                }
            }
            throw v5_12;
        }
        try {
            v4_1.writeTo(new java.io.FileOutputStream(p11.getFileDescriptor()));
            java.io.IOException v5_9 = new android.print.PageRange[1];
            v5_9[0] = android.print.PageRange.ALL_PAGES;
            p13.onWriteFinished(v5_9);
        } catch (java.io.IOException v1) {
            android.util.Log.e("PrintHelperKitkat", "Error writing printed content", v1);
            p13.onWriteFailed(0);
        }
        if (v4_1 != null) {
            v4_1.close();
        }
        if (p11 != null) {
            try {
                p11.close();
            } catch (java.io.IOException v5) {
            }
        }
        return;
    }

Method android.support.v4.print.PrintHelperKitkat$1.onWrite() calling method java.io.FileOutputStream.<init>()


    public void onWrite(android.print.PageRange[] p10, android.os.ParcelFileDescriptor p11, android.os.CancellationSignal p12, android.print.PrintDocumentAdapter$WriteResultCallback p13)
    {
        android.print.pdf.PrintedPdfDocument v4_1 = new android.print.pdf.PrintedPdfDocument(this.this$0.mContext, this.mAttributes);
        try {
            android.graphics.pdf.PdfDocument$Page v3 = v4_1.startPage(1);
            v3.getCanvas().drawBitmap(this.val$bitmap, android.support.v4.print.PrintHelperKitkat.access$000(this.this$0, this.val$bitmap.getWidth(), this.val$bitmap.getHeight(), new android.graphics.RectF(v3.getInfo().getContentRect()), this.val$fittingMode), 0);
            v4_1.finishPage(v3);
        } catch (java.io.IOException v5_12) {
            if (v4_1 != null) {
                v4_1.close();
            }
            if (p11 != null) {
                try {
                    p11.close();
                } catch (java.io.IOException v6) {
                }
            }
            throw v5_12;
        }
        try {
            v4_1.writeTo(new java.io.FileOutputStream(p11.getFileDescriptor()));
            java.io.IOException v5_9 = new android.print.PageRange[1];
            v5_9[0] = android.print.PageRange.ALL_PAGES;
            p13.onWriteFinished(v5_9);
        } catch (java.io.IOException v1) {
            android.util.Log.e("PrintHelperKitkat", "Error writing printed content", v1);
            p13.onWriteFailed(0);
        }
        if (v4_1 != null) {
            v4_1.close();
        }
        if (p11 != null) {
            try {
                p11.close();
            } catch (java.io.IOException v5) {
            }
        }
        return;
    }

Method com.afwsamples.testdpc.cosu.EnableCosuActivity.onConfigFileDownloaded() calling method java.io.FileInputStream.<init>()


    private void onConfigFileDownloaded()
    {
        this.mStatusText.setText(this.getString(2131165454));
        try {
            this.mConfig = com.afwsamples.testdpc.cosu.CosuConfig.createConfig(this, new java.io.FileInputStream(this.mDownloadManager.openDownloadedFile(this.mConfigDownloadId.longValue()).getFileDescriptor()));
        } catch (java.io.FileNotFoundException v0) {
            android.util.Log.e("CosuSetup", "Download file not found.", v0);
            this.finishWithFailure();
            return;
        }
        if (this.mConfig != null) {
            android.util.Log.d("CosuSetup", "CosuConfig:");
            android.util.Log.d("CosuSetup", this.mConfig.toString());
            this.mConfig.applyPolicies(com.afwsamples.testdpc.DeviceAdminReceiver.getComponentName(this));
            this.mConfig.initiateDownloadAndInstall(this.mHandler);
            this.mStatusText.setText(this.getString(2131165452));
            if (!this.mConfig.areAllInstallsFinished()) {
                return;
            } else {
                this.startCosuMode();
                return;
            }
        } else {
            this.finishWithFailure();
            return;
        }
    }

Method com.afwsamples.testdpc.cosu.CosuConfig.onDownloadComplete() calling method java.io.FileInputStream.<init>()


    public Long onDownloadComplete(Long p10)
    {
        java.util.Iterator v2 = this.mDownloadApps.iterator();
        while (v2.hasNext()) {
            com.afwsamples.testdpc.cosu.CosuConfig$DownloadAppInfo v0_1 = ((com.afwsamples.testdpc.cosu.CosuConfig$DownloadAppInfo) v2.next());
            if (p10.equals(v0_1.downloadId)) {
                v0_1.downloadCompleted = 1;
                try {
                    com.afwsamples.testdpc.cosu.CosuUtils.installPackage(this.mContext, new java.io.FileInputStream(this.mDownloadManager.openDownloadedFile(p10.longValue()).getFileDescriptor()), v0_1.packageName);
                } catch (java.io.IOException v1) {
                    android.util.Log.e("CosuSetup", new StringBuilder().append("Error installing package: ").append(v0_1.packageName).toString(), v1);
                    v0_1.installCompleted = 1;
                }
                Long v5_1 = v0_1.downloadId;
            }
            return v5_1;
        }
        android.util.Log.w("CosuSetup", new StringBuilder().append("Unknown download id: ").append(p10).toString());
        v5_1 = 0;
        return v5_1;
    }

Method android.support.v4.util.AtomicFile.openRead() calling method java.io.FileInputStream.<init>()


    public java.io.FileInputStream openRead()
    {
        if (this.mBackupName.exists()) {
            this.mBaseName.delete();
            this.mBackupName.renameTo(this.mBaseName);
        }
        return new java.io.FileInputStream(this.mBaseName);
    }

Method android.support.v4.provider.RawDocumentFile.renameTo() calling method java.io.File.<init>()


    public boolean renameTo(String p3)
    {
        int v1_1;
        java.io.File v0_1 = new java.io.File(this.mFile.getParentFile(), p3);
        if (!this.mFile.renameTo(v0_1)) {
            v1_1 = 0;
        } else {
            this.mFile = v0_1;
            v1_1 = 1;
        }
        return v1_1;
    }

Method android.support.v4.provider.RawDocumentFile.createFile() calling method java.io.File.<init>()


    public android.support.v4.provider.DocumentFile createFile(String p7, String p8)
    {
        String v1 = android.webkit.MimeTypeMap.getSingleton().getExtensionFromMimeType(p7);
        if (v1 != null) {
            p8 = new StringBuilder().append(p8).append(".").append(v1).toString();
        }
        java.io.File v2_1 = new java.io.File(this.mFile, p8);
        try {
            v2_1.createNewFile();
            int v3_5 = new android.support.v4.provider.RawDocumentFile(this, v2_1);
        } catch (java.io.IOException v0) {
            android.util.Log.w("DocumentFile", new StringBuilder().append("Failed to createFile: ").append(v0).toString());
            v3_5 = 0;
        }
        return v3_5;
    }

Method android.support.v4.provider.RawDocumentFile.createDirectory() calling method java.io.File.<init>()


    public android.support.v4.provider.DocumentFile createDirectory(String p3)
    {
        int v1_2;
        java.io.File v0_1 = new java.io.File(this.mFile, p3);
        if ((!v0_1.isDirectory()) && (!v0_1.mkdir())) {
            v1_2 = 0;
        } else {
            v1_2 = new android.support.v4.provider.RawDocumentFile(this, v0_1);
        }
        return v1_2;
    }

Method android.support.v4.content.FileProvider$SimplePathStrategy.getFileForUri() calling method java.io.File.<init>()


    public java.io.File getFileForUri(android.net.Uri p10)
    {
        String v2_1 = p10.getEncodedPath();
        int v4 = v2_1.indexOf(47, 1);
        String v5 = android.net.Uri.decode(v2_1.substring(1, v4));
        String vtmp6 = android.net.Uri.decode(v2_1.substring((v4 + 1)));
        java.io.File v3_1 = ((java.io.File) this.mRoots.get(v5));
        if (v3_1 != null) {
            try {
                java.io.File v1_2 = new java.io.File(v3_1, vtmp6).getCanonicalFile();
            } catch (java.io.IOException v0) {
                throw new IllegalArgumentException(new StringBuilder().append("Failed to resolve canonical path for ").append(v1_2).toString());
            }
            if (v1_2.getPath().startsWith(v3_1.getPath())) {
                return v1_2;
            } else {
                throw new SecurityException("Resolved path jumped beyond configured root");
            }
        } else {
            throw new IllegalArgumentException(new StringBuilder().append("Unable to find configured root for ").append(p10).toString());
        }
    }

Method com.afwsamples.testdpc.policy.PolicyManagementFragment.getStorageUri() calling method java.io.File.<init>()


    private android.net.Uri getStorageUri(String p5)
    {
        java.io.File v0_1 = new java.io.File(new StringBuilder().append(this.getActivity().getFilesDir()).append(java.io.File.separator).append("media").append(java.io.File.separator).append(p5).toString());
        v0_1.getParentFile().mkdirs();
        return android.support.v4.content.FileProvider.getUriForFile(this.getActivity(), "com.afwsamples.testdpc.fileprovider", v0_1);
    }

Method android.support.v4.util.AtomicFile.<init>() calling method java.io.File.<init>()


    public AtomicFile(java.io.File p4)
    {
        this.mBaseName = p4;
        this.mBackupName = new java.io.File(new StringBuilder().append(p4.getPath()).append(".bak").toString());
        return;
    }

Method android.support.v4.content.FileProvider.buildPath() calling method java.io.File.<init>()


    private static varargs java.io.File buildPath(java.io.File p6, String[] p7)
    {
        int v4 = p7.length;
        int v3 = 0;
        java.io.File v2 = p6;
        while (v3 < v4) {
            java.io.File v1_2;
            String v5 = p7[v3];
            if (v5 == null) {
                v1_2 = v2;
            } else {
                v1_2 = new java.io.File(v2, v5);
            }
            v3++;
            v2 = v1_2;
        }
        return v2;
    }

Method android.support.v4.content.FileProvider.<clinit>() calling method java.io.File.<init>()


    static FileProvider()
    {
        java.util.HashMap v0_1 = new String[2];
        v0_1[0] = "_display_name";
        v0_1[1] = "_size";
        android.support.v4.content.FileProvider.COLUMNS = v0_1;
        android.support.v4.content.FileProvider.DEVICE_ROOT = new java.io.File("/");
        android.support.v4.content.FileProvider.sCache = new java.util.HashMap();
        return;
    }

Method android.support.v4.content.ContextCompat.getNoBackupFilesDir() calling method java.io.File.<init>()


    public final java.io.File getNoBackupFilesDir(android.content.Context p6)
    {
        java.io.File v2_1;
        if (android.os.Build$VERSION.SDK_INT < 21) {
            v2_1 = android.support.v4.content.ContextCompat.createFilesDir(new java.io.File(p6.getApplicationInfo().dataDir, "no_backup"));
        } else {
            v2_1 = android.support.v4.content.ContextCompatApi21.getNoBackupFilesDir(p6);
        }
        return v2_1;
    }

Method android.support.v4.content.ContextCompat.getCodeCacheDir() calling method java.io.File.<init>()


    public final java.io.File getCodeCacheDir(android.content.Context p6)
    {
        java.io.File v2_1;
        if (android.os.Build$VERSION.SDK_INT < 21) {
            v2_1 = android.support.v4.content.ContextCompat.createFilesDir(new java.io.File(p6.getApplicationInfo().dataDir, "code_cache"));
        } else {
            v2_1 = android.support.v4.content.ContextCompatApi21.getCodeCacheDir(p6);
        }
        return v2_1;
    }

Method android.support.v4.content.ContextCompat.buildPath() calling method java.io.File.<init>()


    private static varargs java.io.File buildPath(java.io.File p6, String[] p7)
    {
        int v4 = p7.length;
        int v3 = 0;
        java.io.File v2 = p6;
        while (v3 < v4) {
            java.io.File v1_1;
            String v5 = p7[v3];
            if (v2 != null) {
                if (v5 == null) {
                    v1_1 = v2;
                } else {
                    v1_1 = new java.io.File(v2, v5);
                }
            } else {
                v1_1 = new java.io.File(v5);
            }
            v3++;
            v2 = v1_1;
        }
        return v2;
    }