2011-10-05 15:15:45 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-10-20 17:38:39 -04:00
|
|
|
/* vim: set sw=2 ts=8 et ft=cpp : */
|
2012-05-21 12:12:37 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-10-05 15:15:45 -07:00
|
|
|
|
|
|
|
include protocol PContent;
|
2011-09-30 00:00:48 -07:00
|
|
|
include protocol PBrowser;
|
2012-02-05 19:51:06 +00:00
|
|
|
|
2020-11-23 16:05:56 +00:00
|
|
|
include "mozilla/dom/ReferrerInfoUtils.h";
|
2014-04-30 21:52:00 -04:00
|
|
|
include "mozilla/GfxMessageUtils.h";
|
|
|
|
|
2022-02-14 07:51:06 +00:00
|
|
|
using hal::ScreenOrientation from "mozilla/HalIPCUtils.h";
|
2013-10-01 15:25:07 -04:00
|
|
|
using mozilla::hal::SensorType from "mozilla/HalSensor.h";
|
|
|
|
using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h";
|
|
|
|
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
|
2015-04-21 17:04:57 +02:00
|
|
|
using nsIntRect from "nsRect.h";
|
2013-10-01 15:25:07 -04:00
|
|
|
using PRTime from "prtime.h";
|
2011-10-05 15:15:45 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2011-11-02 16:14:01 +01:00
|
|
|
|
|
|
|
namespace hal {
|
2012-05-08 14:36:07 -07:00
|
|
|
struct BatteryInformation {
|
|
|
|
double level;
|
|
|
|
bool charging;
|
|
|
|
double remainingTime;
|
|
|
|
};
|
2012-01-16 14:39:57 +01:00
|
|
|
|
2012-05-08 14:36:07 -07:00
|
|
|
struct SensorData {
|
|
|
|
SensorType sensor;
|
|
|
|
PRTime timestamp;
|
|
|
|
float[] values;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NetworkInformation {
|
2014-03-05 11:54:55 +08:00
|
|
|
uint32_t type;
|
2013-07-11 11:39:36 -04:00
|
|
|
bool isWifi;
|
|
|
|
uint32_t dhcpGateway;
|
2012-05-08 14:36:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WakeLockInformation {
|
2013-05-10 11:20:52 -04:00
|
|
|
nsString topic;
|
2012-05-08 14:36:07 -07:00
|
|
|
uint32_t numLocks;
|
|
|
|
uint32_t numHidden;
|
2013-02-14 15:41:30 -05:00
|
|
|
uint64_t[] lockingProcesses;
|
2012-05-08 14:36:07 -07:00
|
|
|
};
|
|
|
|
|
2012-08-05 01:09:39 -04:00
|
|
|
} // namespace hal
|
2012-03-07 12:03:25 +01:00
|
|
|
|
2011-10-05 15:15:45 -07:00
|
|
|
namespace hal_sandbox {
|
|
|
|
|
2022-02-09 17:29:47 +00:00
|
|
|
[ManualDealloc, NestedUpTo=inside_cpow, ChildImpl=virtual, ParentImpl=virtual]
|
2022-02-09 17:29:46 +00:00
|
|
|
sync protocol PHal {
|
2011-10-05 15:15:45 -07:00
|
|
|
manager PContent;
|
|
|
|
|
2011-11-02 16:14:01 +01:00
|
|
|
child:
|
2016-01-26 13:51:53 -08:00
|
|
|
async NotifyBatteryChange(BatteryInformation aBatteryInfo);
|
|
|
|
async NotifyNetworkChange(NetworkInformation aNetworkInfo);
|
|
|
|
async NotifyWakeLockChange(WakeLockInformation aWakeLockInfo);
|
2011-11-02 16:14:01 +01:00
|
|
|
|
2011-10-05 15:15:45 -07:00
|
|
|
parent:
|
2016-01-26 13:51:53 -08:00
|
|
|
async Vibrate(uint32_t[] pattern, uint64_t[] id, PBrowser browser);
|
|
|
|
async CancelVibrate(uint64_t[] id, PBrowser browser);
|
2011-10-05 15:15:45 -07:00
|
|
|
|
2016-01-26 13:51:53 -08:00
|
|
|
async EnableBatteryNotifications();
|
|
|
|
async DisableBatteryNotifications();
|
2011-11-02 16:14:01 +01:00
|
|
|
sync GetCurrentBatteryInformation()
|
|
|
|
returns (BatteryInformation aBatteryInfo);
|
|
|
|
|
2016-01-26 13:51:53 -08:00
|
|
|
async EnableNetworkNotifications();
|
|
|
|
async DisableNetworkNotifications();
|
2012-01-16 14:39:57 +01:00
|
|
|
sync GetCurrentNetworkInformation()
|
|
|
|
returns (NetworkInformation aNetworkInfo);
|
|
|
|
|
2016-01-26 13:51:53 -08:00
|
|
|
async ModifyWakeLock(nsString aTopic,
|
|
|
|
WakeLockControl aLockAdjust,
|
|
|
|
WakeLockControl aHiddenAdjust,
|
|
|
|
uint64_t aProcessID);
|
|
|
|
async EnableWakeLockNotifications();
|
|
|
|
async DisableWakeLockNotifications();
|
2012-03-07 12:03:25 +01:00
|
|
|
sync GetWakeLockInfo(nsString aTopic)
|
|
|
|
returns (WakeLockInformation aWakeLockInfo);
|
|
|
|
|
Bug 1697647 - Add screen orientation lock api r=ipc-reviewers,mccr8,agi,smaug,jonalmeida
Previously, the screenOrientation.lock API was for Fennec and not supported for Fenix and multi-process use. The overall idea is to now allow apps to use the API through a delegate and make asynchronous calls to LockDeviceOrientation. This required replacing the existing code that returned a default false bool to calls that perform the requested orientation change and instead return a promise that contained either an allow or deny value.
Returning a promise instead of a bool involved changing the API calls from the C++ side to Java. The new general control flow of screenOrientation lock follows: an app calls C++ ScreenOrientation.lock() which eventually dispatches LockOrientationTask to resolve the pending orientation promise. Hal.cpp sends an IPC call to the content process and RecvLockScreenOrientation retrieves the current instance of geckoRuntime and calls the java side LockScreenOrientation. Apps must create a delegate and override onOrientationLock to set the requested orientation. In geckoview's testing, this is done with the android API setRequestedOrientation. Once a device orientation change has been triggered, native OnOrientationChange calls to NotifyScreenConfigurationChange, which notifies all observers and dispatches a change event to resolve the pending orientation promise.
Testing:
I used a demo on the GeckoView Example (https://usefulangle.com/demos/105/screen.html) to test locking to landscape orientation. This required a change to the GVE to show the app from recreating the whole thing on orientation change. In the example AndroidManifest xml file, `orientation` prevents restart when orientation changes.
The Junit/Kotlin tests were to verify that the expected orientation delegate was called with the expected new orientation value, in an orientation change, if the new orientation was the same as the current, and if the pre-lock conditions such as being fullscreen were not met.
A static preference `dom.screenorientation.allow-lock` was added to the dom group, since it affects the ui dom) and is currently turned off. C++ can access it through its mirrored variable dom_screenorientation_allow_lock (same name but with underscores). The junit tests turn the preference on and test the lock feature.
Reference:
Orientation constant values:
C++
1 ScreenOrientation_PortraitPrimary); - vertical with button at bottom
2 ScreenOrientation_PortraitSecondary); - vertical with button at top
4 ScreenOrientation_LandscapePrimary); - horizational w button right
8 ScreenOrientation_LandscapeSecondary); - horization button left
16 ScreenOrientation_Default);
Java
1 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_PRIMARY.value
2 GeckoScreenOrientation.ScreenOrientation.PORTRAIT_SECONDARY.value
4 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_PRIMARY.value
8 GeckoScreenOrientation.ScreenOrientation.LANDSCAPE_SECONDARY.value
Java public API
0 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
1 Activitynfo.SCREEN_ORIENTATION_PORTRAIT
Android
1 ORIENTATION_PORTRAIT
2 ORIENTATION_LANDSCAPE
Differential Revision: https://phabricator.services.mozilla.com/D129427
2021-12-06 13:58:37 +00:00
|
|
|
async LockScreenOrientation(ScreenOrientation aOrientation)
|
2022-03-02 03:48:14 +00:00
|
|
|
returns (nsresult result);
|
2016-01-26 13:51:53 -08:00
|
|
|
async UnlockScreenOrientation();
|
2012-03-13 17:42:46 +01:00
|
|
|
|
2012-02-05 19:51:06 +00:00
|
|
|
child:
|
2016-01-26 13:51:53 -08:00
|
|
|
async NotifySensorChange(SensorData aSensorData);
|
2012-02-05 19:51:06 +00:00
|
|
|
|
2012-09-19 11:17:13 -04:00
|
|
|
parent:
|
2016-01-26 13:51:53 -08:00
|
|
|
async EnableSensorNotifications(SensorType aSensor);
|
|
|
|
async DisableSensorNotifications(SensorType aSensor);
|
2012-02-05 19:51:06 +00:00
|
|
|
|
2016-01-26 13:51:53 -08:00
|
|
|
async __delete__();
|
2011-10-05 15:15:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace hal
|
|
|
|
} // namespace mozilla
|