Search in sources :

Example 51 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ParanoidAndroid.

the class EmergencyButton method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mLockPatternUtils = new LockPatternUtils(mContext);
    mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            takeEmergencyCallAction();
        }
    });
    int phoneState = KeyguardUpdateMonitor.getInstance(mContext).getPhoneState();
    State simState = KeyguardUpdateMonitor.getInstance(mContext).getSimState();
    updateEmergencyCallButton(simState, phoneState);
}
Also used : State(com.android.internal.telephony.IccCardConstants.State) LockPatternUtils(com.android.internal.widget.LockPatternUtils) View(android.view.View)

Example 52 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ParanoidAndroid.

the class KeyguardAbsKeyInputView method onFinishInflate.

@Override
protected void onFinishInflate() {
    mLockPatternUtils = new LockPatternUtils(mContext);
    mPasswordEntry = (TextView) findViewById(getPasswordTextViewId());
    mPasswordEntry.setOnEditorActionListener(this);
    mPasswordEntry.addTextChangedListener(this);
    // Set selected property on so the view can send accessibility events.
    mPasswordEntry.setSelected(true);
    // Poke the wakelock any time the text is selected or modified
    mPasswordEntry.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO: customize timeout for text?
            mCallback.userActivity(0);
        }
    });
    mQuickUnlock = Settings.System.getBoolean(mContext.getContentResolver(), Settings.System.LOCKSCREEN_QUICK_UNLOCK, false);
    mPasswordEntry.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
            if (mCallback != null) {
                mCallback.userActivity(0);
            }
            if (mQuickUnlock && getQuickUnlockAllowed()) {
                if (s.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT && mLockPatternUtils.checkPassword(s.toString())) {
                    mCallback.dismiss(true);
                    mCallback.reportSuccessfulUnlockAttempt();
                }
            }
        }
    });
    mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
    mEcaView = findViewById(R.id.keyguard_selector_fade_container);
    View bouncerFrameView = findViewById(R.id.keyguard_bouncer_frame);
    if (bouncerFrameView != null) {
        mBouncerFrame = bouncerFrameView.getBackground();
    }
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) View(android.view.View)

Example 53 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ParanoidAndroid.

the class KeyguardPatternView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mLockPatternUtils = mLockPatternUtils == null ? new LockPatternUtils(mContext) : mLockPatternUtils;
    mLockPatternView = (LockPatternView) findViewById(R.id.lockPatternView);
    mLockPatternView.setSaveEnabled(false);
    mLockPatternView.setFocusable(false);
    mLockPatternView.setOnPatternListener(new UnlockPatternListener());
    // stealth mode will be the same for the life of this screen
    mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled());
    // vibrate mode will be the same for the life of this screen
    mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
    mForgotPatternButton = (Button) findViewById(R.id.forgot_password_button);
    // note: some configurations don't have an emergency call area
    if (mForgotPatternButton != null) {
        mForgotPatternButton.setText(R.string.kg_forgot_pattern_button_text);
        mForgotPatternButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mCallback.showBackupSecurity();
            }
        });
    }
    setFocusableInTouchMode(true);
    maybeEnableFallback(mContext);
    mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
    mEcaView = findViewById(R.id.keyguard_selector_fade_container);
    View bouncerFrameView = findViewById(R.id.keyguard_bouncer_frame);
    if (bouncerFrameView != null) {
        mBouncerFrame = bouncerFrameView.getBackground();
    }
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils) LockPatternView(com.android.internal.widget.LockPatternView) View(android.view.View)

Example 54 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ParanoidAndroid.

the class KeyguardStatusView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getContext().getResources();
    final Locale locale = Locale.getDefault();
    final String datePattern = res.getString(com.android.internal.R.string.system_ui_date_pattern);
    final String bestFormat = ICU.getBestDateTimePattern(datePattern, locale.toString());
    mDateFormat = new SimpleDateFormat(bestFormat, locale);
    mDateView = (TextView) findViewById(R.id.date);
    mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
    mClockView = (ClockView) findViewById(R.id.clock_view);
    mLockPatternUtils = new LockPatternUtils(getContext());
    // Use custom font in mDateView
    mDateView.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    // Required to get Marquee to work.
    final View[] marqueeViews = { mDateView, mAlarmStatusView };
    for (int i = 0; i < marqueeViews.length; i++) {
        View v = marqueeViews[i];
        if (v == null) {
            throw new RuntimeException("Can't find widget at index " + i);
        }
        v.setSelected(true);
    }
    refresh();
}
Also used : Locale(java.util.Locale) LockPatternUtils(com.android.internal.widget.LockPatternUtils) Resources(android.content.res.Resources) SimpleDateFormat(java.text.SimpleDateFormat) TextView(android.widget.TextView) View(android.view.View)

Example 55 with LockPatternUtils

use of com.android.internal.widget.LockPatternUtils in project android_frameworks_base by ParanoidAndroid.

the class DevicePolicyManagerService method loadSettingsLocked.

