diff options
author | Fyodor Kupolov <fkupolov@google.com> | 2015-05-06 13:18:46 -0700 |
---|---|---|
committer | Fyodor Kupolov <fkupolov@google.com> | 2015-05-06 13:36:03 -0700 |
commit | ef24909d84db9d5aefb825ee1556089fcdcc1678 (patch) | |
tree | f0cd8934ba94f56783628e16279dfea9d3fb1532 /core | |
parent | a1d3c508e160b35f4f8ef56c2fb2fd6f65d5cbbd (diff) | |
download | frameworks_base-ef24909d84db9d5aefb825ee1556089fcdcc1678.zip frameworks_base-ef24909d84db9d5aefb825ee1556089fcdcc1678.tar.gz frameworks_base-ef24909d84db9d5aefb825ee1556089fcdcc1678.tar.bz2 |
Remove restrictions PIN functionality
Bug: 20852231
Change-Id: I5666ee28ff1341ead9b258bc0852d8ba6d313c5e
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/content/Intent.java | 15 | ||||
-rw-r--r-- | core/java/android/os/IUserManager.aidl | 3 | ||||
-rw-r--r-- | core/java/android/os/UserManager.java | 45 | ||||
-rw-r--r-- | core/java/com/android/internal/app/RestrictionsPinActivity.java | 181 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 11 |
5 files changed, 3 insertions, 252 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 54fe786..80c6306 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2588,21 +2588,6 @@ 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. 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.<p/> - * Before launching this activity, make sure that there is a PIN in effect, by calling - * {@link android.os.UserManager#hasRestrictionsChallenge()}. - */ - 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 * perform one time initialization. (This will not be seen by third * party applications because a newly initialized user does not have any diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index c2fd3c3..811418b 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -49,9 +49,6 @@ interface IUserManager { int userHandle); Bundle getApplicationRestrictions(in String packageName); Bundle getApplicationRestrictionsForUser(in String packageName, int userHandle); - boolean setRestrictionsChallenge(in String newPin); - int checkRestrictionsChallenge(in String pin); - boolean hasRestrictionsChallenge(); void removeRestrictions(); void setDefaultGuestRestrictions(in Bundle restrictions); Bundle getDefaultGuestRestrictions(); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 44eb1ed..c7ac7ce 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -744,7 +744,7 @@ public class UserManager { * @see #getSerialNumberForUser(UserHandle) */ public UserHandle getUserForSerialNumber(long serialNumber) { - int ident = getUserHandle((int)serialNumber); + int ident = getUserHandle((int) serialNumber); return ident >= 0 ? new UserHandle(ident) : null; } @@ -1252,49 +1252,10 @@ public class UserManager { * 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. + * @deprecated The restrictions PIN functionality is no longer provided by the system. + * This method is preserved for backwards compatibility reasons and always returns false. */ public boolean setRestrictionsChallenge(String newPin) { - try { - return mService.setRestrictionsChallenge(newPin); - } catch (RemoteException re) { - Log.w(TAG, "Could not change restrictions pin"); - } - return false; - } - - /** - * @hide - * @param pin The PIN to verify, or null to get the number of milliseconds to wait for before - * allowing the user to enter the PIN. - * @return Returns a positive number (including zero) for how many milliseconds before - * you can accept another PIN, when the input is null or the input doesn't match the saved PIN. - * 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 checkRestrictionsChallenge(String pin) { - try { - return mService.checkRestrictionsChallenge(pin); - } catch (RemoteException re) { - Log.w(TAG, "Could not check restrictions pin"); - } - return PIN_VERIFICATION_FAILED_INCORRECT; - } - - /** - * @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_CHALLENGE}. - * @see android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE - * @return whether a restrictions PIN is in effect. - */ - public boolean hasRestrictionsChallenge() { - try { - return mService.hasRestrictionsChallenge(); - } catch (RemoteException re) { - Log.w(TAG, "Could not change restrictions pin"); - } return false; } diff --git a/core/java/com/android/internal/app/RestrictionsPinActivity.java b/core/java/com/android/internal/app/RestrictionsPinActivity.java deleted file mode 100644 index 66585c6..0000000 --- a/core/java/com/android/internal/app/RestrictionsPinActivity.java +++ /dev/null @@ -1,181 +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.Bundle; -import android.os.UserManager; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -import com.android.internal.R; - -/** - * This activity is launched by Settings and other apps to either create a new PIN or - * challenge for an existing PIN. The PIN is maintained by UserManager. - */ -public class RestrictionsPinActivity extends AlertActivity - implements OnClickListener, TextWatcher, OnEditorActionListener { - - protected UserManager mUserManager; - protected boolean mHasRestrictionsPin; - - protected EditText mPinText; - protected TextView mPinErrorMessage; - private Button mOkButton; - private Button mCancelButton; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); - mHasRestrictionsPin = mUserManager.hasRestrictionsChallenge(); - initUi(); - setupAlert(); - } - - protected void initUi() { - AlertController.AlertParams ap = mAlertParams; - ap.mTitle = getString(R.string.restr_pin_enter_admin_pin); - LayoutInflater inflater = - (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - ap.mView = inflater.inflate(R.layout.restrictions_pin_challenge, null); - - mPinErrorMessage = (TextView) ap.mView.findViewById(R.id.pin_error_message); - mPinText = (EditText) ap.mView.findViewById(R.id.pin_text); - mOkButton = (Button) ap.mView.findViewById(R.id.pin_ok_button); - mCancelButton = (Button) ap.mView.findViewById(R.id.pin_cancel_button); - - mPinText.addTextChangedListener(this); - - mOkButton.setOnClickListener(this); - mCancelButton.setOnClickListener(this); - } - - protected boolean verifyingPin() { - return true; - } - - public void onResume() { - super.onResume(); - - setPositiveButtonState(false); - boolean hasPin = mUserManager.hasRestrictionsChallenge(); - if (hasPin) { - mPinErrorMessage.setVisibility(View.INVISIBLE); - mPinText.setOnEditorActionListener(this); - updatePinTimer(-1); - } else if (verifyingPin()) { - setResult(RESULT_OK); - finish(); - } - } - - protected void setPositiveButtonState(boolean enabled) { - mOkButton.setEnabled(enabled); - } - - private boolean updatePinTimer(int pinTimerMs) { - if (pinTimerMs < 0) { - pinTimerMs = mUserManager.checkRestrictionsChallenge(null); - } - boolean enableInput; - if (pinTimerMs >= 200) { - // Do the count down timer for less than a minute, otherwise just say try again later. - if (pinTimerMs <= 60000) { - final int seconds = (pinTimerMs + 200) / 1000; - final String formatString = getResources().getQuantityString( - R.plurals.restr_pin_countdown, - seconds); - mPinErrorMessage.setText(String.format(formatString, seconds)); - } else { - mPinErrorMessage.setText(R.string.restr_pin_try_later); - } - enableInput = false; - mPinErrorMessage.setVisibility(View.VISIBLE); - mPinText.setText(""); - mPinText.postDelayed(mCountdownRunnable, Math.min(1000, pinTimerMs)); - } else { - enableInput = true; - mPinErrorMessage.setText(R.string.restr_pin_incorrect); - } - mPinText.setEnabled(enableInput); - setPositiveButtonState(enableInput); - return enableInput; - } - - protected void performPositiveButtonAction() { - int result = mUserManager.checkRestrictionsChallenge(mPinText.getText().toString()); - if (result == UserManager.PIN_VERIFICATION_SUCCESS) { - setResult(RESULT_OK); - finish(); - } else if (result >= 0) { - mPinErrorMessage.setText(R.string.restr_pin_incorrect); - mPinErrorMessage.setVisibility(View.VISIBLE); - updatePinTimer(result); - mPinText.setText(""); - } - } - - @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(); - setPositiveButtonState(pin != null && pin.length() >= 4); - } - - @Override - public void afterTextChanged(Editable s) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - performPositiveButtonAction(); - return true; - } - - private Runnable mCountdownRunnable = new Runnable() { - public void run() { - if (updatePinTimer(-1)) { - // If we are no longer counting down, clear the message. - mPinErrorMessage.setVisibility(View.INVISIBLE); - } - } - }; - - @Override - public void onClick(View v) { - if (v == mOkButton) { - performPositiveButtonAction(); - } else if (v == mCancelButton) { - setResult(RESULT_CANCELED); - finish(); - } - } -} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index e3930cd..0c5c1b2 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2578,17 +2578,6 @@ android:process=":ui"> </activity> - <activity android:name="com.android.internal.app.RestrictionsPinActivity" - android:theme="@style/Theme.Material.DayNight.Dialog.Alert" - android:excludeFromRecents="true" - android:windowSoftInputMode="adjustPan" - android:process=":ui"> - <intent-filter android:priority="100"> - <action android:name="android.intent.action.RESTRICTIONS_CHALLENGE" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </activity> - <receiver android:name="com.android.server.BootReceiver" android:primaryUserOnly="true"> <intent-filter android:priority="1000"> |