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

Commit 5f44e994 authored by Chris Wren's avatar Chris Wren Committed by Android (Google) Code Review
Browse files

serialize the GCM calls.

Bug: 8777815
Change-Id: Idb8f906d4c596ad4c0ac4a538a7c81453a026835
parent d6360ea9
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.CalendarContract;
import android.provider.CalendarContract.CalendarAlerts;
@@ -133,8 +134,15 @@ public class AlertActivity extends Activity implements OnClickListener {
        initiateGlobalDismiss(alarmIds);
    }

    @SuppressWarnings("unchecked")
    private void initiateGlobalDismiss(List<AlarmId> alarmIds) {
        GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds);
        new AsyncTask<List<AlarmId>, Void, Void>() {
            @Override
            protected Void doInBackground(List<AlarmId>... params) {
                GlobalDismissManager.dismissGlobally(getApplicationContext(), params[0]);
                return null;
            }
        }.execute(alarmIds);
    }

    private class QueryHandler extends AsyncQueryService {
+108 −123
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.calendar.alerts;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -25,7 +24,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.CalendarContract.CalendarAlerts;
import android.provider.CalendarContract.Calendars;
@@ -98,17 +96,12 @@ public class GlobalDismissManager extends BroadcastReceiver {
            Log.i(TAG, "no sender configured");
            return;
        }
        new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {

        Map<Long, Long> eventsToCalendars = lookupEventToCalendarMap(context, eventIds);
        Set<Long> calendars = new LinkedHashSet<Long>();
        calendars.addAll(eventsToCalendars.values());
        if (calendars.isEmpty()) {
                    Log.d(TAG, "foudn no calendars for events");
                    return null;
            Log.d(TAG, "found no calendars for events");
            return;
        }

        Map<Long, Pair<String, String>> calendarsToAccounts =
@@ -116,7 +109,7 @@ public class GlobalDismissManager extends BroadcastReceiver {

        if (calendarsToAccounts.isEmpty()) {
            Log.d(TAG, "found no accounts for calendars");
                    return null;
            return;
        }

        // filter out non-google accounts (necessary?)
@@ -136,7 +129,8 @@ public class GlobalDismissManager extends BroadcastReceiver {
        accounts.removeAll(existingAccounts);

        if (accounts.isEmpty()) {
                    return null;
            // nothing to do, we've already registered all the accounts.
            return;
        }

        // subscribe to remaining accounts
@@ -157,9 +151,6 @@ public class GlobalDismissManager extends BroadcastReceiver {
            .putStringSet(ACCOUNT_KEY, existingAccounts)
            .commit();
        }
                return null;
            }
        }.execute();
    }

    /**
@@ -175,9 +166,6 @@ public class GlobalDismissManager extends BroadcastReceiver {
            Log.i(TAG, "no sender configured");
            return;
        }
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
        Set<Long> eventIds = new HashSet<Long>(alarmIds.size());
        for (AlarmId alarmId: alarmIds) {
            eventIds.add(alarmId.mEventId);
@@ -187,7 +175,7 @@ public class GlobalDismissManager extends BroadcastReceiver {

        if (eventsToCalendars.isEmpty()) {
            Log.d(TAG, "found no calendars for events");
                    return null;
            return;
        }

        Set<Long> calendars = new LinkedHashSet<Long>();
@@ -199,7 +187,7 @@ public class GlobalDismissManager extends BroadcastReceiver {

        if (calendarsToAccounts.isEmpty()) {
            Log.d(TAG, "found no accounts for calendars");
                    return null;
            return;
        }

        // TODO group by account to reduce queries
@@ -231,7 +219,7 @@ public class GlobalDismissManager extends BroadcastReceiver {

        if (syncIdToAccount.isEmpty()) {
            Log.d(TAG, "found no syncIds for events");
                    return null;
            return;
        }

        // TODO group by account to reduce packets
@@ -252,9 +240,6 @@ public class GlobalDismissManager extends BroadcastReceiver {
            }
            cnb.close();
        }
                return null;
            }
        }.execute();
    }

    private static Uri asSync(Uri uri, String accountType, String account) {