• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 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.Dialog;
20 import android.app.StatusBarManager;
21 import android.content.Context;
22 import android.view.Gravity;
23 import android.view.KeyEvent;
24 import android.view.WindowManager;
25 import android.view.Window;
26 import android.os.Bundle;
27 
28 /**
29  * Base class for ICC-related panels in the Phone UI.
30  */
31 public class IccPanel extends Dialog {
32     protected static final String TAG = PhoneGlobals.LOG_TAG;
33 
34     private StatusBarManager mStatusBarManager;
35 
IccPanel(Context context)36     public IccPanel(Context context) {
37         super(context, R.style.IccPanel);
38     }
39 
40     @Override
onCreate(Bundle savedInstanceState)41     protected void onCreate(Bundle savedInstanceState) {
42         super.onCreate(savedInstanceState);
43         Window winP = getWindow();
44         winP.setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE);
45         winP.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
46                 WindowManager.LayoutParams.MATCH_PARENT);
47         winP.setGravity(Gravity.CENTER);
48 
49         // TODO: Ideally, we'd like this dialog to be visible in front of the
50         // keyguard, so the user will see it immediately after boot (without
51         // needing to enter the lock pattern or dismiss the keyguard first.)
52         //
53         // However that's not easy to do.  It's not just a matter of setting
54         // the FLAG_SHOW_WHEN_LOCKED and FLAG_DISMISS_KEYGUARD flags on our
55         // window, since we're a Dialog (not an Activity), and the framework
56         // won't ever let a dialog hide the keyguard (because there could
57         // possibly be stuff behind it that shouldn't be seen.)
58         //
59         // So for now, we'll live with the fact that the user has to enter the
60         // lock pattern (or dismiss the keyguard) *before* being able to type
61         // a SIM network unlock PIN.  That's not ideal, but still OK.
62         // (And eventually this will be a moot point once this UI moves
63         // from the phone app to the framework; see bug 1804111).
64 
65         // TODO: we shouldn't need the mStatusBarManager calls here either,
66         // once this dialog gets moved into the framework and becomes a truly
67         // full-screen UI.
68         PhoneGlobals app = PhoneGlobals.getInstance();
69         mStatusBarManager = (StatusBarManager) app.getSystemService(Context.STATUS_BAR_SERVICE);
70 
71         requestWindowFeature(Window.FEATURE_NO_TITLE);
72     }
73 
74     @Override
onStart()75     protected void onStart() {
76         super.onStart();
77         mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
78     }
79 
80     @Override
onStop()81     public void onStop() {
82         super.onStop();
83         mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
84     }
85 
onKeyDown(int keyCode, KeyEvent event)86     public boolean onKeyDown(int keyCode, KeyEvent event) {
87         if (keyCode == KeyEvent.KEYCODE_BACK) {
88             return true;
89         }
90 
91         return super.onKeyDown(keyCode, event);
92     }
93 }
94