Auto updater for my side loaded UWP apps

As I described before, i have a few tasks to solve for my home automation project. One of the things I wanted to do is to be able to update my application on the different devices easily. I could publish my home automation app to the store, but it’s hard to provide a test environment for the store testers and it takes a while when the app gets certified before i can roll it out to all my devices. Of course I can sign up for an Intune account and use regular MDM to manage my apps, but 1st i need to have this Intune environment which I think is a bit over the top, and 2nd I would be depending on an internet connection. This is also a topic which comes up with some of my customers so I thought I could solve this differently.

Since the app is going to be side loaded I am allowed to use restricted capabilities. The store app uses these capabilities to be able to download and update apps from the store so what APIs are used by this app? It uses (among others) the PackageManager class. This API is protected by the restricted capability packageManagement.

So the first experiment I tried was to build an update button in a test app and I tried to update myself. I created a version (Project, Store, Create App Package and set the version to, I also created a version In my code I added the following line in the click event:

Where the packageLocation pointed to a file on my disk (but could also be a URL to a website). But updating yourself didn’t work. So the next idea I had was to write a little app which I could call with app2app communication and the only thing that little app would do was update the calling app. This works perfectly. So I created a new project called AppUpdate (Blank App). I added another project to the solution called AppUpdaterService (Windows Runtime Component).  I defined 2 parameters (I only use 1 currently) to be passed to this background service and that’s the package family name and the package location.

The entire code of this class looks like this:

Make sure you add the reference to this project to your AppUpdater project.

Inside my dashboard app I call the following code to update myself through the updater app:

The cool thing that happens is my app is closed when the update starts and automatically restarted after the update. This works on both Desktop as Mobile. I still need to test this on my RPI3 and in combination with Assigned Access/Kiosk mode on mobile.

So what’s left? I need to implement something which checks for a new version regularly. I am still debating if I am going to use the updater app to get registrations from other apps and checks if there is an update and if it finds one starts updating the app, it is more generic this way. On the other hand, the app might know better when it should be updating or not and implement the logic itself and just uses the appupdater to do the update.

I was also thinking about using some kind of broadcast in the app to send an update command to the apps on all devices to be able to force an update after I published a newer version on my internal website.

How I need to check for a newer version could be as simple as providing a little text file on the webserver with the latest version number. If the app has a lower version it will update. Or perhaps I should test what happens if I call the update command and the version of the app on the server is the same. If the update is ignored i don’t need to write any specific code to handle this. It might not be the most optimal solution, although we only download the changes in packages.

How to use any app in assigned access mode in Windows 10

As I wrote before, by default when you setup assigned access the UI only shows app which have the aboveLockScreen extension registered. I talked to the PM who owns this feature to ask why and the reason is because we changed the behavior of how assigned access works (lock the screen and launch the app above the lock screen) we found out a lot of existing apps crash when running on the lock screen, so we changed the UI to only show apps which are designed to run above the lock screen.

Although the UI might not show your existing apps anymore you used to run as kiosk app, you can still use those. Obviously you need to test if they work when running above the lock screen.

Besides using MDM or a provisioning package to configure assigned access you can also use PowerShell to setup your app to run. You  can find the documentation over here.

You will also find interesting documentation how to setup auto login and how to make a classic windows app the default app on that page as well.

This experience is something MS wants to improve in the future but for now you have to use this trick to setup your old app as assigned access app.

How to debug DirextX on Windows 10 Mobile

Another one of these little ‘gotchas’. Morten asked the question why he couldn’t debug DirectX on mobile, but it was possible on desktop and the IOT version of windows 10. I am not a DirectX expert at all, but this was weird. So I asked around internally what was going on.

First, if you want to do this on Desktop you need to install the graphics tools as an additional feature before you can do this.

This is something you need to do for Mobile as well, although it happens a bit different. You can do that by hitting ALT-F5 in Visual Studio or use the menu:


btw, you can also use ALT-F5 on desktop and make Visual Studio install the graphic tools for you.

After that you will be able to debug. The following line will return true instead of false:

Why do I only see OneNote and Skype when setting up assigned access in Windows 10?

If you are trying to setup assigned access in Windows 10, you go to settings, accounts, Other Users and there is a link to ‘set up assigned access’. First you need to create a local account you can use for assigned access. You can do that at this ‘Other users’ dialog as well.

On the Assigned access page you can choose an account and the app you want to run in ‘Kiosk’ mode.


The thing is, it only shows 2 apps in my list, OneNote and Skype Video, where are the rest of my apps?


We changed this behavior in Windows 10, once I figured that out it’s easy to spot in the documentation as well. You can find the documentation how to build an app which works in assigned access mode here:

So what’s different in Windows 10 is, once you login with the assigned access account. It starts the app, locks the device and runs the app above lock.  The reason you only will see OneNote and Skype video is because the apps have the ‘abovelock’ extension defined. It’s mentioned in the Appendix

The following is a sample application manifest, you can see the windows.aboveLockScreen uap extension. You must use this extension in your Windows 10 Universal Windows Platform (UWP) app in order for it to display in the Assigned Access app list in Settings.

So once you add this to your app manifest:

It will show up in the list as well.

Screensaver for my app

One of the things my Home Automation app needs to do is run forever. But I don’t want the screen to burn in either. I can allow the phone to lock the screen but at that time my app isn’t running. I could run some background tasks but there is no way to wake up the app and dismiss the lock screen automatically. Therefore I want an app which runs all the time but has some kind of build in screensaver.

First of all I need the app to prevent the lockscreen appearing. I can of course also configure the phone never to show the lockscreen, but I can also solve this in code. It took me some searching and help at twitter (thanks Neil) to figure this out. The useridlemode from Windows Phone isn’t there anymore. You now need to use Windows.System.Display.DisplayRequest().

So when trying to figure out how to determine how long a user is inactive I could only found some win32 API’s. Unfortunately these don’t work on Windows 10 Mobile (the ones I need that is). So I decided I needed to add a timer on every page. Whenever a user does something on the screen I reset the timer. If the timer fires I navigate to the screensaver.xaml page (and do the screensaver magic) and when the users hits the screen the app will return back to the MainPage.xaml.

Since this needs to be done from every page I created a new baseclass every page (except the screensaver page) is going to inherit from. I created a class called DashboardPage.cs

The constructor creates a timer (in this sample set to 5 seconds). Whenever the timer fires I redirect to the Screensaver page. Whenever PointerMoved event is fired the timer is reset. I found out that with the PointerMoved it works on desktop and mobile. You might need to add more events to make it foolproof, but for my scenario on the phone it works.

The only thing you need to change is in your XAML and the code behind. Your page needs to inherit from DashboardPage instead of page like this:

And you need to modify your XAML a bit as well. It needs to look like this:

You can find the complete solution over here.

Of course after I build this Morten Nielsen posted on Twitter he already build a solution. I think his solution is much easier to use.

Create a new project and add a new usercontrol to your project called Screensaver.xaml

The codebehind looks like this:

To get this working you need to add a single line to App.xaml.cs. Add the line after the Windo.Current.Activate()

What happens in the Screensaver code behind is a timer is started. Whenever the timer ‘ticks’ the popup with the screensaver is shown. A tap on the screen removes it again. Every time something happens on the screen the timer is reset. This works really well and you don’t need to modify every single page. So I think I will end up using this solution instead.

You can find a complete working sample here.

List of tasks I need to figure out for my home automation project

As I described before I am working on a little project to use some Lumia 640s in the house to control the home automation. Besides figuring out how to configure and roll out the devices, and figuring out how exactly I am going to put them in the walls, I also have a laundry list of items I need to figure out for the app on the device. Instead of waiting before everything is done I thought it might be useful to take you along the ride. It might even result in some people mentioning to me some of the things I need to figure out are already out there.

So this is the current list of ‘issues’ or tasks I want to figure out before bringing everything together in an app.

  1. App needs to Run forever (embedded mode in mobile like on RPI2)
  2. Dim screen when not used for x minutes (Windows.System.Display.DisplayRequest() helps preventing the lock, need a screensaver to prevent burn in)
  3. Resume app or display screen when movement is detected by using the camera as sensor
  4. Hey Cortana/speech integration in app (dim the lights, goodnight, increase temperature etc)
  5. Walkyie-Talkie or intercom functionality between rooms and broadcast (alljoyn?)
  6. Other device discovery to connect to for the walkie-talkie functionality etc.
  7. App is a Bluetooth beacon in every room (
  8. Self-updating via update app
  9. IP Camera integration so I can watch the cameras from every room
  10. Alljoyn temp control for my Nest and perhaps per room when I add that future system as well
  11. Goodnight command to smartthings so i can turn off all lights in the entire house
  12. Alljoyn light control
  13. Motion sensor in garage and at frontdoor switches on security view on phone
  14. Wakeup time
  15. Radio/music/speaker in room control

Fixed my Bryant two stage furnace with my NEST

When we bought the house we learned it had a fairly new Bryant furnace installed. The previous owner upgraded from an electric furnace a few years ago. When we had an HVAC guy over for an AC quote he mentioned it was a good two stage furnace, better than the one we had in Bothell. Ok, I didn’ really think about until a recent discussion with some colleagues at Microsoft.

When inspecting my connections of my NEST, I assumed the R, G, C and W1 wires needed to be connected. C is for power, the other ones for the fan and heater. In my previous home the Y was used for the airconditioning. I don’t have one in this house yet. Although if you connect the wire to the Y on the backplate of the NEST, the nest assumes you have a AC connected.

Since you need to hook up the W2 on your thermostat to work with a two stage furnace to make it work. I connected the spare wire to the W2 on the backplate. The NEST gives you a message the wiring is changed and now a two stage heating system is connected. That looked promising. One of my colleagues mentioned it might not be smart to just randomly connect wires and he was correct of course. So disconnected the W2 wire from the NEST and took a better look at my furnace. (In the picture below the W2 connector is lefr from the blue wire)


Great thing about internet is you can find all kinds of information. I happen to have a Bryant 355MAV042080F model. Some googling on Bing pointed me to the user manual and the installation instructions. Cool.

Also on the inside there are some schematics of the furnace.


After some reading and inspecting the furnace after opening it up I saw the yellow wire wasn’t connected at all. So i hooked it up to the W2 connector, checked if the SW2 switch was on (which was). Hooked the wire up on my NEST and voila, two stage furnace worked. Yellow light came on when HIGH HEAT was switched on (just cranked the NEST up to 90) and the green light came on when in LOW HEAT mode (when I switched the NEST to 1 degree more than the current temperature).


No idea why the W2 wire wasn’t hooked up. The original Honeywell thermostat supports this system as well. I took some pictures before I installed the NEST and it wasn’t connected when I removed the old thermostat.

So I am kinda proud of myself I increased the efficiency of our thermostat.

How to disable the SIM error message on your Windows Mobile device

wp_ss_20160124_0001Some people use Windows Mobile devices without a SIM. I use it to test different things during my job and also on my developer devices at home. I just started a little project where I want to use the Lumia 640 as a control device and these devices will never get a SIM. So this pesky little warning prevents the device from automatically starting up and run my control software.

Fortunately this is easy to fix. If you install the Imaging and Configuration Designer (ICD) you can set a configuration setting and provision your devices to this setting. Installing the ICD is easy. Instructions can be found here. The cool thing about provisioning package is you can mimic a lot of the more fancy Mobile Device Management features. So if you need to test deployment, settings like WiFi and email you can do that without any MDM server and just use provisioning packages. These packages are just a bunch of zipped up XML like any MDM syncml is as well. So easy to test your things without needing to go to the IT guy and ask him to setup some policies and you enrolling the devices in a work account.

The setting you are looking for is called AllowSIMErrorDialogPromptWhenNoSim under the experience group.

Since this is the first time I will show a step by step guide. Future posts will just mention the settings involved.

First you create a new project (File New Project). Enter the name RemoveSIMErrorDialogPromptWhenNoSim

Hit next and choose Provisioning package and hit next again

On the next screen choose ‘Common to all Windows mobile editions’ this will give us all the options available for mobile and not just a subset.

You can skip the page to import a provisioning package (or import my package linked to this blogpost to see what I did) and click Finish

In the search box type SIMerror and click on the AllowSIMErrorDIalogPromptWhenNoSIM and configure it to No.

Save your project and choose Export – Provisioning package. Leave the defaults and click Next (if you want to change your package the next time make sure you increment the version, otherwise your device won’t take the changes.

I leave the encrypt package and sign package checkboxes unchecked and click next.

Select the location where you want to store the provisioning package and click next.

On the final ‘build the provisioning package’ you click the build button.

And you are done. If you navigate to the directory you will find the RemoveSIMErrorDialogPromptWhenNoSim.ppkg file.

You can drag and drop the file to your connected phone in file explorer.

On your device you will see a message popup asking you if you trust the package which is trying to be installed.

If you click Yes, add it your device will be provisioned. If you reboot your device now you will not see the annoying screen anymore. Mission accomplished.

If you decide you want to remove the setting you can do that by going to the settings screen. Accounts, provisioning.

You can find this provisioingpackage over here. Make sure you check it before you install it since these packages are really powerful and can totally mess up your device settings.

New project: Lumia 640 as touch control device for my home automation

The other day I was chatting with Morten Nielsen on twitter about some ideas for home automation. I want to be able to control lights, temperature etc in some rooms in my home. Ideally that would be done with some kind of easy to use touch screen device. The Raspberry Pi came to mind. There are some screens you can attach to it. It’s low power and pretty easy to put inside the drywall and make the screen look nice on top of that.

14528240889_5d4fde6341_k-728x420Morten mentioned he used a Dell Venue Pro 8 is also a nice and affordable device. But when I found out you can switch your Windows 10 Mobile device to embedded mode it sounded that a really affordable Lumia 640 (last one I bought was just $60 on AT&T and I got a free unlock code as well) would be a perfect fit too. It has al kind of sensors, so you can undim the screen when somebody is in front of it. Cortana should work for voicecommands. It runs any Windows 10 Universal App (Morten is working on an AllJoyn solution).

We have provisioning tools to configure the devices, heck, i could use my intune test account to maintain the devices as well.

Plenty of ideas to look into and so I will try to post some of my findings during the way about what I want to do and what the results of these investigations are. Some of the things which needs to be solved are:

  • I need an app which is a dashboard which can control my z-wave lights, temperature, perhaps music and intergrate with security cameras
  • It need to be easy to configure the devices in every room and easy to update the software as well. So i am looking into writing my own updater app (packagemanager) and provisioning of the devices by using our provisioning tools
  • Cortana integration would be cool
  • Device could be a bluetooth token which opens some possibilities
  • Device could be a IP camera for security purposes
  • AllPlay music services, control music playing in the entire home, although i need to hook up some good speakers instead of just the device

Plenty of stuff to figure out and probably never a project which will be completely done.

Posting blog posts through OneNote

Microsoft introduced a new plugin for WordPress. This plugin lets you use OneNote pages as input for your posts. That’s pretty convenient. You can write and scribble in OneNote every time you want and once you’re finished you can just move that page over to WordPress with a single click.

To make this work you need to install the OneNote published plugin in your WordPress blog. After you have installed it you need to configure the plugin according the instructions (you need to create an application so WordPress can access your OneNote files which are stored in your OneDrive)

After this you can add a post in WordPress and select one of the pages from OneNote. Pretty cool. This pages was written in OneNote as an example.

And of course a screen clip can be inserted in OneNote as well 🙂