Home | History | Annotate | Download | only in stk
      1 /*
      2  * Copyright (C) 2007 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.stk;
     18 
     19 import android.app.Application;
     20 
     21 import com.android.internal.telephony.gsm.stk.Duration;
     22 
     23 /**
     24  * Top-level Application class for STK app.
     25  */
     26 abstract class StkApp extends Application {
     27     // Application constants
     28     public static final boolean DBG = true;
     29 
     30     // Identifiers for option menu items
     31     static final int MENU_ID_END_SESSION = android.view.Menu.FIRST;
     32     static final int MENU_ID_BACK = android.view.Menu.FIRST + 1;
     33     static final int MENU_ID_HELP = android.view.Menu.FIRST + 2;
     34 
     35     // UI timeout, 30 seconds - used for display dialog and activities.
     36     static final int UI_TIMEOUT = (40 * 1000);
     37 
     38     // Tone default timeout - 2 seconds
     39     static final int TONE_DFEAULT_TIMEOUT = (2 * 1000);
     40 
     41     public static final String TAG = "STK App";
     42 
     43     /**
     44      * This function calculate the time in MS from a duration instance.
     45      * returns zero when duration is null.
     46      */
     47     public static int calculateDurationInMilis(Duration duration) {
     48         int timeout = 0;
     49         if (duration != null) {
     50             switch (duration.timeUnit) {
     51             case MINUTE:
     52                 timeout = 1000 * 60;
     53                 break;
     54             case TENTH_SECOND:
     55                 timeout = 1000 * 10;
     56                 break;
     57             case SECOND:
     58             default:
     59                 timeout = 1000;
     60                 break;
     61             }
     62             timeout *= duration.timeInterval;
     63         }
     64         return timeout;
     65     }
     66 }
     67