The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
[UWP]How to identify whether a device is Surface Hub in code? RRS feed

  • Question

  • Hi All,

    Recently we have started expanding our App to support Surface Hub(both 55-inch & 84-inch). At many places we designed entirely different set of UIs for Hub thus the need come up to identify the device is Surface Hub or not so that we could show the specific UI.

    I explored various Device identification/Input Apis but unfortunately none of them provides any lead on identifying a device.

    I don't remember it fully but I guess I read it somewhere that now UWP SDK doesn't allow developers to identify specific device types since UWP app is expected to run on all kinds of Win 10 running devices - may be someone could confirm this. However since the Resolution of Hubs are much higher than normal Desktop/Tablet devices I'm sure showing various UIs can be manipulated using VisualState triggers.

    Still it'd be great if somehow I would be able to identify whether a device is Surface Hub or not before my App starts running, more like identifying whether touch capabilities are present on the current device.

        

    Hopefully someone would be able to help me out with a reasonable solution here!

      

    Thanks,

    Dash




    • Edited by PDash Friday, May 12, 2017 3:35 AM
    • Edited by Barry Wang Monday, May 15, 2017 1:42 AM title tag
    Friday, May 12, 2017 3:35 AM

Answers

  • namespace My {
    
      public enum DeviceTypeEnum { Default, Phone, IoT, Desktop, XBox, Hub, Tablet }
    
      class DeviceInfo {
    
        public static DeviceTypeEnum GetDeviceType() {
    
          switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) {
            case "Windows.Mobile": return DeviceTypeEnum.Phone;
            case "Windows.Desktop": return DeviceTypeEnum.Desktop;
            case "Windows.Team": return DeviceTypeEnum.Hub;
            case "Windows.IoT": return DeviceTypeEnum.IoT;
            case "Windows.Xbox": return DeviceTypeEnum.XBox;
            default: return DeviceTypeEnum.Default;
          }
        }
      }
    }

    • Proposed as answer by Barry Wang Wednesday, May 24, 2017 6:51 AM
    • Marked as answer by PDash Tuesday, August 8, 2017 2:16 AM
    Thursday, May 18, 2017 1:01 PM
  • Dear All,

    Finally I was able to deploy the app and check the solution mentioned earlier. I'm happy to say that it did work, I was able to get the family name.

    Find the attached image, where top right corner shows the family name when running on a Surface Hub.Screenshot

    I've modified Peter's solution to detect Tablet device type as well.

    public enum DeviceType { Phone, Desktop, Tablet, IoT, SurfaceHub, Other }
    
    public class AppInfoService 
    {
     public static DeviceType GetDeviceType()
            {
    
                switch (AnalyticsInfo.VersionInfo.DeviceFamily)
                {
                    case "Windows.Mobile":
                        return DeviceType.Phone;
                    case "Windows.Desktop":
                        return UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse
                            ? DeviceType.Desktop : DeviceType.Tablet;
                    case "Windows.Universal":
                        return DeviceType.IoT;
                    case "Windows.Team":
                        return DeviceType.SurfaceHub;
                    default:
                        return DeviceType.Other;
                }
            }
    }

    • Edited by PDash Tuesday, August 8, 2017 2:27 AM Modified solution.
    • Marked as answer by PDash Tuesday, August 8, 2017 2:28 AM
    Monday, August 7, 2017 8:05 AM

