Navigation Menu

Skip to content

Commit

Permalink
[lipstick] Add busy notifications for usb-mode selection. Contributes…
Browse files Browse the repository at this point in the history
… to JB#44479

Plugging in USB PC connection can result in a USB mode selection box
(e.g. showing Developer mode, Media transfer (MTP) Charging only).
Selecting some options (e.g. MTP) can result in a delay while the
connection is set up. Currently there's no indication that anything is
happening while the connection is being established.

This change adds a periodic notification and animation to highlight to
the user that their request hasn't been ignored.

It includes the following changes:

1. Tied the charging notification logic to USB mode selection. Previously
the "Charging..." notification would overlap the USB selection dialog,
risking a dangerous information overload scenario. This change delays the
charging notification until after the user has selected a USB mode option.
This bends the truth a little, because the phone will actually be charging
even while the dialog is visible, but hopefully this provides an
overall better experience for the user.

2. Refactored to move code from lipstick-qt5 to lipstick-jolla-home and
improve the separation between lipstick middleware and the lipstick
application layer.

3. Updated to use new target property from QUsbModed.

4. Untangled the QUsbModed events and modes for clarity, so they're
now handled seperately, rather than being streamed together.

5. Switched internally used slots to private methods.

6. Renamed some properties and methods to remove duplicate reference
to USB, for example from USBModeSelector::setUSBMode() to
USBModeSelector::setMode().

7. Require libusb-moded-qt5 >= 1.8 for building. This version is needed
to allow access to the target property.
  • Loading branch information
llewelld committed Feb 21, 2019
1 parent dfcffb5 commit 6a18938
Show file tree
Hide file tree
Showing 9 changed files with 349 additions and 155 deletions.
4 changes: 2 additions & 2 deletions rpm/lipstick-qt5.spec
Expand Up @@ -5,7 +5,7 @@ Name: lipstick-qt5
%define icondirectory %{_datadir}/icons/hicolor/86x86/apps

Summary: QML toolkit for homescreen creation
Version: 0.32.18
Version: 0.33.1
Release: 1
Group: System/Libraries
License: LGPLv2.1
Expand Down Expand Up @@ -38,7 +38,7 @@ BuildRequires: pkgconfig(ngf-qt5)
BuildRequires: pkgconfig(contextkit-statefs) >= 0.2.7
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(wayland-server)
BuildRequires: pkgconfig(usb-moded-qt5) >= 1.7
BuildRequires: pkgconfig(usb-moded-qt5) >= 1.8
BuildRequires: pkgconfig(systemsettings)
BuildRequires: pkgconfig(nemodevicelock)
BuildRequires: qt5-qttools-linguist
Expand Down
1 change: 1 addition & 0 deletions src/homeapplication.cpp
Expand Up @@ -181,6 +181,7 @@ HomeApplication::HomeApplication(int &argc, char **argv, const QString &qmlPath)
m_qmlEngine->rootContext()->setContextProperty("LipstickSettings", LipstickSettings::instance());
m_qmlEngine->rootContext()->setContextProperty("volumeControl", m_volumeControl);
m_qmlEngine->rootContext()->setContextProperty("connectivityMonitor", m_connectivityMonitor);
m_qmlEngine->rootContext()->setContextProperty("usbModeSelector", m_usbModeSelector);

connect(this, SIGNAL(homeReady()), this, SLOT(sendStartupNotifications()));
}
Expand Down
10 changes: 9 additions & 1 deletion src/notifications/batterynotifier.cpp
Expand Up @@ -109,7 +109,9 @@ void BatteryNotifier::prepareNotification()
toRemove << NotificationRemoveCharger
<< NotificationChargingComplete
<< NotificationLowBattery;
if (m_chargingCompletion == NeedsCharging) {
// In the case of USB devices, charging notifications on
// connection are handled by USBModeSelector rather than here.
if (m_chargingCompletion == NeedsCharging && !isUsbDevice()) {
toSend << NotificationCharging;
}
} else {
Expand Down Expand Up @@ -343,3 +345,9 @@ BatteryNotifier::ChargerType BatteryNotifier::getCharger() const
? ChargerNo
: ChargerUnknown)));
}

bool BatteryNotifier::isUsbDevice() const
{
QString name(propertyString(m_chargerType));
return (name == "dcp" || name == "cdp" || name == "usb");
}
7 changes: 7 additions & 0 deletions src/notifications/batterynotifier.h
Expand Up @@ -125,6 +125,13 @@ private slots:
ChargingState getState() const;
ChargerType getCharger() const;

/*! Determines whether the current device is a USB device that will by
* handled by usb_moded.
*
* \returns true if the device will be handled by usb_moded, false o/w.
*/
bool isUsbDevice() const;

//! Low battery notifier for getting notifications about low battery state
LowBatteryNotifier *m_lowBatteryNotifier;

Expand Down

0 comments on commit 6a18938

Please sign in to comment.