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

Commit 6195eb13 authored by David Turner's avatar David Turner Committed by Android (Google) Code Review
Browse files

Merge "Prevent Dropbox from crashing system server pre-boot." into honeycomb

parents 48395385 34165c69
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -97,10 +97,18 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub {
    // Ensure that all log entries have a unique timestamp
    private long mLastTimestamp = 0;

    private volatile boolean mBooted = false;

    /** Receives events that might indicate a need to clean up files. */
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent != null && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                mBooted = true;
                return;
            }

            // Else, for ACTION_DEVICE_STORAGE_LOW:
            mCachedQuotaUptimeMillis = 0;  // Force a re-check of quota size

            // Run the initialization in the background (not this main thread).
@@ -132,7 +140,11 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub {
        // Set up intent receivers
        mContext = context;
        mContentResolver = context.getContentResolver();
        context.registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW));

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        context.registerReceiver(mReceiver, filter);

        mContentResolver.registerContentObserver(
            Settings.Secure.CONTENT_URI, true,
@@ -224,6 +236,9 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub {
            Intent dropboxIntent = new Intent(DropBoxManager.ACTION_DROPBOX_ENTRY_ADDED);
            dropboxIntent.putExtra(DropBoxManager.EXTRA_TAG, tag);
            dropboxIntent.putExtra(DropBoxManager.EXTRA_TIME, time);
            if (!mBooted) {
                dropboxIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
            }
            mContext.sendBroadcast(dropboxIntent, android.Manifest.permission.READ_LOGS);

        } catch (IOException e) {