← Back to team overview

ubuntu-phone team mailing list archive

Re: Find out if running on a phone

 

On 16-01-11 03:08 PM, Lorn Potter wrote:
> 
> 
> On 12/01/16 05:35, Robert Park wrote:
>> But the point is that you can't have coffee that says "if desktop: x; if
>> phone: y" because it can change at any time and you can't rely on that.
> 
> Yes this desktop/phablet mode thing would be dynamic. It can change at any time, which is why it needs to be detected
> dynamically.

Input and output devices may appear or disappear dynamically.  They may change other properties dynamically (keyboard
layout, display size or resolution). None of those is a "system mode".  Yes, they are things that applications need to
adjust for.  That has been the case for a number of years already on the desktop and does not requires a "system mode."

> When you connect bt keyboard & external display, phone is now in desktop mode. When you flip back your laptop's
> touchscreen, it's it now phablet mode. It already does the first one except there is no API to let developers know for
> certain what mode it is in.

When you connect an external keyboard, you now have an external keyboard.  Unless you are writing a keyboard
configuration settings app, there is usually no reason for an application to be aware of how many keyboards I have
connected.  The shell may need to know, so it can display the OSK or not as appropriate (configurably).  Apps shouldn't
normally be aware of changes to keyboard layout or IM selection either.  An argument can be made that an application may
need to know certain kinds of input devices are present and adapt accordingly:  a game controller is not a mouse and
vice versa, a drawing tablet and a mouse are not the same, and so on.  That's not a desktop vs. phone thing, it's a
feature detection thing.

When you connect an external display, the shell needs to know.  It may choose to enter windowed mode (or it may not,
depending on configuration).  The app may need to know its display surface has changed size.  Neither of those is a
desktop/phone mode thing and apps should not go around acting like they're on a desktop just because I'm cloning my
phone to a projector for a presentation.  It's not a desktop vs. phone thing, it's a feature detection thing.

When connecting external monitors, if the hardware supports it, I want to be able to run some apps on the phone display
as if they were on a phone display and on the external monitors using a windowed display as if they're on a desktop
screen, and I want to run them both at the same time.  Is my phone in desktop mode or phone mode when I do that?

>> **MUCH** better user experience if you do feature detection, eg "if
>> push_notifications_available: enable_push_notifications()", this way
>> they work everywhere they exist, rather than trying to guess whether or
>> not they exist by making assumptions about what is a "phone" vs what is
>> a "desktop".
> 
> It really depends on what you are doing.

What would you be doing where a feature availability check would not do the right thing every time?

> We can either provide an API to do so or developers will try and guess these things on their own.

We can't stop developers from writing crappy software.  What we can do is not aid and abet them.

We need APIs for feature detection.  Apps need feature detection.  Apps don't need "system mode" detection.  We don't
want apps to have "system mode" detection because we don't want to have a "system mode."

-- 
Stephen M. Webb  <stephen.webb@xxxxxxxxxxxxx>


Follow ups

References