Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2009 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.phone; |
| 18 | |
| 19 | import android.app.AlertDialog; |
| 20 | import android.content.Context; |
| 21 | import android.os.SystemProperties; |
| 22 | import android.util.Log; |
| 23 | import android.view.WindowManager; |
| 24 | |
| 25 | /** |
| 26 | * Helper class for displaying the DisplayInfo sent by CDMA network. |
| 27 | */ |
| 28 | public class CdmaDisplayInfo { |
| 29 | private static final String LOG_TAG = "CdmaDisplayInfo"; |
| 30 | private static final boolean DBG = (SystemProperties.getInt("ro.debuggable", 0) == 1); |
| 31 | |
| 32 | /** CDMA DisplayInfo dialog */ |
| 33 | private static AlertDialog sDisplayInfoDialog = null; |
| 34 | |
| 35 | /** |
| 36 | * Handle the DisplayInfo record and display the alert dialog with |
| 37 | * the network message. |
| 38 | * |
| 39 | * @param context context to get strings. |
| 40 | * @param infoMsg Text message from Network. |
| 41 | */ |
| 42 | public static void displayInfoRecord(Context context, String infoMsg) { |
| 43 | |
| 44 | if (DBG) log("displayInfoRecord: infoMsg=" + infoMsg); |
| 45 | |
| 46 | if (sDisplayInfoDialog != null) { |
| 47 | sDisplayInfoDialog.dismiss(); |
| 48 | } |
| 49 | |
| 50 | // displaying system alert dialog on the screen instead of |
| 51 | // using another activity to display the message. This |
| 52 | // places the message at the forefront of the UI. |
| 53 | sDisplayInfoDialog = new AlertDialog.Builder(context) |
| 54 | .setIcon(android.R.drawable.ic_dialog_info) |
| 55 | .setTitle(context.getText(R.string.network_message)) |
| 56 | .setMessage(infoMsg) |
| 57 | .setCancelable(true) |
| 58 | .create(); |
| 59 | |
| 60 | sDisplayInfoDialog.getWindow().setType( |
| 61 | WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); |
| 62 | sDisplayInfoDialog.getWindow().addFlags( |
| 63 | WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
| 64 | |
| 65 | sDisplayInfoDialog.show(); |
| 66 | PhoneGlobals.getInstance().wakeUpScreen(); |
| 67 | |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Dismiss the DisplayInfo record |
| 72 | */ |
| 73 | public static void dismissDisplayInfoRecord() { |
| 74 | |
| 75 | if (DBG) log("Dissmissing Display Info Record..."); |
| 76 | |
| 77 | if (sDisplayInfoDialog != null) { |
| 78 | sDisplayInfoDialog.dismiss(); |
| 79 | sDisplayInfoDialog = null; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | private static void log(String msg) { |
| 84 | Log.d(LOG_TAG, "[CdmaDisplayInfo] " + msg); |
| 85 | } |
| 86 | } |