|
1 /* |
|
2 * Copyright (c) 2009 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: Java side Core UI accessor. |
|
15 * |
|
16 */ |
|
17 package com.nokia.mj.impl.coreuiavkon; |
|
18 |
|
19 import java.util.Hashtable; |
|
20 |
|
21 import com.nokia.mj.impl.utils.Uid; |
|
22 import com.nokia.mj.impl.utils.Logger; |
|
23 import com.nokia.mj.impl.rt.support.Jvm; |
|
24 import com.nokia.mj.impl.rt.support.ApplicationUtils; |
|
25 import com.nokia.mj.impl.rt.support.ApplicationInfo; |
|
26 |
|
27 import com.nokia.mj.impl.coreui.CoreUi; |
|
28 |
|
29 |
|
30 /** |
|
31 * A gate to CoreUi Avkon implementation. |
|
32 */ |
|
33 public class CoreUiImpl extends CoreUi |
|
34 { |
|
35 public static final int OrientationUndefined = 0; |
|
36 public static final int OrientationPortrait = 1; |
|
37 public static final int OrientationLandscape = 2; |
|
38 |
|
39 public static final int ScreenModeNoStartScreen = 0; |
|
40 public static final int ScreenModeDefaultStartScreen = 1; |
|
41 public static final int ScreenModeMidletDefinedScreen = 2; |
|
42 |
|
43 public CoreUiImpl() |
|
44 { |
|
45 // Load the native. |
|
46 Jvm.loadSystemLibrary("javacoreui"); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Connects to the already created CoreUi. |
|
51 * @return permission to start the application. There is a small time |
|
52 * window where user is able to cancel the application |
|
53 * start. In this case the CoreUi stores the request and |
|
54 * informs the caller of this method that the application |
|
55 * should not be started. |
|
56 */ |
|
57 protected boolean connectToUiImpl() |
|
58 { |
|
59 return _connect(); |
|
60 } |
|
61 |
|
62 /** |
|
63 * For creating the UI from Java side. This is meant for the pre-warmed |
|
64 * VM use case. Calling this method will lead creation of the CoreUI. |
|
65 * @param uid The UID of the application. |
|
66 * @param backGroundStart Should the UI be put into background. |
|
67 */ |
|
68 protected void createUiImpl(Uid uid, boolean backGroundStart) |
|
69 { |
|
70 int selectedOrientation = OrientationUndefined; |
|
71 int selectedScreenMode = ScreenModeDefaultStartScreen; |
|
72 |
|
73 ApplicationInfo appInfo = ApplicationInfo.getInstance(); |
|
74 |
|
75 String rootPath = appInfo.getRootPath(); |
|
76 |
|
77 String orientation = appInfo.getAttribute("Nokia-MIDlet-App-Orientation"); |
|
78 if (orientation != null) |
|
79 { |
|
80 if (orientation.toLowerCase().equals("portrait")) |
|
81 { |
|
82 selectedOrientation = OrientationPortrait; |
|
83 } |
|
84 else if (orientation.toLowerCase().equals("landscape")) |
|
85 { |
|
86 selectedOrientation = OrientationLandscape; |
|
87 } |
|
88 } |
|
89 |
|
90 String splashScreenImg = appInfo.getAttribute("MIDlet-Splash-Screen-Image"); |
|
91 if (splashScreenImg != null) |
|
92 { |
|
93 if (splashScreenImg.toLowerCase().equals("suppress")) |
|
94 { |
|
95 selectedScreenMode = ScreenModeNoStartScreen; |
|
96 backGroundStart = true; |
|
97 } |
|
98 else |
|
99 { |
|
100 selectedScreenMode = ScreenModeMidletDefinedScreen; |
|
101 } |
|
102 } |
|
103 if (!_createUi(uid.toString(), selectedOrientation, selectedScreenMode, |
|
104 rootPath, backGroundStart)) |
|
105 { |
|
106 Logger.LOG(Logger.EJavaUI, Logger.EInfo, "JAVA createUiImpl Error"); |
|
107 throw new RuntimeException("Core UI creation failed!"); |
|
108 } |
|
109 } |
|
110 |
|
111 /** |
|
112 * For asking the runtime to do the shutdown of the application. |
|
113 */ |
|
114 protected void shutdownRequestImpl() |
|
115 { |
|
116 ApplicationUtils.getInstance().notifyExitCmd(); |
|
117 } |
|
118 |
|
119 /** |
|
120 * For asking the runtime to bring the application to foreground. |
|
121 */ |
|
122 protected void foregroundRequestImpl() |
|
123 { |
|
124 _toForeground(); |
|
125 } |
|
126 |
|
127 /** |
|
128 * For asking if the UI is in foreground. |
|
129 */ |
|
130 protected boolean isUiInForegroundImpl() |
|
131 { |
|
132 return _isForeground(); |
|
133 } |
|
134 |
|
135 private native boolean _connect(); |
|
136 private native boolean _createUi(String appUid, int orientation, |
|
137 int selectedScreenMode, String rootpath, |
|
138 boolean backGroundStart); |
|
139 private native void _toForeground(); |
|
140 private native boolean _isForeground(); |
|
141 } |