类android.provider.Settings.Global源码实例Demo

下面列出了怎么用android.provider.Settings.Global的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: ZenModeFiltering.java
/**
 * @param extras extras of the notification with EXTRA_PEOPLE populated
 * @param contactsTimeoutMs timeout in milliseconds to wait for contacts response
 * @param timeoutAffinity affinity to return when the timeout specified via
 *                        <code>contactsTimeoutMs</code> is hit
 */
public static boolean matchesCallFilter(Context context, int zen, ZenModeConfig config,
        UserHandle userHandle, Bundle extras, ValidateNotificationPeople validator,
        int contactsTimeoutMs, float timeoutAffinity) {
    if (zen == Global.ZEN_MODE_NO_INTERRUPTIONS) return false; // nothing gets through
    if (zen == Global.ZEN_MODE_ALARMS) return false; // not an alarm
    if (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
        if (config.allowRepeatCallers && REPEAT_CALLERS.isRepeat(context, extras)) {
            return true;
        }
        if (!config.allowCalls) return false; // no other calls get through
        if (validator != null) {
            final float contactAffinity = validator.getContactAffinity(userHandle, extras,
                    contactsTimeoutMs, timeoutAffinity);
            return audienceMatches(config.allowCallsFrom, contactAffinity);
        }
    }
    return true;
}
 
源代码2 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private void populateZenRule(AutomaticZenRule automaticZenRule, ZenRule rule, boolean isNew) {
    if (isNew) {
        rule.id = ZenModeConfig.newRuleId();
        rule.creationTime = System.currentTimeMillis();
        rule.component = automaticZenRule.getOwner();
    }

    if (rule.enabled != automaticZenRule.isEnabled()) {
        rule.snoozing = false;
    }
    rule.name = automaticZenRule.getName();
    rule.condition = null;
    rule.conditionId = automaticZenRule.getConditionId();
    rule.enabled = automaticZenRule.isEnabled();
    rule.zenMode = NotificationManager.zenModeFromInterruptionFilter(
            automaticZenRule.getInterruptionFilter(), Global.ZEN_MODE_OFF);
}
 
源代码3 项目: android_9.0.0_r45   文件: ZenModeHelper.java
public void dump(PrintWriter pw, String prefix) {
    pw.print(prefix); pw.print("mZenMode=");
    pw.println(Global.zenModeToString(mZenMode));
    final int N = mConfigs.size();
    for (int i = 0; i < N; i++) {
        dump(pw, prefix, "mConfigs[u=" + mConfigs.keyAt(i) + "]", mConfigs.valueAt(i));
    }
    pw.print(prefix); pw.print("mUser="); pw.println(mUser);
    synchronized (mConfig) {
        dump(pw, prefix, "mConfig", mConfig);
    }

    pw.print(prefix); pw.print("mSuppressedEffects="); pw.println(mSuppressedEffects);
    mFiltering.dump(pw, prefix);
    mConditions.dump(pw, prefix);
}
 
源代码4 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private int computeZenMode() {
    if (mConfig == null) return Global.ZEN_MODE_OFF;
    synchronized (mConfig) {
        if (mConfig.manualRule != null) return mConfig.manualRule.zenMode;
        int zen = Global.ZEN_MODE_OFF;
        for (ZenRule automaticRule : mConfig.automaticRules.values()) {
            if (automaticRule.isAutomaticActive()) {
                if (zenSeverity(automaticRule.zenMode) > zenSeverity(zen)) {
                    // automatic rule triggered dnd and user hasn't seen update dnd dialog
                    if (Settings.Global.getInt(mContext.getContentResolver(),
                            Global.ZEN_SETTINGS_SUGGESTION_VIEWED, 1) == 0) {
                        Settings.Global.putInt(mContext.getContentResolver(),
                                Global.SHOW_ZEN_SETTINGS_SUGGESTION, 1);
                    }
                    zen = automaticRule.zenMode;
                }
            }
        }
        return zen;
    }
}
 
