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

Commit efa2abad authored by gang.huang's avatar gang.huang Committed by gang huang
Browse files

Fix FD leaks in BootReceiver.

Bug: 372123174
Test: Manual.
Change-Id: I32e8030c025ad2403c961eadacafc97abdf76085
parent 0d42cb57
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.modules.utils.TypedXmlPullParser;
import com.android.modules.utils.TypedXmlSerializer;
import com.android.server.am.DropboxRateLimiter;

import libcore.io.IoUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

@@ -147,6 +148,10 @@ public class BootReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(final Context context, Intent intent) {
        if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
            return;
        }

        // Log boot events in the background to avoid blocking the main thread with I/O
        new Thread() {
            @Override
@@ -212,6 +217,8 @@ public class BootReceiver extends BroadcastReceiver {
                } catch (Exception e) {
                    Slog.wtf(TAG, "Error watching for trace events", e);
                    return 0;  // Unregister the handler.
                } finally {
                    IoUtils.closeQuietly(fd);
                }
                return OnFileDescriptorEventListener.EVENT_INPUT;
            }