symbian programming overview. 6.893 spring 2004: symbian larry rudolph how to program cellphone?...

24
Symbian Programming Overview

Upload: phebe-parker

Post on 21-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

Symbian Programming

Overview

Page 2: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

How to program Cellphone?

Limited to Series 60 phones

Java MidP 2.0 (see wiki, forums)

compile offline and load

limited API

C++

full API

non-standard C++

Python -- coming soon

Page 3: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Getting App onto Phone

Compile application into .app

Create package file (.pkg)

resources files, libraries

including a digitally signed certificate -- authentication -- and author’s key (.cer and .key)

Installation file (.sis) via makesis tool

Transfer to phone via email or bluetooth and then user installs

Page 4: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Overview of SymbianSymbian is a company that produces an operating system

Originally developed for handheld Psion and called Epoc Operating System

Symbian is 40% owned by Nokia, partly owned by Sony Ericson, partly owned by Psion, and others

Require 70% agreement to make basic changes

Page 5: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

A little history

Started in early days of C++

Goal to be

real-time

small footprint

small touch-screen

integrated

secure & reliable

Page 6: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Biggest Security Flaws

Applications must be certifiedIf not certified, user choice to continueApplications either GUI or Server

a server app can easily hideFile system not fully exposed to userFile system has no access control lists

despite kernel/user execution, any application can do anything

Application can control all keys

Page 7: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Biggest Programming Issue

System may run for years

Persistent state across power downs

addressbook application may never terminate

Small memory leaks accumulate over time

Must write perfect leak-free code!

unachievable goal

try anyway

Page 8: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Why will there be Memory Leaks

No garbage collection

No memory protection

no page tables

No “try”, “throw”, “catch”

operating systems calls

trap harness and leave

Silly naming conventions

Page 9: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Keep track of all allocated objects

Always keep live pointer to anything allocated in heap

can use pointer to deallocate

extra care when constructing compound classes

Deallocate after use

Page 10: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Stacks

Objects allocated at top of stack

Top of stack disappears when procedure returns

Cannot construct objects on stack since they maybe constructed in procedure

Objects go in heap

No reference counts on objects

Page 11: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Heap allocation

Within one procedure:

Allocate pointer to heap object

Allocate (construct) object on heap

Use object

Deallocate object on heap

Deallocate pointer to heap object

Page 12: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Pointer to object not on stack

If pointer is on stack, what happens when there is an exception?

may pop out several levels of stack

Need to put objects on different type of stack

one that does not disappear during exception

keep pointers in heap on “cleanup stack”

Page 13: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Cleanup Stack

Cleanup Stack resides in heap

what if Construct causes exception?

Class* self = new(ELeave) Class(aInt)CleanupStack::PushL(self)self->Construct(aObj);CleanupStack::Pop(self);

Page 14: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Exception Handling

On exception, cleanup stack is popped and objects are removed.

(always check for null pointers)

Exceptions may be handled far back in time of program execution

Page 15: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

In the days before “try”

TRAPD(error, callExampleL() );

void CreateObject() {Object* obj = new (ELeave) Object

Trapd is a trap harness

It calls proceedure callExample()

Normal return, TRAPD continues

Exception, has error set to code

Page 16: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Throwing exceptions

User::Leave()

of allocation runs out of memory in a

new(ELeave)

Page 17: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Descriptors

TBuf

TBufC

HBufC

TPtr

TPtrC

Page 18: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Active Scheduler

Non-preemptive scheduler

Create a scheduler

Post wait for event(s)

Return to scheduler

Handle event

Page 19: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Page 20: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

O2S How it helps you

Overcome firewalls

Overcome IP address, Dynamic DNS

do not have to program in the names of all services & devices

Publish and subscribe facility

HUB is useful resource

Python based

UI independence

Page 21: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

O2S Planner

Better support for publish-subscribe

Easier to piece together application

Better Human support

Page 22: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

More on O2S

Branch in O2S CVS directory

easier to ask for help

Name stuff based on group name

can easily find each other

Page 23: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Eye-toy

Playstation 2 game

Camera watches user

Identify body outline, especially hands and head

Hands punch virtual characters

Head hits balloon or soccer ball

Page 24: Symbian Programming Overview. 6.893 Spring 2004: Symbian Larry Rudolph How to program Cellphone? Limited to Series 60 phones Java MidP 2.0 (see wiki,

6.893 Spring 2004: Symbian Larry Rudolph

Mosquito