FileDocCategorySizeDatePackage
SecureSetting.javaAPI DocAndroid 5.1 API2692Thu Mar 12 22:22:42 GMT 2015com.android.systemui.qs

SecureSetting

public abstract class SecureSetting extends android.database.ContentObserver implements com.android.systemui.statusbar.policy.Listenable
Helper for managing a secure setting.

Fields Summary
private static final int
DEFAULT
private final android.content.Context
mContext
private final String
mSettingName
private boolean
mListening
private int
mUserId
private int
mObservedValue
Constructors Summary
public SecureSetting(android.content.Context context, android.os.Handler handler, String settingName)


          

           
        super(handler);
        mContext = context;
        mSettingName = settingName;
        mUserId = ActivityManager.getCurrentUser();
    
Methods Summary
public intgetValue()

        return Secure.getIntForUser(mContext.getContentResolver(), mSettingName, DEFAULT, mUserId);
    
protected abstract voidhandleValueChanged(int value, boolean observedChange)

public voidonChange(boolean selfChange)

        final int value = getValue();
        handleValueChanged(value, value != mObservedValue);
        mObservedValue = value;
    
public voidsetListening(boolean listening)

        if (listening == mListening) return;
        mListening = listening;
        if (listening) {
            mObservedValue = getValue();
            mContext.getContentResolver().registerContentObserver(
                    Secure.getUriFor(mSettingName), false, this, mUserId);
        } else {
            mContext.getContentResolver().unregisterContentObserver(this);
            mObservedValue = DEFAULT;
        }
    
public voidsetUserId(int userId)

        mUserId = userId;
        if (mListening) {
            setListening(false);
            setListening(true);
        }
    
public voidsetValue(int value)

        Secure.putIntForUser(mContext.getContentResolver(), mSettingName, value, mUserId);