@@ -71,7 +71,7 @@ public void onRestore(Element element) {
7171 keymasterState = element .readByte ();
7272 repository .onRestore (element , oldPackageVersion , KM_APPLET_PACKAGE_VERSION );
7373 seProvider .onRestore (element , oldPackageVersion , KM_APPLET_PACKAGE_VERSION );
74- handleDataUpgrade ();
74+ handleDataUpgrade (oldPackageVersion );
7575 }
7676
7777 @ Override
@@ -99,38 +99,32 @@ public Element onSave() {
9999 }
100100
101101 public boolean isUpgradeAllowed (short oldVersion ) {
102- boolean upgradeAllowed = false ;
103- short oldMajorVersion = (short ) ((oldVersion >> 8 ) & 0x00FF );
104- short oldMinorVersion = (short ) (oldVersion & 0x00FF );
105- short currentMajorVersion = (short ) (KM_APPLET_PACKAGE_VERSION >> 8 & 0x00FF );
106- short currentMinorVersion = (short ) (KM_APPLET_PACKAGE_VERSION & 0x00FF );
107102 // Downgrade of the Applet is not allowed.
108- // Upgrade is not allowed to a next version which is not immediate.
109- if ((short ) (currentMajorVersion - oldMajorVersion ) == 1 ) {
110- if (currentMinorVersion == 0 ) {
111- upgradeAllowed = true ;
112- }
113- } else if ((short ) (currentMajorVersion - oldMajorVersion ) == 0 ) {
114- if (currentMinorVersion >= oldMinorVersion ) {
115- upgradeAllowed = true ;
116- }
103+ if (oldVersion > KM_APPLET_PACKAGE_VERSION ) {
104+ return false ;
117105 }
118- return upgradeAllowed ;
106+ return true ;
119107 }
120108
121- public void handleDataUpgrade () {
122- // In version 3.0, two new provisionStatus states are introduced
123- // 1. PROVISION_STATUS_SE_LOCKED - bit 6 of provisionStatus
124- // 2. PROVISION_STATUS_OEM_PUBLIC_KEY - bit 7 of provisionStatus
125- // In the process of upgrade from 2.0 to 3.0 OEM PUBLIC Key is provisioned
126- // in SEProvider.so update the state of the provision status by making
127- // 7th bit HIGH.
128- provisionStatus |= PROVISION_STATUS_OEM_ROOT_PUBLIC_KEY ;
129- // Check if the provisioning is already locked. If so update
130- // the state of the provisionStatus by making 6th bit HIGH.
131- // Lock the SE Factory provisioning as well.
132- if ( 0 != (provisionStatus & PROVISION_STATUS_OEM_PROVISIONING_LOCKED )) {
133- provisionStatus |= PROVISION_STATUS_SE_FACTORY_PROVISIONING_LOCKED ;
109+ public void handleDataUpgrade (short oldVersion ) {
110+ switch (oldVersion ) {
111+ case KM_APPLET_PACKAGE_VERSION_2_0 :
112+ // In version 3.0, two new provisionStatus states are introduced
113+ // 1. PROVISION_STATUS_SE_LOCKED - bit 6 of provisionStatus
114+ // 2. PROVISION_STATUS_OEM_PUBLIC_KEY - bit 7 of provisionStatus
115+ // In the process of upgrade from 2.0 to 3.0 OEM PUBLIC Key is provisioned
116+ // in SEProvider.so update the state of the provision status by making
117+ // 7th bit HIGH.
118+ provisionStatus |= PROVISION_STATUS_OEM_ROOT_PUBLIC_KEY ;
119+ // Check if the provisioning is already locked. If so update
120+ // the state of the provisionStatus by making 6th bit HIGH.
121+ // Lock the SE Factory provisioning as well.
122+ if (0 != (provisionStatus & PROVISION_STATUS_OEM_PROVISIONING_LOCKED )) {
123+ provisionStatus |= PROVISION_STATUS_SE_FACTORY_PROVISIONING_LOCKED ;
124+ }
125+ break ;
126+ default :
127+ break ;
134128 }
135129 }
136130}
0 commit comments