48 #include "javacommonutils.h" |
54 #include "javacommonutils.h" |
49 #include "logger.h" |
55 #include "logger.h" |
50 |
56 |
51 // NAMESPACE DECLARATION |
57 // NAMESPACE DECLARATION |
52 using namespace java; |
58 using namespace java; |
53 |
59 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
60 using namespace SwiUI; |
|
61 #endif // !SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
62 |
|
63 IMPORT_C HBufC* CreateHBufCFromJavaStringLC(JNIEnv* aEnv, jstring aString); |
|
64 |
|
65 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
54 /** |
66 /** |
55 * MIDP Stub SIS file UID. The application type Uid for MIDlets in S60 |
67 * MIDP Stub SIS file UID. The application type Uid for MIDlets in S60 |
56 */ |
68 */ |
57 const TUid KMidletApplicationTypeUid = { 0x10210E26 }; |
69 const TUid KMidletApplicationTypeUid = { 0x10210E26 }; |
58 |
70 |
78 jint aUid, HBufC16 *aGroupName, HBufC16 *aMIDletName, HBufC16 *aTargetDrive, |
97 jint aUid, HBufC16 *aGroupName, HBufC16 *aMIDletName, HBufC16 *aTargetDrive, |
79 HBufC16 *aIconFileName, HBufC16 *aJarFileName, jboolean aHidden, |
98 HBufC16 *aIconFileName, HBufC16 *aJarFileName, jboolean aHidden, |
80 jboolean aBackground); |
99 jboolean aBackground); |
81 |
100 |
82 /** |
101 /** |
83 * Internal helper method for checking whether Application Shell is already running |
|
84 * Used JNI method ...1startAppShellUi |
|
85 * |
|
86 * @return ETrue if AppShell is running |
|
87 */ |
|
88 TBool isAppShellUiRunning(); |
|
89 |
|
90 /** |
|
91 * Internal helper method for checking whether this code is executing in |
102 * Internal helper method for checking whether this code is executing in |
92 * a device that has correctly working version of |
103 * a device that has correctly working version of |
93 * RApaLsSession::ForceCommitNonNativeApplicationsUpdatesL() |
104 * RApaLsSession::ForceCommitNonNativeApplicationsUpdatesL() |
94 * |
105 * |
95 * @return ETrue if force commit works well |
106 * @return ETrue if force commit works well |
96 */ |
107 */ |
97 TBool isForceCommitSupported(); |
108 TBool isForceCommitSupported(); |
|
109 #endif // !SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
110 |
|
111 /** |
|
112 * Internal helper method for checking whether Application Shell is already running |
|
113 * Used JNI method ...1startAppShellUi |
|
114 * |
|
115 * @return ETrue if AppShell is running |
|
116 */ |
|
117 TBool isAppShellUiRunning(); |
98 |
118 |
99 /** |
119 /** |
100 * Internal helper method for starting menu application |
120 * Internal helper method for starting menu application |
101 * |
121 * |
102 * @return KErrNone or Symbian error code |
122 * @return KErrNone or Symbian error code |
127 { |
147 { |
128 // Cannot connect to AppArc server |
148 // Cannot connect to AppArc server |
129 return err; |
149 return err; |
130 } |
150 } |
131 |
151 |
132 #if 1 |
152 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
133 //#ifndef RD_JAVA_USIF_APP_REG |
|
134 // Delete any pending (un)registrations (possible if |
153 // Delete any pending (un)registrations (possible if |
135 // e.g. device rebooted before commit). |
154 // e.g. device rebooted before commit). |
136 // This call does nothing if there is no pending registrations. |
155 // This call does nothing if there is no pending registrations. |
137 // Ignore errors. |
156 // Ignore errors. |
138 (void)pApaSession->RollbackNonNativeApplicationsUpdates(); |
157 (void)pApaSession->RollbackNonNativeApplicationsUpdates(); |
143 { |
162 { |
144 // Close session and return error |
163 // Close session and return error |
145 pApaSession->Close(); |
164 pApaSession->Close(); |
146 return err; |
165 return err; |
147 } |
166 } |
148 #endif // RD_JAVA_USIF_APP_REG |
167 #endif // !SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
149 |
168 |
150 // Return handle to session. Utilize the fact that in Symbian |
169 // Return handle to session. Utilize the fact that in Symbian |
151 // all pointer addresses are MOD 4 so the last 2 bits are 0 |
170 // all pointer addresses are MOD 4 so the last 2 bits are 0 |
152 // and can be shifted out. This way the returned handle is |
171 // and can be shifted out. This way the returned handle is |
153 // always positive whereas Symbian error codes are always negative. |
172 // always positive whereas Symbian error codes are always negative. |
167 * @param[in] aJarFileName The full path name of the jar file |
186 * @param[in] aJarFileName The full path name of the jar file |
168 * @param[in] aHidden |
187 * @param[in] aHidden |
169 * @param[in] aBackground |
188 * @param[in] aBackground |
170 * @return 0 if registration succeeded or Symbian error code |
189 * @return 0 if registration succeeded or Symbian error code |
171 */ |
190 */ |
172 #if 0 |
191 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
173 //#ifdef RD_JAVA_USIF_APP_REG |
|
174 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1registerApplication |
192 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1registerApplication |
175 (JNIEnv */*aEnv*/, jclass /*aClass*/, jint /*aSessionHandle*/, jint /*aUid*/, jstring /*aGroupName*/, |
193 (JNIEnv */*aEnv*/, jclass /*aClass*/, jint /*aSessionHandle*/, jint /*aUid*/, jstring /*aGroupName*/, |
176 jstring /*aMIDletName*/, jstring /*aTargetDrive*/, jstring /*aIconFileName*/, |
194 jstring /*aMIDletName*/, jstring /*aTargetDrive*/, jstring /*aIconFileName*/, |
177 jstring /*aJarFileName*/, jboolean /*aHidden*/, jboolean /*aBackground*/) |
195 jstring /*aJarFileName*/, jboolean /*aHidden*/, jboolean /*aBackground*/) |
178 { |
196 { |
179 return KErrNone; |
197 return KErrNone; |
180 } |
198 } |
181 #else |
199 #else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
182 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1registerApplication |
200 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1registerApplication |
183 (JNIEnv *aEnv, jclass aClass, jint aSessionHandle, jint aUid, jstring aGroupName, |
201 (JNIEnv *aEnv, jclass aClass, jint aSessionHandle, jint aUid, jstring aGroupName, |
184 jstring aMIDletName, jstring aTargetDrive, jstring aIconFileName, |
202 jstring aMIDletName, jstring aTargetDrive, jstring aIconFileName, |
185 jstring aJarFileName, jboolean aHidden, jboolean aBackground) |
203 jstring aJarFileName, jboolean aHidden, jboolean aBackground) |
186 { |
204 { |
475 // close file server connection |
492 // close file server connection |
476 CleanupStack::PopAndDestroy(&fileServ); |
493 CleanupStack::PopAndDestroy(&fileServ); |
477 |
494 |
478 return err; |
495 return err; |
479 } |
496 } |
|
497 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
480 |
498 |
481 |
499 |
482 /** |
500 /** |
483 * Unregisters Java Application from S60 AppArc |
501 * Unregisters Java Application from S60 AppArc |
484 * |
502 * |
485 * @param[in] aSessionHandle |
503 * @param[in] aSessionHandle |
486 * @param[in] aUid The Uid of the application to be unregistered.. |
504 * @param[in] aUid The Uid of the application to be unregistered.. |
487 * @return 0 if unregistration succeeded or Symbian error code |
505 * @return 0 if unregistration succeeded or Symbian error code |
488 */ |
506 */ |
489 #if 0 |
507 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
490 //#ifdef RD_JAVA_USIF_APP_REG |
|
491 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1unregisterApplication |
508 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1unregisterApplication |
492 (JNIEnv *, jclass, jint /*aSessionHandle*/, jint /*aUid*/) |
509 (JNIEnv *, jclass, jint /*aSessionHandle*/, jint /*aUid*/) |
493 { |
510 { |
494 return KErrNone; |
511 return KErrNone; |
495 } |
512 } |
496 #else |
513 #else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
497 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1unregisterApplication |
514 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1unregisterApplication |
498 (JNIEnv *, jclass, jint aSessionHandle, jint aUid) |
515 (JNIEnv *, jclass, jint aSessionHandle, jint aUid) |
499 { |
516 { |
500 // Convert session handle to pointer. |
517 // Convert session handle to pointer. |
501 RApaLsSession *pApaSession = |
518 RApaLsSession *pApaSession = |
554 { |
570 { |
555 #ifdef __WINS__ |
571 #ifdef __WINS__ |
556 // Use always this synchronous commit when running in emulator |
572 // Use always this synchronous commit when running in emulator |
557 // to make writing autotest cases easier. |
573 // to make writing autotest cases easier. |
558 TRAP(err, pApaSession->CommitNonNativeApplicationsUpdatesL()); |
574 TRAP(err, pApaSession->CommitNonNativeApplicationsUpdatesL()); |
559 #else |
575 #else // __WINS__ |
560 // asynchronous commit |
576 // asynchronous commit |
561 TRAP(err, pApaSession->ForceCommitNonNativeApplicationsUpdatesL()); |
577 TRAP(err, pApaSession->ForceCommitNonNativeApplicationsUpdatesL()); |
562 #endif // __WINS__ |
578 #endif // __WINS__ |
563 } |
579 } |
564 #endif // RD_JAVA_USIF_APP_REG |
580 #endif // !SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
565 |
581 |
566 if (KErrNone == err) |
582 if (KErrNone == err) |
567 { |
583 { |
568 pApaSession->Close(); |
584 pApaSession->Close(); |
569 delete pApaSession; |
585 delete pApaSession; |
584 // Convert session handle to pointer. |
600 // Convert session handle to pointer. |
585 RApaLsSession *pApaSession = |
601 RApaLsSession *pApaSession = |
586 reinterpret_cast<RApaLsSession*>(aSessionHandle<<2); |
602 reinterpret_cast<RApaLsSession*>(aSessionHandle<<2); |
587 |
603 |
588 TInt err = KErrNone; |
604 TInt err = KErrNone; |
589 #if 1 |
605 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
590 //#ifndef RD_JAVA_USIF_APP_REG |
|
591 err = pApaSession->RollbackNonNativeApplicationsUpdates(); |
606 err = pApaSession->RollbackNonNativeApplicationsUpdates(); |
592 #endif // RD_JAVA_USIF_APP_REG |
607 #endif // !SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
593 pApaSession->Close(); |
608 pApaSession->Close(); |
594 delete pApaSession; |
609 delete pApaSession; |
595 |
610 |
596 return err; |
611 return err; |
597 } |
612 } |
972 else |
988 else |
973 { |
989 { |
974 return EFalse; |
990 return EFalse; |
975 } |
991 } |
976 } |
992 } |
|
993 #endif // !SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
994 |
|
995 /** |
|
996 * See JNI method __1logComponent. |
|
997 * This method makes calls that may leave. |
|
998 */ |
|
999 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1000 void AddInstallLogEntryL( |
|
1001 JNIEnv */*aEnv*/, jint /*aAction*/, jint /*aUid*/, |
|
1002 jstring /*aName*/, jstring /*aVendor*/, |
|
1003 jint /*aMajorVersion*/, jint /*aMinorVersion*/, jint /*aMicroVersion*/) |
|
1004 { |
|
1005 } |
|
1006 #else |
|
1007 void AddInstallLogEntryL( |
|
1008 JNIEnv *aEnv, jint aAction, jint aUid, jstring aName, jstring aVendor, |
|
1009 jint aMajorVersion, jint aMinorVersion, jint aMicroVersion) |
|
1010 { |
|
1011 TUid uid = TUid::Uid(aUid); |
|
1012 HBufC *name = CreateHBufCFromJavaStringLC(aEnv, aName); |
|
1013 HBufC *vendor = CreateHBufCFromJavaStringLC(aEnv, aVendor); |
|
1014 TVersion version(aMajorVersion, aMinorVersion, aMicroVersion); |
|
1015 |
|
1016 // Create log task object. |
|
1017 CTask* task = CTask::NewL(KLogTaskImplUid, EFalse); |
|
1018 CleanupStack::PushL(task); |
|
1019 |
|
1020 // Initalize log task parameters. |
|
1021 TLogTaskParam params; |
|
1022 params.iName.Copy(name->Left(KMaxLogNameLength)); |
|
1023 params.iVendor.Copy(vendor->Left(KMaxLogVendorLength)); |
|
1024 params.iVersion = version; |
|
1025 params.iUid = uid; |
|
1026 // Time must be universal time. |
|
1027 TTime time; |
|
1028 time.UniversalTime(); |
|
1029 params.iTime = time; |
|
1030 params.iAction = (TLogTaskAction)aAction; |
|
1031 params.iIsStartup = EFalse; // Startup list was not modified. |
|
1032 |
|
1033 TLogTaskParamPckg pckg(params); |
|
1034 task->SetParameterL(pckg, 0); |
|
1035 |
|
1036 // Create log task manager. |
|
1037 CTaskManager* taskManager = CTaskManager::NewL(); |
|
1038 CleanupStack::PushL(taskManager); |
|
1039 |
|
1040 // Add the log task to the task list. |
|
1041 taskManager->AddTaskL(task); |
|
1042 taskManager->ExecutePendingTasksL(); |
|
1043 |
|
1044 // Cleanup. |
|
1045 CleanupStack::PopAndDestroy(taskManager); |
|
1046 CleanupStack::Pop(task); |
|
1047 |
|
1048 CleanupStack::PopAndDestroy(vendor); |
|
1049 CleanupStack::PopAndDestroy(name); |
|
1050 } |
|
1051 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1052 |
|
1053 /** |
|
1054 * Adds an entry to platform installation log. |
|
1055 */ |
|
1056 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1addInstallLogEntry |
|
1057 (JNIEnv *aEnv, jclass, jint aAction, jint aUid, jstring aName, jstring aVendor, |
|
1058 jint aMajorVersion, jint aMinorVersion, jint aMicroVersion) |
|
1059 { |
|
1060 TRAPD(err, AddInstallLogEntryL( |
|
1061 aEnv, aAction, aUid, aName, aVendor, |
|
1062 aMajorVersion, aMinorVersion, aMicroVersion)); |
|
1063 return err; |
|
1064 } |