Module: AppWindowManager

AppWindowManager manages the interaction of AppWindow instances.

  • Controll the open/close request of the living appWindow instances.
  • Deliver the resize/orientation lock/setVisible request from LayoutManager/OrientationManager/VisibilityManager to the active appWindow instance.
Source:

Members

(static) _nfcHandler :Object

Handles system browser URL sharing via NFC.

Handles system browser URL sharing via NFC. Starts listening for peerready events once NFC is enabled in settings

Type:
  • Object
Source:

Methods

(static) _start()

The init process from bootstrap to homescreen is opened: bootstrap

  1. Applications is ready.

The init process from bootstrap to homescreen is opened: bootstrap

  1. Applications is ready. (mozApps are parsed.)
  2. Bootstrap tells HomescreenLauncher to init.
  3. Homescreen is ready.
  4. Bootstrap tells FTULauncher to fetch FTU(First Time Use app) info.
  5. FTU app is skipped or done.
  6. AppWindowManager open homescreen app via homescreenWindowManager.
Source:

(static) broadcastMessage(message, detailopt)

Broadcast message to all running app window instances

Used while an event needs to be manipulated by all running instances.

Broadcast message to all running app window instances

Used while an event needs to be manipulated by all running instances. You should register the event handler in the appWindow as well.

Parameters:
Name Type Attributes Description
message String

The message name.

detail Object <optional>

The detail of the message.

Source:
Example
AppWindowManager.broadcastMessage('earthquake');

AppWindow.prototype._handle__earthquake = function() {
  // Run on my own!
};

AppWindow.REGISTERED_EVENTS.push('_earthquake');

(static) display(newApp, openAnimationopt, closeAnimationopt, eventTypeopt)

Switch to a different app

.

Switch to a different app

Parameters:
Name Type Attributes Description
newApp AppWindow

The new app window instance.

openAnimation String <optional>

The open animation for opening app.

closeAnimation String <optional>

The close animation for closing app.

eventType String <optional>

The event type of displaying app.

Source:

(static) fireActivity(activityContentopt)

After show the window of activity or homescreen, fire the following activity.

After show the window of activity or homescreen, fire the following activity.

Parameters:
Name Type Attributes Description
activityContent Object <optional>
Source:

(static) fireNotificationClicked(notificationIdopt)

After show the window of activity or homescreen, fire the event of notification clicked.

After show the window of activity or homescreen, fire the event of notification clicked.

Parameters:
Name Type Attributes Description
notificationId String <optional>
Source:

(static) kill(origin)

Kill the running app window by origin

AppWindow instances are responsible to kill theirselves whenever there's something wrong when the app/page is running.

Kill the running app window by origin

AppWindow instances are responsible to kill theirselves whenever there's something wrong when the app/page is running. For example: OOM, crashed, window.close().

When we need to kill a running instance, we call kill on the instance and let the instance to request 'close' to AppWindowManager or just destroy itself if it's at background.

AppWindowManager kill process

Parameters:
Name Type Description
origin String

The origin of the running app window to be killed.

Source:

(static) launch(config)

Instanciate app window by configuration

.

Instanciate app window by configuration

Parameters:
Name Type Description
config AppConfig

The configuration of the app window.

Source:

(static) onShowWindow(detailopt)

The event 'showwindow' may come with details, which means there is some steps need to be done after we show or don't show the active app, or the homescreen window.

The event 'showwindow' may come with details, which means there is some steps need to be done after we show or don't show the active app, or the homescreen window.

Parameters:
Name Type Attributes Description
detail Object <optional>

The detail of the event.

Source:

(static) switchApp(appCurrent, appNext, switchingopt, openAnimationopt, closeAnimationopt)

Switch from the current app to the next app.

Switch from the current app to the next app.

Parameters:
Name Type Attributes Description
appCurrent AppWindow

Displayed appWindow instance.

appNext AppWindow

appWindow instance to be shown.

switching Boolean <optional>

Homescreen doesn't involve in the two apps.

openAnimation String <optional>

The open animation for opening app.

closeAnimation String <optional>

The close animation for closing app.

Source:

(inner) getActiveApp() → {AppWindow}

Get active app.

Get active app. If active app is null, we'll return homescreen as default.

Source:
Returns:

The app is active.

Type
AppWindow

(inner) getActiveWindow() → {AppWindow|null}

HierarchyManager will use this function to get the active window instance.

HierarchyManager will use this function to get the active window instance.

Source:
Returns:

The active app window instance

Type
AppWindow | null

(inner) getApp(origin, manifestURLopt) → {AppWindow}

Match app origin and get the first matching one.

Match app origin and get the first matching one.

Parameters:
Name Type Attributes Description
origin String

The origin to be matched.

manifestURL String <optional>

The manifestURL to be matched.

Source:
Returns:

The app window object matched.

Type
AppWindow

(inner) getAppByURL(url) → {AppWindow}

Match app window that is currently at a specific url.

Match app window that is currently at a specific url.

Parameters:
Name Type Description
url String

The url to be matched.

Source:
Returns:

The app window object matched.

Type
AppWindow

(inner) getApps() → {Object}

Get all apps.

Get all apps.

Source:
Returns:

The running app window references stored by its instanceID.

Type
Object

(inner) isBusyLoading()

Indicates the system is busy doing something.

Indicates the system is busy doing something. Now it stands for the foreground app is not loaded yet.

XXX: AppWindowManager should register a service for isBusyLoading query by Service.register('isBusyLoading', appWindowManager).

Source:

(inner) isRunning(app) → {Boolean}

Test the app is already running.

Test the app is already running.

Parameters:
Name Type Description
app AppConfig

The configuration of app.

Source:
Returns:

The app is running or not.

Type
Boolean

(inner) stopRecording()

Abuse the settings database to notify interested certified apps that the current foreground window is about to close.

Abuse the settings database to notify interested certified apps that the current foreground window is about to close. This is a hack implemented to fix bug 1051172 so that apps can be notified that they will be closing without having to wait for the visibilitychange event that does not arrive until after the app has been hidden.

This function is called from display() above to handle switching from an app to the homescreen or to the task switcher. It is also called from stack_manager.js to handle edge gestures. I tried calling it from screen_manager.js to handle screen blanking and the sleep button, but the visibiltychange event arrived before the will hide notification did in that case, so it was not necessary.

We ought to be able to remove this function and the code that calls it when bug 1034001 is fixed.

See also bugs 995540 and 1006200 and the private.broadcast.attention_screen_opening setting hack in attention_screen.js

Source:

Type Definitions

AppConfig

App Config

.

App Config

Type:
  • Object
Properties:
Name Type Attributes Default Description
manifestURL String <optional>

The manifestURL of the app

url String

The URL of the activity handling page

origin String

The origin of the app

stayBackground Boolean <optional>
false

This app is launched at background or not. Usually this means it's a request from system message.

changeURL Boolean <optional>
false

Need to change the URL of the running app or not. If it's true, we only change the URL when the app is not running at foreground.

Source: