See Demo Mode in action: The Demo Mode Settings app uses every available Demo Mode modifier.
Control Android’s Demo Mode from your app.
This library wraps Android’s Demo Mode controls in an understandable API for debugging or screenshots.
Sending Demo Mode broadcasts is as easy as
sendBroadcast(new NotificationsBuilder().visible(false).build())
Note that the system-signed DUMP permission is needed to send broadcasts to alter the Demo Mode state.
Also, Demo Mode must be enabled in the system settings. This can be done in the system settings app. This library can set this system setting with DemoModePermissions.setDemoModeAllowed(context, true)
but requires the system-signed WRITE_SECURE_SETTINGS permission to do so.
To grant these system-signed permissions to an app via adb, run the following commands. Do not forget to add the permissions to the app’s manifest, as well.
adb shell pm grant <com.example.app> android.permission.DUMP
adb shell pm grant <com.example.app> android.permission.WRITE_SECURE_SETTINGS
Android (Marshmallow and above) has a public SystemUI Tuner. Users can find the SystemUI Tuner in the device settings app. Developers can send the corresponding SystemUI Tuner broadcasts from the adb shell, but applications need the system-signed DUMP permission to send these broadcasts.
The documentation on Demo Mode is unclear about what extras should be sent with the broadcasts and is incorrect in some places. (For example, the "sync" and "eri" icons cannot currently be changed via broadcasts.)
This library makes Demo Mode easier to use in Android applications by handling permissions and wrapping the implementation of creating the broadcast Intents in an understandable and working API.
The current implementation of this library is based off AOSP commit 1291b83a2fb8ae8a095d50730f75013151f6ce3f.
The relevant implementation code that receives the broadcast is in DemoMode
, BatteryControllerImpl
, Clock
, DemoStatusIcons
, NetworkControllerImpl
, NotificationIconAreaController
, and OperatorNameViewController
.
Gradle:
implementation 'com.nightlynexus.demomode:demomode:0.6.0'
Copyright 2016 Eric Cochran
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.