Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78873f40 authored by Dan Sandler's avatar Dan Sandler Committed by The Android Automerger
Browse files

Avoid crashing on startup when policy forbids lockscreen camera.

Bug: 19554426
Change-Id: I5b2898d7d114de87d925b5eccc8e4b189e4713de
parent 0c46bbe8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.Display;
@@ -2175,6 +2176,14 @@ public abstract class BaseStatusBar extends SystemUI implements
    }

    public boolean isKeyguardSecure() {
        if (mStatusBarKeyguardViewManager == null) {
            // startKeyguard() hasn't been called yet, so we don't know.
            // Make sure anything that needs to know isKeyguardSecure() checks and re-checks this
            // value onVisibilityChanged().
            Slog.w(TAG, "isKeyguardSecure() called before startKeyguard(), returning false",
                    new Throwable());
            return false;
        }
        return mStatusBarKeyguardViewManager.isSecure();
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -220,6 +220,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL

    public void setPhoneStatusBar(PhoneStatusBar phoneStatusBar) {
        mPhoneStatusBar = phoneStatusBar;
        updateCameraVisibility(); // in case onFinishInflate() was called too early
    }

    private Intent getCameraIntent() {
@@ -231,6 +232,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    }

    private void updateCameraVisibility() {
        if (mCameraImageView == null) {
            // Things are not set up yet; reply hazy, ask again later
            return;
        }
        ResolveInfo resolved = mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(),
                PackageManager.MATCH_DEFAULT_ONLY,
                mLockPatternUtils.getCurrentUser());
@@ -253,7 +258,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private boolean isCameraDisabledByDpm() {
        final DevicePolicyManager dpm =
                (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
        if (dpm != null) {
        if (dpm != null && mPhoneStatusBar != null) {
            try {
                final int userId = ActivityManagerNative.getDefault().getCurrentUser().id;
                final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);