Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c27950df authored by Nextbit's avatar Nextbit Committed by Adnan Begovic
Browse files

Keyguard: Allow applications to customize left-corner widget

Adds ability for trusted applications to set the application widget and
action in the lower left corner of the Keyguard.  Its behavior is
modeled against the on-screen camera widget most commonly found on the
lower right corner of the Keyguard.

Three intents are defined: one to set the widget, one to clear the
widget, and one to notify when the widget is activated.

Applications calling this intent must have this permission:
android.permission.SET_KEYGUARD_APPLICATION_WIDGET.

Change-Id: I8c5b11fd1cc1888c710bf3736e3c28d77fc57e37
parent 14d26c51
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1234,6 +1234,12 @@ public class DevicePolicyManager {
     */
    public static final int KEYGUARD_DISABLE_SECURE_CAMERA = 1 << 1;

    /**
     * Disable the application widget on keyguard screens (e.g. PIN/Pattern/Password)
     * @hide
     */
    public static final int KEYGUARD_DISABLE_APPLICATION_WIDGET = 1 << 2;

    /**
     * Disable all current and future keyguard customizations.
     */
+56 −0
Original line number Diff line number Diff line
@@ -2770,6 +2770,43 @@ public class Intent implements Parcelable, Cloneable {
    public static final String ACTION_THEME_RESOURCES_CACHED =
            "android.intent.action.THEME_RESOURCES_CACHED";

   /**
    * Allows an application to add a widget to the keyguard which will launch the application
    * associated with the widget. It has 2 extras - one for the icon to use
    * {@link #EXTRA_KEYGUARD_APPLICATION_WIDGET_ICON} and the other for the package name
    * {@link #EXTRA_KEYGUARD_APPLICATION_WIDGET_PACKAGE_NAME} of the application associated with
    * the widget. You must hold "android.permission.SET_KEYGUARD_APPLICATION_WIDGET" to receive
    * this broadcast.
    *
    * @hide
    */
    public static final String ACTION_SET_KEYGUARD_APPLICATION_WIDGET =
            "android.intent.action.SET_KEYGUARD_APPLICATION_WIDGET_ACTION";

    /**
     * Allows an application to remove the widget on the keyguard which was added using the
     * {@link #ACTION_SET_KEYGUARD_APPLICATION_WIDGET} intent. You must hold
     * "android.permission.SET_KEYGUARD_APPLICATION_WIDGET" to receive this
     * broadcast.
     *
     * @hide
     */
    public static final String ACTION_UNSET_KEYGUARD_APPLICATION_WIDGET =
            "android.intent.action.UNSET_KEYGUARD_APPLICATION_WIDGET_ACTION";

    /**
     * Allows an application to know when the application associated with the keyguard application
     * widget has been launched. It has 1 extra -
     * {@link #EXTRA_KEYGUARD_APPLICATION_WIDGET_PACKAGE_NAME} which has the package name
     * associated with the widget. You must hold
     * "android.permission.SET_KEYGUARD_APPLICATION_WIDGET" to receive this broadcast.
     *
     * @see #ACTION_SET_KEYGUARD_APPLICATION_WIDGET
     * @hide
     */
    public static final String ACTION_KEYGUARD_APPLICATION_WIDGET_LAUNCH_ACTION =
            "android.intent.action.KEYGUARD_APPLICATION_WIDGET_LAUNCH_ACTION";

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // Standard intent categories (see addCategory()).
@@ -3434,6 +3471,25 @@ public class Intent implements Parcelable, Cloneable {
     */
    public static final String EXTRA_THEME_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";

    /**
     * Extra for {@link #ACTION_SET_KEYGUARD_APPLICATION_WIDGET} which tells the keyguard
     * the icon to use for the widget.
     *
     * @hide
     */
    public static final String EXTRA_KEYGUARD_APPLICATION_WIDGET_ICON =
            "android.intent.extra.EXTRA_KEYGUARD_APPLICATION_WIDGET_ICON";

    /**
     * Extra for {@link #ACTION_SET_KEYGUARD_APPLICATION_WIDGET} and
     * {@link #ACTION_KEYGUARD_APPLICATION_WIDGET_LAUNCH_ACTION}. It contains the package name
     * of the application widget.
     *
     * @hide
     */
    public static final String EXTRA_KEYGUARD_APPLICATION_WIDGET_PACKAGE_NAME =
            "android.intent.extra.EXTRA_KEYGUARD_APPLICATION_WIDGET_PACKAGE_NAME";

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // Intent flags (see mFlags variable).
+3 −1
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ interface IKeyguardService {
    oneway void doKeyguardTimeout(in Bundle options);
    oneway void setCurrentUser(int userId);
    oneway void showAssistant();
    oneway void dispatch(in MotionEvent event);
    oneway void dispatchCameraEvent(in MotionEvent event);
    oneway void dispatchApplicationWidgetEvent(in MotionEvent event);
    oneway void launchCamera();
    oneway void launchApplicationWidget();
    oneway void onBootCompleted();
}
+18 −0
Original line number Diff line number Diff line
@@ -155,6 +155,8 @@ public class LockPatternUtils {
    public final static String LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS
            = "lockscreen.power_button_instantly_locks";
    public final static String LOCKSCREEN_WIDGETS_ENABLED = "lockscreen.widgets_enabled";
    public final static String LOCKSCREEN_APPLICATION_WIDGET_ENABLED =
            "lockscreen.application_widget_enabled";
    public final static String LOCKSCREEN_CAMERA_ENABLED = "lockscreen.camera_enabled";

    public final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory";
@@ -1457,6 +1459,22 @@ public class LockPatternUtils {
        setBoolean(LOCKSCREEN_WIDGETS_ENABLED, enabled, userId);
    }

    public boolean getApplicationWidgetEnabled() {
        return getApplicationWidgetEnabled(getCurrentOrCallingUserId());
    }

    public boolean getApplicationWidgetEnabled(int userId) {
        return getBoolean(LOCKSCREEN_APPLICATION_WIDGET_ENABLED, true, userId);
    }

    public void setApplicationWidgetEnabled(boolean enabled) {
        setApplicationWidgetEnabled(enabled, getCurrentOrCallingUserId());
    }

    public void setApplicationWidgetEnabled(boolean enabled, int userId) {
        setBoolean(LOCKSCREEN_APPLICATION_WIDGET_ENABLED, enabled, userId);
    }

    public boolean getCameraEnabled() {
        return getCameraEnabled(getCurrentOrCallingUserId());
    }
+8 −0
Original line number Diff line number Diff line
@@ -2619,6 +2619,14 @@
        android:protectionLevel="signature" />


    <!-- Allows an application to set the application widget on the keyguard.
         <p> Not for use by third-party applications.
         @hide -->
    <permission android:name="android.permission.SET_KEYGUARD_APPLICATION_WIDGET"
        android:label="@string/permlab_keyguardApplicationWidget"
        android:description="@string/permdesc_keyguardApplicationWidget"
        android:protectionLevel="system|signature" />

    <!-- The system process is explicitly the only one allowed to launch the
         confirmation UI for full backup/restore -->
    <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP"/>
Loading