源代码5 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private void appendDefaultEveryNightRule(ZenModeConfig config) {
    if (config == null) return;

    final ScheduleInfo weeknights = new ScheduleInfo();
    weeknights.days = ZenModeConfig.ALL_DAYS;
    weeknights.startHour = 22;
    weeknights.endHour = 7;
    weeknights.exitAtAlarm = true;
    final ZenRule rule = new ZenRule();
    rule.enabled = false;
    rule.name = mDefaultRuleEveryNightName;
    rule.conditionId = ZenModeConfig.toScheduleConditionId(weeknights);
    rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
    rule.component = ScheduleConditionProvider.COMPONENT;
    rule.id = ZenModeConfig.EVERY_NIGHT_DEFAULT_RULE_ID;
    rule.creationTime = System.currentTimeMillis();
    config.automaticRules.put(rule.id, rule);
}
 
源代码6 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private void appendDefaultEventRules(ZenModeConfig config) {
    if (config == null) return;

    final EventInfo events = new EventInfo();
    events.calendar = null; // any calendar
    events.reply = EventInfo.REPLY_YES_OR_MAYBE;
    final ZenRule rule = new ZenRule();
    rule.enabled = false;
    rule.name = mDefaultRuleEventsName;
    rule.conditionId = ZenModeConfig.toEventConditionId(events);
    rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
    rule.component = EventConditionProvider.COMPONENT;
    rule.id = ZenModeConfig.EVENTS_DEFAULT_RULE_ID;
    rule.creationTime = System.currentTimeMillis();
    config.automaticRules.put(rule.id, rule);
}
 
源代码7 项目: android_9.0.0_r45   文件: ZenModeConfig.java
public static ZenRule readRuleXml(XmlPullParser parser) {
    final ZenRule rt = new ZenRule();
    rt.enabled = safeBoolean(parser, RULE_ATT_ENABLED, true);
    rt.snoozing = safeBoolean(parser, RULE_ATT_SNOOZING, false);
    rt.name = parser.getAttributeValue(null, RULE_ATT_NAME);
    final String zen = parser.getAttributeValue(null, RULE_ATT_ZEN);
    rt.zenMode = tryParseZenMode(zen, -1);
    if (rt.zenMode == -1) {
        Slog.w(TAG, "Bad zen mode in rule xml:" + zen);
        return null;
    }
    rt.conditionId = safeUri(parser, RULE_ATT_CONDITION_ID);
    rt.component = safeComponentName(parser, RULE_ATT_COMPONENT);
    rt.creationTime = safeLong(parser, RULE_ATT_CREATION_TIME, 0);
    rt.enabler = parser.getAttributeValue(null, RULE_ATT_ENABLER);
    rt.condition = readConditionXml(parser);

    // all default rules and user created rules updated to zenMode important interruptions
    if (rt.zenMode != Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
            && Condition.isValidId(rt.conditionId, SYSTEM_AUTHORITY)) {
        Slog.i(TAG, "Updating zenMode of automatic rule " + rt.name);
        rt.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
    }
    return rt;
}
 
源代码8 项目: MediaSDK   文件: AudioCapabilities.java
@SuppressLint("InlinedApi")
/* package */ static AudioCapabilities getCapabilities(Context context, @Nullable Intent intent) {
  if (deviceMaySetExternalSurroundSoundGlobalSetting()
      && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
    return EXTERNAL_SURROUND_SOUND_CAPABILITIES;
  }
  if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) {
    return DEFAULT_AUDIO_CAPABILITIES;
  }
  return new AudioCapabilities(
      intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS),
      intent.getIntExtra(
          AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT));
}
 
源代码9 项目: MediaSDK   文件: AudioCapabilities.java
/**
 * Returns the global settings {@link Uri} used by the device to specify external surround sound,
 * or null if the device does not support this functionality.
 */
