1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 package com.android.inputmethod.dictionarypack;
18 
19 import android.content.BroadcastReceiver;
20 import android.content.Context;
21 import android.content.Intent;
22 
23 public final class EventHandler extends BroadcastReceiver {
24     /**
25      * Receives a intent broadcast.
26      *
27      * We receive every day a broadcast indicating that date changed.
28      * Then we wait a random amount of time before actually registering
29      * the download, to avoid concentrating too many accesses around
30      * midnight in more populated timezones.
31      * We receive all broadcasts here, so this can be either the DATE_CHANGED broadcast, the
32      * UPDATE_NOW private broadcast that we receive when the time-randomizing alarm triggers
33      * for regular update or from applications that want to test the dictionary pack, or a
34      * broadcast from DownloadManager telling that a download has finished.
35      * See inside of AndroidManifest.xml to see which events are caught.
36      * Also @see {@link BroadcastReceiver#onReceive(Context, Intent)}
37      *
38      * @param context the context of the application.
39      * @param intent the intent that was broadcast.
40      */
41     @Override
onReceive(final Context context, final Intent intent)42     public void onReceive(final Context context, final Intent intent) {
43         intent.setClass(context, DictionaryService.class);
44         context.startService(intent);
45     }
46 }
47