Skip to content

Commit

Permalink
w2d: Arrange items and add more info about each
Browse files Browse the repository at this point in the history
  • Loading branch information
bmndc authored Aug 4, 2024
1 parent 1d9c950 commit 3f07f9f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 28 deletions.
44 changes: 38 additions & 6 deletions assets/js/w2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,60 @@
var id = e.target.id;
if (id) openMenu(id);
}, true); */
function openMenu(t) {

/** Invoke configure mozActivity/webActivity and redirect user to a Settings page
*
* @param p - section ID for the page in the Settings app
* @see https://gitlab.com/project-pris/system/-/blob/master/src/system/b2g/webapps/settings.gaiamobile.org/src/index.html?ref_type=heads
* @see https://gitlab.com/project-pris/system/-/tree/master/src/system/b2g/webapps/settings.gaiamobile.org/src/elements?ref_type=heads
*/
function openMenu(p) {
// KaiOS 2.5
if (window.MozActivity) {
var act = new MozActivity({ name: "configure", data: { target: "device", section: t, }, });
var act = new MozActivity({
name: "configure",
data: {
target: "device",
section: p,
},
});
act.onerror = function (e) {
console.error(act, e);
window.alert("Error:", JSON.stringify(act), e);
};
}
// KaiOS 3 and later
else if (window.WebActivity) {
var act = new WebActivity("configure", { target: "device", section: t, });
var act = new WebActivity("configure", {
target: "device",
section: p,
});
act.start().catch(function (e) {
console.error(e, act);
window.alert("Error: " + e);
});
}
else { window.alert('Please open the page from the device itself!') }
// Not a KaiOS device?
else {
window.alert('It appears your device does\'t support mozActivity or webActivity APIs. Please open the page on the phone itself.');
}
};

/** Configure adbd port to 5555 for wireless ADB connection
*
* @requires navigator.engmodeExtension
* @requires navigator.jrdExtension
* @requires navigator.kaiosExtension
*/
function wadb() {
var masterExt = navigator.engmodeExtension || navigator.jrdExtension || navigator.kaiosExtension;
var propSet = { 'service.adb.tcp.port': 5555, 'ctl.stop': 'adbd', 'ctl.start': 'adbd' };
var propSet = {
'service.adb.tcp.port': 5555,
'ctl.stop': 'adbd',
'ctl.start': 'adbd'
};
for (var key in propSet) {
masterExt.setPropertyValue(key, propSet[key])
};
window.alert('ADB port has been set to 5555.')
window.alert('ADB port has been set to 5555.');
}
54 changes: 32 additions & 22 deletions w2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,64 @@ custom_js: w2d
---
Please note that for the buttons on this page to function correctly, you need to open this page in the built-in Browser app on your KaiOS phone.

It's unclear how a page in the Settings app can be hidden on conditions. My theory is, when you pop a SIM card into the phone, B2G looks up some information of the carrier and matches a certain ID with one of the default configurations under `/system/b2g/defaults/customization/` (see [GerdaOS's main system](https://gitlab.com/project-pris/system/-/tree/master/src/system/b2g/defaults/customization) and [leo's system](https://github.com/bmndc/nokia-leo/tree/system/b2g/defaults/customization)). If it finds a match, B2G will toggle Device Settings flags based on the JSON values, and decide whether to enable certain features of the phone or not.
It's unclear how a page in the Settings app can be hidden on condition. My theory is, when you pop a SIM card into the phone, B2G looks up some information of the carrier and matches a certain ID with one of the default configurations under `/system/b2g/defaults/customization/` (see [GerdaOS's system](https://gitlab.com/project-pris/system/-/tree/master/src/system/b2g/defaults/customization) and [leo's system](https://github.com/bmndc/nokia-leo/tree/system/b2g/defaults/customization)). If it finds a match, B2G will toggle Device Settings flags based on the JSON values, and decide whether to enable certain features of the phone or not.

Now, what this does is merely hiding the menus from the Settings app so that normal users cannot access it. But they can still be opened with other means.

mozActivity on Firefox OS and KaiOS 2.5, and webActivity on KaiOS 3+, is a system-level function which allows applications to share data, view and perform actions across each other. An app can register to handle a mozActivity/webActivity in its `manifest.webapp` file, and other apps can reference to a registered mozActivity/webActivity to perform actions e.g. sharing photos and videos from Gallery to Messages, or opening a page in the Settings app if the phone isn't connected to the Internet.
mozActivity on Firefox OS and KaiOS 2.5, and webActivity on KaiOS 3+, is a system-level function which allows applications to share data, view and perform actions across each other. An app can register to handle a mozActivity/webActivity in its `manifest.webapp` file, and other apps can reference to a registered mozActivity/webActivity to perform actions e.g. sharing photos and videos from Gallery to Messages, or opening a page in the Settings app if the phone isn't connected to the Internet (see [Web Activities on KaiOS](https://kaios.dev/2023/02/web-activities-on-kaios/)).

On 22 September 2020, Tom Barrasso (tbrrss) and Luxferre made a striking discovery: not only installed apps can activate a mozActivity and webActivity, websites when browsed in the built-in Browser app can also trigger them. This page works by using mozActivity and webActivity to open hidden menus in the Settings app.

Source code of the JavaScript code used on this page can be found [here](https://github.com/bmndc/nokia-leo/blob/docs/assets/js/w2d.js).

## W2D KaiOS Jailbreak
Attempt to open the Developer menu in the Settings app, where you can enable ADB and DevTools access. Works on both KaiOS 2.5 and KaiOS 3. (W2D: web-to-dev)
Under Settings, Device, the Developer menu houses options to turn on ADB and DevTools, plus a number of GUI debugging tools. On production devices this menu is hidden by default. This button below will attempt to open the menu. Works on both KaiOS 2.5 and KaiOS 3. (W2D: web-to-dev)

Once you're connected to WebIDE, you can toggle the Device Settings flag `developer.menu.enabled` to have this menu shown permanently.
Once you connect to WebIDE, you can toggle the Device Settings flag `developer.menu.enabled` to have this menu shown permanently.

<button onclick="openMenu('developer')">Launch Developer menu</button>

## Hotspot for JioPhones
Attempt to open Internet sharing menu under Settings, Network & Connectivity, which is hidden on JioPhones and newer locked HMD/Nokia phones... although the hardware is perfectly capable of doing such thing. Works on both KaiOS 2.5 and KaiOS 3.

<button onclick="openMenu('hotspot')">Launch Hotspot menu</button>
Attempt to open Internet sharing menu under Settings, Network & Connectivity, which is hidden on JioPhones and newer, locked HMD/Nokia phones, although the hardware is perfectly capable of doing such thing. Works on both KaiOS 2.5 and KaiOS 3.

## Connect to ADB wirelessly (experimental)
If you don't have an USB cable nearby, this button below will attempt to open a 5555 port for `adbd` on your phone so that you can connect to ADB on your computer wirelessly by typing `adb connect [your.phone.ip.address]:5555`. For more details, see [Sideloading and debugging third-party applications](https://github.com/bmndc/nokia-leo/wiki/Sideloading-and-debugging-third%E2%80%90party-applications).

You can find your phone's local IP address (192.168.1.x) by going to Settings, Network & Connectivity, Wi-Fi, Available networks and click on the connected Wi-Fi access point; or download N4NO's [My IP Address](https://www.kaiostech.com/store/apps/?bundle_id=com.n4no.myipaddress) from KaiStore.
*Note: On the latest JioPhone Prima 4G, the phone will appear to open the menu, then redirect to a blank page.*

Note that both the phone and computer have to be on the same Wi-Fi network (you can tether to your computer), your phone has to allow at least one of these three permissions: `engmodeExtension`, `jrdExtension`, `kaiosExtension` and you have to turn on debugging mode on your phone prior to clicking this button.
<button onclick="openMenu('hotspot')">Launch Hotspot menu</button>

<button onclick="wadb()">Set ADB port to 5555</button>
## Turn on Greyscale Mode or change contrast level
Attempt to open the incomplete Color Filter menu, where you can set your screen to display black-and-white only or invert all colours. If you want to adjust the contrast level of the screen, click on the second button; Contrast option in the Color Filter menu does not do anything.

## Turn on Greyscale Mode
In this menu, you can set your screen to greyscale or invert all colours.
Use D-Pad Up and Down to increase or decrease the contrast level respectively.

<button onclick="openMenu('accessibility-colors')">Launch Color Filter menu</button>
<button onclick="openMenu('colorfilter-contrast')">Launch Contrast menu</button>

## Turn off Flip open to answer
On older KaiOS flip or sliding phones, such as the Nokia 8110 4G and Nokia 2720 Flip, opening the phone will automatically answer any incoming calls. This button below will attempt to open the Answer Mode menu where you can disable that behaviour. On KaiOS 3 flip phones, this menu is shown by default.

<button onclick="openMenu('answer-mode')">Launch Answer Mode menu</button>

## VoLTE/VoWiFi (not recommended)
Some carriers don't support VoLTE/VoWiFi on KaiOS phones. This attempts to open the VoLTE/VoWiFi menu. Note that this will open a blank page on most devices.
Alternatively, you can connect the phone to WebIDE and toggle the Device Settings flag `phone.answer.flipopen.enabled`.

<button onclick="openMenu('volte-vowifi')">Launch VoLTE/VoWiFi menu</button>
<button onclick="openMenu('answer-mode')">Launch Answer Mode menu</button>

## Readout (not recommended)
This button below will attempt to open the hidden Readout screen reader menu in Settings, which is hidden on many devices because it is unusable outside of KaiOS's built-in apps. Note that on most devices, the menu will be blank.
Attempt to open the Readout menu in Settings, where you can turn on KaiOS's built-in screen reader and change its speech rate. Only consider using this feature if you plan to *only* use built-in apps; most apps from KaiStore do not properly label their buttons, which makes this feature unusable.

On devices with dedicated volume buttons, you can quickly toggle on/off this feature by repeatedly pressing Volume up and Volume down. You can also toggle the feature under Device Settings in WebIDE.
On phones with dedicated volume buttons, you can toggle this feature by repeatedly pressing the side volume buttons Vol+ and Vol-. You can also toggle the Device Settings flag `accessibility.screenreader` in WebIDE.

<button onclick="openMenu('accessibility-readout-mode')">Launch Readout menu</button>

## Connect to ADB wirelessly (experimental)
If you don't have an USB cable nearby, this button below will attempt to open a 5555 port for `adbd` on your phone so that you can connect to ADB on your computer wirelessly by typing `adb connect [your.phone.ip.address]:5555`. For more details, see [Sideloading and debugging third-party applications](https://github.com/bmndc/nokia-leo/wiki/Sideloading-and-debugging-third%E2%80%90party-applications).

You can find your phone's local IP address (192.168.1.x) by going to Settings, Network & Connectivity, Wi-Fi, Available networks and click on the connected Wi-Fi access point; or download N4NO's [My IP Address](https://www.kaiostech.com/store/apps/?bundle_id=com.n4no.myipaddress) from KaiStore.

Note that both the phone and computer have to be on the same Wi-Fi network (you can tether to your computer), your phone has to allow at least one of these three permissions: `engmodeExtension`, `jrdExtension`, `kaiosExtension` and you have to turn on debugging mode on your phone prior to clicking this button.

<button onclick="wadb()">Set ADB port to 5555</button>

## VoLTE/VoWiFi (doesn't work)
Attempt to open the VoLTE/VoWiFi menu under Network &amp; Connectivity, as some carriers may not support VoLTE and/or VoWiFi for certain devices. mozActivity fails to highlight list items in this menu and you won't be able to select anything.

<button onclick="openMenu('volte-vowifi')">Launch VoLTE/VoWiFi menu</button>

*For list of all hidden settings accessible via mozActivity, check out [Cyan's dedicated website](https://cyan-2048.github.io/kaios_scripts).*

0 comments on commit 3f07f9f

Please sign in to comment.