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

Commit 2cfa060e authored by Nan Wu's avatar Nan Wu
Browse files

Fix NullPointerException caused by logging

This reverts commit 22601e04 and
fix the bug.

Bug: 268248340
Test: manual test

Change-Id: I23bf0b2fc124b6b4073d276469f9646a5736c065
parent 672c2e10
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.system.Os;
import android.system.OsConstants;
import android.system.StructStat;
import android.util.Log;
import android.util.Slog;

import dalvik.system.CloseGuard;
import dalvik.system.VMRuntime;
@@ -329,6 +330,14 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {
    }

    private static FileDescriptor openInternal(File file, int mode) throws FileNotFoundException {
        if ((mode & MODE_WRITE_ONLY) != 0 && (mode & MODE_APPEND) == 0
                && (mode & MODE_TRUNCATE) == 0 && ((mode & MODE_READ_ONLY) == 0)
                && file != null && file.exists()) {
            Slog.wtfQuiet(TAG, "ParcelFileDescriptor.open is called with w without t or a or r, "
                    + "which will have a different behavior beginning in Android Q."
                    + "\nMode: " + mode + "\nFilename: " + file.getPath());
        }

        final int flags = FileUtils.translateModePfdToPosix(mode) | ifAtLeastQ(O_CLOEXEC);

        int realMode = S_IRWXU | S_IRWXG;