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.cat.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     // Display Text timeouts
     36     static final int DISP_TEXT_CLEAR_AFTER_DELAY_TIMEOUT = (15 * 1000);
     37     static final int DISP_TEXT_WAIT_FOR_USER_TIMEOUT = (60 * 1000);
     38 
     39     // UI timeout, 30 seconds - used for menues and input
     40     static final int UI_TIMEOUT = (30 * 1000);
     41 
     42     // Tone default timeout - 2 seconds
     43     static final int TONE_DEFAULT_TIMEOUT = (2 * 1000);
     44 
     45     public static final String TAG = "STK App";
     46 
     47     /**
     48      * This function calculate the time in MS from a duration instance.
     49      * returns zero when duration is null.
     50      */
     51     public static int calculateDurationInMilis(Duration duration) {
     52         int timeout = 0;
     53         if (duration != null) {
     54             switch (duration.timeUnit) {
     55             case MINUTE:
     56                 timeout = 1000 * 60;
     57                 break;
     58             case TENTH_SECOND:
     59                 timeout = 1000 / 10;
     60                 break;
     61             case SECOND:
     62             default:
     63                 timeout = 1000;
     64                 break;
     65             }
     66             timeout *= duration.timeInterval;
     67         }
     68         return timeout;
     69     }
     70 }
     71