@Nullable
/* package */ static Uri getExternalSurroundSoundGlobalSettingUri() {
  return deviceMaySetExternalSurroundSoundGlobalSetting()
      ? Global.getUriFor(EXTERNAL_SURROUND_SOUND_KEY)
      : null;
}
 
源代码10 项目: android_9.0.0_r45   文件: PowerManagerService.java
private void updateConstants() {
    synchronized (mLock) {
        try {
            mParser.setString(Settings.Global.getString(mResolver,
                    Settings.Global.POWER_MANAGER_CONSTANTS));
        } catch (IllegalArgumentException e) {
            // Failed to parse the settings string, log this and move on
            // with defaults.
            Slog.e(TAG, "Bad alarm manager settings", e);
        }

        NO_CACHED_WAKE_LOCKS = mParser.getBoolean(KEY_NO_CACHED_WAKE_LOCKS,
                DEFAULT_NO_CACHED_WAKE_LOCKS);
    }
}
 
源代码11 项目: android_9.0.0_r45   文件: PowerManagerService.java
private void incrementBootCount() {
    synchronized (mLock) {
        int count;
        try {
            count = Settings.Global.getInt(
                    getContext().getContentResolver(), Settings.Global.BOOT_COUNT);
        } catch (SettingNotFoundException e) {
            count = 0;
        }
        Settings.Global.putInt(
                getContext().getContentResolver(), Settings.Global.BOOT_COUNT, count + 1);
    }
}
 
private void updateLocationState(BatterySaverController caller) {
    final boolean kill =
            (caller.getBatterySaverPolicy().getGpsMode()
                    == PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF) &&
            caller.isEnabled() && !caller.isInteractive();

    if (DEBUG) {
        Slog.d(TAG, "Battery saver " + (kill ? "stopping" : "restoring") + " location.");
    }
    Settings.Global.putInt(mContext.getContentResolver(),
            Global.LOCATION_GLOBAL_KILL_SWITCH, kill ? 1 : 0);
}
 
/**
 * {@link com.android.server.power.PowerManagerService} calls it when the system is booted.
 */
public void onBootCompleted() {
    if (DEBUG) {
        Slog.d(TAG, "onBootCompleted");
    }
    // Just booted. We don't want LOW_POWER_MODE to be persisted, so just always clear it.
    putGlobalSetting(Global.LOW_POWER_MODE, 0);

    // This is called with the power manager lock held. Don't do anything that may call to
    // upper services. (e.g. don't call into AM directly)
    // So use a BG thread.
    runOnBgThread(() -> {

        final ContentResolver cr = mContext.getContentResolver();
        cr.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.LOW_POWER_MODE),
                false, mSettingsObserver, UserHandle.USER_SYSTEM);
        cr.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.LOW_POWER_MODE_STICKY),
                false, mSettingsObserver, UserHandle.USER_SYSTEM);
        cr.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL),
                false, mSettingsObserver, UserHandle.USER_SYSTEM);

        synchronized (mLock) {

            mBootCompleted = true;

            refreshSettingsLocked();

            doAutoBatterySaverLocked();
        }
    });
}
 
void refreshSettingsLocked() {
    final boolean lowPowerModeEnabled = getGlobalSetting(
            Settings.Global.LOW_POWER_MODE, 0) != 0;
    final boolean lowPowerModeEnabledSticky = getGlobalSetting(
            Settings.Global.LOW_POWER_MODE_STICKY, 0) != 0;
    final int lowPowerModeTriggerLevel = getGlobalSetting(
            Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);

    setSettingsLocked(lowPowerModeEnabled, lowPowerModeEnabledSticky,
            lowPowerModeTriggerLevel);
}
 
