Search in sources :

Example 41 with LockPatternUtils

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

the class KeyguardHostView method onFinishInflate.

@Override
protected void onFinishInflate() {
    mSecurityContainer = (KeyguardSecurityContainer) findViewById(R.id.keyguard_security_container);
    mLockPatternUtils = new LockPatternUtils(mContext);
    mSecurityContainer.setLockPatternUtils(mLockPatternUtils);
    mSecurityContainer.setSecurityCallback(this);
    mSecurityContainer.showPrimarySecurityScreen(false);
// mSecurityContainer.updateSecurityViews(false /* not bouncing */);
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils)

Example 42 with LockPatternUtils

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

the class RetailDemoModeService method onSwitchUser.

@Override
public void onSwitchUser(int userId) {
    if (!mDeviceInDemoMode) {
        return;
    }
    if (DEBUG) {
        Slog.d(TAG, "onSwitchUser: " + userId);
    }
    final UserInfo ui = getUserManager().getUserInfo(userId);
    if (!ui.isDemo()) {
        Slog.wtf(TAG, "Should not allow switch to non-demo user in demo mode");
        return;
    }
    if (!mIsCarrierDemoMode && !mWakeLock.isHeld()) {
        mWakeLock.acquire();
    }
    mCurrentUserId = userId;
    mAmi.updatePersistentConfigurationForUser(getSystemUsersConfiguration(), userId);
    turnOffAllFlashLights();
    muteVolumeStreams();
    if (!mWifiManager.isWifiEnabled()) {
        mWifiManager.setWifiEnabled(true);
    }
    // Disable lock screen for demo users.
    LockPatternUtils lockPatternUtils = new LockPatternUtils(getContext());
    lockPatternUtils.setLockScreenDisabled(true, userId);
    if (!mIsCarrierDemoMode) {
        // Show reset notification (except in carrier demo mode).
        mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId));
        synchronized (mActivityLock) {
            mUserUntouched = true;
        }
        MetricsLogger.count(getContext(), DEMO_SESSION_COUNT, 1);
        mHandler.removeMessages(MSG_INACTIVITY_TIME_OUT);
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                mPreloadAppsInstaller.installApps(userId);
            }
        });
    }
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils) UserInfo(android.content.pm.UserInfo)

Example 43 with LockPatternUtils

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

the class BaseStatusBar method start.

public void start() {
    mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
    mDisplay = mWindowManager.getDefaultDisplay();
    mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
    mNotificationData = new NotificationData(this);
    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mDreamManager = IDreamManager.Stub.asInterface(ServiceManager.checkService(DreamService.DREAM_SERVICE));
    mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, mSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false, mSettingsObserver);
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false, mSettingsObserver, UserHandle.USER_ALL);
    if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) {
        mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT), false, mSettingsObserver, UserHandle.USER_ALL);
    }
    mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS), true, mLockscreenSettingsObserver, UserHandle.USER_ALL);
    mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    mRecents = getComponent(Recents.class);
    final Configuration currentConfig = mContext.getResources().getConfiguration();
    mLocale = currentConfig.locale;
    mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
    mFontScale = currentConfig.fontScale;
    mDensity = currentConfig.densityDpi;
    mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
    mLockPatternUtils = new LockPatternUtils(mContext);
    // Connect in to the status bar manager service
    mCommandQueue = new CommandQueue(this);
    int[] switches = new int[9];
    ArrayList<IBinder> binders = new ArrayList<IBinder>();
    ArrayList<String> iconSlots = new ArrayList<>();
    ArrayList<StatusBarIcon> icons = new ArrayList<>();
    Rect fullscreenStackBounds = new Rect();
    Rect dockedStackBounds = new Rect();
    try {
        mBarService.registerStatusBar(mCommandQueue, iconSlots, icons, switches, binders, fullscreenStackBounds, dockedStackBounds);
    } catch (RemoteException ex) {
    // If the system process isn't there we're doomed anyway.
    }
    createAndAddWindows();
    // set up
    mSettingsObserver.onChange(false);
    disable(switches[0], switches[6], false);
    setSystemUiVisibility(switches[1], switches[7], switches[8], 0xffffffff, fullscreenStackBounds, dockedStackBounds);
    topAppWindowChanged(switches[2] != 0);
    // StatusBarManagerService has a back up of IME token and it's restored here.
    setImeWindowStatus(binders.get(0), switches[3], switches[4], switches[5] != 0);
    // Set up the initial icon state
    int N = iconSlots.size();
    int viewIndex = 0;
    for (int i = 0; i < N; i++) {
        setIcon(iconSlots.get(i), icons.get(i));
    }
    // Set up the initial notification state.
    try {
        mNotificationListener.registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()), UserHandle.USER_ALL);
    } catch (RemoteException e) {
        Log.e(TAG, "Unable to register notification listener", e);
    }
    if (DEBUG) {
        Log.d(TAG, String.format("init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", icons.size(), switches[0], switches[1], switches[2], switches[3]));
    }
    mCurrentUserId = ActivityManager.getCurrentUser();
    setHeadsUpUser(mCurrentUserId);
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    mContext.registerReceiver(mBroadcastReceiver, filter);
    IntentFilter internalFilter = new IntentFilter();
    internalFilter.addAction(WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION);
    internalFilter.addAction(BANNER_ACTION_CANCEL);
    internalFilter.addAction(BANNER_ACTION_SETUP);
    mContext.registerReceiver(mBroadcastReceiver, internalFilter, PERMISSION_SELF, null);
    IntentFilter allUsersFilter = new IntentFilter();
    allUsersFilter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
    mContext.registerReceiverAsUser(mAllUsersReceiver, UserHandle.ALL, allUsersFilter, null, null);
    updateCurrentProfilesCache();
    IVrManager vrManager = IVrManager.Stub.asInterface(ServiceManager.getService("vrmanager"));
    try {
        vrManager.registerListener(mVrStateCallbacks);
    } catch (RemoteException e) {
        Slog.e(TAG, "Failed to register VR mode state listener: " + e);
    }
    mNonBlockablePkgs = new ArraySet<String>();
    Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray(com.android.internal.R.array.config_nonBlockableNotificationPackages));
}
Also used : IntentFilter(android.content.IntentFilter) Rect(android.graphics.Rect) Recents(com.android.systemui.recents.Recents) Configuration(android.content.res.Configuration) LockPatternUtils(com.android.internal.widget.LockPatternUtils) ArrayList(java.util.ArrayList) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) RemoteException(android.os.RemoteException) IVrManager(android.service.vr.IVrManager)

