Symbian Security Studio

About symbian software programming ,security analysis and other things about symbian.

Monday, April 28, 2008

E32USER-CBase 66

E32USER-CBase 66的错误很诡异,竟然只要在函数外加上TRAPD就行了。
例如
TRAPD(err, iTree->ClearL(););
User::LeaveIfError(err);
原来是iTree->ClearL();
官方的说法是
This panic is raised if an attempt is being made to insert a cleanup item into a position on the cleanup stack reserved for marking the current TRAP nest level. In practice this error occurs if the call to CleanupStack::PushL() happens when there has been no call to TRAP().
学习啊学习啊

Tuesday, April 22, 2008

Symbian expanding R&D team in China

Symbian expanding R&D team in China

Symbian, after established an R&D center in August 2007 in Beijing, is expanding its R&D team in China, with the number of staff likely to reach 160 by the end of 2008 and further increase to 250-300 in 2009, according to market sources in China.

Consumers in China accounted for about 10% of the 77.3 million Symbian smartphones shipped to consumers worldwide in 2007, making China an increasingly important market for Symbian, the sources noted.

In addition, Symbian applications developed by developers in China currently account for one out of eight Symbian applications in use worldwide, the sources added.

Thursday, April 10, 2008

Symbian中如何转换异步操作为同步操作

因为Symbian中的一个核心思想是利用单线程中的活动对象来实现多线程操作,所以我们经常会遇到很多操作是用活动对象完成的。大多数情况下,正如Symbian推荐的一样,使用活动对象有很多好处,开销更小,更快。但是,在实际操作中给开发者带来的难度也不小,不过这也是嵌入式开发的一个通病。
最不可思议的事情是有很多很明显的同步事件竟然也要用异步完成,如图像的编码解码,取得IMEI,这些操作很多情况下都是需要即时处理的,如果用异步操作有时候感觉很奇怪。
这里我对现有的异步操作转换为同步操作的方法做一个简单介绍:
第一种是使用User::WaitForRequest(),这也是Symbian推荐的一种方法,比较简单,在很多情况下比较方便。很多书里面都有介绍。这里我就不多说了。
第二种是使用
CActiveSchedulerWait *iWait;
iWait->Start();
aWait->AsyncStop();
为什么要使用CActiveSchedulerWait呢?因为很多情况下使用第一种方法会出现得不到响应的情况,就是始终卡在WaitForRequest上,这个现象我们会在下一篇文章中进行介绍。
那么如何使用CActiveSchedulerWait呢,关键是理解他的原理。CActiveSchedulerWait与CActiveScheduler是合作使用的,所以你必须已经安装CActiveScheduler并开启,这在GUI程序中并不困难,因为一般架构默认生成,在exe中就需要好好安排。
首先初始化一个CActiveSchedulerWait,然后在你的异步对象函数后调用,例如
iImageEncoder->Convert( &iStatus, *iBitmap );
SetActive();
iWait->Start();
这样程序就会卡在这里等待异步事件完成。
但是当异步事件完成后,你必须通知aWait->AsyncStop();
这行函数应该在iImageEncoder的RunL中调用,它会通知iWait停止等待。
这样就成功了。
在第三版中如果iWait->Start();//Panics with KERN-EXEC 3
多半是mmp文件中EPOCSTACKSIZE 的设置不对。

--------------------
zesky 版权所有
如果转载请注明出自www.symbian-security.cn

Labels: , ,

Monday, April 7, 2008

使用CBufferedImageDecoder 的小问题

我使用CBufferedImageDecoder 来处理缓冲中的图像,已经在模拟器上实现了,可是在真机上,总是在OpenL失败,不知道什么原因?
[CODE]CThumbDecoder* CThumbDecoder::NewL( CFbsBitmap* bitmap,HBufC8* data,RFs& fs,MThumbDecoder &observer )
{
CThumbDecoder* self=new(ELeave)CThumbDecoder(bitmap,data,observer);
CleanupStack::PushL(self);
StartLog(_L("ConstuctL"));
self->ConstuctL(fs);
StartLog(_L("OpenL"));
self->OpenL();
StartLog(_L("ConvertL"));
self->ConvertL();
StartLog(_L(""));
CleanupStack::Pop();
return self;
}
void CThumbDecoder::OpenL()
{
// const CImageDecoder::TOptions options = CImageDecoder::EOptionAlwaysThread;
iDecoder->OpenL(*iData/*,options*/);
iBitmap->Create(iDecoder->FrameInfo().iOverallSizeInPixels,
iDecoder->FrameInfo().iFrameDisplayMode );
}
void CThumbDecoder::ConstuctL(RFs& fs)
{
iDecoder=CBufferedImageDecoder::NewL(fs);
CActiveScheduler::Add(this);
}[/CODE]
参数设为EOptionAlwaysThread或者不设我都试过,在真机上都退出了。
关键是模拟器上一切正常,真机却总是失败。
后来我突然想起来,真机与模拟器相比最大的区别就是内存大小!
所以我在模拟器上为了方便处理设置的大的处理图像的内存在真机上可能不行,所以失败了,后来把图像缓冲的大小从40000改到4000就Ok了。
不过这只是用来处理小图像,估计大图像还得用大缓冲,具体怎么搞,再研究吧。

Thursday, April 3, 2008

如何Symbian下如何处理非文件的CFbsBitmap图像显示及处理

在Symbian中如果要进行图像相关的操作,就必须使用CFbsBitmap来进行相关操作。而Symbian得这种图像格式是不公开的,因此在显示之前都是使用CImageDecoder进行适当的转换,但是在使用过程中,我发现这个类只能处理存储在磁盘上的文件,并把它进行转换。当然,在绝大多数情况下我们都是把磁盘上的图像文件拿过来进行显示,但是也有很多情况,图像经过处理是在内存中存在,并没有进行保存,比如我们从网络上下载的图像,或者我们自定义情况下的图像处理过程,还有就是大量的游戏中的图像处理。
在Nokia论坛有很多讨论
http://discussion.forum.nokia.com/forum/showthread.php?t=32326&highlight=InternalizeL+CFbsBitmap
但是貌似还没有得到合适的方法
经过查阅资料我发现有一个类可以很方便地解决这个问题
CBufferedImageDecoder
OpenL()
void OpenL(const TDesC8& aSourceData, const TDesC8& aMIMEType, const CImageDecoder::TOptions aOptions=CImageDecoder::EOptionNone);
Description
Creates a decoder for the image in the source buffer.

The plugin decoder to use is determined by the specified MIME type (aMIMEType). If an appropriate plugin decoder is found it is used to scan the beginning of the image.

If no appropriate plugin decoder can be found this function leaves with KEComErrNoInterfaceIdentified.

这样们就可以把图像首先读取成HBuf8,在用Open打开,进行转换。
这样就可以解决很多问题。

---------------------
zesky
版权所有
www.symbian-security.cn

Labels: , ,