源代码15 项目: android_9.0.0_r45   文件: BatterySaverPolicy.java
private void refreshSettings() {
    final BatterySaverPolicyListener[] listeners;
    synchronized (mLock) {
        // Load the non-device-specific setting.
        final String setting = getGlobalSetting(Settings.Global.BATTERY_SAVER_CONSTANTS);

        // Load the device specific setting.
        // We first check the global setting, and if it's empty or the string "null" is set,
        // use the default value from config.xml.
        String deviceSpecificSetting = getGlobalSetting(
                Settings.Global.BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS);
        mDeviceSpecificSettingsSource =
                Settings.Global.BATTERY_SAVER_DEVICE_SPECIFIC_CONSTANTS;

        if (TextUtils.isEmpty(deviceSpecificSetting) || "null".equals(deviceSpecificSetting)) {
            deviceSpecificSetting =
                    mContext.getString(getDeviceSpecificConfigResId());
            mDeviceSpecificSettingsSource = "(overlay)";
        }

        // Update.
        updateConstantsLocked(setting, deviceSpecificSetting);

        listeners = mListeners.toArray(new BatterySaverPolicyListener[mListeners.size()]);
    }

    // Notify the listeners.
    mHandler.post(() -> {
        for (BatterySaverPolicyListener listener : listeners) {
            listener.onBatterySaverPolicyChanged(this);
        }
    });
}
 
源代码16 项目: android_9.0.0_r45   文件: BatterySaverPolicy.java
public void dump(PrintWriter pw) {
    synchronized (mLock) {
        pw.println();
        mBatterySavingStats.dump(pw, "");

        pw.println();
        pw.println("Battery saver policy (*NOTE* they only apply when battery saver is ON):");
        pw.println("  Settings: " + Settings.Global.BATTERY_SAVER_CONSTANTS);
        pw.println("    value: " + mSettings);
        pw.println("  Settings: " + mDeviceSpecificSettingsSource);
        pw.println("    value: " + mDeviceSpecificSettings);

        pw.println();
        pw.println("  mAccessibilityEnabled=" + mAccessibilityEnabled);
        pw.println("  " + KEY_VIBRATION_DISABLED + ":config=" + mVibrationDisabledConfig);
        pw.println("  " + KEY_VIBRATION_DISABLED + ":effective=" + mVibrationDisabledEffective);
        pw.println("  " + KEY_ANIMATION_DISABLED + "=" + mAnimationDisabled);
        pw.println("  " + KEY_FULLBACKUP_DEFERRED + "=" + mFullBackupDeferred);
        pw.println("  " + KEY_KEYVALUE_DEFERRED + "=" + mKeyValueBackupDeferred);
        pw.println("  " + KEY_FIREWALL_DISABLED + "=" + mFireWallDisabled);
        pw.println("  " + KEY_DATASAVER_DISABLED + "=" + mDataSaverDisabled);
        pw.println("  " + KEY_LAUNCH_BOOST_DISABLED + "=" + mLaunchBoostDisabled);
        pw.println("  " + KEY_ADJUST_BRIGHTNESS_DISABLED + "=" + mAdjustBrightnessDisabled);
        pw.println("  " + KEY_ADJUST_BRIGHTNESS_FACTOR + "=" + mAdjustBrightnessFactor);
        pw.println("  " + KEY_GPS_MODE + "=" + mGpsMode);
        pw.println("  " + KEY_FORCE_ALL_APPS_STANDBY + "=" + mForceAllAppsStandby);
        pw.println("  " + KEY_FORCE_BACKGROUND_CHECK + "=" + mForceBackgroundCheck);
        pw.println("  " + KEY_OPTIONAL_SENSORS_DISABLED + "=" + mOptionalSensorsDisabled);
        pw.println("  " + KEY_AOD_DISABLED + "=" + mAodDisabled);
        pw.println("  " + KEY_SEND_TRON_LOG + "=" + mSendTronLog);
        pw.println();

        pw.print("  Interactive File values:\n");
        dumpMap(pw, "    ", mFilesForInteractive);
        pw.println();

        pw.print("  Noninteractive File values:\n");
        dumpMap(pw, "    ", mFilesForNoninteractive);
    }
}
 