Example 44 with LockPatternUtils

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

the class TrustManagerService method refreshAgentList.

void refreshAgentList(int userIdOrAll) {
    if (DEBUG)
        Slog.d(TAG, "refreshAgentList(" + userIdOrAll + ")");
    if (!mTrustAgentsCanRun) {
        return;
    }
    if (userIdOrAll != UserHandle.USER_ALL && userIdOrAll < UserHandle.USER_SYSTEM) {
        Log.e(TAG, "refreshAgentList(userId=" + userIdOrAll + "): Invalid user handle," + " must be USER_ALL or a specific user.", new Throwable("here"));
        userIdOrAll = UserHandle.USER_ALL;
    }
    PackageManager pm = mContext.getPackageManager();
    List<UserInfo> userInfos;
    if (userIdOrAll == UserHandle.USER_ALL) {
        userInfos = mUserManager.getUsers(true);
    } else {
        userInfos = new ArrayList<>();
        userInfos.add(mUserManager.getUserInfo(userIdOrAll));
    }
    LockPatternUtils lockPatternUtils = mLockPatternUtils;
    ArraySet<AgentInfo> obsoleteAgents = new ArraySet<>();
    obsoleteAgents.addAll(mActiveAgents);
    for (UserInfo userInfo : userInfos) {
        if (userInfo == null || userInfo.partial || !userInfo.isEnabled() || userInfo.guestToRemove)
            continue;
        if (!userInfo.supportsSwitchToByUser())
            continue;
        if (!StorageManager.isUserKeyUnlocked(userInfo.id))
            continue;
        if (!mActivityManager.isUserRunning(userInfo.id))
            continue;
        if (!lockPatternUtils.isSecure(userInfo.id))
            continue;
        if (!mStrongAuthTracker.canAgentsRunForUser(userInfo.id))
            continue;
        DevicePolicyManager dpm = lockPatternUtils.getDevicePolicyManager();
        int disabledFeatures = dpm.getKeyguardDisabledFeatures(null, userInfo.id);
        final boolean disableTrustAgents = (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
        List<ComponentName> enabledAgents = lockPatternUtils.getEnabledTrustAgents(userInfo.id);
        if (enabledAgents == null) {
            continue;
        }
        List<ResolveInfo> resolveInfos = resolveAllowedTrustAgents(pm, userInfo.id);
        for (ResolveInfo resolveInfo : resolveInfos) {
            ComponentName name = getComponentName(resolveInfo);
            if (!enabledAgents.contains(name))
                continue;
            if (disableTrustAgents) {
                List<PersistableBundle> config = dpm.getTrustAgentConfiguration(null, /* admin */
                name, userInfo.id);
                // Disable agent if no features are enabled.
                if (config == null || config.isEmpty())
                    continue;
            }
            AgentInfo agentInfo = new AgentInfo();
            agentInfo.component = name;
            agentInfo.userId = userInfo.id;
            if (!mActiveAgents.contains(agentInfo)) {
                agentInfo.label = resolveInfo.loadLabel(pm);
                agentInfo.icon = resolveInfo.loadIcon(pm);
                agentInfo.settings = getSettingsComponentName(pm, resolveInfo);
                agentInfo.agent = new TrustAgentWrapper(mContext, this, new Intent().setComponent(name), userInfo.getUserHandle());
                mActiveAgents.add(agentInfo);
            } else {
                obsoleteAgents.remove(agentInfo);
            }
        }
    }
    boolean trustMayHaveChanged = false;
    for (int i = 0; i < obsoleteAgents.size(); i++) {
        AgentInfo info = obsoleteAgents.valueAt(i);
        if (userIdOrAll == UserHandle.USER_ALL || userIdOrAll == info.userId) {
            if (info.agent.isManagingTrust()) {
                trustMayHaveChanged = true;
            }
            info.agent.destroy();
            mActiveAgents.remove(info);
        }
    }
    if (trustMayHaveChanged) {
        if (userIdOrAll == UserHandle.USER_ALL) {
            updateTrustAll();
        } else {
            updateTrust(userIdOrAll, 0);
        }
    }
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) ArraySet(android.util.ArraySet) LockPatternUtils(com.android.internal.widget.LockPatternUtils) UserInfo(android.content.pm.UserInfo) Intent(android.content.Intent) ResolveInfo(android.content.pm.ResolveInfo) PersistableBundle(android.os.PersistableBundle) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Example 45 with LockPatternUtils

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

the class KeyguardAbsKeyInputView method onFinishInflate.

@Override
protected void onFinishInflate() {
    mLockPatternUtils = new LockPatternUtils(mContext);
    mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this);
    mEcaView = findViewById(R.id.keyguard_selector_fade_container);
    mMaxCountdownTimes = mContext.getResources().getInteger(R.integer.config_max_unlock_countdown_times);
    EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button);
    if (button != null) {
        button.setCallback(this);
    }
}
Also used : LockPatternUtils(com.android.internal.widget.LockPatternUtils)

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