28 #include "TerminalControlSession.h" |
28 #include "TerminalControlSession.h" |
29 #include "PlatformSecurityPolicies.h" |
29 #include "PlatformSecurityPolicies.h" |
30 #include "TcTrustedSession.h" |
30 #include "TcTrustedSession.h" |
31 //Device encryption utility |
31 //Device encryption utility |
32 #include <DevEncEngineConstants.h> |
32 #include <DevEncEngineConstants.h> |
33 #include <DevEncSession.h> |
33 #include <DevEncSessionBase.h> |
34 //Feature manager |
34 //Feature manager |
35 #include <featmgr.h> |
35 #include <featmgr.h> |
36 //For debugging purpose |
36 //For debugging purpose |
37 #include "debug.h" |
37 #include "debug.h" |
38 |
38 |
1409 // Checks if phone memory is encrypted or not. |
1409 // Checks if phone memory is encrypted or not. |
1410 // --------------------------------------------------------- |
1410 // --------------------------------------------------------- |
1411 TBool CTerminalControlSession::IsDeviceMemoryEncrypted() |
1411 TBool CTerminalControlSession::IsDeviceMemoryEncrypted() |
1412 { |
1412 { |
1413 RDEBUG("CTerminalControlSession::IsDeviceMemoryEncrypted >>"); |
1413 RDEBUG("CTerminalControlSession::IsDeviceMemoryEncrypted >>"); |
1414 |
|
1415 TBool ret(EFalse); |
1414 TBool ret(EFalse); |
1416 |
|
1417 //First check if the feature is supported on device |
1415 //First check if the feature is supported on device |
1418 TRAPD(ferr, FeatureManager::InitializeLibL()); |
1416 TRAPD(ferr, FeatureManager::InitializeLibL()); |
1419 if (ferr != KErrNone) |
1417 if (ferr != KErrNone) |
1420 { |
1418 { |
1421 RDEBUG_2("feature mgr initialization error, %d", ferr); |
1419 RDEBUG_2("feature mgr initialization error, %d", ferr); |
1423 } |
1421 } |
1424 ret = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature); |
1422 ret = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature); |
1425 FeatureManager::UnInitializeLib(); |
1423 FeatureManager::UnInitializeLib(); |
1426 |
1424 |
1427 //If feature is supported, check if any drive is encrypted. |
1425 //If feature is supported, check if any drive is encrypted. |
|
1426 |
1428 if (ret) |
1427 if (ret) |
1429 { |
1428 { |
1430 CDevEncSession* devEncSession = new CDevEncSession( EDriveC ); |
1429 RLibrary library; |
|
1430 CDevEncSessionBase* devEncSession = NULL; |
|
1431 TInt err = library.Load(KDevEncCommonUtils); |
1431 |
1432 |
|
1433 if (err != KErrNone) |
|
1434 { |
|
1435 RDEBUG_2("Error in finding the library... %d", err); |
|
1436 ret = EFalse; |
|
1437 } |
|
1438 else |
|
1439 { |
|
1440 TLibraryFunction entry = library.Lookup(1); |
|
1441 |
|
1442 if (!entry) |
|
1443 { |
|
1444 RDEBUG("Error in loading the library..."); |
|
1445 ret = EFalse; |
|
1446 } |
|
1447 else |
|
1448 { |
|
1449 devEncSession = (CDevEncSessionBase*) entry(); |
|
1450 RDEBUG("Library is found and loaded successfully..."); |
|
1451 } |
|
1452 } |
|
1453 |
1432 if (!devEncSession) |
1454 if (!devEncSession) |
1433 { |
1455 { |
1434 RDEBUG("Can't instantiate device encryption session.."); |
1456 RDEBUG("Can't instantiate device encryption session.."); |
1435 return EFalse; |
|
1436 } |
|
1437 |
|
1438 TInt err = devEncSession->Connect(); |
|
1439 if (KErrNone == err) |
|
1440 { |
|
1441 //Session with device encryption is established. Check if any drive is encrypted |
|
1442 TInt encStatus (KErrNone); |
|
1443 TInt err = devEncSession->DiskStatus( encStatus ); |
|
1444 RDEBUG_3("err = %d, encstatus = %d", err, encStatus); |
|
1445 if ( KErrNone == err && encStatus != EDecrypted ) |
|
1446 { |
|
1447 RDEBUG("Memory is encrypted"); |
|
1448 ret = ETrue; |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 RDEBUG("Memory is not encrypted"); |
|
1453 ret = EFalse; |
|
1454 } |
|
1455 } |
|
1456 else |
|
1457 { |
|
1458 RDEBUG_2("Error %d while establishing connection with device encryption engine", err); |
|
1459 ret = EFalse; |
1457 ret = EFalse; |
1460 } |
1458 } |
1461 |
1459 else |
1462 delete devEncSession; devEncSession = NULL; |
1460 { |
1463 } |
1461 devEncSession->SetDrive( EDriveC ); |
1464 |
1462 TInt err = devEncSession->Connect(); |
|
1463 if (err == KErrNone) |
|
1464 { |
|
1465 //Session with device encryption is established. Check if any drive is encrypted |
|
1466 TInt encStatus (KErrNone); |
|
1467 TInt err = devEncSession->DiskStatus( encStatus ); |
|
1468 devEncSession->Close(); |
|
1469 RDEBUG_2("encstatus = %d", encStatus); |
|
1470 if ( err == KErrNone && encStatus != EDecrypted ) |
|
1471 { |
|
1472 RDEBUG("Memory is encrypted"); |
|
1473 ret = ETrue; |
|
1474 } |
|
1475 else |
|
1476 { |
|
1477 RDEBUG("Memory is not encrypted"); |
|
1478 ret = EFalse; |
|
1479 } |
|
1480 } |
|
1481 else |
|
1482 { |
|
1483 RDEBUG_2("Error %d while establishing connection with device encryption engine", err); |
|
1484 ret = EFalse; |
|
1485 } |
|
1486 } |
|
1487 delete devEncSession; devEncSession = NULL; |
|
1488 |
|
1489 if (library.Handle()) |
|
1490 library.Close(); |
|
1491 |
|
1492 } |
1465 RDEBUG_2("CTerminalControlSession::IsDeviceMemoryEncrypted, ret = %d <<", ret); |
1493 RDEBUG_2("CTerminalControlSession::IsDeviceMemoryEncrypted, ret = %d <<", ret); |
1466 return ret; |
1494 return ret; |
1467 } |
1495 } |
1468 |
1496 |
1469 // ---------------------------------------------------------------------------------------- |
1497 // ---------------------------------------------------------------------------------------- |