on xenial help sign in
Handle chassis cases that are not documented
commit9c21cc5784dee0adc879fa40b013b88042ed2969 authorPete Woods <pete.woods@canonical.com> dateFri 17 Mar 2017, 14:14 (10 years ago) parent411188c
2 files changed+16−7
plugins/Unity/Platform/platform.cpp+12−5 tests/plugins/Unity/Platform/platformtest.cpp+4−2
plugins/Unity/Platform/platform.cpp+12−5
@@ -33,13 +33,20 @@ void Platform::init()
3333 QDBusInterface seatIface("org.freedesktop.login1", "/org/freedesktop/login1/seat/self", "org.freedesktop.login1.Seat",
3434 QDBusConnection::systemBus(), this);
3535
36− // From the docs at https://www.freedesktop.org/wiki/Software/systemd/hostnamed/
37− // the options are "desktop", "laptop", "server", "tablet", "handset", as well
38− // as the special chassis types "vm" and "container".
36+ // From the source at https://cgit.freedesktop.org/systemd/systemd/tree/src/hostname/hostnamed.c#n130
37+ // "vm\0"
38+ // "container\0"
39+ // "desktop\0"
40+ // "laptop\0"
41+ // "server\0"
42+ // "tablet\0"
43+ // "handset\0"
44+ // "watch\0"
45+ // "embedded\0",
3946 m_chassis = iface.property("Chassis").toString();
4047
41− // A PC is not a phone or tablet.
42− m_isPC = !QSet<QString>{"handset", "tablet"}.contains(m_chassis);
48+ // A PC is not a handset, tablet or watch.
49+ m_isPC = !QSet<QString>{"handset", "tablet", "watch"}.contains(m_chassis);
4350 m_isMultiSession = seatIface.property("CanMultiSession").toBool() && seatIface.property("CanGraphical").toBool();
4451}
4552
tests/plugins/Unity/Platform/platformtest.cpp+4−2
@@ -86,13 +86,15 @@ private Q_SLOTS:
8686 QTest::addColumn<QString>("chassis");
8787 QTest::addColumn<bool>("result");
8888
89+ QTest::newRow("vm") << "vm" << true;
90+ QTest::newRow("container") << "container" << true;
8991 QTest::newRow("desktop") << "desktop" << true;
9092 QTest::newRow("laptop") << "laptop" << true;
9193 QTest::newRow("server") << "server" << true;
9294 QTest::newRow("tablet") << "tablet" << false;
9395 QTest::newRow("handset") << "handset" << false;
94− QTest::newRow("vm") << "vm" << true;
95− QTest::newRow("container") << "container" << true;
96+ QTest::newRow("watch") << "watch" << false;
97+ QTest::newRow("embedded") << "embedded" << true;
9698 }
9799
98100 void testIsPC()