Bug 1194751 - Part 2. Remove unused nsIScreen::LockMinimumBrightness and related methods. r=snorp
authorKan-Ru Chen <kanru@kanru.info>
Thu, 09 Mar 2017 19:16:29 +0800
changeset 397835 5df5fa8ee892ff9f893bf8ae15a66a89a1a72325
parent 397834 57f989c1010f40a2b99ee89d61bd1621c633ab4a
child 397836 ace97d197b699443091db818a2e18222a7065bb0
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1194751
milestone55.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 1194751 - Part 2. Remove unused nsIScreen::LockMinimumBrightness and related methods. r=snorp It's not used anywhere in gecko or addons. Remove it will make removing PScreenManager easier. MozReview-Commit-ID: K3BHnktO7wU
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
widget/android/nsScreenManagerAndroid.cpp
widget/android/nsScreenManagerAndroid.h
widget/nsBaseScreen.cpp
widget/nsBaseScreen.h
widget/nsIScreen.idl
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1056,26 +1056,16 @@ public class GeckoAppShell
     @WrapForJNI(calledFrom = "gecko")
     private static void cancelVibrate() {
         sVibrationMaybePlaying = false;
         sVibrationEndTime = 0;
         vibrator().cancel();
     }
 
     @WrapForJNI(calledFrom = "gecko")
