1 /* 2 * Copyright (C) 2007-2008 Esmertec AG. 3 * Copyright (C) 2007-2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mms.transaction; 19 20 import com.android.mms.R; 21 import com.android.mms.ui.ManageSimMessages; 22 23 import android.app.Notification; 24 import android.app.NotificationManager; 25 import android.app.PendingIntent; 26 import android.content.BroadcastReceiver; 27 import android.content.Context; 28 import android.content.Intent; 29 import android.provider.Settings; 30 import android.provider.Telephony; 31 32 /** 33 * Receive Intent.SIM_FULL_ACTION. Handle notification that SIM is full. 34 */ 35 public class SimFullReceiver extends BroadcastReceiver { 36 37 @Override 38 public void onReceive(Context context, Intent intent) { 39 if (Settings.Secure.getInt(context.getContentResolver(), 40 Settings.Secure.DEVICE_PROVISIONED, 0) == 1 && 41 Telephony.Sms.Intents.SIM_FULL_ACTION.equals(intent.getAction())) { 42 43 NotificationManager nm = (NotificationManager) 44 context.getSystemService(Context.NOTIFICATION_SERVICE); 45 46 Intent viewSimIntent = new Intent(context, ManageSimMessages.class); 47 viewSimIntent.setAction(Intent.ACTION_VIEW); 48 viewSimIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 49 PendingIntent pendingIntent = PendingIntent.getActivity( 50 context, 0, viewSimIntent, 0); 51 52 Notification notification = new Notification(); 53 notification.icon = R.drawable.stat_sys_no_sim; 54 notification.tickerText = context.getString(R.string.sim_full_title); 55 notification.defaults = Notification.DEFAULT_ALL; 56 57 notification.setLatestEventInfo( 58 context, context.getString(R.string.sim_full_title), 59 context.getString(R.string.sim_full_body), 60 pendingIntent); 61 nm.notify(ManageSimMessages.SIM_FULL_NOTIFICATION_ID, notification); 62 } 63 } 64 65 } 66