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 17package com.android.cellbroadcastreceiver; 18 19import android.app.Application; 20import android.telephony.CellBroadcastMessage; 21import android.util.Log; 22import android.preference.PreferenceManager; 23 24import java.util.ArrayList; 25import java.util.concurrent.atomic.AtomicInteger; 26 27/** 28 * The application class loads the default preferences at first start, 29 * and remembers the time of the most recently received broadcast. 30 */ 31public class CellBroadcastReceiverApp extends Application { 32 private static final String TAG = "CellBroadcastReceiverApp"; 33 34 @Override 35 public void onCreate() { 36 super.onCreate(); 37 // TODO: fix strict mode violation from the following method call during app creation 38 PreferenceManager.setDefaultValues(this, R.xml.preferences, false); 39 } 40 41 /** List of unread non-emergency alerts to show when user selects the notification. */ 42 private static final ArrayList<CellBroadcastMessage> sNewMessageList = 43 new ArrayList<CellBroadcastMessage>(4); 44 45 /** Latest area info cell broadcast received. */ 46 private static CellBroadcastMessage sLatestAreaInfo; 47 48 /** Adds a new unread non-emergency message and returns the current list. */ 49 static ArrayList<CellBroadcastMessage> addNewMessageToList(CellBroadcastMessage message) { 50 sNewMessageList.add(message); 51 return sNewMessageList; 52 } 53 54 /** Clears the list of unread non-emergency messages. */ 55 static void clearNewMessageList() { 56 sNewMessageList.clear(); 57 } 58 59 /** Saves the latest area info broadcast received. */ 60 static void setLatestAreaInfo(CellBroadcastMessage areaInfo) { 61 sLatestAreaInfo = areaInfo; 62 } 63 64 /** Returns the latest area info broadcast received. */ 65 static CellBroadcastMessage getLatestAreaInfo() { 66 return sLatestAreaInfo; 67 } 68} 69