diff options
author | Amith Yamasani <yamasani@google.com> | 2013-06-12 14:19:10 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2013-06-25 16:03:55 -0700 |
commit | 655d0e2029e6ae77a47e922dce4c4989818b8dd1 (patch) | |
tree | 67a9e2261c5e61f5a1b8f7f4f8cfcca5b433046c /core | |
parent | bf991a8f426921c26e21e54e493781e1d5eb39ff (diff) | |
download | frameworks_base-655d0e2029e6ae77a47e922dce4c4989818b8dd1.zip frameworks_base-655d0e2029e6ae77a47e922dce4c4989818b8dd1.tar.gz frameworks_base-655d0e2029e6ae77a47e922dce4c4989818b8dd1.tar.bz2 |
Single-user restrictions
Introduces a new "blocked" state for each package. This is used to temporarily
disable an app via Settings->Restrictions.
PIN creation and challenge activities for use by Settings and other apps. PIN
is stored by the User Manager and it manages the interval for retry attempts
across reboots.
Change-Id: I4915329d1f72399bbcaf93a9ca9c0d2e69d098dd
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ApplicationPackageManager.java | 22 | ||||
-rw-r--r-- | core/java/android/content/Intent.java | 12 | ||||
-rw-r--r-- | core/java/android/content/pm/ApplicationInfo.java | 9 | ||||
-rw-r--r-- | core/java/android/content/pm/IPackageManager.aidl | 3 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 17 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 29 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageUserState.java | 3 | ||||
-rw-r--r-- | core/java/android/os/IUserManager.aidl | 3 | ||||
-rw-r--r-- | core/java/android/os/UserManager.java | 58 | ||||
-rw-r--r-- | core/java/com/android/internal/app/AlertActivity.java | 14 | ||||
-rw-r--r-- | core/java/com/android/internal/app/RestrictionsPinActivity.java | 187 | ||||
-rw-r--r-- | core/java/com/android/internal/app/RestrictionsPinSetupActivity.java | 28 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 29 | ||||
-rw-r--r-- | core/res/res/layout/pin_challenge.xml | 84 | ||||
-rw-r--r-- | core/res/res/values/strings.xml | 18 | ||||
-rwxr-xr-x | core/res/res/values/symbols.xml | 7 |
16 files changed, 501 insertions, 22 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 271494f..432e9b1 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -1296,6 +1296,28 @@ final class ApplicationPackageManager extends PackageManager { return PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; } + @Override + public boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked, + UserHandle user) { + try { + return mPM.setApplicationBlockedSettingAsUser(packageName, blocked, + user.getIdentifier()); + } catch (RemoteException re) { + // Should never happen! + } + return false; + } + + @Override + public boolean getApplicationBlockedSettingAsUser(String packageName, UserHandle user) { + try { + return mPM.getApplicationBlockedSettingAsUser(packageName, user.getIdentifier()); + } catch (RemoteException re) { + // Should never happen! + } + return false; + } + /** * @hide */ diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 897e6fe..bda7112 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2440,6 +2440,18 @@ public class Intent implements Parcelable, Cloneable { "android.intent.action.GET_RESTRICTION_ENTRIES"; /** + * Activity to challenge the user for a PIN that was configured when setting up + * restrictions. 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#hasRestrictionsPin()}. + */ + public static final String ACTION_RESTRICTIONS_PIN_CHALLENGE = + "android.intent.action.RESTRICTIONS_PIN_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/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index 870610b..9c46d96 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -346,6 +346,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { public static final int FLAG_CANT_SAVE_STATE = 1<<28; /** + * Value for {@link #flags}: true if the application is blocked via restrictions and for + * most purposes is considered as not installed. + * {@hide} + */ + public static final int FLAG_BLOCKED = 1<<27; + + /** * Flags associated with the application. Any combination of * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE}, * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and @@ -359,7 +366,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { * {@link #FLAG_INSTALLED}. */ public int flags = 0; - + /** * The required smallest screen width the application can run on. If 0, * nothing has been specified. Comes from diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index a0e1555..eaff7b2 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -399,4 +399,7 @@ interface IPackageManager { /** Reflects current DeviceStorageMonitorService state */ boolean isStorageLow(); + + boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked, int userId); + boolean getApplicationBlockedSettingAsUser(String packageName, int userId); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 4266d85..8a8751e 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -3083,6 +3083,23 @@ public abstract class PackageManager { public abstract int getApplicationEnabledSetting(String packageName); /** + * Puts the package in a blocked state, which is almost like an uninstalled state, + * making the package unavailable, but it doesn't remove the data or the actual + * package file. + * @hide + */ + public abstract boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked, + UserHandle userHandle); + + /** + * Returns the blocked state of a package. + * @see #setApplicationBlockedSettingAsUser(String, boolean, UserHandle) + * @hide + */ + public abstract boolean getApplicationBlockedSettingAsUser(String packageName, + UserHandle userHandle); + + /** * Return whether the device has been booted into safe mode. */ public abstract boolean isSafeMode(); diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 883516e..8f0c62d 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -159,7 +159,8 @@ public class PackageParser { private static WeakReference<byte[]> mReadBuffer; private static boolean sCompatibilityModeEnabled = true; - private static final int PARSE_DEFAULT_INSTALL_LOCATION = PackageInfo.INSTALL_LOCATION_UNSPECIFIED; + private static final int PARSE_DEFAULT_INSTALL_LOCATION = + PackageInfo.INSTALL_LOCATION_UNSPECIFIED; static class ParsePackageItemArgs { final Package owner; @@ -274,15 +275,20 @@ public class PackageParser { grantedPermissions, state, UserHandle.getCallingUserId()); } - private static boolean checkUseInstalled(int flags, PackageUserState state) { - return state.installed || ((flags & PackageManager.GET_UNINSTALLED_PACKAGES) != 0); + /** + * Returns true if the package is installed and not blocked, or if the caller + * explicitly wanted all uninstalled and blocked packages as well. + */ + private static boolean checkUseInstalledOrBlocked(int flags, PackageUserState state) { + return (state.installed && !state.blocked) + || (flags & PackageManager.GET_UNINSTALLED_PACKAGES) != 0; } public static PackageInfo generatePackageInfo(PackageParser.Package p, int gids[], int flags, long firstInstallTime, long lastUpdateTime, HashSet<String> grantedPermissions, PackageUserState state, int userId) { - if (!checkUseInstalled(flags, state)) { + if (!checkUseInstalledOrBlocked(flags, state)) { return null; } PackageInfo pi = new PackageInfo(); @@ -3724,7 +3730,7 @@ public class PackageParser { return true; } } - if (!state.installed) { + if (!state.installed || state.blocked) { return true; } if (state.stopped) { @@ -3757,6 +3763,11 @@ public class PackageParser { } else { ai.flags &= ~ApplicationInfo.FLAG_INSTALLED; } + if (state.blocked) { + ai.flags |= ApplicationInfo.FLAG_BLOCKED; + } else { + ai.flags &= ~ApplicationInfo.FLAG_BLOCKED; + } if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { ai.enabled = true; } else if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) { @@ -3771,7 +3782,7 @@ public class PackageParser { public static ApplicationInfo generateApplicationInfo(Package p, int flags, PackageUserState state, int userId) { if (p == null) return null; - if (!checkUseInstalled(flags, state)) { + if (!checkUseInstalledOrBlocked(flags, state)) { return null; } if (!copyNeeded(flags, p, state, null, userId) @@ -3855,7 +3866,7 @@ public class PackageParser { public static final ActivityInfo generateActivityInfo(Activity a, int flags, PackageUserState state, int userId) { if (a == null) return null; - if (!checkUseInstalled(flags, state)) { + if (!checkUseInstalledOrBlocked(flags, state)) { return null; } if (!copyNeeded(flags, a.owner, state, a.metaData, userId)) { @@ -3892,7 +3903,7 @@ public class PackageParser { public static final ServiceInfo generateServiceInfo(Service s, int flags, PackageUserState state, int userId) { if (s == null) return null; - if (!checkUseInstalled(flags, state)) { + if (!checkUseInstalledOrBlocked(flags, state)) { return null; } if (!copyNeeded(flags, s.owner, state, s.metaData, userId)) { @@ -3937,7 +3948,7 @@ public class PackageParser { public static final ProviderInfo generateProviderInfo(Provider p, int flags, PackageUserState state, int userId) { if (p == null) return null; - if (!checkUseInstalled(flags, state)) { + if (!checkUseInstalledOrBlocked(flags, state)) { return null; } if (!copyNeeded(flags, p.owner, state, p.metaData, userId) diff --git a/core/java/android/content/pm/PackageUserState.java b/core/java/android/content/pm/PackageUserState.java index dcd54fc..94e3f79 100644 --- a/core/java/android/content/pm/PackageUserState.java +++ b/core/java/android/content/pm/PackageUserState.java @@ -28,6 +28,7 @@ public class PackageUserState { public boolean stopped; public boolean notLaunched; public boolean installed; + public boolean blocked; // Is the app restricted by owner / admin public int enabled; public String lastDisableAppCaller; @@ -37,6 +38,7 @@ public class PackageUserState { public PackageUserState() { installed = true; + blocked = false; enabled = COMPONENT_ENABLED_STATE_DEFAULT; } @@ -45,6 +47,7 @@ public class PackageUserState { stopped = o.stopped; notLaunched = o.notLaunched; enabled = o.enabled; + blocked = o.blocked; lastDisableAppCaller = o.lastDisableAppCaller; disabledComponents = o.disabledComponents != null ? new HashSet<String>(o.disabledComponents) : null; diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index a11358a..7589a5a 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -46,4 +46,7 @@ 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(); } diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index cb5ed4f..c33a28a 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -140,6 +140,13 @@ public class UserManager { */ public static final String DISALLOW_REMOVE_USER = "no_remove_user"; + /** @hide */ + public static final int PIN_VERIFICATION_FAILED_INCORRECT = -3; + /** @hide */ + public static final int PIN_VERIFICATION_FAILED_NOT_SET = -2; + /** @hide */ + public static final int PIN_VERIFICATION_SUCCESS = -1; + private static UserManager sInstance = null; /** @hide */ @@ -620,4 +627,55 @@ public class UserManager { Log.w(TAG, "Could not set application restrictions for user " + user.getIdentifier()); } } + + /** + * @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. + */ + public boolean changeRestrictionsPin(String newPin) { + try { + return mService.changeRestrictionsPin(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 checkRestrictionsPin(String pin) { + try { + return mService.checkRestrictionsPin(pin); + } catch (RemoteException re) { + Log.w(TAG, "Could not check restrictions pin"); + } + return PIN_VERIFICATION_FAILED_INCORRECT; + } + + /** + * 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 + * @return whether a restrictions PIN is in effect. + */ + public boolean hasRestrictionsPin() { + try { + return mService.hasRestrictionsPin(); + } catch (RemoteException re) { + Log.w(TAG, "Could not change restrictions pin"); + } + return false; + } } diff --git a/core/java/com/android/internal/app/AlertActivity.java b/core/java/com/android/internal/app/AlertActivity.java index 7251256..7456def 100644 --- a/core/java/com/android/internal/app/AlertActivity.java +++ b/core/java/com/android/internal/app/AlertActivity.java @@ -36,18 +36,18 @@ public abstract class AlertActivity extends Activity implements DialogInterface * @see #mAlertParams */ protected AlertController mAlert; - + /** * The parameters for the alert. */ protected AlertController.AlertParams mAlertParams; - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + mAlert = new AlertController(this, this, getWindow()); - mAlertParams = new AlertController.AlertParams(this); + mAlertParams = new AlertController.AlertParams(this); } public void cancel() { @@ -65,7 +65,7 @@ public abstract class AlertActivity extends Activity implements DialogInterface /** * Sets up the alert, including applying the parameters to the alert model, * and installing the alert's content. - * + * * @see #mAlert * @see #mAlertParams */ @@ -73,7 +73,7 @@ public abstract class AlertActivity extends Activity implements DialogInterface mAlertParams.apply(mAlert); mAlert.installContent(); } - + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mAlert.onKeyDown(keyCode, event)) return true; @@ -85,6 +85,4 @@ public abstract class AlertActivity extends Activity implements DialogInterface if (mAlert.onKeyUp(keyCode, event)) return true; return super.onKeyUp(keyCode, event); } - - } diff --git a/core/java/com/android/internal/app/RestrictionsPinActivity.java b/core/java/com/android/internal/app/RestrictionsPinActivity.java new file mode 100644 index 0000000..57436f7 --- /dev/null +++ b/core/java/com/android/internal/app/RestrictionsPinActivity.java @@ -0,0 +1,187 @@ +/* + * 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.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +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.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 DialogInterface.OnClickListener, TextWatcher, OnEditorActionListener { + + private UserManager mUserManager; + + private EditText mPin1Text; + private EditText mPin2Text; + private TextView mPinErrorMessage; + private TextView mPinMessage; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + 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); + ap.mPositiveButtonListener = this; + ap.mNegativeButtonListener = this; + LayoutInflater inflater = + (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); + ap.mView = inflater.inflate(R.layout.pin_challenge, null); + + mPinMessage = (TextView) ap.mView.findViewById(R.id.pin_message); + mPin1Text = (EditText) ap.mView.findViewById(R.id.pin1_text); + mPin2Text = (EditText) ap.mView.findViewById(R.id.pin2_text); + mPinErrorMessage = (TextView) ap.mView.findViewById(R.id.pin_error_message); + mPin1Text.addTextChangedListener(this); + mPin2Text.addTextChangedListener(this); + + mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); + + setupAlert(); + } + + protected boolean verifyingPin() { + return true; + } + + public void onResume() { + super.onResume(); + + setPositiveButtonState(false); + boolean hasPin = mUserManager.hasRestrictionsPin(); + if (verifyingPin()) { + if (hasPin) { + mPinMessage.setVisibility(View.GONE); + mPinErrorMessage.setVisibility(View.GONE); + mPin2Text.setVisibility(View.GONE); + mPin1Text.setOnEditorActionListener(this); + updatePinTimer(-1); + } else { + setResult(RESULT_OK); + finish(); + } + } else if (hasPin) { + // Shouldn't really be in this state, exit + setResult(RESULT_OK); + finish(); + } + } + + private void setPositiveButtonState(boolean enabled) { + mAlert.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enabled); + } + + private void updatePinTimer(int pinTimerMs) { + if (pinTimerMs < 0) { + pinTimerMs = mUserManager.checkRestrictionsPin(null); + } + if (pinTimerMs >= 200) { + final int seconds = (pinTimerMs + 200) / 1000; + final String formatString = getResources().getQuantityString( + R.plurals.restr_pin_countdown, + seconds); + mPinErrorMessage.setText(String.format(formatString, seconds)); + mPinErrorMessage.setVisibility(View.VISIBLE); + mPin1Text.setEnabled(false); + mPin1Text.setText(""); + setPositiveButtonState(false); + mPin1Text.postDelayed(mCountdownRunnable, Math.min(1000, pinTimerMs)); + } else { + mPinErrorMessage.setVisibility(View.INVISIBLE); + mPin1Text.setEnabled(true); + mPin1Text.setText(""); + } + } + + public void onClick(DialogInterface dialog, int which) { + setResult(RESULT_CANCELED); + if (which == AlertDialog.BUTTON_POSITIVE) { + performPositiveButtonAction(); + } else if (which == AlertDialog.BUTTON_NEGATIVE) { + finish(); + } + } + + private void performPositiveButtonAction() { + if (verifyingPin()) { + int result = mUserManager.checkRestrictionsPin(mPin1Text.getText().toString()); + if (result == UserManager.PIN_VERIFICATION_SUCCESS) { + setResult(RESULT_OK); + finish(); + } else if (result >= 0) { + updatePinTimer(result); + } + } else { + if (mUserManager.changeRestrictionsPin(mPin1Text.getText().toString())) { + 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 pin1 = mPin1Text.getText(); + if (!verifyingPin()) { + CharSequence pin2 = mPin2Text.getText(); + boolean match = pin1 != null && pin2 != null && pin1.length() >= 4 + && pin1.toString().equals(pin2.toString()); + setPositiveButtonState(match); + mPinErrorMessage.setVisibility(match ? View.INVISIBLE : View.VISIBLE); + } else { + setPositiveButtonState(pin1 != null && pin1.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() { + updatePinTimer(-1); + } + }; +} diff --git a/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java b/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java new file mode 100644 index 0000000..35f2967 --- /dev/null +++ b/core/java/com/android/internal/app/RestrictionsPinSetupActivity.java @@ -0,0 +1,28 @@ +/* + * 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; + +/** + * 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 RestrictionsPinSetupActivity extends RestrictionsPinActivity { + + protected boolean verifyingPin() { + return false; + } +} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index ca274e3..40d3428 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2432,6 +2432,29 @@ android:process=":ui"> </activity> + <activity android:name="com.android.internal.app.RestrictionsPinSetupActivity" + android:theme="@style/Theme.Holo.Dialog.Alert" + android:permission="android.permission.MANAGE_USERS" + android:excludeFromRecents="true" + android:windowSoftInputMode="adjustPan" + android:process=":ui"> + <intent-filter android:priority="100"> + <action android:name="android.intent.action.RESTRICTIONS_PIN_CREATE" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + + <activity android:name="com.android.internal.app.RestrictionsPinActivity" + android:theme="@style/Theme.Holo.Dialog.Alert" + android:excludeFromRecents="true" + android:windowSoftInputMode="adjustPan" + android:process=":ui"> + <intent-filter android:priority="100"> + <action android:name="android.intent.action.RESTRICTIONS_PIN_CHALLENGE" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> + <receiver android:name="com.android.server.BootReceiver" android:primaryUserOnly="true"> <intent-filter> @@ -2470,9 +2493,9 @@ </receiver> <receiver android:name="com.android.server.MasterClearReceiver" - android:permission="android.permission.MASTER_CLEAR" - android:priority="100" > - <intent-filter> + android:permission="android.permission.MASTER_CLEAR"> + <intent-filter + android:priority="100" > <!-- For Checkin, Settings, etc.: action=MASTER_CLEAR --> <action android:name="android.intent.action.MASTER_CLEAR" /> diff --git a/core/res/res/layout/pin_challenge.xml b/core/res/res/layout/pin_challenge.xml new file mode 100644 index 0000000..2cb14b4 --- /dev/null +++ b/core/res/res/layout/pin_challenge.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<!-- Layout used as the dialog's content View for EditTextPreference. --> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginTop="48dp" + android:layout_marginBottom="48dp" + android:overScrollMode="ifContentScrolls"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="8dip" + android:orientation="vertical"> + + <TextView android:id="@+id/pin_message" + style="?android:attr/textAppearanceMedium" + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/restr_pin_create_pin" + android:textColor="?android:attr/textColorSecondary" /> + + <!-- TextView android:id="@+id/pin1_label" + style="?android:attr/textAppearanceSmall" + android:layout_marginBottom="16dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/restr_pin_enter_pin" + android:textColor="?android:attr/textColorSecondary" /--> + + <EditText android:id="@+id/pin1_text" + style="?android:attr/textAppearanceMedium" + android:layout_marginBottom="16dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/restr_pin_enter_pin" + android:inputType="textPassword" + android:textColor="?android:attr/textColorPrimary" /> + + <!-- TextView android:id="@+id/pin2_label" + style="?android:attr/textAppearanceSmall" + android:layout_marginBottom="16dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/restr_pin_confirm_pin" + android:textColor="?android:attr/textColorSecondary" /--> + + <EditText android:id="@+id/pin2_text" + style="?android:attr/textAppearanceMedium" + android:layout_marginBottom="16dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/restr_pin_confirm_pin" + android:inputType="textPassword" + android:textColor="?android:attr/textColorPrimary" /> + + <TextView android:id="@+id/pin_error_message" + style="?android:attr/textAppearanceSmall" + android:layout_marginBottom="16dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/restr_pin_error_doesnt_match" + android:textColor="#FFFF0000" /> + + </LinearLayout> + +</ScrollView> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 1938b88..4b02a7d 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4018,7 +4018,7 @@ <!-- Message shown when user enters wrong PIN --> <string name="kg_wrong_pin">Wrong PIN</string> <!-- Countdown message shown after too many failed unlock attempts --> - <string name="kg_too_many_failed_attempts_countdown">Try again in <xliff:g id="number">%d</xliff:g> seconds.</string> + <string name="kg_too_many_failed_attempts_countdown">Try again in <xliff:g id="number">%1$d</xliff:g> seconds.</string> <!-- Instructions for using the pattern unlock screen --> <string name="kg_pattern_instructions">Draw your pattern</string> <!-- Instructions for using the SIM PIN unlock screen --> @@ -4227,4 +4227,20 @@ <!-- North America Tabloid media size: 11" × 17" --> <string name="mediaSize_na_tabloid">Tabloid</string> + <!-- PIN creation dialog message [CHAR LIMIT=none] --> + <string name="restr_pin_create_pin">Create a PIN for modifying restrictions</string> + <!-- PIN entry dialog label for PIN [CHAR LIMIT=none] --> + <string name="restr_pin_enter_pin">Enter PIN</string> + <!-- PIN entry dialog label for PIN confirmation [CHAR LIMIT=none] --> + <string name="restr_pin_confirm_pin">Confirm PIN</string> + <!-- PIN entry dialog error when PINs are not the same [CHAR LIMIT=none] --> + <string name="restr_pin_error_doesnt_match">PINs don\'t match. Try again.</string> + <!-- PIN entry dialog error when PIN is too short [CHAR LIMIT=none] --> + <string name="restr_pin_error_too_short">PIN is too short. Must be at least 4 digits.</string> + <!-- PIN entry dialog countdown message for next chance to enter the PIN [CHAR LIMIT=none] --> + <!-- Phrase describing a time duration using seconds [CHAR LIMIT=16] --> + <plurals name="restr_pin_countdown"> + <item quantity="one">Incorrect PIN. Try again in 1 second.</item> + <item quantity="other">Incorrect PIN. Try again in <xliff:g id="count">%d</xliff:g> seconds.</item> + </plurals> </resources> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 7f39364..a1166fc 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -213,6 +213,10 @@ <java-symbol type="id" name="sms_short_code_remember_undo_instruction" /> <java-symbol type="id" name="breadcrumb_section" /> <java-symbol type="id" name="action_bar_spinner" /> + <java-symbol type="id" name="pin_message" /> + <java-symbol type="id" name="pin1_text" /> + <java-symbol type="id" name="pin2_text" /> + <java-symbol type="id" name="pin_error_message" /> <java-symbol type="attr" name="actionModeShareDrawable" /> <java-symbol type="attr" name="alertDialogCenterButtons" /> @@ -898,6 +902,7 @@ <java-symbol type="string" name="mediaSize_na_junior_legal" /> <java-symbol type="string" name="mediaSize_na_ledger" /> <java-symbol type="string" name="mediaSize_na_tabloid" /> + <java-symbol type="string" name="restr_pin_enter_pin" /> <java-symbol type="plurals" name="abbrev_in_num_days" /> <java-symbol type="plurals" name="abbrev_in_num_hours" /> @@ -920,6 +925,7 @@ <java-symbol type="plurals" name="num_hours_ago" /> <java-symbol type="plurals" name="num_minutes_ago" /> <java-symbol type="plurals" name="num_seconds_ago" /> + <java-symbol type="plurals" name="restr_pin_countdown" /> <java-symbol type="array" name="carrier_properties" /> <java-symbol type="array" name="config_data_usage_network_types" /> @@ -1145,6 +1151,7 @@ <java-symbol type="layout" name="sms_short_code_confirmation_dialog" /> <java-symbol type="layout" name="action_bar_up_container" /> <java-symbol type="layout" name="app_not_authorized" /> + <java-symbol type="layout" name="pin_challenge" /> <java-symbol type="anim" name="slide_in_child_bottom" /> <java-symbol type="anim" name="slide_in_right" /> |