源代码17 项目: android_9.0.0_r45   文件: SyncManagerConstants.java
public void start() {
    BackgroundThread.getHandler().post(() -> {
        mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.SYNC_MANAGER_CONSTANTS), false, this);
        refresh();
    });
}
 
源代码18 项目: android_9.0.0_r45   文件: SyncManagerConstants.java
private void refresh() {
    synchronized (mLock) {

        String newValue = Settings.Global.getString(mContext.getContentResolver(),
                Global.SYNC_MANAGER_CONSTANTS);
        final KeyValueListParser parser = new KeyValueListParser(',');
        try {
            parser.setString(newValue);
        } catch (IllegalArgumentException e) {
            Slog.wtf(TAG, "Bad constants: " + newValue);
        }

        mInitialSyncRetryTimeInSeconds = parser.getInt(
                KEY_INITIAL_SYNC_RETRY_TIME_IN_SECONDS,
                DEF_INITIAL_SYNC_RETRY_TIME_IN_SECONDS);

        mMaxSyncRetryTimeInSeconds = parser.getInt(
                KEY_MAX_SYNC_RETRY_TIME_IN_SECONDS,
                DEF_MAX_SYNC_RETRY_TIME_IN_SECONDS);

        mRetryTimeIncreaseFactor = parser.getFloat(
                KEY_RETRY_TIME_INCREASE_FACTOR,
                DEF_RETRY_TIME_INCREASE_FACTOR);

        mMaxRetriesWithAppStandbyExemption = parser.getInt(
                KEY_MAX_RETRIES_WITH_APP_STANDBY_EXEMPTION,
                DEF_MAX_RETRIES_WITH_APP_STANDBY_EXEMPTION);

        mKeyExemptionTempWhitelistDurationInSeconds = parser.getInt(
                KEY_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS,
                DEF_EXEMPTION_TEMP_WHITELIST_DURATION_IN_SECONDS);

    }
}
 
源代码19 项目: android_9.0.0_r45   文件: HdmiControlService.java
private void registerContentObserver() {
    ContentResolver resolver = getContext().getContentResolver();
    String[] settings = new String[] {
            Global.HDMI_CONTROL_ENABLED,
            Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED,
            Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
            Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED,
            Global.MHL_INPUT_SWITCHING_ENABLED,
            Global.MHL_POWER_CHARGE_ENABLED
    };
    for (String s : settings) {
        resolver.registerContentObserver(Global.getUriFor(s), false, mSettingsObserver,
                UserHandle.USER_ALL);
    }
}
 
源代码20 项目: android_9.0.0_r45   文件: HdmiControlService.java
@Override
public void onChange(boolean selfChange, Uri uri) {
    String option = uri.getLastPathSegment();
    boolean enabled = readBooleanSetting(option, true);
    switch (option) {
        case Global.HDMI_CONTROL_ENABLED:
            setControlEnabled(enabled);
            break;
        case Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED:
            if (isTvDeviceEnabled()) {
                tv().setAutoWakeup(enabled);
            }
            setCecOption(OptionKey.WAKEUP, enabled);
            break;
        case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED:
            for (int type : mLocalDevices) {
                HdmiCecLocalDevice localDevice = mCecController.getLocalDevice(type);
                if (localDevice != null) {
                    localDevice.setAutoDeviceOff(enabled);
                }
            }
            // No need to propagate to HAL.
            break;
        case Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED:
            if (isTvDeviceEnabled()) {
                tv().setSystemAudioControlFeatureEnabled(enabled);
            }
            break;
        case Global.MHL_INPUT_SWITCHING_ENABLED:
            setMhlInputChangeEnabled(enabled);
            break;
        case Global.MHL_POWER_CHARGE_ENABLED:
            mMhlController.setOption(OPTION_MHL_POWER_CHARGE, toInt(enabled));
            break;
    }
}
 
