Fix NullPointerException caused by logging

This reverts commit 22601e0422 and
fix the bug.

Bug: 268248340
Test: manual test

Change-Id: I23bf0b2fc124b6b4073d276469f9646a5736c065
This commit is contained in:
Nan Wu
2023-02-09 01:02:59 +00:00
parent 672c2e10e2
commit 2cfa060ece

View File

@@ -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;