WP7 HUB_Platform overview


Published on

Fase 3.1

Published in: Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

WP7 HUB_Platform overview

  1. 1. Windows Phone Platform Overview<br /> A different kind of phone, designed for a life in motion<br />
  2. 2. Windows Phone Hardware<br />
  3. 3. Topics<br />Windows Phone hardware examined<br />Processor and operating system<br />Graphical Display<br />Touch input<br />Location sensors<br />Camera<br />Memory<br />Network<br />
  4. 4. The Windows Phone Device<br />The Windows Phone is a pretty powerful device<br />Best regarded as a computer that can make phone calls<br />Runs an operating system specially optimised for mobile devices<br />
  5. 5. Windows Phone processor speed<br />The Windows phone hardware standard requires that a Windows Phone device will have a processor “clock speed” of at least 1 GHz<br />This means that something will go “tick” inside the phone 1,000,000,000 times a second<br />A tick lasts a nanosecond, the time it takes light to travel around 30 cm<br />
  6. 6. Processors and Clocks<br />Each time the clock in a Central Processor Unit (CPU) goes “tick” a particular low-level operation will be performed<br />Perform part of a hardware instruction<br />Load data from memory<br />Store data into memory<br />The faster the clock ticks, the faster the processor is running <br />
  7. 7. Clocks and speeds<br />A Windows PC processor runs at 2-4 GHz, a <br />A Windows Phone processors start at 1 GHz<br />This does not mean a phone is around half the speed of a desktop PC<br />The clock speed is just one factor that determines computer speed<br />A bit like engine size in a car<br />
  8. 8. Speed and processors<br />Some processors need more “ticks” to perform the same action<br />Phones use “Reduced Instruction Set Computing” designs which reduce the amount they can do per clock tick<br />The desktop PC may contain multiple processors<br />The Windows Phone cannot run at full speed all the time as this would flatten the battery<br />
  9. 9. Performance and programs<br />When you write a Windows Phone application you have to worry about performance<br />There is not the spare processing power available to compensate for poor programming techniques<br />Performance must be considered at all times<br />This will turn us into better programmers<br />The techniques we are going to learn will improve all the programs we write<br />
  10. 10. Windows Phone Operating System<br />Windows Phone 7 is not based on the Windows 7 operating system<br />The numbering is coincidental<br />Windows Phone is actually based on Windows Compact Edition (Windows CE)<br />This is an operating system specially built for use in battery operated devices with low power processors<br />
  11. 11. Operating Systems and Programs<br />From the point of view of a programmer the operating system is becoming less important<br />We are going to write Silverlight and XNA applications that make method calls to use the underlying system<br />How that underlying system works does not affect our programs directly<br />They can run on any platform <br />11<br />
  12. 12. Windows Phone Graphical Display<br />The Windows Phone has a high resolution display with at least 800x480 pixel resolution<br />This makes a lot of work for the hardware<br />The higher the resolution of the display the more work needed to keep it up to date<br />The display can be used in landscape and portrait mode<br />The phone will detect how it is being held and a program can change the display to match<br />
  13. 13. Graphics Hardware Acceleration<br />Desktop PCs have used graphical acceleration for a long time<br />The Graphical Processing Unit (GPU) draws the display and performs image processing on it<br />GPUs are now appearing in mobile phones<br />The Windows Phone contains a GPU<br />Used to render user Silverlight user interfaces<br />Also used to create 3D games in XNA <br />
  14. 14. Touch Input<br />Modern mobile devices are making increasing use of touch screens<br />These are now provided in addition to a keyboard<br />The Windows Phone user interface is entirely touch based, using a capacitive multi-touch input device<br />
  15. 15. Resistive Touch Input Screens<br />Early mobile devices used resistive touch screens<br />Touching the screen connects two plastic membranes to form a circuit<br />The resistance across this circuit is used to work out the location of the touch<br />This technology is very precise (particularly if a stylus is used) <br />But it cannot easily detect more than one touch<br />
  16. 16. Capacitive Touch Input<br />Capacitive touch sensors detect the change in capacitance caused by touch event<br />There is no physical movement<br />The touch sensor can be printed on a glass screen<br />The resolution of a capacitive screen is not as great as a resistive one<br />This is not a problem as the user will be touching with a finger, not a stylus<br />A capacitive screen can track multiple touches<br />
  17. 17. Touch and Gestures<br />Gestures are particular movements made with one or more finger<br />Dragging an item on the screen<br />Pinching movements to zoom in and out<br />The Windows Phone operating system has built in support for gesture input<br />A program can be sent a message when a user has performed a particular gesture<br />
  18. 18. Location Support<br />A Windows Phone contains a Global Positioning System (GPS) receiver<br />Works well when outdoors with a view of the sky<br />The phone will also other location information<br />Location of cellphone towers in use<br />Location of WiFi access point<br />This “assisted” positioning makes it possible to determine position when inside buildings<br />
  19. 19. Accelerometer<br />The accelerometer can measure acceleration in three directions (X, Y and Z)<br />This can be used to detect movement of the phone<br />It can also be used to determine how the phone is being held<br />This orientation information can be used to control games by tipping the phone <br />
  20. 20. Camera<br />The camera will be at least 5Megapixels<br />This makes for good quality pictures<br />The pictures which are taken are stored within the phone and transferred to the Windows PC using the Zune software<br />Programs can load these pictures, and other pictures from the media in the phone<br />Your programs can also initiate a photograph<br />
  21. 21. Camera Limitations<br />Our programs can’t read a live video feed from the camera in this Windows Phone release<br />This is not a hardware limitation<br />Our programs can’t take a picture without user involvement<br />This is to stop the creation of “spyware” applications that take pictures without user consent<br />
  22. 22. Hardware Buttons<br />All Windows Phones have a specific set of physical buttons<br />Start, Back, Lock, Search, Camera, Volume<br />These will work in exactly the same way on every version of the phone<br />Programs are required to use them in a particular way too<br />
  23. 23. Start Button<br />Starts a new program<br />When the user presses Start they are always taken to the start menu to choose a program to run<br />The application that was running when Start was pressed is removed from memory<br />This is part of the way that Windows Phone enforces the “one program at a time” rule<br />23<br />
  24. 24. Back button<br />This button has several uses<br />Within a particular program it moves you back to the previous menu<br />When at the top level menu of a program it is used to exit the program and return to the Start menu<br />At the Start menu the back button will return the user to the program they were running when they pressed Start to do something new<br />24<br />
  25. 25. The Back button and the Phone UI<br />Back is rather hard to explain<br />But very easy for users to get to grips with<br />It makes it easy to drop in and out of applications on the phone without having to keep finding them and restarting them<br />For us developers it means that programs may be “woken up” from having been stopped<br />25<br />
  26. 26. Other Buttons<br />Lock Button<br />Stops the currently running program and locks the phone<br />Search<br />Starts a search operation. Your program should respond to search appropriately<br />Camera<br />Stop the current program and take a picture<br />26<br />
  27. 27. Phone Keyboard<br />Some Windows Phone devices will be fitted with hardware keyboards<br />The system provides a “software” keyboard that uses the touch screen <br />When we design our programs we need to make sure that they can be used with or without a physical keyboard<br />27<br />
  28. 28. Phone Memory<br />There are two flavours of memory<br />Main memory <br />This is where programs are loaded and executed<br />Fast memory chips connected directly to the processor<br />Mass storage memory <br />This is where program, data and media are stored<br />Slower storage that holds its data when the power is turned off<br />28<br />
  29. 29. Main Memory<br />A Windows Phone will have at least 256Mbytes of main memory<br />A few years ago this was a huge amount, but these days it is not quite as impressive<br />It can soon get eaten up by programs that use a lot of graphics in their user interfaces<br />In contrast a desktop PC will have around 8 times that memory space, with at least 2Gbytes of RAM<br />29<br />
  30. 30. Mass Storage<br />A Windows Phone will have at least 8Gbytes of mass storage<br />In program terms this is a lot, but most of it will be used store media<br />A single music track is around 8 Mbytes<br />A high quality picture is around 2 Mbytes<br />An hour of good quality video is around 1Gbyte<br />30<br />
  31. 31. Network<br />Windows Phones have lots of connectivity options:<br />WiFi wireless network (high speed)<br />3G phone network (high to media speed)<br />GPRS phone network (low speed)<br />Out of coverage (no speed)<br />Software on a mobile device must deal with all these types of network<br />31<br />
  32. 32. Programming Considerations<br />A Windows Phone is an amazing device<br />But it is limited by size and battery power<br />Users will expect a high quality experience<br />This will be based on their experience on much more powerful devices which are not mobile<br />Our job as developers is to make the most of what the platform gives us<br />This gives us more to think about when we write our programs<br />
  33. 33. The Good News<br />Programming for a phone is fun!<br />The range of features a device has, and the fact it is mobile makes it possible to invent completely new applications<br />The development environment is really powerful and easy to use<br />You get a lot of help from the system in creating great user interfaces<br />33<br />
  34. 34. Review<br />Windows Phone is a computer, but one working specifically in the mobile environment<br />All Windows Phone devices are built to a particular standard with standard features<br />Performance and storage is restricted and our program design must reflect this<br />Network connectivity is variable on a phone<br />Programming a phone is harder than a desktop, but still fun<br />34<br />
  35. 35. Windows PhoneEcosystem<br />
  36. 36. Topics<br />The ecosystem that surrounds the Windows Phone device<br />Zune media management and connection<br />Windows Live and Xbox Live and Windows Phone<br />Bing search and Windows Phone<br />Bing Maps and Windows Phone<br />Windows Phone Notification Services<br />
  37. 37. Windows Phone Ecosystem<br />A Windows Phone device is surrounded by other services which provide an “ecosystem”<br />These services bind to software in the phone device<br />We can write software that makes use of these services to create brand new solutions<br />In this section we are going to take a look at the services and consider how we might use them<br />37<br />
  38. 38. Zune Software<br />The Zune software provides the link between the Windows Phone and the PC<br />It allows media to be synchronised with the phone<br />It also provides the link to the device for development with Visual Studio<br />
  39. 39. Windows Live and Xbox Live<br />A Windows Phone owner can register their phone with Xbox Live<br />This will also connect them with their Xbox Gamertag if they have one<br />Games can use the gamertag to manage achievements and high scores<br />39<br />
  40. 40. Bing Maps<br />Programs in the phone can request maps from the Bing service<br />There is also a Silverlight control you can add to your programs to view and navigate the map<br />You can also make searches for items near your position <br />40<br />
  41. 41. Windows Notification Service<br />It is often the case that external systems need to send a message to a program in a phone<br />Tell you that your dry cleaning is ready<br />Challenge a gamer to a duel<br />Applications register with the Windows Phone notification service and servers can then use this to send messages to the phone user<br />These are buffered if the phone is not connected when the message is sent<br />41<br />
  42. 42. Creating a service of your own<br />There is no reason why you can’t create your own network based service for a Windows Phone client to use<br />You need to write the server application too<br />You can write both ends of the service in C# and you could host the service in the Windows Azure cloud<br />Students can get free access to some cloud services<br />42<br />
  43. 43. Review<br />A mobile phone is now a connected component of a much larger “ecosystem”<br />A Windows Phone can use several of these<br />Zune PC connection and media synchronisation<br />Windows Live and Xbox Live<br />Bing Maps<br />Windows Notification Service<br />Your programs can use these elements to make brand new connected applications<br />43<br />
  44. 44. Windows PhoneProgramExecution<br />
  45. 45. Topics<br />The Windows Phone Operating System<br />Multi-tasking on Windows Phone<br />Windows Phone and Managed Code<br />Just in Time compilation<br />Program “sandboxes” and Managed Code<br />Developer Implications<br />
  46. 46. The Windows Phone Operating System<br />Windows Phone 7 does not use Windows 7 as an operating system<br />The fact they have the same number is just a coincidence<br />Windows Phone instead uses an operating system called Windows CE<br />This is specially designed for use on small, battery powered, devices<br />
  47. 47. Multi-Tasking <br />Multi-tasking means running multiple programs at once<br />Windows PCs let you do this<br />You can have IE and Word both running at once<br />Unfortunately multi-tasking places heavy demands on the processor and uses a lot of memory<br />Therefore the first version of Windows Phone does not provide multi-tasking <br />47<br />
  48. 48. Missing Multi-Tasking<br />A mobile device does not really have a screen large enough to view two programs at once<br />The phone has been designed to make it as easy as possible to switch between programs<br />Must users want task switching rather than multi-tasking<br />The operating system itself can multi-task<br />The music player and email programs can both run at the same time as user programs<br />48<br />
  49. 49. Programs on Windows Phone<br />Programs for Windows Phone are written in .NET and run within a Managed Code environment on the device<br />The phone performs Just in Time compilation of the intermediate language (Microsoft Intermediate Language – MSIL)<br />The programs that run are assemblies that are signed by the developer<br />This is used to prove where the code came from<br />
  50. 50. Microsoft .NET<br />.NET is the name for an architecture from Microsoft that runs programs <br />It includes standards for the following:<br />Design of MSIL and program file format<br />Data types<br />System libraries<br />C# programming language<br />VB .NET programming language<br />50<br />
  51. 51. The Microsoft Intermediate Language<br />The Microsoft Intermediate Language (MSIL) is a half way house between a high level language and machine code<br />It is designed to be easy to translate into machine code<br />The phone can run MSIL from any .NET compiler<br />C#, Visual Basic, F#, IronPython, IronRuby, C++<br />The user interface code must be C#<br />
  52. 52. Running .NET Assemblies<br />When a .NET program needs to run something has to convert the intermediate language into real machine code for the target processor<br />This happens in the instant before the program actually runs<br />It is called “Just In Time” compilation<br />52<br />
  53. 53. Just in Time Compilation<br />Visual Studio Development Environment<br />C# source file<br />C# compiler<br />Target hardware<br />Windows PC<br /> Xbox<br /> Windows Phone<br />Assembly file containing MSIL<br />Just In Time compiler<br />Machine code in memory<br />
  54. 54. Just in Time Compilation<br />Visual Studio Development Environment<br />C# source file<br />C# compiler<br />Target hardware<br />Windows PC<br /> Xbox<br /> Windows Phone<br />Assembly file containing MSIL<br />Just In Time compiler<br />Programmer writes the program<br />Machine code in memory<br />
  55. 55. Just in Time Compilation<br />Visual Studio Development Environment<br />C# source file<br />C# compiler<br />Target hardware<br />Windows PC<br /> Xbox<br /> Windows Phone<br />Assembly file containing MSIL<br />Just In Time compiler<br />Visual Studio compiles the source<br />Machine code in memory<br />
  56. 56. Just in Time Compilation<br />Visual Studio Development Environment<br />C# source file<br />C# compiler<br />Target hardware<br />Windows PC<br /> Xbox<br /> Windows Phone<br />Assembly file containing MSIL<br />Just In Time compiler<br />The assembly file is transferred to the target<br />Machine code in memory<br />
  57. 57. Just in Time Compilation<br />Visual Studio Development Environment<br />C# source file<br />C# compiler<br />Target hardware<br />Windows PC<br /> Xbox<br /> Windows Phone<br />Assembly file containing MSIL<br />Just In Time compiler<br />When the program runs the Just In Time compiler converts the MSIL into binary<br />Machine code in memory<br />
  58. 58. Just in Time Compilation<br />Visual Studio Development Environment<br />C# source file<br />C# compiler<br />Target hardware<br />Windows PC<br /> Xbox<br /> Windows Phone<br />Assembly file containing MSIL<br />Just In Time compiler<br />The machine code runs inside the target<br />Machine code in memory<br />
  59. 59. Intermediate Language<br />Good things about intermediate languages<br />Can run on a range of platforms<br />Can use lots of different programming languages (as long as they compile down to MSIL)<br />Programs are smaller than machine code<br />Programs can be digitally signed and verified<br />Bad things about intermediate languages<br />The need to Just In Time (JIT) compile them slows down program execution<br />
  60. 60. Managed Code<br />When your program runs on Windows Phone it actually runs in a “managed” environment<br />This means that what it does is validated before the program is allowed to do it<br />Array subscripts are checked<br />Program not allowed to attempt to control hardware directly<br />This stops the phone from being affected by a rogue application<br />60<br />
  61. 61. Review<br />The built-in programs inside the phone can multi-task but only one application can run at a time in the phone<br />The phone users the .NET Microsoft Intermediate Language for applications<br />These are “Just in Time” compiled when they are started and run inside a managed shell<br />This trades raw speed for safety and portability<br />61<br />
  62. 62. Windows PhoneApplicationDevelopment<br />
  63. 63. Topics<br />Writing programs for Windows Phone<br />The Windows Phone emulator<br />Using the Windows Phone features from software<br />Silverlight and XNA program development<br />Development tools<br />Windows Phone Marketplace<br />
  64. 64. Windows Phone Programming<br />Writing programs for Windows Phone is the same as writing for any .NET platform<br />Edit, compile and debug within Visual Studio<br />But you need to remember you are writing for a platform a bit more constrained than a PC<br />You can incorporate .third party NET libraries (assemblies) into your applications<br />64<br />
  65. 65. Windows Phone Emulator<br />The emulator runs on your PC<br />It contains exactly the same code as the real phone, but compiled for the Windows PC<br />It lets you see what your programs look like and whether they work correctly<br />It does not show you what the application performance will be like on a real device <br />65<br />
  66. 66. Using Windows Phone from software<br />Windows Phone provides a library of “Launchers” and “Choosers” that your programs can invoke<br />Launchers start other tasks in the phone<br />Start a phone call<br />Choosers allow the user to select an option and then restart your program so it can use the returned value<br />Select a contact from the Address Book<br />
  67. 67. Network Connectivity<br />A Windows Phone will be able to use the 3G phone network and WIFI to connect to the internet<br />Your programs will be able to interact with servers, call web services and engage in REST sessions<br />In the present version of the operating system there is no support for direct socket connections<br />
  68. 68. Silverlight and XNA applications<br />You can build two kinds of applications for a Windows Phone<br />Silverlight<br />Business applications and simple casual games<br />XNA<br />XNA is a game development environment with support for 2D and 3D games with hardware accelerated graphics <br />
  69. 69. Silverlight Applications<br />This is not a very good looking Silverlight application<br />But it does show that you can build displays for user applications using Silverlight<br />There are lots of custom display components for the phone that you can use<br />69<br />
  70. 70. XNA Applications<br />XNA is a game development environment for Windows PC, Xbox and now Windows Phone<br />Existing XNA games are very easy to move onto the phone<br />The phone provides 3D graphics support for games<br />Built in shaders<br />70<br />
  71. 71. Creating an Application<br />You select the type of your application (XNA or Silverlight) when you create the new project in Visual Studio<br />It is not possible to create a single program that uses both technologies<br />There is no technical reason why you could not create a Silverlight game or an XNA business application<br />71<br />
  72. 72. Development Tools<br />The Development Tools for the platform are a free download<br />They tools provide a version of Visual Studio and the Windows Phone emulator<br />These will also integrate into an existing Visual Studio installation<br />You can also obtain free versions of the Expression Blend user interface design tools for Silverlight<br />72<br />
  73. 73. Windows Phone Marketplace<br />You can develop and test your application on the emulator for free<br />To sell your application or deploy it to a real device you must register as a developer<br />This costs $99 per year<br />Students can become developers for free via Microsoft DreamSpark<br />73<br />
  74. 74. Marketplace Rules<br />In a year of your subscription you can publish any number of “paid” applications and up to 5 free ones<br />To distribute more free applications costs $20 per application<br />When you sell an application you get 70% of the price you charge<br />You can distribute “demo” and “time trialed” versions of your application<br />74<br />
  75. 75. Marketplace approval<br />A program submitted for sale via marketplace is submitted to an approvals process<br />This includes checks for matters of taste and decency, along with proper application behaviour<br />If the program fails the process you will be given a report and can re-submit the application<br />75<br />
  76. 76. Review<br />Windows Phone programs are developed in the same way as any other .NET application<br />The Windows Phone emulator does not emulate the speed of the platform<br />Programs can make use of phone functions<br />Windows Phone programs either Silverlight (business) or XNA (game) based<br />The development tools are all free<br />You need to join the marketplace to sell apps<br />