1page.title=Implementing Emergency Affordance
2@jd:body
3
4<!--
5    Copyright 2016 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19
20<div id="qv-wrapper">
21  <div id="qv">
22    <h2>In this document</h2>
23    <ol id="auto-toc">
24    </ol>
25  </div>
26</div>
27
28<p>All mobile devices sold in India from the 1st January 2017 will need to
29provide a panic button to meet Indian Department of Telecommunications (DoT)
30requirements.</p>
31
32<p>An Emergency Affordance feature has been developed to provide a reference
33implementation of the panic button for Android devices to address these
34regulatory requirements. This will be enabled by default in future Android
35releases but must be patched into existing builds. Currently, this feature is
36exclusively targeted at devices that are sold in the Indian market but can be
37included on all devices sold throughout the world as the feature has no effect
38outside India.</p>
39
40<h2 id="examples-source">Examples and source</h2> <p>The Emergency Affordance
41feature is implemented in the Android Open Source Project (AOSP) <a
42href="https://android.googlesource.com/platform/frameworks/base/">frameworks/base</a>
43project. It is available in the master branch and will be enabled by default in
44future Android releases.</p>
45
46<p>This feature is currently available in the following branches and commits.
47This information is provided to enable device manufacturers to easily patch the
48necessary changes into their existing builds. Device manufacturers wanting to
49implement the AOSP reference emergency affordance feature can cherry-pick the
50commits from the applicable branches into their own builds.</p>
51
52<p class="table-caption" id="cherry-picks-reference-implementation">
53  <strong>Table 1.</strong> Cherry-picks for AOSP reference emergency affordance feature</p>
54<table>
55<tbody>
56<tr>
57<th scope="col">Branch</th>
58<th scope="col">Commits</th>
59</tr>
60<tr>
61<td>master</td>
62<td><a href="https://android-review.googlesource.com/#/c/284723/">e0c3c66</a>
63Added Emergency affordance feature<br>
64<a href="https://android-review.googlesource.com/#/c/287188/">42a4338</a>
65Added translations for emergency action string<br>
66<a href="https://android-review.googlesource.com/#/c/286858/">4df8d64</a>
67Fixed an issue where the emergency affordance would show on tablets
68</td>
69</tr>
70<tr>
71<td>nougat-dev</td>
72<td><a href="https://android-review.googlesource.com/#/c/284761/">e6680d9</a>
73Added Emergency affordance feature<br>
74<a href="https://android-review.googlesource.com/#/c/287293/">95e1865</a>
75Added translations for emergency action string<br>
76<a href="https://android-review.googlesource.com/#/c/286953/">a70bb89</a>
77Fixed an issue where the emergency affordance would show on tablets
78</td>
79</tr>
80<tr>
81<td>marshmallow-dev</td>
82<td><a href="https://android-review.googlesource.com/#/c/284624/">cd22634</a>
83Added Emergency affordance feature<br>
84<a href="https://android-review.googlesource.com/#/c/286937/">13f51c6</a>
85Added translations for emergency action string<br>
86<a href="https://android-review.googlesource.com/#/c/287241/">6531666</a>
87Fixed an issue where the emergency affordance would show on tablets
88</td>
89</tr>
90<tr>
91<td class="style1">lollipop-mr1-dev</td>
92<td><a href="https://android-review.googlesource.com/#/c/284743/">5fbc86b</a>
93Added Emergency affordance feature<br>
94<a href="https://android-review.googlesource.com/#/c/287382/">1b60879</a>
95Added translations for emergency action string<br>
96<a href="https://android-review.googlesource.com/#/c/286856/">d74366f</a>
97Fixed an issue where the emergency affordance would show on tablets
98</td>
99
100</tr>
101</tbody>
102</table>
103
104<h2 id="implementation">Implementation</h2> <p>The Emergency Affordance feature
105makes no changes to the APIs exposed through the Android SDK. When enabled and
106activated, it provides two triggers that can initiate an emergency call to
107112, which is the single emergency number to be used in India and mandated by
108the DoT regulations.<br> An emergency call is initiated by either:</p> <ul>
109<li>Long pressing the <strong>EMERGENCY</strong> button on the lockscreen
110(Figure 1)</li> <li>Tapping the <strong>Emergency</strong> option from the
111<em>Global Action Menu</em> (Figure 2), accessed by long pressing the power
112key.</li> </ul>
113
114<table>
115  <tr>
116    <td width="50%"><img src="images/emergency-button.png" alt="emergency
117button" width="246" id="emergency-button" />
118<p class="img-caption">
119  <strong>Figure 1.</strong> Long press the <strong>EMERGENCY</strong> button,
120highlighted with a red box, on the lock screen.</p></td>
121    <td width="50%"><img src="images/emergency-option.png" alt="emergency
122option" width="247" id="emergency-option" />
123<p class="img-caption">
124  <strong>Figure 2.</strong> Tap the <strong>Emergency</strong> action item on
125the <em>Global Action Menu</em>.</p></td>
126  </tr>
127</table>
128
129<p>This feature introduces the following internal components:</p> <ul>
130<li>EmergencyAffordanceManager<br>
131<code>frameworks/base/core/java/com/android/internal/policy/EmergencyAffordanceManager.java</code>
132</li> <li>EmergencyAffordanceService<br>
133<code>frameworks/base/services/core/java/com/android/server/emergency/EmergencyAffordanceService.java</code>
134</li> </ul>
135
136<h3 id="EmergencyAffordanceManager">EmergencyAffordanceManager</h3> <p>The
137EmergencyAffordanceManager provides an internal API to use the Emergency
138Affordance feature. It provides methods for initiating the emergency call and
139querying at runtime if the feature should be enabled.</p> <ul> <li><code>void
140performEmergencyCall()</code> - Initiates an emergency call</li>
141<li><code>boolean needsEmergencyAffordance()</code> - Determines if the feature
142should be active</li> </ul> <p>The feature may be permanently disabled at build
143time by changing the <code>EmergencyAffordanceManager.ENABLED</code> constant
144to <code>false</code>. This will cause <code>needsEmergencyAffordance()</code>
145to always return false and prevent the <code>EmergencyAffordanceService</code>
146from starting.</p>
147
148<h3 id="EmergencyAffordanceService">EmergencyAffordanceService</h3> <p>The
149<code>EmergencyAffordanceService</code> is a system service that monitors the
150Mobile Country Code (MCC) of all the detected cellular networks and the MCC of
151the installed SIM cards. If any of the installed SIM cards or detected cellular
152networks have a MCC matching one of India's MCCs (404,405) then the feature
153will be enabled. This means the feature can be enabled in India even if no SIM
154card is present. It is assumed the mobile network will permit registration for
155emergency calls even without a SIM card installed. The feature will remain
156enabled until a non-India SIM is installed and none of the detected networks
157have a matching MCC.</p>
158
159<p>The following resources and settings affect the behavior of the Emergency
160Affordance feature. If the config type is "Resource" it is an internal resource
161defined in <code>frameworks/base/core/res/res/values/config.xml</code>. If
162config type is "Setting" it is a setting stored in the systems settings
163provider.</p>
164
165<p class="table-caption" id="settings-affecting behavior">
166  <strong>Table 2.</strong> Settings affecting behavior of emergency affordance
167feature</p>
168<table>
169<tbody>
170<tr>
171<th scope="col">Config Type</th>
172<th scope="col">Name</th>
173<th scope="col">Description</th>
174</tr>
175<tr>
176<td>Resource</td>
177<td>config_emergency_call_number</td>
178<td>The phone number that is automatically dialed when the emergency call is
179initiated.<br>
180Type: String<br>
181Default: 112</td>
182</tr>
183<tr>
184<td>Resource</td>
185<td>config_emergency_mcc_codes</td>
186<td>An array of Integers listing the MCCs the feature should be active in.<br>
187Type: Array of Integers<br>
188Default: {404,405}</td>
189</tr>
190<tr>
191<td>Setting</td>
192<td>emergency_affordance_number</td>
193<td>Global setting override with the number to call with the emergency
194affordance. This will only have an effect on debuggable build images (ie. build
195type is userdebug or eng). This is intended only for testing.<br>
196Type: String<br>
197Default: unset</td>
198</tr>
199<tr>
200<td>Setting </td>
201<td>force_emergency_affordance</td>
202<td>Global setting, whether the emergency affordance should be shown regardless
203of device state. This is intended only for testing.<br>
204Type: Boolean (1 or 0)<br>
205Default: unset --&gt; 0</td>
206</tr>
207</tbody>
208</table>
209
210<h3 id="112">Enable emergency calls to '112'</h3> <p>The emergency affordance
211feature connects the call using the emergency dialer so that the call can be
212connected when the lock screen is active. The emergency dialer only connects
213calls to the list of numbers provided by the Radio Interface Layer (RIL),
214through the system property 'ril.ecclist', when no SIM is installed and
215'<code>ril.ecclist&lt;<i>SimSlotNumber</i>&gt;</code>' when a SIM is inserted
216and <code><i>&lt;SimSlotNumber&gt;</code></i> is the slot ID of the default
217subscriber.<br> Device manufacturers using the emergency affordance feature
218must ensure that devices in India always enable 112 as an emergency number in
219the RIL.</p>
220
221<h2 id="validation">Validation</h2> <p>While testing, on a debuggable build,
222the number that is called can be changed with the following command:</p>
223<pre>
224$ adb shell settings put global emergency_affordance_number <i>&lt;number_to_call&gt;</i>
225</pre>
226
227<p>Although this setting can be set on a normal user build, it will be ignored.
228To actually connect the call the number must be in the list of emergency
229numbers provided by the RIL. This can be temporarily set using the following
230command executed from a root shell on a userdebug device:</p>
231<pre>
232$ setprop ril.ecclist "$(getprop ril.ecclist),<i>&lt;number_to_call&gt;</i>"
233</pre>
234
235<p>The following command can also be used to force the Emergency Affordance
236feature to be enabled even in the absence of an Indian mobile network being
237detected or an Indian SIM card being inserted.</p>
238<pre>
239$ adb shell settings put global force_emergency_affordance 1
240</pre>
241
242<p>During testing it is recommend that at least the following cases are
243tested.</p>
244
245<ul> <li>Once activated, long pressing the <strong>EMERGENCY</strong> button on
246the lockscreen (Figure 1) initiates a call the specified emergency number.</li>
247<li>Once activated, the <strong>Emergency</strong> item on the Global Action
248Menu is present and that tapping it initiates a call to the specified emergency
249number.</li> <li>The feature <b>is not</b> <b>activated</b> in the absence of a
250detected Indian Mobile Network with a non-India SIM card installed.</li>
251<li>The feature <b>is activated</b> on the device whilst an Indian SIM card is
252installed, regardless of the detected mobile networks.</li> <li>The feature
253<b>is</b> <b>activated</b> on the device whilst an in the presence of a Indian
254Mobile Network regardless of the SIM cards installed.</li> </ul>
255
256<p>If a device includes supports multiple SIM cards then testing should ensure
257that the SIM MCC detection works correctly in each SIM slot. The feature is not
258governed by Android compatibility, so there are no CTS tests for it.</p>
259
260<h2 id="faq">Frequently Asked Questions</h2>
261
262<h5 id="q-112">Q. The emergency number '112' has not been commissioned yet in
263India, should it still be used?</h5>
264
265<p>'112' is the number that will be used in India as the Public Safety
266Answering Point (PSAP) as defined by the Integrated Emergency Communications
267and Response Systems (IECRS). Until the PSAP is commissioned all calls to '112'
268will be routed to the existing '100' emergency number.</p>
269
270<h5 id="q-other-triggers">Q. What about other triggers like "triple" pressing
271the power button?</h5> <p>Device manufacturer may choose to implement
272additional triggers. Triple tapping the hardware power button is also an
273approved trigger action by the India DoT. However, this trigger is not
274supported in the AOSP reference implementation as a number of other widely used
275applications use the power button gestures, including repeated tapping of the
276power button. These applications might interfere with the emergency dialer, or
277the user may accidentally trigger the panic button while trying to trigger
278actions in these applications.</p>
279