Home | History | Annotate | Download | only in cellbroadcastreceiver
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of 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,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.cellbroadcastreceiver;
     18 
     19 import android.app.Application;
     20 import android.telephony.CellBroadcastMessage;
     21 
     22 import java.util.ArrayList;
     23 
     24 /**
     25  * The application class loads the default preferences at first start,
     26  * and remembers the time of the most recently received broadcast.
     27  */
     28 public class CellBroadcastReceiverApp extends Application {
     29     private static final String TAG = "CellBroadcastReceiverApp";
     30 
     31     /** List of unread non-emergency alerts to show when user selects the notification. */
     32     private static final ArrayList<CellBroadcastMessage> sNewMessageList =
     33             new ArrayList<CellBroadcastMessage>(4);
     34 
     35     /** Latest area info cell broadcast received. */
     36     private static CellBroadcastMessage sLatestAreaInfo;
     37 
     38     /** Adds a new unread non-emergency message and returns the current list. */
     39     static ArrayList<CellBroadcastMessage> addNewMessageToList(CellBroadcastMessage message) {
     40         sNewMessageList.add(message);
     41         return sNewMessageList;
     42     }
     43 
     44     /** Clears the list of unread non-emergency messages. */
     45     static void clearNewMessageList() {
     46         sNewMessageList.clear();
     47     }
     48 
     49     /** Saves the latest area info broadcast received. */
     50     static void setLatestAreaInfo(CellBroadcastMessage areaInfo) {
     51         sLatestAreaInfo = areaInfo;
     52     }
     53 
     54     /** Returns the latest area info broadcast received. */
     55     static CellBroadcastMessage getLatestAreaInfo() {
     56         return sLatestAreaInfo;
     57     }
     58 }
     59