use of android.service.notification.Condition in project android_frameworks_base by ResurrectionRemix.
the class ZenModePanel method handleUpdateConditions.
private void handleUpdateConditions() {
if (mTransitionHelper.isTransitioning()) {
return;
}
final int conditionCount = mConditions == null ? 0 : mConditions.length;
if (DEBUG)
Log.d(mTag, "handleUpdateConditions conditionCount=" + conditionCount);
// forever
bind(forever(), mZenRadioGroupContent.getChildAt(FOREVER_CONDITION_INDEX), FOREVER_CONDITION_INDEX);
// countdown
if (mCountdownConditionSupported && mTimeCondition != null) {
bind(mTimeCondition, mZenRadioGroupContent.getChildAt(COUNTDOWN_CONDITION_INDEX), COUNTDOWN_CONDITION_INDEX);
}
// countdown until alarm
if (mCountdownConditionSupported) {
Condition nextAlarmCondition = getTimeUntilNextAlarmCondition();
if (nextAlarmCondition != null) {
mZenRadioGroup.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.VISIBLE);
mZenRadioGroupContent.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.VISIBLE);
bind(nextAlarmCondition, mZenRadioGroupContent.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX), COUNTDOWN_ALARM_CONDITION_INDEX);
} else {
mZenRadioGroup.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.GONE);
mZenRadioGroupContent.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX).setVisibility(View.GONE);
}
}
// ensure something is selected
if (mExpanded && isShown()) {
ensureSelection();
}
mZenConditions.setVisibility(mSessionZen != Global.ZEN_MODE_OFF ? View.VISIBLE : View.GONE);
}
use of android.service.notification.Condition in project android_frameworks_base by ResurrectionRemix.
the class EventConditionProvider method evaluateSubscriptionsW.
private void evaluateSubscriptionsW() {
if (DEBUG)
Slog.d(TAG, "evaluateSubscriptions");
if (!mBootComplete) {
if (DEBUG)
Slog.d(TAG, "Skipping evaluate before boot complete");
return;
}
final long now = System.currentTimeMillis();
List<Condition> conditionsToNotify = new ArrayList<>();
synchronized (mSubscriptions) {
for (int i = 0; i < mTrackers.size(); i++) {
mTrackers.valueAt(i).setCallback(mSubscriptions.isEmpty() ? null : mTrackerCallback);
}
setRegistered(!mSubscriptions.isEmpty());
long reevaluateAt = 0;
for (Uri conditionId : mSubscriptions) {
final EventInfo event = ZenModeConfig.tryParseEventConditionId(conditionId);
if (event == null) {
conditionsToNotify.add(createCondition(conditionId, Condition.STATE_FALSE));
continue;
}
CheckEventResult result = null;
if (event.calendar == null) {
// event could exist on any tracker
for (int i = 0; i < mTrackers.size(); i++) {
final CalendarTracker tracker = mTrackers.valueAt(i);
final CheckEventResult r = tracker.checkEvent(event, now);
if (result == null) {
result = r;
} else {
result.inEvent |= r.inEvent;
result.recheckAt = Math.min(result.recheckAt, r.recheckAt);
}
}
} else {
// event should exist on one tracker
final int userId = EventInfo.resolveUserId(event.userId);
final CalendarTracker tracker = mTrackers.get(userId);
if (tracker == null) {
Slog.w(TAG, "No calendar tracker found for user " + userId);
conditionsToNotify.add(createCondition(conditionId, Condition.STATE_FALSE));
continue;
}
result = tracker.checkEvent(event, now);
}
if (result.recheckAt != 0 && (reevaluateAt == 0 || result.recheckAt < reevaluateAt)) {
reevaluateAt = result.recheckAt;
}
if (!result.inEvent) {
conditionsToNotify.add(createCondition(conditionId, Condition.STATE_FALSE));
continue;
}
conditionsToNotify.add(createCondition(conditionId, Condition.STATE_TRUE));
}
rescheduleAlarm(now, reevaluateAt);
}
for (Condition condition : conditionsToNotify) {
if (condition != null) {
notifyCondition(condition);
}
}
if (DEBUG)
Slog.d(TAG, "evaluateSubscriptions took " + (System.currentTimeMillis() - now));
}
use of android.service.notification.Condition in project android_frameworks_base by ResurrectionRemix.
the class ConditionProviders method notifyConditions.
public void notifyConditions(String pkg, ManagedServiceInfo info, Condition[] conditions) {
synchronized (mMutex) {
if (DEBUG)
Slog.d(TAG, "notifyConditions pkg=" + pkg + " info=" + info + " conditions=" + (conditions == null ? null : Arrays.asList(conditions)));
conditions = removeDuplicateConditions(pkg, conditions);
if (conditions == null || conditions.length == 0)
return;
final int N = conditions.length;
for (int i = 0; i < N; i++) {
final Condition c = conditions[i];
final ConditionRecord r = getRecordLocked(c.id, info.component, true);
r.info = info;
r.condition = c;
}
}
final int N = conditions.length;
for (int i = 0; i < N; i++) {
final Condition c = conditions[i];
if (mCallback != null) {
mCallback.onConditionChanged(c.id, c);
}
}
}
use of android.service.notification.Condition in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeVoiceActivity method onVoiceSettingInteraction.
@Override
protected boolean onVoiceSettingInteraction(Intent intent) {
if (intent.hasExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED)) {
int minutes = intent.getIntExtra(EXTRA_DO_NOT_DISTURB_MODE_MINUTES, -1);
Condition condition = null;
int mode = Global.ZEN_MODE_OFF;
if (intent.getBooleanExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED, false)) {
if (minutes > 0) {
condition = ZenModeConfig.toTimeCondition(this, minutes, UserHandle.myUserId());
}
mode = Global.ZEN_MODE_ALARMS;
}
setZenModeConfig(mode, condition);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (audioManager != null) {
// Show the current Zen Mode setting.
audioManager.adjustStreamVolume(AudioManager.STREAM_NOTIFICATION, AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
}
notifySuccess(getChangeSummary(mode, minutes));
} else {
Log.v(TAG, "Missing extra android.provider.Settings.EXTRA_DO_NOT_DISTURB_MODE_ENABLED");
finish();
}
return false;
}
use of android.service.notification.Condition in project android_frameworks_base by crdroidandroid.
the class ZenModePanel method handleUpdateManualRule.
private void handleUpdateManualRule(ZenRule rule) {
final int zen = rule != null ? rule.zenMode : Global.ZEN_MODE_OFF;
handleUpdateZen(zen);
final Condition c = rule != null ? rule.condition : null;
handleExitConditionChanged(c);
}
Aggregations