源代码21 项目: android_9.0.0_r45   文件: HdmiCecLocalDeviceTv.java
HdmiCecLocalDeviceTv(HdmiControlService service) {
    super(service, HdmiDeviceInfo.DEVICE_TV);
    mPrevPortId = Constants.INVALID_PORT_ID;
    mAutoDeviceOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
            true);
    mAutoWakeup = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, true);
    mSystemAudioControlFeatureEnabled =
            mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);
    mStandbyHandler = new HdmiCecStandbyModeHandler(service, this);
}
 
HdmiCecLocalDevicePlayback(HdmiControlService service) {
    super(service, HdmiDeviceInfo.DEVICE_PLAYBACK);

    mAutoTvOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, false);

    // The option is false by default. Update settings db as well to have the right
    // initial setting on UI.
    mService.writeBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, mAutoTvOff);
}
 
源代码23 项目: android_9.0.0_r45   文件: NetworkScoreService.java
private void registerRecommendationSettingsObserver() {
    final Uri packageNameUri = Global.getUriFor(Global.NETWORK_RECOMMENDATIONS_PACKAGE);
    mRecommendationSettingsObserver.observe(packageNameUri,
            ServiceHandler.MSG_RECOMMENDATIONS_PACKAGE_CHANGED);

    final Uri settingUri = Global.getUriFor(Global.NETWORK_RECOMMENDATIONS_ENABLED);
    mRecommendationSettingsObserver.observe(settingUri,
            ServiceHandler.MSG_RECOMMENDATION_ENABLED_SETTING_CHANGED);
}
 
源代码24 项目: android_9.0.0_r45   文件: ZenLog.java
private static String zenModeToString(int zenMode) {
    switch (zenMode) {
        case Global.ZEN_MODE_OFF: return "off";
        case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return "important_interruptions";
        case Global.ZEN_MODE_ALARMS: return "alarms";
        case Global.ZEN_MODE_NO_INTERRUPTIONS: return "no_interruptions";
        default: return "unknown";
    }
}
 
源代码25 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private void setManualZenMode(int zenMode, Uri conditionId, String reason, String caller,
        boolean setRingerMode) {
    ZenModeConfig newConfig;
    synchronized (mConfig) {
        if (mConfig == null) return;
        if (!Global.isValidZenMode(zenMode)) return;
        if (DEBUG) Log.d(TAG, "setManualZenMode " + Global.zenModeToString(zenMode)
                + " conditionId=" + conditionId + " reason=" + reason
                + " setRingerMode=" + setRingerMode);
        newConfig = mConfig.copy();
        if (zenMode == Global.ZEN_MODE_OFF) {
            newConfig.manualRule = null;
            for (ZenRule automaticRule : newConfig.automaticRules.values()) {
                if (automaticRule.isAutomaticActive()) {
                    automaticRule.snoozing = true;
                }
            }
        } else {
            final ZenRule newRule = new ZenRule();
            newRule.enabled = true;
            newRule.zenMode = zenMode;
            newRule.conditionId = conditionId;
            newRule.enabler = caller;
            newConfig.manualRule = newRule;
        }
        setConfigLocked(newConfig, reason, null, setRingerMode);
    }
}
 
源代码26 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private void applyConfig(ZenModeConfig config, String reason,
        ComponentName triggeringComponent, boolean setRingerMode) {
    final String val = Integer.toString(config.hashCode());
    Global.putString(mContext.getContentResolver(), Global.ZEN_MODE_CONFIG_ETAG, val);
    if (!evaluateZenMode(reason, setRingerMode)) {
        applyRestrictions();  // evaluateZenMode will also apply restrictions if changed
    }
    mConditions.evaluateConfig(config, triggeringComponent, true /*processSubscriptions*/);
}
 