All replies

  • Hi PDash,

    Have you tried to check the device platform?

    The following code is used to do this:

     var devicePlatform = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily


    As you can see in the following link, UWP is divided into several families. I hope this can help you

    https://docs.microsoft.com/en-us/windows/uwp/get-started/universal-application-platform-guide#device-families

    Friday, May 12, 2017 12:24 PM
  • Thanks for the reply!

    Yes I've gone through Rob's reply even before starting this thread. Let me explain you a bit why I need this.

    Lately when we started the groundwork to support our UWP app in Surface Hub(both 55 & 84-inch), the biggest challenge came as designing a perfect API and the respective UI changes for it.

    We figured out the initial design and this design is entire different from the existing app design. For example presently we have the Hamburger menu on left-top corner of page and in Surface Hub design there will be two Hamburger menus on left-top and right-top corners. Since Surface Hub screen space is massive and we expect more than one person to work on it at the same time these kind of changes are expected, moreover even the Surface Hub design guidelines these kind of design changes are suggested.

    Now when it comes to development the first question is how to identify the app is running on Surface Hub so that we can show the respective UI on it - if we target for Resolution then the problem is Surface Hub 55-inch have resolution 1920x1080 and so does normal Desktop/Laptop screens have. So I can conclude that if I show the Surface Hub specific UI using VisualState triggers and targeting screen resolution then I'll end up showing Surface Hub UI on normal screens since resolution is same in both the devices - How to handle this situation?

    Apart from that say I want to fire a specific Analytics event only when the app is on Surface Hub, then I need to identify the device for sure. These are few of the starting requirements which forced me to ask this question over here.

    I hope to find a relevant solution over here!

    Monday, May 15, 2017 4:02 AM
  • @PDash,

    Targeting to a specific device family is reasonable base on docs:

    https://docs.microsoft.com/en-us/windows/uwp/layout/design-and-ui-intro

    "Windows doesn't provide a way for your app to detect the specific device your app is running on. It can tell you the device family (mobile, desktop, etc) the app is running on, the effective resolution, and the amount of screen space available to the app (the size of the app's window)."

    However when checking the docs I cannot find Surface Hub related device family:

    https://docs.microsoft.com/en-us/windows/uwp/get-started/universal-application-platform-guide

    Can you give Samuel's code a test to see whether Surface Hub has a specific device family like trying this code(you can put it in lifecycle events):

     var devicefamily = AnalyticsInfo.VersionInfo.DeviceFamily;

    If it does have a specific device family you can try set a specific view like this video mentioned:

    https://channel9.msdn.com/Series/Windows-10-development-for-absolute-beginners/UWP-039-Adaptive-Layout-with-Device-Specific-Views

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Barry Wang Tuesday, May 16, 2017 2:54 AM
    Tuesday, May 16, 2017 2:48 AM
  • I understood after spending some time that detecting a device is hard and not supposed to be done from development end. However our requirements are stiff thus we need to figure out a way to achieve this.

    The Surface Hub is being shipped, once we have it will test Samuel's solution and update the same over here. I hope MS has specified a separate Device family for Hubs!

    Tuesday, May 16, 2017 3:35 AM
  • @PDash,

    Since I do not have a device so I recommend you give that a test. But now I was informed from my internal channel that "Windows.Team" is the device family for Surface Hub.  And I got the direction that you can use this library to detect the Hub. Please give them a try.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    • Edited by Barry Wang Tuesday, May 16, 2017 4:51 AM
    Tuesday, May 16, 2017 4:47 AM
  • Even I came to know about this lately. The following condition is supposed to enable developers to identify whether the device is Surface Hub or not.

    if(AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Team")
    {
        //Surface Hub detected.
    }
    Someone suggested this in another forum but this code isn't verified. So I'm waiting for the device to be delivered only then I can check and confirm the legitimacy of this.

    Tuesday, May 16, 2017 5:46 AM
  • namespace My {
    
      public enum DeviceTypeEnum { Default, Phone, IoT, Desktop, XBox, Hub, Tablet }
    
      class DeviceInfo {
    
        public static DeviceTypeEnum GetDeviceType() {
    
          switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) {
            case "Windows.Mobile": return DeviceTypeEnum.Phone;
            case "Windows.Desktop": return DeviceTypeEnum.Desktop;
            case "Windows.Team": return DeviceTypeEnum.Hub;
            case "Windows.IoT": return DeviceTypeEnum.IoT;
            case "Windows.Xbox": return DeviceTypeEnum.XBox;
            default: return DeviceTypeEnum.Default;
          }
        }
      }
    }

    • Proposed as answer by Barry Wang Wednesday, May 24, 2017 6:51 AM
    • Marked as answer by PDash Tuesday, August 8, 2017 2:16 AM
    Thursday, May 18, 2017 1:01 PM
  • @PDash,

    Any updates about this issue?Have you tested this yet?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 8, 2017 9:47 AM
  • @PDash,

    Any updates about this issue?Have you tested this yet?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    The device is yet to reach our development office. In transit from Australia, hopefully we are getting it very soon. I'll definitely update the thread once we have the device with us here.

    Thursday, June 8, 2017 9:56 AM
  • @PDash,

    Thanks. We will wait for your updates.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 12, 2017 2:14 AM
  • Few updates:

    1. We got the Surface Hub. It's Hard Disk Drive got crashed, had to get a new one shipped from Microsoft support.
    2. The Surface OS is entire different with limited app options. In fact the store of Surface is different from normal Windows 10 Store.
    3. While trying installing the app on Surface HUb, I realized normal appx packages couldn't be installed on it, thus explored other ways of doing it.
    4. Tried remote debugging using visual studio, but again remote debugging agent couldn't be installed on Hub.
    5. You can create a special package for Surface with extension ".ppkg" using Windows Configuration Designer. I tried this but again the package couldn't added to Surface. I'm not sure if I'm doing something wrong but I tried how it was mentioned on the Surface Hub help page but it didn't work.

    Now, basically I'm stuck to install my application under development on Surface Hub to test and work on it. I request the experts here to help me out finding a way to debug/run the application on the machine without releasing the app to store.

    -Dash

    Monday, August 7, 2017 3:41 AM
  • @PDash,

    The steps does not work for you? Did you enabled developer mode?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 7, 2017 6:37 AM
  • Yes I enabled Developer mode in Surface Hub. I followed the steps mentioned here but still was not able to make it work. However I'm not sure if I'm doing everything right.

    I'm still struggling to find a way to deploy/run my app on Surface Hub.

    Monday, August 7, 2017 7:13 AM
  • Dear All,

    Finally I was able to deploy the app and check the solution mentioned earlier. I'm happy to say that it did work, I was able to get the family name.

    Find the attached image, where top right corner shows the family name when running on a Surface Hub.Screenshot

    I've modified Peter's solution to detect Tablet device type as well.

    public enum DeviceType { Phone, Desktop, Tablet, IoT, SurfaceHub, Other }
    
    public class AppInfoService 
    {
     public static DeviceType GetDeviceType()
            {
    
                switch (AnalyticsInfo.VersionInfo.DeviceFamily)
                {
                    case "Windows.Mobile":
                        return DeviceType.Phone;
                    case "Windows.Desktop":
                        return UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse
                            ? DeviceType.Desktop : DeviceType.Tablet;
                    case "Windows.Universal":
                        return DeviceType.IoT;
                    case "Windows.Team":
                        return DeviceType.SurfaceHub;
                    default:
                        return DeviceType.Other;
                }
            }
    }

    • Edited by PDash Tuesday, August 8, 2017 2:27 AM Modified solution.
    • Marked as answer by PDash Tuesday, August 8, 2017 2:28 AM
    Monday, August 7, 2017 8:05 AM