430 likes | 590 Views
MBL391 Compact Framework: Phone Features. Mark Gilbert Program Manager. Agenda. Overview Smartphone Support User Interface Security Visual Studio .NET Accessing Phone Features Placing a Call Sending and Receiving SMS Messages Accessing the SIM Card Summary. Overview.
E N D
MBL391Compact Framework: Phone Features Mark Gilbert Program Manager
Agenda • Overview • Smartphone Support • User Interface • Security • Visual Studio .NET • Accessing Phone Features • Placing a Call • Sending and Receiving SMS Messages • Accessing the SIM Card • Summary
Overview • Taking the .NET platform to devices • .NET Compact Framework • Creating .NET tools for devices • Smart Device Features of Visual Studio • Key bets • Mobile devices fundamental to the web service ecosystem • Scale .NET down to devices • Support for open standards (Web, CLI, 3GPP) • Best of connected and disconnected • Enable great developer productivity
.NET Compact Framework On Phones • Benefits • Developer productivity, great tools • Same programming framework on devices, desktop, and server • High performing JIT enabled runtime environment • No special libraries needed for games • Smart application functionality with small OTA file size • Robust smart client side application model • Client side UI, threads, etc. • Garbage Collection, type safe code • Networking • GPRS, Dial-up, 1xRT, … • XML Web services support • Phone-specific APIs • SMS, Phone Dialing, SIM Card • P/Invoke in v1.0
Pocket PC Phone And Smartphone • Pocket PC Phone Edition • Touch Screen • PDA Form Factor • Storage in RAM • 32-64MB RAM, ~200-400MHz CPU • Smartphone • No Touch Screen • Phone Form Factor • Durable Like a Phone • Storage on Flash • 16MB RAM, ~125-200MHz CPU • Both • Multimedia Features • Pocket Outlook, Pocket Internet Explorer • GSM or CDMA Radio • SD Card • More…
Agenda • Overview • Smartphone Support • User Interface • Security • Visual Studio .NET • Accessing Phone Features • Placing a Call • Sending and Receiving SMS Messages • Accessing the SIM Card • Summary
.NET Compact Framework 1.0 For Smartphone • Will be a feature of next version of Smartphone • New UI Support • ROM-only – no CAB Install of Framework • Managed apps follow native security model • Added support for 5 new languages • Dutch, Danish, Swedish, Portuguese Brasilia, UK English • Multilingual User Interface (MUI) Support • Entire v1 feature set supported • SQL Server CE not supported
Smartphone User Interface • Simple, one-handed operation • No touch screen • Everything is full screen • Navigation via a 5-way controller • Scrolling and soft keys instead of tapping • Minimize application “depth” • Text input • Primarily through T9 and other key-based systems • Minimize text input • Everything is a list • Lists simplify display and ease localisation • Menu items minimised • Eliminate complexity
Button CheckBox ComboBox ContextMenu DataGrid DomainUpDown FileOpenDialog HScrollBar ImageList Label ListBox ListView TreeView FileSaveDialog Supported controls Supported ControlsPocket PC and Windows CE.NET MainMenu NumericUpDown Panel PictureBox ProgressBar RadioButton StatusBar TabControl TextBox Timer ToolBar VScrollBar MessageBox Form
Button CheckBox ComboBox ContextMenu DataGrid DomainUpDown FileOpenDialog HScrollBar ImageList Label ListBox ListView TreeView FileSaveDialog Supported controls Supported ControlsSmartphone MainMenu NumericUpDown Panel PictureBox ProgressBar RadioButton StatusBar TabControl TextBox Timer ToolBar VScrollBar MessageBox Form
Smartphone Controls • TextBox • .Multiline = True: MLE Control • .Multiline = False: Edit Control
Smartphone Controls • ComboBox • Action to view all items full screen
Smartphone Controls • TreeView • Recommended Full Screen • No CheckBoxes on Smartphone • ListView • Recommended Full Screen
Soft Keys (Menus) • Left SoftKey can not have menu items • If there is no MainMenu on the form • SoftKey press raises KeyDown and KeyUp events • KeyEventArgs.KeyCode is Keys.F1 and F2
Home Key • Home Key returns to home screen • No KeyPress event thrown • So Home Key can’t be overridden
Back Key • Back Key navigates back to previous screen • Next window in z-order brought to front • Exceptions • Always cancels out of modal dialogs • Backspace when focus on Textbox • When menu showing cancels out of menu • Overriding Default Behavior • Set KeyPressEventArgs.Handled = true • Intended for custom controls or games
Control Focus And Tabbing • Focus is critical to Smartphone UI model • Up and Down navigation keys switch between controls • Focusable Controls • CheckBox, ComboBox, ListView, TreeView, Form, TextBox • Tab order goes in order of focusable controls in controls collection • Custom Controls • Focusable unless Enabled property set to false • Developer must ‘tab out’ of their control by overriding the up/down keys and giving focus to next control • Designer Issue • Designer adds controls to code in reverse order
Gaming • Full Screen Mode • Game Buttons • Two Softkeys • 5 way D-pad • Back key (optional)
Visual Studio .NET Add-in Features • Smartphone add-in to Visual Studio .NET 2003 • In future Smartphone SDK • Forms Designer • Smartphone supported controls only • Correct default properties for all controls • Smartphone Emulators • Virtual Radio and Radio Required • CAB File Creation • Smartphone CAB files different format than PPC • Command Line only • Code signing features
Security And Managed Code • No Code Access Security in .NET Compact Framework 1.0 • Instead, defer security check to OS • Managed apps follow same policy as native • Security check also done on P/Invoke call • Application must be signed with carrier approved cert to run on locked devices
Signing Process • Two variables in the signing process • How is security policy configured? • OPEN – applications don’t need signing • LOCKED – applications need signing • PROMPT – signed applications run, unsigned applications prompt user • Which certificates are on the device? • Mobile2Market • Mobile Operator
Security In Visual Studio • Visual Studio will sign device exes with test cert provided in Smartphone SDK • Smartphone Emulator will ship as “OPEN” • You can change security policy for testing • Signing your application • Use signcode.exe wizard • Verify signature using chktrust
Agenda • Overview • Smartphone Support • User Interface • Security • Visual Studio .NET • Accessing Phone Features • Placing a Call • Sending and Receiving SMS Messages • Accessing the SIM Card • Summary
Extending The Platform • Phone APIs • Non-managed in v1.0 (using P/Invoke) • Fully managed and integrated in security model in v2.0 • Can use Pocket PC Phone features from .NET Compact Framework 1.0 today • Microsoft and the development community provide great samples • Use as-is or modify if you choose
Native Interop • Platform Invoke (P/Invoke) • Call custom native code and Windows APIs • Declare statement in Visual Basic • DLLImport Attribute in C# • Very flexible • Good support on the device • Other more advanced options • MessageWindow Class • Accessing COM Objects
Placing A Phone Call • Programmatically call a contact • “Phone Tech Support” feature • Two options • Dial number directly • Prompt user to dial number
Placing Call P/Invoke And Sample API [DllImport("phone.dll")] private static extern IntPtr PhoneMakeCall (ref PhoneMakeCallInfo ppmci); namespacePhoneDialingSample { public classPhoneDialer { unsafe public static voidMakeCall (string PhoneNumber, bool PromptUser); public static voidMakeCall (string PhoneNumber); } }
Accessing SIM Card • Get key pieces of information • Device phone number • SMS Service Provider Server (SMSC) • Access SIM Contacts and other data
SMS – Short Message Service • User to User • Instant Messaging • Short Messages • Machine to User • Information Updates (Weather/Stocks/…) • Machine to Machine • Programmatic communication using SMS as connection medium • Games, Push-to-Pull, Data updates, …
Receiving SMS Messages • More complex than send • Pocket PC Ozone has new Outlook Mail Rule Client API • In-proc COM object can peek at SMS messages before they appear in Inbox • Need to get messages to managed app • Code sample coming soon
SMS Sample APIs namespaceShortMessagingSample { public classShortMessageService { public ShortMessageService(); publicvirtual void Send(ShortMessage msg); publicvirtual void Send(string destination, string message); public MessageCollection MessagesList; publicevent MessageHandler OnMessageReceived; } public classShortMessage { public String To; public String From; public String Options; public String Time; public String Body; publicint MessageId; } }
Accessing Phone Features Placing Phone Calls Sending & Receiving SMS Messages Accessing information from SIM Card
Accessing Phone Features Placing Phone Calls Sending and Receiving Messages Accessing the SIM Card demo
Summary • New RAD development for Smartphone! • .NET CF Forms rich subset of the desktop • Same development experience as desktop • Supports device native “look/feel” • Extensible control model • Start using phone functionality from .NET Compact Framework with Pocket PC Phone today! • Phone Dialing, SMS, SIM Card Access • Great samples to be posted soonhttp://smartdevice.microsoftdev.com/learn/Code+Samples
Additional Resources • For the latest news and topics on Microsoft Pocket PC and Smartphone development: www.microsoft.com/mobile/developer • For detailed information on the .NET Compact Framework and Visual Studio .NET: mobility.microsoftdev.com • For detailed information on ASP.NET Mobile controls: www.asp.net/mobile • For detailed information on Tablet PC development: www.tabletpcdeveloper.com • To become a Microsoft Mobility Solutions partner: www.microsoft.com/mobile/partner • To learn how to decrease time to market: www.microsoft.com/mobile/mobile2market • For technical information and downloads: msdn.microsoft.com • Post-conference Mobility Developer Conference infowww.mymsevents.com • Market Smartphone and Pocket PC applications to mobile operators with Mobile2Market, visit www.microsoft.com/mobile/mobile2market
Community Resources • Community Resources http://www.microsoft.com/communities/default.mspx • Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ • Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx • User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Accessing SIM Card P/Invokes [DllImport("sms.dll")] private static extern IntPtr SmsGetPhoneNumber (IntPtr psmsaAddress); [DllImport("cellcore.dll")] private static extern IntPtr SimInitialize (IntPtr dwFlags, IntPtr lpfnCallBack, IntPtr dwParam, out IntPtr lphSim); [DllImport("cellcore.dll")] private static extern IntPtr SimGetRecordInfo (IntPtr hSim, IntPtr dwAddress, ref SimRecord lpSimRecordInfo); [DllImport("cellcore.dll")] private static extern IntPtr SimReadRecord (IntPtr hSim, IntPtr dwAddress, IntPtr dwRecordType, IntPtr dwIndex, byte[] lpData, IntPtr dwBufferSize, ref IntPtr lpdwBytesRead); [DllImport("cellcore.dll")] private static extern IntPtr SimDeinitialize (IntPtr hSim );
SIM Card Sample APIs namespaceSimCardSample { public classSimCard { unsafe public static PhoneAddressGetPhoneNumber(); public static StringGetServiceProvider(); } }
Sending SMS Messages P/Invoke [DllImport("sms.dll")] private static extern IntPtr SmsOpen (String ptsMessageProtocol, IntPtr dwMessageModes, ref IntPtr psmshHandle, IntPtr phMessageAvailableEvent); [DllImport("sms.dll")] private static extern IntPtr SmsSendMessage (IntPtr smshHandle, IntPtr psmsaSMSCAddress, IntPtr psmsaDestinationAddress, IntPtr pstValidityPeriod, byte[] pbData, IntPtr dwDataSize, byte[] pbProviderSpecificData, IntPtr dwProviderSpecificDataSize, SMS_DATA_ENCODING smsdeDataEncoding, IntPtr dwOptions, IntPtr psmsmidMessageID); [DllImport("sms.dll")] private static extern IntPtr SmsClose (IntPtr smshHandle);
Community Resources • Community Resources http://www.microsoft.com/communities/default.mspx • Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ • Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx • User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.