Bug 879695 - Notify the modem that screen state has been changed. r=vicamo,kanru
authorAlexandre Lissy <alexandre.lissy@etu.univ-tours.fr>
Thu, 06 Jun 2013 15:28:59 +0800
changeset 134226 0dbc583676132a4d1f6174cb63a25ddc2aa8f6d2
parent 134225 953b1e4c5c170d0d5281ba46b3b46e0178186bcf
child 134227 a47f4e36197f7fe3422a08c5d668f168cdf7e1f9
push id29104
push useremorley@mozilla.com
push dateThu, 06 Jun 2013 09:46:57 +0000
treeherdermozilla-inbound@8aa6c4c5dabc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo, kanru
bugs879695
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 879695 - Notify the modem that screen state has been changed. r=vicamo,kanru This seems to be needed on some devices to ensure proper low power state of the modem. --- dom/system/gonk/RadioInterfaceLayer.js | 15 +++++++++++++++ widget/gonk/nsWindow.cpp | 9 +++++++++ 2 files changed, 24 insertions(+)
dom/system/gonk/RadioInterfaceLayer.js
widget/gonk/nsWindow.cpp
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -48,16 +48,17 @@ const kSmsReceivedObserverTopic         
 const kSmsSendingObserverTopic           = "sms-sending";
 const kSmsSentObserverTopic              = "sms-sent";
 const kSmsFailedObserverTopic            = "sms-failed";
 const kSmsDeliverySuccessObserverTopic   = "sms-delivery-success";
 const kSmsDeliveryErrorObserverTopic     = "sms-delivery-error";
 const kMozSettingsChangedObserverTopic   = "mozsettings-changed";
 const kSysMsgListenerReadyObserverTopic  = "system-message-listener-ready";
 const kSysClockChangeObserverTopic       = "system-clock-change";
+const kScreenStateChangedTopic           = "screen-state-changed";
 const kTimeNitzAutomaticUpdateEnabled    = "time.nitz.automatic-update.enabled";
 const kTimeNitzAvailable                 = "time.nitz.available";
 const kCellBroadcastSearchList           = "ril.cellbroadcast.searchlist";
 
 const DOM_MOBILE_MESSAGE_DELIVERY_RECEIVED = "received";
 const DOM_MOBILE_MESSAGE_DELIVERY_SENDING  = "sending";
 const DOM_MOBILE_MESSAGE_DELIVERY_SENT     = "sent";
 const DOM_MOBILE_MESSAGE_DELIVERY_ERROR    = "error";
@@ -345,16 +346,17 @@ function RadioInterfaceLayer() {
   }
   for (let msgname of RIL_IPC_CELLBROADCAST_MSG_NAMES) {
     ppmm.addMessageListener(msgname, this);
   }
   Services.obs.addObserver(this, "xpcom-shutdown", false);
   Services.obs.addObserver(this, kMozSettingsChangedObserverTopic, false);
   Services.obs.addObserver(this, kSysMsgListenerReadyObserverTopic, false);
   Services.obs.addObserver(this, kSysClockChangeObserverTopic, false);
+  Services.obs.addObserver(this, kScreenStateChangedTopic, false);
 
   this._sentSmsEnvelopes = {};
 
   this.portAddressedSmsApps = {};
   this.portAddressedSmsApps[WAP.WDP_PORT_PUSH] = this.handleSmsWdpPortPush.bind(this);
 
   this._targetMessageQueue = [];
 
@@ -1957,22 +1959,27 @@ RadioInterfaceLayer.prototype = {
         // Shutdown all RIL network interfaces
         this.dataNetworkInterface.shutdown();
         this.mmsNetworkInterface.shutdown();
         this.suplNetworkInterface.shutdown();
         ppmm = null;
         Services.obs.removeObserver(this, "xpcom-shutdown");
         Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic);
         Services.obs.removeObserver(this, kSysClockChangeObserverTopic);
+        Services.obs.removeObserver(this, kScreenStateChangedTopic);
         break;
       case kSysClockChangeObserverTopic:
         if (this._lastNitzMessage) {
           this._lastNitzMessage.receiveTimeInMS += parseInt(data, 10);
         }
         break;
+      case kScreenStateChangedTopic:
+        debug("Received a screen-state-changed event: " + JSON.stringify(data));
+        this.setScreenState(data);
+        break;
     }
   },
 
   // Flag to determine whether the UI's system app is ready to receive
   // events yet.
   _sysMsgListenerReady: false,
 
   // Flag to determine the radio state to start with when we boot up. It
@@ -2186,16 +2193,24 @@ RadioInterfaceLayer.prototype = {
                              callIndex: callIndex});
   },
 
   getAvailableNetworks: function getAvailableNetworks(requestId) {
     this.worker.postMessage({rilMessageType: "getAvailableNetworks",
                              requestId: requestId});
   },
 
+  setScreenState: function setScreenState(state) {
+    debug("setScreenState: " + JSON.stringify(state));
+    this.worker.postMessage({
+      rilMessageType: "setScreenState",
+      on: (state === "on")
+    });
+  },
+
   sendMMI: function sendMMI(message) {
     debug("SendMMI " + JSON.stringify(message));
     message.rilMessageType = "sendMMI";
     this.worker.postMessage(message);
   },
 
   cancelMMI: function cancelMMI(message) {
     // Some MMI codes trigger radio operations, but unfortunately the RIL only
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -94,16 +94,25 @@ public:
         for (uint32_t i = 0; i < sTopWindows.Length(); i++) {
             nsWindow *win = sTopWindows[i];
 
             if (nsIWidgetListener* listener = win->GetWidgetListener()) {
                 listener->SizeModeChanged(mIsOn ? nsSizeMode_Fullscreen : nsSizeMode_Minimized);
             }
         }
 
+        // Notify observers that the screen state has just changed.
+        nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
+        if (observerService) {
+          observerService->NotifyObservers(
+            nullptr, "screen-state-changed",
+            mIsOn ? NS_LITERAL_STRING("on").get() : NS_LITERAL_STRING("off").get()
+          );
+        }
+
         return NS_OK;
     }
 
 private:
     bool mIsOn;
 };
 
 static const char* kSleepFile = "/sys/power/wait_for_fb_sleep";