-    private static void setKeepScreenOn(final boolean on) {
-        ThreadUtils.postToUiThread(new Runnable() {
-            @Override
-            public void run() {
-                // TODO
-            }
-        });
-    }
-
-    @WrapForJNI(calledFrom = "gecko")
     private static boolean isNetworkLinkUp() {
         ConnectivityManager cm = (ConnectivityManager)
            getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
         try {
             NetworkInfo info = cm.getActiveNetworkInfo();
             if (info == null || !info.isConnected())
                 return false;
         } catch (SecurityException se) {
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -601,24 +601,16 @@ auto GeckoAppShell::ScheduleRestart() ->
 constexpr char GeckoAppShell::SetFullScreen_t::name[];
 constexpr char GeckoAppShell::SetFullScreen_t::signature[];
 
 auto GeckoAppShell::SetFullScreen(bool a0) -> void
 {
     return mozilla::jni::Method<SetFullScreen_t>::Call(GeckoAppShell::Context(), nullptr, a0);
 }
 
-constexpr char GeckoAppShell::SetKeepScreenOn_t::name[];
-constexpr char GeckoAppShell::SetKeepScreenOn_t::signature[];
-
-auto GeckoAppShell::SetKeepScreenOn(bool a0) -> void
-{
-    return mozilla::jni::Method<SetKeepScreenOn_t>::Call(GeckoAppShell::Context(), nullptr, a0);
-}
-
 constexpr char GeckoAppShell::SetScreenDepthOverride_t::name[];
 constexpr char GeckoAppShell::SetScreenDepthOverride_t::signature[];
 
 auto GeckoAppShell::SetScreenDepthOverride(int32_t a0) -> void
 {
     return mozilla::jni::Method<SetScreenDepthOverride_t>::Call(GeckoAppShell::Context(), nullptr, a0);
 }
 
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -1697,36 +1697,16 @@ public:
         static const mozilla::jni::CallingThread callingThread =
                 mozilla::jni::CallingThread::GECKO;
         static const mozilla::jni::DispatchTarget dispatchTarget =
                 mozilla::jni::DispatchTarget::CURRENT;
     };
 
     static auto SetFullScreen(bool) -> void;
 
-    struct SetKeepScreenOn_t {
-        typedef GeckoAppShell Owner;
-        typedef void ReturnType;
-        typedef void SetterType;
-        typedef mozilla::jni::Args<
-                bool> Args;
-        static constexpr char name[] = "setKeepScreenOn";
-        static constexpr char signature[] =
-                "(Z)V";
-        static const bool isStatic = true;
-        static const mozilla::jni::ExceptionMode exceptionMode =
-                mozilla::jni::ExceptionMode::ABORT;
-        static const mozilla::jni::CallingThread callingThread =
-                mozilla::jni::CallingThread::GECKO;
-        static const mozilla::jni::DispatchTarget dispatchTarget =
-                mozilla::jni::DispatchTarget::CURRENT;
-    };
-
-    static auto SetKeepScreenOn(bool) -> void;
-
     struct SetScreenDepthOverride_t {
         typedef GeckoAppShell Owner;
         typedef void ReturnType;
         typedef void SetterType;
         typedef mozilla::jni::Args<
                 int32_t> Args;
         static constexpr char name[] = "setScreenDepthOverride";
         static constexpr char signature[] =
--- a/widget/android/nsScreenManagerAndroid.cpp
+++ b/widget/android/nsScreenManagerAndroid.cpp
@@ -112,26 +112,16 @@ nsScreenAndroid::GetPixelDepth(int32_t *
 
 
 NS_IMETHODIMP
 nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
 {
     return GetPixelDepth(aColorDepth);
 }
 
-
-void
-nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness)
-{
-    if (mDisplayType == DisplayType::DISPLAY_PRIMARY &&
-        mozilla::jni::IsAvailable()) {
-        java::GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
-    }
-}
-
 class nsScreenManagerAndroid::ScreenManagerHelperSupport final
     : public ScreenManagerHelper::Natives<ScreenManagerHelperSupport>
 {
 public:
     typedef ScreenManagerHelper::Natives<ScreenManagerHelperSupport> Base;
 
     static int32_t AddDisplay(int32_t aDisplayType, int32_t aWidth, int32_t aHeight, float aDensity) {
         int32_t screenId = -1; // return value
--- a/widget/android/nsScreenManagerAndroid.h
+++ b/widget/android/nsScreenManagerAndroid.h
@@ -27,19 +27,16 @@ public:
     NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
 
     uint32_t GetId() const { return mId; };
     DisplayType GetDisplayType() const { return mDisplayType; }
 
     void SetDensity(double aDensity) { mDensity = aDensity; }
     float GetDensity();
 
-protected:
-    virtual void ApplyMinimumBrightness(uint32_t aBrightness) override;
-
 private:
     uint32_t mId;
     DisplayType mDisplayType;
     nsIntRect mRect;
     float mDensity;
 };
 
 class nsScreenManagerAndroid final : public nsIScreenManager
--- a/widget/nsBaseScreen.cpp
+++ b/widget/nsBaseScreen.cpp
@@ -8,18 +8,16 @@
 #define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
 
 #include "nsBaseScreen.h"
 
 NS_IMPL_ISUPPORTS(nsBaseScreen, nsIScreen)
 
 nsBaseScreen::nsBaseScreen()
 {
-  for (uint32_t i = 0; i < nsIScreen::BRIGHTNESS_LEVELS; i++)
-    mBrightnessLocks[i] = 0;
 }
 
 nsBaseScreen::~nsBaseScreen() { }
 
 NS_IMETHODIMP
 nsBaseScreen::GetRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                 int32_t *outWidth, int32_t *outHeight)
 {
@@ -29,58 +27,16 @@ nsBaseScreen::GetRectDisplayPix(int32_t 
 NS_IMETHODIMP
 nsBaseScreen::GetAvailRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                      int32_t *outWidth, int32_t *outHeight)
 {
   return GetAvailRect(outLeft, outTop, outWidth, outHeight);
 }
 
 NS_IMETHODIMP
-nsBaseScreen::LockMinimumBrightness(uint32_t aBrightness)
-{
-  MOZ_ASSERT(aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
-             "Invalid brightness level to lock");
-  mBrightnessLocks[aBrightness]++;
-  MOZ_ASSERT(mBrightnessLocks[aBrightness] > 0,
-             "Overflow after locking brightness level");
-
-  CheckMinimumBrightness();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsBaseScreen::UnlockMinimumBrightness(uint32_t aBrightness)
-{
-  MOZ_ASSERT(aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
-             "Invalid brightness level to lock");
-  MOZ_ASSERT(mBrightnessLocks[aBrightness] > 0,
-             "Unlocking a brightness level with no corresponding lock");
-  mBrightnessLocks[aBrightness]--;
-
-  CheckMinimumBrightness();
-
-  return NS_OK;
-}
-
-void
-nsBaseScreen::CheckMinimumBrightness()
-{
-  uint32_t brightness = nsIScreen::BRIGHTNESS_LEVELS;
-  for (int32_t i = nsIScreen::BRIGHTNESS_LEVELS - 1; i >=0; i--) {
-    if (mBrightnessLocks[i] > 0) {
-      brightness = i;
-      break;
-    }
-  }
-
-  ApplyMinimumBrightness(brightness);
-}
-
-NS_IMETHODIMP
 nsBaseScreen::GetContentsScaleFactor(double* aContentsScaleFactor)
 {
   *aContentsScaleFactor = 1.0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBaseScreen::GetDefaultCSSScaleFactor(double* aScaleFactor)
--- a/widget/nsBaseScreen.h
+++ b/widget/nsBaseScreen.h
@@ -23,59 +23,23 @@ public:
   // These simply forward to the device-pixel versions;
   // implementations where desktop pixels may not correspond
   // to per-screen device pixels must override.
   NS_IMETHOD GetRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                int32_t *outWidth, int32_t *outHeight) override;
   NS_IMETHOD GetAvailRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                     int32_t *outWidth, int32_t *outHeight) override;
 
-  /**
-   * Simple management of screen brightness locks. This abstract base class
-   * allows all widget implementations to share brightness locking code.
-   */
-  NS_IMETHOD LockMinimumBrightness(uint32_t aBrightness) override;
-  NS_IMETHOD UnlockMinimumBrightness(uint32_t aBrightness) override;
-
   NS_IMETHOD GetRotation(uint32_t* aRotation) override {
     *aRotation = nsIScreen::ROTATION_0_DEG;
     return NS_OK;
   }
   NS_IMETHOD SetRotation(uint32_t aRotation) override { return NS_ERROR_NOT_AVAILABLE; }
 
   NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
 
   NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
 
 protected:
   virtual ~nsBaseScreen();
-
-  /**
-   * Manually set the current level of brightness locking. This is called after
-   * we determine, based on the current active locks, what the strongest
-   * lock is. You should normally not call this function - it will be
-   * called automatically by this class.
-   *
-   * Each widget implementation should implement this in a way that
-   * makes sense there. This is normally the only function that
-   * contains widget-specific code.
-   *
-   * The default implementation does nothing.
-   *
-   * @param aBrightness The current brightness level to set. If this is
-   *                    nsIScreen::BRIGHTNESS_LEVELS
-   *                    (an impossible value for a brightness level to be),
-   *                    then that signifies that there is no current
-   *                    minimum brightness level, and the screen can shut off.
-   */
-  virtual void ApplyMinimumBrightness(uint32_t aBrightness) { }
-
-private:
-  /**
-   * Checks what the minimum brightness value is, and calls
-   * ApplyMinimumBrightness.
-   */
-  void CheckMinimumBrightness();
-
-  uint32_t mBrightnessLocks[nsIScreen::BRIGHTNESS_LEVELS];
 };
 
 #endif // nsBaseScreen_h
--- a/widget/nsIScreen.idl
+++ b/widget/nsIScreen.idl
@@ -16,25 +16,16 @@ enum class DisplayType: int32_t {
   DISPLAY_VIRTUAL   // wireless displays, such as Chromecast, WiFi-Display, etc.
 };
 %}
 
 [scriptable, uuid(826e80c8-d70f-42e2-8aa9-82c05f2a370a)]
 interface nsIScreen : nsISupports
 {
   /**
-   * Levels of brightness for the screen, from off to full brightness.
-   */
-  const unsigned long BRIGHTNESS_DIM = 0;
-  const unsigned long BRIGHTNESS_FULL = 1;
-
-  /* The number of different brightness levels */
-  const unsigned long BRIGHTNESS_LEVELS = 2;
-
-  /**
    * Allowable screen rotations, when the underlying widget toolkit
    * supports rotating the screen.
    *
    * ROTATION_0_DEG is the default, unrotated configuration.
    */
   const unsigned long   ROTATION_0_DEG = 0;
   const unsigned long  ROTATION_90_DEG = 1;
   const unsigned long ROTATION_180_DEG = 2;
@@ -53,34 +44,16 @@ interface nsIScreen : nsISupports
   void GetAvailRect(out long left, out long top, out long width, out long height);
 
   /**
    * And these report in desktop pixels
    */
   void GetRectDisplayPix(out long left, out long top, out long width, out long height);
   void GetAvailRectDisplayPix(out long left, out long top, out long width, out long height);
 
-  /**
-   * Locks the minimum brightness of the screen, forcing it to be at
-   * least as bright as a certain brightness level. Each call to this
-   * function must eventually be followed by a corresponding call to
-   * unlockMinimumBrightness, with the same brightness level.
-   *
-   * @param brightness A brightness level, one of the above constants.
-   */
-  void lockMinimumBrightness(in unsigned long brightness);
-
-  /**
-   * Releases a lock on the screen brightness. This must be called
-   * (eventually) after a corresponding call to lockMinimumBrightness.
-   *
-   * @param brightness A brightness level, one of the above constants.
-   */
-  void unlockMinimumBrightness(in unsigned long brightness);
-  
   readonly attribute long pixelDepth;
   readonly attribute long colorDepth;
   /**
    * Get/set the screen rotation, on platforms that support changing
    * screen rotation.
    */
   attribute unsigned long rotation;