cmsdk: Add notification light setting to system profiles (1/2)
Change-Id: Ic6705792948c5393fc5ca9b207bc250b252e66da
This commit is contained in:
parent
1d2351e0fc
commit
14683b949d
@ -94,6 +94,8 @@ public final class Profile implements Parcelable, Comparable {
|
||||
|
||||
private int mDozeMode = DozeMode.DEFAULT;
|
||||
|
||||
private int mNotificationLightMode = NotificationLightMode.DEFAULT;
|
||||
|
||||
/**
|
||||
* Lock modes of a device
|
||||
*/
|
||||
@ -130,6 +132,18 @@ public final class Profile implements Parcelable, Comparable {
|
||||
public static final int DISABLE = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification light modes available on a device
|
||||
*/
|
||||
public static class NotificationLightMode {
|
||||
/** Represents a default Notification light mode (user choice) */
|
||||
public static final int DEFAULT = 0;
|
||||
/** Represents an enabled Notification light mode */
|
||||
public static final int ENABLE = 1;
|
||||
/** Represents a disabled Notification light mode */
|
||||
public static final int DISABLE = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available trigger types on the device, usually hardware
|
||||
*/
|
||||
@ -621,6 +635,9 @@ public final class Profile implements Parcelable, Comparable {
|
||||
dest.writeInt(mExpandedDesktopMode);
|
||||
dest.writeInt(mDozeMode);
|
||||
|
||||
// === ELDERBERRY ===
|
||||
dest.writeInt(mNotificationLightMode);
|
||||
|
||||
// Go back and write size
|
||||
int parcelableSize = dest.dataPosition() - startPosition;
|
||||
dest.setDataPosition(sizePosition);
|
||||
@ -695,6 +712,9 @@ public final class Profile implements Parcelable, Comparable {
|
||||
mExpandedDesktopMode = in.readInt();
|
||||
mDozeMode = in.readInt();
|
||||
}
|
||||
if (parcelableVersion >= Build.CM_VERSION_CODES.ELDERBERRY) {
|
||||
mNotificationLightMode = in.readInt();
|
||||
}
|
||||
|
||||
in.setDataPosition(startPosition + parcelableSize);
|
||||
}
|
||||
@ -883,6 +903,28 @@ public final class Profile implements Parcelable, Comparable {
|
||||
mDirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link NotificationLightMode} associated with the {@link Profile}
|
||||
* @return
|
||||
*/
|
||||
public int getNotificationLightMode() {
|
||||
return mNotificationLightMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link NotificationLightMode} associated with the {@link Profile}
|
||||
* @return
|
||||
*/
|
||||
public void setNotificationLightMode(int notificationLightMode) {
|
||||
if (notificationLightMode < NotificationLightMode.DEFAULT
|
||||
|| notificationLightMode > NotificationLightMode.DISABLE) {
|
||||
mNotificationLightMode = NotificationLightMode.DEFAULT;
|
||||
} else {
|
||||
mNotificationLightMode = notificationLightMode;
|
||||
}
|
||||
mDirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link AirplaneModeSettings} associated with the {@link Profile}
|
||||
* @return
|
||||
@ -993,6 +1035,10 @@ public final class Profile implements Parcelable, Comparable {
|
||||
builder.append(mDozeMode);
|
||||
builder.append("</doze-mode>\n");
|
||||
|
||||
builder.append("<notification-light-mode>");
|
||||
builder.append(mNotificationLightMode);
|
||||
builder.append("</notification-light-mode>\n");
|
||||
|
||||
mAirplaneMode.getXmlString(builder, context);
|
||||
|
||||
mBrightness.getXmlString(builder, context);
|
||||
@ -1141,6 +1187,9 @@ public final class Profile implements Parcelable, Comparable {
|
||||
if (name.equals("doze-mode")) {
|
||||
profile.setDozeMode(Integer.valueOf(xpp.nextText()));
|
||||
}
|
||||
if (name.equals("notification-light-mode")) {
|
||||
profile.setNotificationLightMode(Integer.valueOf(xpp.nextText()));
|
||||
}
|
||||
if (name.equals("profileGroup")) {
|
||||
ProfileGroup pg = ProfileGroup.fromXml(xpp, context);
|
||||
profile.addProfileGroup(pg);
|
||||
@ -1213,6 +1262,14 @@ public final class Profile implements Parcelable, Comparable {
|
||||
mDozeMode == DozeMode.ENABLE ? 1 : 0,
|
||||
UserHandle.USER_CURRENT);
|
||||
}
|
||||
|
||||
// Set notification light mode
|
||||
if (mNotificationLightMode != NotificationLightMode.DEFAULT) {
|
||||
Settings.System.putIntForUser(context.getContentResolver(),
|
||||
Settings.System.NOTIFICATION_LIGHT_PULSE,
|
||||
mNotificationLightMode == NotificationLightMode.ENABLE ? 1 : 0,
|
||||
UserHandle.USER_CURRENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user