/**
   @SYMTestCaseID		APPFWK-APPARC-0036

   @SYMPREQ			    Policing server apis

   @SYMTestCaseDesc 	Testing whether untrusted applications are able to override MIME types mapping

   @SYMTestPriority 	High

   @SYMTestStatus 		Implemented

   @SYMTestActions      To connect to RApaLsSession and try to register trusted and untrusted apps for mime types.
   @SYMTestExpectedResults Test should complete without any panic.

 */
void CT_DataTypeMappingWithSid1::ExecuteL(RApaLsSession& aLs)
{
    TInt ret;
    TBool added=EFalse;
    _LIT8(KLitAudioFake, "audio/fakedata");

    TDataType dataType( KLitAudioFake );

    TUid trustedAppUid = {0x10207f8f};
    TUid untrustedAppUid = {0xA3010010};
    TUid retAppUid( KNullUid );

    ret=aLs.InsertDataMapping(dataType, KDataTypePriorityHigh, trustedAppUid);
    INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityHigh"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid);
    TEST(retAppUid == trustedAppUid);

    ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, untrustedAppUid, added);
    INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), untrustedAppUid, retAppUid);
    TEST(retAppUid == untrustedAppUid);

    ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, trustedAppUid, added);
    INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid);
    TEST(retAppUid == trustedAppUid);

    ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh+1, untrustedAppUid, added);
    INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with KDataTypePriorityTrustedHigh+1"));
    INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    ret = aLs.AppForDataType(dataType,retAppUid);
    INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
    INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid);
    TEST(retAppUid == trustedAppUid);

    //delete data type mapping
    ret=aLs.DeleteDataMapping(dataType);
    INFO_PRINTF3(_L("Deleting data mapping: Expected return code: %d, Actual return code: %d"), KErrNone, ret);
    TEST(ret==KErrNone);
}
Beispiel #2
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TInt CExPolicy_Server::SetFileMapping(TFileMappingItem& aDataMapping)
{		
	TInt RetErr(KErrNone);
	RApaLsSession ls;
	RetErr= ls.Connect();
	if(RetErr == KErrNone)
	{
		if(aDataMapping.iUid.iUid == 0)
		{
			RetErr = ls.DeleteDataMapping(aDataMapping.iDataType);			
		}
		else
		{
			RetErr = ls.InsertDataMapping(aDataMapping.iDataType,aDataMapping.iPriority,aDataMapping.iUid);
		}
		
	}

	ls.Close();
	
	return RetErr;
}