private void loadSettingsLocked(DevicePolicyData policy, int userHandle) {
    JournaledFile journal = makeJournaledFile(userHandle);
    FileInputStream stream = null;
    File file = journal.chooseForRead();
    try {
        stream = new FileInputStream(file);
        XmlPullParser parser = Xml.newPullParser();
        parser.setInput(stream, null);
        int type;
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
        }
        String tag = parser.getName();
        if (!"policies".equals(tag)) {
            throw new XmlPullParserException("Settings do not start with policies tag: found " + tag);
        }
        type = parser.next();
        int outerDepth = parser.getDepth();
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                continue;
            }
            tag = parser.getName();
            if ("admin".equals(tag)) {
                String name = parser.getAttributeValue(null, "name");
                try {
                    DeviceAdminInfo dai = findAdmin(ComponentName.unflattenFromString(name), userHandle);
                    if (DBG && (UserHandle.getUserId(dai.getActivityInfo().applicationInfo.uid) != userHandle)) {
                        Slog.w(TAG, "findAdmin returned an incorrect uid " + dai.getActivityInfo().applicationInfo.uid + " for user " + userHandle);
                    }
                    if (dai != null) {
                        ActiveAdmin ap = new ActiveAdmin(dai);
                        ap.readFromXml(parser);
                        policy.mAdminMap.put(ap.info.getComponent(), ap);
                        policy.mAdminList.add(ap);
                    }
                } catch (RuntimeException e) {
                    Slog.w(TAG, "Failed loading admin " + name, e);
                }
            } else if ("failed-password-attempts".equals(tag)) {
                policy.mFailedPasswordAttempts = Integer.parseInt(parser.getAttributeValue(null, "value"));
                XmlUtils.skipCurrentTag(parser);
            } else if ("password-owner".equals(tag)) {
                policy.mPasswordOwner = Integer.parseInt(parser.getAttributeValue(null, "value"));
                XmlUtils.skipCurrentTag(parser);
            } else if ("active-password".equals(tag)) {
                policy.mActivePasswordQuality = Integer.parseInt(parser.getAttributeValue(null, "quality"));
                policy.mActivePasswordLength = Integer.parseInt(parser.getAttributeValue(null, "length"));
                policy.mActivePasswordUpperCase = Integer.parseInt(parser.getAttributeValue(null, "uppercase"));
                policy.mActivePasswordLowerCase = Integer.parseInt(parser.getAttributeValue(null, "lowercase"));
                policy.mActivePasswordLetters = Integer.parseInt(parser.getAttributeValue(null, "letters"));
                policy.mActivePasswordNumeric = Integer.parseInt(parser.getAttributeValue(null, "numeric"));
                policy.mActivePasswordSymbols = Integer.parseInt(parser.getAttributeValue(null, "symbols"));
                policy.mActivePasswordNonLetter = Integer.parseInt(parser.getAttributeValue(null, "nonletter"));
                XmlUtils.skipCurrentTag(parser);
            } else {
                Slog.w(TAG, "Unknown tag: " + tag);
                XmlUtils.skipCurrentTag(parser);
            }
        }
    } catch (NullPointerException e) {
        Slog.w(TAG, "failed parsing " + file + " " + e);
    } catch (NumberFormatException e) {
        Slog.w(TAG, "failed parsing " + file + " " + e);
    } catch (XmlPullParserException e) {
        Slog.w(TAG, "failed parsing " + file + " " + e);
    } catch (FileNotFoundException e) {
    // Don't be noisy, this is normal if we haven't defined any policies.
    } catch (IOException e) {
        Slog.w(TAG, "failed parsing " + file + " " + e);
    } catch (IndexOutOfBoundsException e) {
        Slog.w(TAG, "failed parsing " + file + " " + e);
    }
    try {
        if (stream != null) {
            stream.close();
        }
    } catch (IOException e) {
    // Ignore
    }
    // Validate that what we stored for the password quality matches
    // sufficiently what is currently set.  Note that this is only
    // a sanity check in case the two get out of sync; this should
    // never normally happen.
    LockPatternUtils utils = new LockPatternUtils(mContext);
    if (utils.getActivePasswordQuality() < policy.mActivePasswordQuality) {
        Slog.w(TAG, "Active password quality 0x" + Integer.toHexString(policy.mActivePasswordQuality) + " does not match actual quality 0x" + Integer.toHexString(utils.getActivePasswordQuality()));
        policy.mActivePasswordQuality = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
        policy.mActivePasswordLength = 0;
        policy.mActivePasswordUpperCase = 0;
        policy.mActivePasswordLowerCase = 0;
        policy.mActivePasswordLetters = 0;
        policy.mActivePasswordNumeric = 0;
        policy.mActivePasswordSymbols = 0;
        policy.mActivePasswordNonLetter = 0;
    }
    validatePasswordOwnerLocked(policy);
    syncDeviceCapabilitiesLocked(policy);
    updateMaximumTimeToLockLocked(policy);
}
Also used : JournaledFile(com.android.internal.util.JournaledFile) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileNotFoundException(java.io.FileNotFoundException) LockPatternUtils(com.android.internal.widget.LockPatternUtils) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) DeviceAdminInfo(android.app.admin.DeviceAdminInfo) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) AtomicFile(android.util.AtomicFile) File(java.io.File) JournaledFile(com.android.internal.util.JournaledFile)

Aggregations

LockPatternUtils (com.android.internal.widget.LockPatternUtils)96 ComponentName (android.content.ComponentName)24 UserInfo (android.content.pm.UserInfo)24 DevicePolicyManager (android.app.admin.DevicePolicyManager)19 UserManager (android.os.UserManager)16 IOException (java.io.IOException)11 IntentFilter (android.content.IntentFilter)10 Intent (android.content.Intent)9 View (android.view.View)9 Cursor (android.database.Cursor)6 RemoteException (android.os.RemoteException)6 ArrayList (java.util.ArrayList)6 ContentResolver (android.content.ContentResolver)5 Configuration (android.content.res.Configuration)5 Rect (android.graphics.Rect)5 SoundPool (android.media.SoundPool)5 IBinder (android.os.IBinder)5 IVrManager (android.service.vr.IVrManager)5 StatusBarIcon (com.android.internal.statusbar.StatusBarIcon)5 KeyguardDisplayManager (com.android.keyguard.KeyguardDisplayManager)5