Fix NPE when there's no forgot password button.
Test: manual Bug: 149887743 Change-Id: If2238aec2e618f617b7459b819303c03f009941a
This commit is contained in:
@@ -62,7 +62,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="?attr/sudMarginSides"
|
android:layout_marginStart="?attr/sudMarginSides"
|
||||||
android:layout_marginEnd="?attr/sudMarginSides"
|
android:layout_marginEnd="?attr/sudMarginSides"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
|
@@ -59,7 +59,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="?attr/sudMarginSides"
|
android:layout_marginStart="?attr/sudMarginSides"
|
||||||
android:layout_marginEnd="?attr/sudMarginSides" />x
|
android:layout_marginEnd="?attr/sudMarginSides" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
@@ -77,7 +77,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="?attr/sudMarginSides"
|
android:layout_marginStart="?attr/sudMarginSides"
|
||||||
android:layout_marginEnd="?attr/sudMarginSides"
|
android:layout_marginEnd="?attr/sudMarginSides"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -61,7 +61,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="?attr/sudMarginSides"
|
android:layout_marginStart="?attr/sudMarginSides"
|
||||||
android:layout_marginEnd="?attr/sudMarginSides"
|
android:layout_marginEnd="?attr/sudMarginSides"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
|
@@ -72,7 +72,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="?attr/sudMarginSides"
|
android:layout_marginStart="?attr/sudMarginSides"
|
||||||
android:layout_marginEnd="?attr/sudMarginSides"
|
android:layout_marginEnd="?attr/sudMarginSides"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@ import android.os.Handler;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -57,7 +58,7 @@ import com.android.settings.core.InstrumentedFragment;
|
|||||||
* Base fragment to be shared for PIN/Pattern/Password confirmation fragments.
|
* Base fragment to be shared for PIN/Pattern/Password confirmation fragments.
|
||||||
*/
|
*/
|
||||||
public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFragment {
|
public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFragment {
|
||||||
|
public static final String TAG = ConfirmDeviceCredentialBaseFragment.class.getSimpleName();
|
||||||
public static final String TITLE_TEXT = SETTINGS_PACKAGE_NAME + ".ConfirmCredentials.title";
|
public static final String TITLE_TEXT = SETTINGS_PACKAGE_NAME + ".ConfirmCredentials.title";
|
||||||
public static final String HEADER_TEXT = SETTINGS_PACKAGE_NAME + ".ConfirmCredentials.header";
|
public static final String HEADER_TEXT = SETTINGS_PACKAGE_NAME + ".ConfirmCredentials.header";
|
||||||
public static final String DETAILS_TEXT = SETTINGS_PACKAGE_NAME + ".ConfirmCredentials.details";
|
public static final String DETAILS_TEXT = SETTINGS_PACKAGE_NAME + ".ConfirmCredentials.details";
|
||||||
@@ -78,7 +79,8 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
|||||||
|
|
||||||
protected boolean mReturnCredentials = false;
|
protected boolean mReturnCredentials = false;
|
||||||
protected Button mCancelButton;
|
protected Button mCancelButton;
|
||||||
protected Button mForgotButton;
|
/** Button allowing managed profile password reset, null when is not shown. */
|
||||||
|
@Nullable protected Button mForgotButton;
|
||||||
protected int mEffectiveUserId;
|
protected int mEffectiveUserId;
|
||||||
protected int mUserId;
|
protected int mUserId;
|
||||||
protected UserManager mUserManager;
|
protected UserManager mUserManager;
|
||||||
@@ -133,10 +135,18 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
|||||||
}
|
}
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
});
|
});
|
||||||
mForgotButton = view.findViewById(R.id.forgotButton);
|
setupForgotButtonIfManagedProfile(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupForgotButtonIfManagedProfile(View view) {
|
||||||
if (mUserManager.isManagedProfile(mUserId)
|
if (mUserManager.isManagedProfile(mUserId)
|
||||||
&& mUserManager.isQuietModeEnabled(UserHandle.of(mUserId))
|
&& mUserManager.isQuietModeEnabled(UserHandle.of(mUserId))
|
||||||
&& mDevicePolicyManager.canProfileOwnerResetPasswordWhenLocked(mUserId)) {
|
&& mDevicePolicyManager.canProfileOwnerResetPasswordWhenLocked(mUserId)) {
|
||||||
|
mForgotButton = view.findViewById(R.id.forgotButton);
|
||||||
|
if (mForgotButton == null) {
|
||||||
|
Log.wtf(TAG, "Forgot button not found in managed profile credential dialog");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mForgotButton.setVisibility(View.VISIBLE);
|
mForgotButton.setVisibility(View.VISIBLE);
|
||||||
mForgotButton.setOnClickListener(v -> {
|
mForgotButton.setOnClickListener(v -> {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
@@ -145,8 +155,6 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
|||||||
getActivity().startActivity(intent);
|
getActivity().startActivity(intent);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
mForgotButton.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -267,7 +267,9 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
mHeaderTextView.setAlpha(0f);
|
mHeaderTextView.setAlpha(0f);
|
||||||
mDetailsTextView.setAlpha(0f);
|
mDetailsTextView.setAlpha(0f);
|
||||||
mCancelButton.setAlpha(0f);
|
mCancelButton.setAlpha(0f);
|
||||||
mForgotButton.setAlpha(0f);
|
if (mForgotButton != null) {
|
||||||
|
mForgotButton.setAlpha(0f);
|
||||||
|
}
|
||||||
mPasswordEntry.setAlpha(0f);
|
mPasswordEntry.setAlpha(0f);
|
||||||
mErrorTextView.setAlpha(0f);
|
mErrorTextView.setAlpha(0f);
|
||||||
}
|
}
|
||||||
@@ -279,7 +281,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
if (mCancelButton.getVisibility() == View.VISIBLE) {
|
if (mCancelButton.getVisibility() == View.VISIBLE) {
|
||||||
result.add(mCancelButton);
|
result.add(mCancelButton);
|
||||||
}
|
}
|
||||||
if (mForgotButton.getVisibility() == View.VISIBLE) {
|
if (mForgotButton != null) {
|
||||||
result.add(mForgotButton);
|
result.add(mForgotButton);
|
||||||
}
|
}
|
||||||
result.add(mPasswordEntry);
|
result.add(mPasswordEntry);
|
||||||
|
@@ -240,7 +240,9 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
super.prepareEnterAnimation();
|
super.prepareEnterAnimation();
|
||||||
mHeaderTextView.setAlpha(0f);
|
mHeaderTextView.setAlpha(0f);
|
||||||
mCancelButton.setAlpha(0f);
|
mCancelButton.setAlpha(0f);
|
||||||
mForgotButton.setAlpha(0f);
|
if (mForgotButton != null) {
|
||||||
|
mForgotButton.setAlpha(0f);
|
||||||
|
}
|
||||||
mLockPatternView.setAlpha(0f);
|
mLockPatternView.setAlpha(0f);
|
||||||
mDetailsTextView.setAlpha(0f);
|
mDetailsTextView.setAlpha(0f);
|
||||||
}
|
}
|
||||||
@@ -268,7 +270,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
if (mCancelButton.getVisibility() == View.VISIBLE) {
|
if (mCancelButton.getVisibility() == View.VISIBLE) {
|
||||||
result.add(new ArrayList<>(Collections.singletonList(mCancelButton)));
|
result.add(new ArrayList<>(Collections.singletonList(mCancelButton)));
|
||||||
}
|
}
|
||||||
if (mForgotButton.getVisibility() == View.VISIBLE) {
|
if (mForgotButton != null) {
|
||||||
result.add(new ArrayList<>(Collections.singletonList(mForgotButton)));
|
result.add(new ArrayList<>(Collections.singletonList(mForgotButton)));
|
||||||
}
|
}
|
||||||
LockPatternView.CellState[][] cellStates = mLockPatternView.getCellStates();
|
LockPatternView.CellState[][] cellStates = mLockPatternView.getCellStates();
|
||||||
|
Reference in New Issue
Block a user