源代码27 项目: android_9.0.0_r45   文件: ZenModeHelper.java
@VisibleForTesting
protected void applyZenToRingerMode() {
    if (mAudioManager == null) return;
    // force the ringer mode into compliance
    final int ringerModeInternal = mAudioManager.getRingerModeInternal();
    int newRingerModeInternal = ringerModeInternal;
    switch (mZenMode) {
        case Global.ZEN_MODE_NO_INTERRUPTIONS:
        case Global.ZEN_MODE_ALARMS:
            if (ringerModeInternal != AudioManager.RINGER_MODE_SILENT) {
                setPreviousRingerModeSetting(ringerModeInternal);
                newRingerModeInternal = AudioManager.RINGER_MODE_SILENT;
            }
            break;
        case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
            // do not apply zen to ringer, streams zen muted in AudioService
            break;
        case Global.ZEN_MODE_OFF:
            if (ringerModeInternal == AudioManager.RINGER_MODE_SILENT) {
                newRingerModeInternal = getPreviousRingerModeSetting();
                setPreviousRingerModeSetting(null);
            }
            break;
    }
    if (newRingerModeInternal != -1) {
        mAudioManager.setRingerModeInternal(newRingerModeInternal, TAG);
    }
}
 
源代码28 项目: android_9.0.0_r45   文件: ZenModeHelper.java
private static int zenSeverity(int zen) {
    switch (zen) {
        case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return 1;
        case Global.ZEN_MODE_ALARMS: return 2;
        case Global.ZEN_MODE_NO_INTERRUPTIONS: return 3;
        default: return 0;
    }
}
 
源代码29 项目: android_9.0.0_r45   文件: ZenModeHelper.java
@Override
public int onSetRingerModeExternal(int ringerModeOld, int ringerModeNew, String caller,
        int ringerModeInternal, VolumePolicy policy) {
    int ringerModeInternalOut = ringerModeNew;
    final boolean isChange = ringerModeOld != ringerModeNew;
    final boolean isVibrate = ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE;

    int newZen = -1;
    switch (ringerModeNew) {
        case AudioManager.RINGER_MODE_SILENT:
            if (isChange) {
                if (mZenMode == Global.ZEN_MODE_OFF) {
                    newZen = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
                }
                ringerModeInternalOut = isVibrate ? AudioManager.RINGER_MODE_VIBRATE
                        : AudioManager.RINGER_MODE_SILENT;
            } else {
                ringerModeInternalOut = ringerModeInternal;
            }
            break;
        case AudioManager.RINGER_MODE_VIBRATE:
        case AudioManager.RINGER_MODE_NORMAL:
            if (mZenMode != Global.ZEN_MODE_OFF) {
                newZen = Global.ZEN_MODE_OFF;
            }
            break;
    }
    if (newZen != -1) {
        setManualZenMode(newZen, null, "ringerModeExternal", caller,
                false /*setRingerMode*/);
    }

    ZenLog.traceSetRingerModeExternal(ringerModeOld, ringerModeNew, caller,
            ringerModeInternal, ringerModeInternalOut);
    return ringerModeInternalOut;
}
 
源代码30 项目: android_9.0.0_r45   文件: ZenModeHelper.java
@Override
public int getRingerModeAffectedStreams(int streams) {
    // ringtone and notification streams are always affected by ringer mode
    // system stream is affected by ringer mode when not in priority-only
    streams |= (1 << AudioSystem.STREAM_RING) |
            (1 << AudioSystem.STREAM_NOTIFICATION) |
            (1 << AudioSystem.STREAM_SYSTEM);

    if (mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS) {
        // alarm and music streams affected by ringer mode when in total silence
        streams |= (1 << AudioSystem.STREAM_ALARM) |
                (1 << AudioSystem.STREAM_MUSIC);
    } else {
        streams &= ~((1 << AudioSystem.STREAM_ALARM) |
                (1 << AudioSystem.STREAM_MUSIC));
    }

    if (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
            && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig)) {
        // system stream is not affected by ringer mode in priority only when the ringer
        // is zen muted (all other notification categories are muted)
        streams &= ~(1 << AudioSystem.STREAM_SYSTEM);
    } else {
        streams |= (1 << AudioSystem.STREAM_SYSTEM);
    }
    return streams;
}
 
 类所在包
 同包方法