javacommons/utils/tsrc/javasrc/com/nokia/mj/impl/rt/test/ApplicationUtilsImpl.java
changeset 80 d6dafc5d983f
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.mj.impl.rt.test;
       
    19 
       
    20 import java.security.Permission;
       
    21 import java.security.AccessControlException;
       
    22 
       
    23 import com.nokia.mj.impl.rt.support.ApplicationUtils;
       
    24 import com.nokia.mj.impl.rt.support.ApplicationInfo;
       
    25 import com.nokia.mj.impl.utils.Uid;
       
    26 
       
    27 public class ApplicationUtilsImpl extends ApplicationUtils
       
    28 {
       
    29 
       
    30     public static final int NOTIFY_CALL = 0;
       
    31     public static final int UI_DISPOSED_CALL = 1;
       
    32     public static final int PAUSE_CALL = 2;
       
    33     public static final int RESUME_CALL = 3;
       
    34     public static final int PERMISSION_CALL1 = 4;
       
    35     public static final int PERMISSION_CALL2 = 5;
       
    36 
       
    37     public static int[] mCalledArr = new int[6];
       
    38 
       
    39     static
       
    40     {
       
    41         clear();
       
    42     }
       
    43 
       
    44     public static Permission mPermission = null;
       
    45     public static Uid mUid = null;
       
    46 
       
    47     public static void clear()
       
    48     {
       
    49         for (int i = 0; i < mCalledArr.length; ++i)
       
    50         {
       
    51             mCalledArr[i] = 0;
       
    52         }
       
    53     }
       
    54 
       
    55     public static boolean checkCalls(int checkInd)
       
    56     {
       
    57         for (int i = 0; i < mCalledArr.length; ++i)
       
    58         {
       
    59             if (checkInd == i)
       
    60             {
       
    61                 if (mCalledArr[i] != 1)
       
    62                 {
       
    63                     return false;
       
    64                 }
       
    65             }
       
    66             else if (mCalledArr[i] != 0)
       
    67             {
       
    68                 return false;
       
    69             }
       
    70         }
       
    71         return true;
       
    72     }
       
    73 
       
    74     public static String print()
       
    75     {
       
    76         StringBuffer sb = new StringBuffer();
       
    77         for (int i = 0; i < mCalledArr.length; ++i)
       
    78         {
       
    79             sb.append("\n");
       
    80             sb.append("  " + (i + 1) + " == " + mCalledArr[i]);
       
    81         }
       
    82         return sb.toString();
       
    83     }
       
    84 
       
    85     public static void doShutdownImpl()
       
    86     {
       
    87 //        sInstance.doShutdown();
       
    88         ((ApplicationUtilsImpl)sInstance).doShutdown();
       
    89     }
       
    90 
       
    91     public void notifyExitCmd()
       
    92     {
       
    93         mCalledArr[NOTIFY_CALL]++;
       
    94     }
       
    95 
       
    96     public void uiDisposed()
       
    97     {
       
    98         mCalledArr[UI_DISPOSED_CALL]++;
       
    99     }
       
   100 
       
   101     public void pauseApplication()
       
   102     {
       
   103         mCalledArr[PAUSE_CALL]++;
       
   104     }
       
   105 
       
   106     public void resumeApplication()
       
   107     {
       
   108         mCalledArr[RESUME_CALL]++;
       
   109     }
       
   110 
       
   111     public void checkPermission(Permission p)
       
   112     throws AccessControlException,
       
   113         NullPointerException
       
   114     {
       
   115         mPermission = p;
       
   116         mCalledArr[PERMISSION_CALL1]++;
       
   117     }
       
   118 
       
   119     public void checkPermission(Uid appUid,Permission p)
       
   120     throws AccessControlException,
       
   121         NullPointerException
       
   122     {
       
   123         mPermission = p;
       
   124         mUid = appUid;
       
   125         mCalledArr[PERMISSION_CALL2]++;
       
   126     }
       
   127 
       
   128     public static void releaseWaiterImpl(boolean doStart)
       
   129     {
       
   130         ((ApplicationUtilsImpl)sInstance).releaseStartWaiter(doStart);
       
   131     }
       
   132 
       
   133 }