[Nexus 5 Original Android Development] Jubakuba:
Send this to him if he wants his management to work alongside Quiet Hours:

// Method assumes Quiet Hours has been toggled at least once.
// If you don't care to check that the user HAS access to Quiet Hours to display/not display
// a preference...only use the value that saves the type of Rom being run (Non-aokp/AOKP)
// by trying to access the AOKP settings table in another manner.
private void hasQuietHours(Context context) {
boolean hasQuietHours = true;
boolean isAokp = false;
try {
Settings.System.getInt(
context.getContentResolver(),
"quiet_hours_enabled");
} catch (SettingNotFoundException e) {
hasQuietHours = false;
}

if (!hasQuietHours) {
// Check if exists in AOKP table since they've
// decided not to conform on KitKat =[
isAokp = getAokpValue(context, "quiet_hours_enabled") != null;
if (isAokp) {
hasQuietHours = true;
}
}

// I'd recommend saving this value to sharedPrefs to figure out which method should be used for checking...
// would speed up usage against which table to use...
final SharedPreferences shared = context.getSharedPreferences(
KEY_REMINDER_ACTION, Context.MODE_PRIVATE);
int quietHoursType = -1;

if (hasQuietHours) {
if (!isAOKP) {
quietHoursType = 2;
} else {
quietHoursType = 1;
}
}

shared.edit().putInt("quiethours", quietHoursType).commit();
}

// Method to check if you should fire sound/vibrations
// method: 0 == sound 1 == vibration 2 == LED
// if true = don't fire the sound/vibration/led
// if false = go ahead.
public boolean inQuietHours (Context context, int method) {
final SharedPreferences shared = this.getSharedPreferences(
KEY_REMINDER_ACTION, Context.MODE_PRIVATE);
int quietHoursType = shared.getInt("quiethours", -1);
if (quietHoursType == -1) {
return false;
}

boolean isAokp = false;

String quietHours = "quiet_hours_enabled";
String start = "quiet_hours_start";
String end = "quiet_hours_end";
String setting = null;

switch (method) {
case 0:
setting = "quiet_hours_mute";
break;
case 1:
setting = "quiet_hours_still";
break;
default:
setting = "quiet_hours_dim";
break;
}

if (quietHoursType == 2) {
isAokp = true;
}

boolean quietHoursEnabled = false;
boolean mode = false;
int quietHoursStart = 0;
int quietHoursEnd = 0;
if (isAokp) {
String aokpMode = getAokpValue(context, setting);
mode = aokpMode != null ? Integer.parseInt(aokpMode) != 0 : false;
if (mode) {
String aokpEnabled = getAokpValue(context, quietHours);
String aokpStart = getAokpValue(context, start);
String aokpEnd = getAokpValue(context, end);
quietHoursEnabled = aokpEnabled != null ? Integer.parseInt(aokpEnabled) != 0 : false;
quietHoursStart = aokpStart != null ? Integer.parseInt(aokpStart) : 0;
quietHoursEnd = aokpEnd != null ? Integer.parseInt(aokpEnd) : 0;
}
} else {
quietHoursEnabled = Settings.System.getInt(context.getContentResolver(),
quietHours, 0) != 0;
mode = Settings.System.getInt(context.getContentResolver(),
setting, 0) != 0;
quietHoursStart = Settings.System.getInt(context.getContentResolver(),
start, 0);
quietHoursEnd = Settings.System.getInt(context.getContentResolver(),
end, 0);
}

if (quietHoursEnabled && mode) {
// 24-hours toggleable
if (quietHoursStart == quietHoursEnd) {
return true;
}
// Get the date in "quiet hours" format.
Calendar calendar = Calendar.getInstance();
int minutes = calendar.get(Calendar.HOUR_OF_DAY) * 60 + calendar.get(Calendar.MINUTE);
if (quietHoursEnd < quietHoursStart) {
// Starts at night, ends in the morning.
return (minutes > quietHoursStart) || (minutes < quietHoursEnd);
} else {
return (minutes > quietHoursStart) && (minutes < quietHoursEnd);
}
}
return false;
}

public String getAokpValue(Context context, String key) {
// Damn you AOKP. Inflection ftw.
try {
String className = "android.provider.Settings$AOKP";

Class<?> clazz = Class.forName(className);
Class[] params = new Class[2];
params[0] = ContentResolver.class;
params[1] = String.class;

Object[] paramObjects = new Object[2];
paramObjects[0] = context.getContentResolver();
paramObjects[1] = key;

Method method = clazz.getDeclaredMethod("getString", params);
method.setAccessible(true);
Object result = method.invoke(null, paramObjects);

String value = (String) result;
if (value != null) {
try {
Integer.parseInt(value);
} catch (NumberFormatException ex) {
return null;
}
}
return value;
} catch (NoSuchMethodException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e1) {
e1.printStackTrace();
} catch (InvocationTargetException e1) {
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
return null;
}