Martin Suchan – BloQ Random #WPdev stuff

21Aug/140

New API in Windows Phone 8.1 Update 1

Accessory-App-Windows-Phone-348x620As a part of the "Preview for Developers" program Microsoft just recently released the first larger update for Windows Phone 8.1 called just "Windows Phone 8.1 Update" with OS version number 8.10.14147.180. The original Windows Phone 8.1 was 8.10.12359.845.

According to MSDN blog article this update brings primarily these new end user features:

  • Cortana is now available for couple of new countries
  • Live Folders - native implementation of app folders on the Start screen
  • Option to simply select multiple SMS messages for deleting/forwarding
  • Apps Corner, Private VPN, Store Live Tile, Internet sharing via Bluetooth, customizable snooze time for Alarms and more.

But probably the most interesting feature, that might be part of this update as well, is is the support for notification on accessories, typically on smart watches and other wearables. The best hint for this functionality is already in the phone settings - the new "accessory apps" section.

The second hint is the new available API, that'll be shown in the rest of this article.

Comparing emulator images

In my previous article about new API available in Windows Phone 8 GDR3 I've shown, that it's really easy to extract libraries from two emulator images and compare them for any changes. I used similar approach this time as well, only for the actual comparing I used the NDepend tool instead of the previously used Framework Design Studio. This tool is also shown in this handy article from Scott Hanselman.

wp8.1.1.diffSo how have I done it? First I installed Visual Studio 2013 including Update 3 + additional WP8.1 Update 1 emulator images. Then I mounted in Disc Manager the .vhd images for both WP8.1 and WP8.1 Update 1 emulators, that can be found in "C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Emulation\Images" as virtual drives and extracted all native image libraries from C:\Windows\System32 folder. It's easy to find these files, they all end with *.ni.dll. Additionally I also included the Windows.ni.winmd library containing the Windows Phone Runtime API.

Then in NDepend I just created project for comparing two sets of assemblies and in the Search window when selected Changes -> Added types I got nice list of all new types and method. This list also contained new/changed internal and private methods so after manually modifying the search query to show only public types I received the following list.

In short, if my findings are right, Windows Phone 8.1 Update 1 contains:

  • new property VisibleBounds and VisibleBoundsChanged event in PhoneApplicationPage
  • new namespace Windows.Phone.Notification.Management for most likely supporting accessory apps and wearables
  • and also quite a few changes in internal and private classes, but these are for no use for common developers

VisibleBoundsSampleVisibleBounds in PhoneApplicationPage

When developing Windows Phone 8.1 WinRT apps it's already possible to detect, if there is any overlay on the screen, typically the application bar, status bar or input keyboard. This information is available in ApplicationView.VisibleBounds. Unfortunately no such property was available until now in Windows Phone 8 or 8.1 Silverlight projects.

The new PhoneApplicationPage.VisibleBounds get-only property of type Thickness and PhoneApplicationPage.VisibleBoundChanged event of type EventHandler is available in Windows Phone 8 and 8.1 Silverlight projects using reflection. I've already created and uploaded to GitHub sample that shows, how it can be used for detecting width of top status bar, AppBar or even width of software buttons bar on Lumia 630 or similar phones. Simple class with extension methods that you can use is here.

Windows.Phone.Notification.Management API

This is a big one, new namespace with lot of types, that might be used in the future for managing notifications on wearables. Full list of all types and methods is available here on Pastebin, originally found by Jeremy . Unfortunately, I have no other information about this API - what it does or when can we use it. It's for no use right now just like the  "accessory apps" section in settings. The question also is if this API is meant to be used by common developers in the future, or it's just for OEM manufacturers?

The summary

Windows Phone 8.1 Update 1 contains couple of new APIs, but right now we can only use the new VisibleBounds property and VisibleBoundsChanged event in PhoneApplicationPage using reflection. It's also not clear, what is the future of the other Windows.Phone.Notification.Management API, but if anything else, it's definitely a nice hint that something new is coming to the Windows Phone ecosystem.