diff --git a/api/current.txt b/api/current.txt index 5b2543b2454e8..8366333257cf4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6375,7 +6375,6 @@ package android.content { field public static final java.lang.String ACTION_PROVIDER_CHANGED = "android.intent.action.PROVIDER_CHANGED"; field public static final java.lang.String ACTION_QUICK_CLOCK = "android.intent.action.QUICK_CLOCK"; field public static final java.lang.String ACTION_REBOOT = "android.intent.action.REBOOT"; - field public static final java.lang.String ACTION_RESTRICTIONS_PIN_CHALLENGE = "android.intent.action.RESTRICTIONS_PIN_CHALLENGE"; field public static final java.lang.String ACTION_RUN = "android.intent.action.RUN"; field public static final java.lang.String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; field public static final java.lang.String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; @@ -18552,14 +18551,13 @@ package android.os { method public java.lang.String getUserName(); method public android.os.Bundle getUserRestrictions(); method public android.os.Bundle getUserRestrictions(android.os.UserHandle); - method public boolean hasRestrictionsPin(); method public boolean isUserAGoat(); method public boolean isUserRunning(android.os.UserHandle); method public boolean isUserRunningOrStopping(android.os.UserHandle); + method public boolean setRestrictionsChallenge(java.lang.String); method public void setUserRestriction(java.lang.String, boolean); method public void setUserRestrictions(android.os.Bundle); method public void setUserRestrictions(android.os.Bundle, android.os.UserHandle); - field public static final java.lang.String DISALLOW_APP_RESTRICTIONS = "no_app_restrictions"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; field public static final java.lang.String DISALLOW_CONFIG_WIFI = "no_config_wifi"; diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index dfc0412959534..2f2aae4ff0636 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2469,16 +2469,19 @@ public class Intent implements Parcelable, Cloneable { "android.intent.action.GET_RESTRICTION_ENTRIES"; /** + * @hide * Activity to challenge the user for a PIN that was configured when setting up - * restrictions. Launch the activity using + * restrictions. Restrictions include blocking of apps and preventing certain user operations, + * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle). + * Launch the activity using * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the * result is {@link android.app.Activity#RESULT_OK} for a successful response to the * challenge.
* Before launching this activity, make sure that there is a PIN in effect, by calling - * {@link android.os.UserManager#hasRestrictionsPin()}. + * {@link android.os.UserManager#hasRestrictionsChallenge()}. */ - public static final String ACTION_RESTRICTIONS_PIN_CHALLENGE = - "android.intent.action.RESTRICTIONS_PIN_CHALLENGE"; + public static final String ACTION_RESTRICTIONS_CHALLENGE = + "android.intent.action.RESTRICTIONS_CHALLENGE"; /** * Sent the first time a user is starting, to allow system apps to diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index bd2d9ac5ada86..3c9d0d904a6c8 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -46,8 +46,8 @@ interface IUserManager { int userHandle); Bundle getApplicationRestrictions(in String packageName); Bundle getApplicationRestrictionsForUser(in String packageName, int userHandle); - boolean changeRestrictionsPin(in String newPin); - int checkRestrictionsPin(in String pin); - boolean hasRestrictionsPin(); + boolean setRestrictionsChallenge(in String newPin); + int checkRestrictionsChallenge(in String pin); + boolean hasRestrictionsChallenge(); void removeRestrictions(); } diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 10b97652d1ba3..a3752a1a2d956 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -140,16 +140,6 @@ public class UserManager { */ public static final String DISALLOW_REMOVE_USER = "no_remove_user"; - /** - * Key for user restrictions. Specifies if a user is disallowed from setting app restrictions - * via a restrictions PIN. The default isfalse. If app restrictions have already
- * been set up, then this user restriction cannot be set to true.
- *
- * Type: Boolean
- * @see #hasRestrictionsPin()
- */
- public static final String DISALLOW_APP_RESTRICTIONS = "no_app_restrictions";
-
/** @hide */
public static final int PIN_VERIFICATION_FAILED_INCORRECT = -3;
/** @hide */
@@ -650,15 +640,14 @@ public class UserManager {
}
/**
- * @hide
- * Sets a new restrictions PIN. This should only be called after verifying that there
- * currently isn't a PIN set, or after the user successfully enters the current PIN.
- * @param newPin
- * @return Returns true if the PIN was changed successfully.
+ * Sets a new challenge PIN for restrictions. This is only for use by pre-installed
+ * apps and requires the MANAGE_USERS permission.
+ * @param newPin the PIN to use for challenge dialogs.
+ * @return Returns true if the challenge PIN was set successfully.
*/
- public boolean changeRestrictionsPin(String newPin) {
+ public boolean setRestrictionsChallenge(String newPin) {
try {
- return mService.changeRestrictionsPin(newPin);
+ return mService.setRestrictionsChallenge(newPin);
} catch (RemoteException re) {
Log.w(TAG, "Could not change restrictions pin");
}
@@ -674,9 +663,9 @@ public class UserManager {
* Returns {@link #PIN_VERIFICATION_SUCCESS} if the input matches the saved PIN. Returns
* {@link #PIN_VERIFICATION_FAILED_NOT_SET} if there is no PIN set.
*/
- public int checkRestrictionsPin(String pin) {
+ public int checkRestrictionsChallenge(String pin) {
try {
- return mService.checkRestrictionsPin(pin);
+ return mService.checkRestrictionsChallenge(pin);
} catch (RemoteException re) {
Log.w(TAG, "Could not check restrictions pin");
}
@@ -684,16 +673,17 @@ public class UserManager {
}
/**
+ * @hide
* Checks whether the user has restrictions that are PIN-protected. An application that
* participates in restrictions can check if the owner has requested a PIN challenge for
* any restricted operations. If there is a PIN in effect, the application should launch
- * the PIN challenge activity {@link android.content.Intent#ACTION_RESTRICTIONS_PIN_CHALLENGE}.
- * @see android.content.Intent#ACTION_RESTRICTIONS_PIN_CHALLENGE
+ * the PIN challenge activity {@link android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE}.
+ * @see android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE
* @return whether a restrictions PIN is in effect.
*/
- public boolean hasRestrictionsPin() {
+ public boolean hasRestrictionsChallenge() {
try {
- return mService.hasRestrictionsPin();
+ return mService.hasRestrictionsChallenge();
} catch (RemoteException re) {
Log.w(TAG, "Could not change restrictions pin");
}
diff --git a/core/java/com/android/internal/app/RestrictionsPinActivity.java b/core/java/com/android/internal/app/RestrictionsPinActivity.java
index 211247488ff38..66585c629099b 100644
--- a/core/java/com/android/internal/app/RestrictionsPinActivity.java
+++ b/core/java/com/android/internal/app/RestrictionsPinActivity.java
@@ -52,7 +52,7 @@ public class RestrictionsPinActivity extends AlertActivity
super.onCreate(icicle);
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
- mHasRestrictionsPin = mUserManager.hasRestrictionsPin();
+ mHasRestrictionsPin = mUserManager.hasRestrictionsChallenge();
initUi();
setupAlert();
}
@@ -83,7 +83,7 @@ public class RestrictionsPinActivity extends AlertActivity
super.onResume();
setPositiveButtonState(false);
- boolean hasPin = mUserManager.hasRestrictionsPin();
+ boolean hasPin = mUserManager.hasRestrictionsChallenge();
if (hasPin) {
mPinErrorMessage.setVisibility(View.INVISIBLE);
mPinText.setOnEditorActionListener(this);
@@ -100,7 +100,7 @@ public class RestrictionsPinActivity extends AlertActivity
private boolean updatePinTimer(int pinTimerMs) {
if (pinTimerMs < 0) {
- pinTimerMs = mUserManager.checkRestrictionsPin(null);
+ pinTimerMs = mUserManager.checkRestrictionsChallenge(null);
}
boolean enableInput;
if (pinTimerMs >= 200) {
@@ -128,7 +128,7 @@ public class RestrictionsPinActivity extends AlertActivity
}
protected void performPositiveButtonAction() {
- int result = mUserManager.checkRestrictionsPin(mPinText.getText().toString());
+ int result = mUserManager.checkRestrictionsChallenge(mPinText.getText().toString());
if (result == UserManager.PIN_VERIFICATION_SUCCESS) {
setResult(RESULT_OK);
finish();
diff --git a/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java b/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java
deleted file mode 100644
index f7fc6c67ed83e..0000000000000
--- a/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.app;
-
-import android.content.Context;
-import android.os.UserManager;
-import android.text.Editable;
-import android.text.TextUtils;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import com.android.internal.R;
-
-/**
- * This activity is launched by Settings and other apps to either create a new PIN or
- * change an existing PIN. The PIN is maintained by UserManager.
- */
-public class RestrictionsPinSetupActivity extends RestrictionsPinActivity {
-
- private EditText mNewPinText;
- private EditText mConfirmPinText;
-
- protected void initUi() {
- AlertController.AlertParams ap = mAlertParams;
- ap.mTitle = getString(R.string.restr_pin_enter_pin);
- ap.mPositiveButtonText = getString(R.string.ok);
- ap.mNegativeButtonText = getString(R.string.cancel);
- LayoutInflater inflater =
- (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- ap.mView = inflater.inflate(R.layout.restrictions_pin_setup, null);
-
- mPinText = (EditText) ap.mView.findViewById(R.id.pin_text);
- mNewPinText = (EditText) ap.mView.findViewById(R.id.pin_new_text);
- mConfirmPinText = (EditText) ap.mView.findViewById(R.id.pin_confirm_text);
- mNewPinText.addTextChangedListener(this);
- mConfirmPinText.addTextChangedListener(this);
-
- if (!mHasRestrictionsPin) {
- mPinText.setVisibility(View.GONE);
- }
- }
-
- public void onResume() {
- super.onResume();
- setPositiveButtonState(false);
- }
-
- protected boolean verifyingPin() {
- return false;
- }
-
- @Override
- protected void performPositiveButtonAction() {
- if (mHasRestrictionsPin) {
- int result = mUserManager.checkRestrictionsPin(mPinText.getText().toString());
- if (result != UserManager.PIN_VERIFICATION_SUCCESS) {
- // TODO: Set message that existing pin doesn't match
- return;
- }
- }
- if (mUserManager.changeRestrictionsPin(mNewPinText.getText().toString())) {
- // TODO: Send message to PIN recovery agent about the recovery email address
- setResult(RESULT_OK);
- finish();
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- CharSequence pin = mPinText.getText();
- CharSequence pin1 = mNewPinText.getText();
- CharSequence pin2 = mConfirmPinText.getText();
- boolean match = pin1 != null && pin2 != null && pin1.length() >= 4
- && pin1.toString().equals(pin2.toString())
- && (!mHasRestrictionsPin || (pin != null && pin.length() >= 4));
- boolean showError = !TextUtils.isEmpty(pin1) && !TextUtils.isEmpty(pin2);
- // TODO: Check recovery email address as well
- setPositiveButtonState(match);
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- }
-
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- performPositiveButtonAction();
- return true;
- }
-}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 49945f0d58f8c..83a0c56460682 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2546,25 +2546,13 @@
android:process=":ui">
-