Loading api/current.xml +66 −31 Original line number Diff line number Diff line Loading @@ -20208,7 +20208,7 @@ deprecated="not deprecated" visibility="public" > <method name="getActiveMinimumPasswordLength" <method name="getCurrentFailedPasswordAttempts" return="int" abstract="false" native="false" Loading @@ -20219,8 +20219,8 @@ visibility="public" > </method> <method name="getActivePasswordMode" return="int" <method name="getMaximumTimeToLock" return="long" abstract="false" native="false" synchronized="false" Loading @@ -20230,7 +20230,7 @@ visibility="public" > </method> <method name="getCurrentFailedPasswordAttempts" <method name="getMinimumPasswordLength" return="int" abstract="false" native="false" Loading @@ -20241,8 +20241,8 @@ visibility="public" > </method> <method name="getMaximumTimeToLock" return="long" <method name="getPasswordMode" return="int" abstract="false" native="false" synchronized="false" Loading @@ -20252,8 +20252,8 @@ visibility="public" > </method> <method name="getMinimumPasswordLength" return="int" <method name="isActivePasswordSufficient" return="boolean" abstract="false" native="false" synchronized="false" Loading @@ -20263,8 +20263,8 @@ visibility="public" > </method> <method name="getPasswordMode" return="int" <method name="isAdminActive" return="boolean" abstract="false" native="false" synchronized="false" Loading @@ -20273,9 +20273,11 @@ deprecated="not deprecated" visibility="public" > <parameter name="who" type="android.content.ComponentName"> </parameter> </method> <method name="isAdminActive" return="boolean" <method name="lockNow" return="void" abstract="false" native="false" synchronized="false" Loading @@ -20284,8 +20286,6 @@ deprecated="not deprecated" visibility="public" > <parameter name="who" type="android.content.ComponentName"> </parameter> </method> <method name="removeActiveAdmin" return="void" Loading @@ -20300,6 +20300,19 @@ <parameter name="who" type="android.content.ComponentName"> </parameter> </method> <method name="resetPassword" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="password" type="java.lang.String"> </parameter> </method> <method name="setMaximumTimeToLock" return="void" abstract="false" Loading Loading @@ -20395,7 +20408,7 @@ type="int" transient="false" volatile="false" value="2000" value="3000" static="true" final="true" deprecated="not deprecated" Loading @@ -20406,40 +20419,29 @@ type="int" transient="false" volatile="false" value="1000" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="PASSWORD_MODE_UNSPECIFIED" type="int" transient="false" volatile="false" value="0" value="2000" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="WIPE_EXTERNAL_STORAGE" <field name="PASSWORD_MODE_SOMETHING" type="int" transient="false" volatile="false" value="2" value="1000" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="WIPE_LOW_LEVEL_FORMAT" <field name="PASSWORD_MODE_UNSPECIFIED" type="int" transient="false" volatile="false" value="1" value="0" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -53548,6 +53550,17 @@ <parameter name="stroke" type="android.gesture.GestureStroke"> </parameter> </method> <method name="clone" return="java.lang.Object" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="describeContents" return="int" abstract="false" Loading Loading @@ -54737,6 +54750,17 @@ <parameter name="t" type="long"> </parameter> </constructor> <method name="clone" return="java.lang.Object" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <field name="timestamp" type="long" transient="false" Loading Loading @@ -55061,6 +55085,17 @@ visibility="public" > </method> <method name="clone" return="java.lang.Object" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="computeOrientedBoundingBox" return="android.gesture.OrientedBoundingBox" abstract="false" core/java/android/app/DevicePolicyManager.java +73 −41 Original line number Diff line number Diff line Loading @@ -79,9 +79,10 @@ public class DevicePolicyManager { * Activity action: have the user enter a new password. This activity * should be launched after using {@link #setPasswordMode(ComponentName, int)} * or {@link #setMinimumPasswordLength(ComponentName, int)} to have the * user enter a new password that meets the current requirements. If the * current password is sufficient, the activity will exit immediately without * being displayed to the user. Upon receiving a result from this activity, * user enter a new password that meets the current requirements. You can * use {@link #isActivePasswordSufficient()} to determine whether you need * to have the user select a new password in order to meet the current * constraints. Upon being resumed from this activity, * you can check the new password characteristics to see if they are * sufficient. */ Loading Loading @@ -122,21 +123,31 @@ public class DevicePolicyManager { /** * Constant for {@link #setPasswordMode}: the policy has no requirements * for the password. * for the password. Note that mode constants are ordered so that higher * values are more restrictive. */ public static final int PASSWORD_MODE_UNSPECIFIED = 0; /** * Constant for {@link #setPasswordMode}: the policy requires some kind * of password, but doesn't care what it is. Note that mode constants * are ordered so that higher values are more restrictive. */ public static final int PASSWORD_MODE_SOMETHING = 1000; /** * Constant for {@link #setPasswordMode}: the user must have at least a * numeric password. * numeric password. Note that mode constants are ordered so that higher * values are more restrictive. */ public static final int PASSWORD_MODE_NUMERIC = 1000; public static final int PASSWORD_MODE_NUMERIC = 2000; /** * Constant for {@link #setPasswordMode}: the user must have at least an * alphanumeric password. * alphanumeric password. Note that mode constants are ordered so that higher * values are more restrictive. */ public static final int PASSWORD_MODE_ALPHANUMERIC = 2000; public static final int PASSWORD_MODE_ALPHANUMERIC = 3000; /** * Called by an application that is administering the device to set the Loading @@ -147,10 +158,15 @@ public class DevicePolicyManager { * take place immediately. To prompt the user for a new password, use * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. * * <p>Mode constants are ordered so that higher values are more restrictive; * thus the highest requested mode constant (between the policy set here, * the user's preference, and any other considerations) is the one that * is in effect. * * @param admin Which {@link DeviceAdmin} this request is associated with. * @param mode The new desired mode. One of * {@link #PASSWORD_MODE_UNSPECIFIED}, {@link #PASSWORD_MODE_NUMERIC}, * or {@link #PASSWORD_MODE_ALPHANUMERIC}. * {@link #PASSWORD_MODE_UNSPECIFIED}, {@link #PASSWORD_MODE_SOMETHING}, * {@link #PASSWORD_MODE_NUMERIC}, or {@link #PASSWORD_MODE_ALPHANUMERIC}. */ public void setPasswordMode(ComponentName admin, int mode) { if (mService != null) { Loading @@ -177,21 +193,6 @@ public class DevicePolicyManager { return PASSWORD_MODE_UNSPECIFIED; } /** * Retrieve the password mode associated with the last password the * user selected. */ public int getActivePasswordMode() { if (mService != null) { try { return mService.getActivePasswordMode(); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } return PASSWORD_MODE_UNSPECIFIED; } /** * Called by an application that is administering the device to set the * minimum allowed password length. After setting this, the user Loading Loading @@ -234,18 +235,22 @@ public class DevicePolicyManager { } /** * Retrieve the password length associated with the last password the * user selected. * Determine whether the current password the user has set is sufficient * to meet the policy requirements (mode, minimum length) that have been * requested. * * @return Returns true if the password meets the current requirements, * else false. */ public int getActiveMinimumPasswordLength() { public boolean isActivePasswordSufficient() { if (mService != null) { try { return mService.getActiveMinimumPasswordLength(); return mService.isActivePasswordSufficient(); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } return 0; return false; } /** Loading @@ -263,6 +268,30 @@ public class DevicePolicyManager { return -1; } /** * Force a new password on the user. This takes effect immediately. The * given password must meet the current password minimum length constraint * or it will be rejected. The given password will be accepted regardless * of the current password mode, automatically adjusting the password mode * higher if needed. (The string you give here is acceptable for any mode; * if it contains only digits, that is still an acceptable alphanumeric * password.) * * @param password The new password for the user. * @return Returns true if the password was applied, or false if it is * not acceptable for the current constraints. */ public boolean resetPassword(String password) { if (mService != null) { try { return mService.resetPassword(password); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } return false; } /** * Called by an application that is administering the device to set the * maximum time for user activity until the device will lock. This limits Loading Loading @@ -298,22 +327,25 @@ public class DevicePolicyManager { } /** * Constant for {@link #wipeData}: perform a low-level format of data * storage. * Make the device lock immediately, as if the lock screen timeout has * expired at the point of this call. */ public static final int WIPE_LOW_LEVEL_FORMAT = 0x0001; /** * Constant for {@link #wipeData}: also wipe any external storage. */ public static final int WIPE_EXTERNAL_STORAGE = 0x0002; public void lockNow() { if (mService != null) { try { mService.lockNow(); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } } /** * Ask the user date be wiped. This will cause the device to reboot, * erasing all user data while next booting up. * erasing all user data while next booting up. External storage such * as SD cards will not be erased. * * @param flags Bit mask of additional options: currently * {@link #WIPE_LOW_LEVEL_FORMAT} and {@link #WIPE_EXTERNAL_STORAGE}. * @param flags Bit mask of additional options: currently must be 0. */ public void wipeData(int flags) { if (mService != null) { Loading core/java/android/app/IDevicePolicyManager.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -26,17 +26,20 @@ import android.content.ComponentName; interface IDevicePolicyManager { void setPasswordMode(in ComponentName who, int mode); int getPasswordMode(); int getActivePasswordMode(); void setMinimumPasswordLength(in ComponentName who, int length); int getMinimumPasswordLength(); int getActiveMinimumPasswordLength(); boolean isActivePasswordSufficient(); int getCurrentFailedPasswordAttempts(); boolean resetPassword(String password); void setMaximumTimeToLock(in ComponentName who, long timeMs); long getMaximumTimeToLock(); void lockNow(); void wipeData(int flags); void setActiveAdmin(in ComponentName policyReceiver); Loading core/java/android/os/IPowerManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ interface IPowerManager void setPokeLock(int pokey, IBinder lock, String tag); int getSupportedWakeLockFlags(); void setStayOnSetting(int val); void setMaximumScreenOffTimeount(int timeMs); void preventScreenOn(boolean prevent); boolean isScreenOn(); void reboot(String reason); Loading core/java/com/android/internal/widget/LockPatternUtils.java +36 −22 Original line number Diff line number Diff line Loading @@ -79,9 +79,9 @@ public class LockPatternUtils { * pin = digit-only password * password = alphanumeric password */ public static final int MODE_PATTERN = 0; public static final int MODE_PIN = 1; public static final int MODE_PASSWORD = 2; public static final int MODE_PATTERN = DevicePolicyManager.PASSWORD_MODE_SOMETHING; public static final int MODE_PIN = DevicePolicyManager.PASSWORD_MODE_NUMERIC; public static final int MODE_PASSWORD = DevicePolicyManager.PASSWORD_MODE_ALPHANUMERIC; /** * The minimum number of dots the user must include in a wrong pattern Loading @@ -95,6 +95,7 @@ public class LockPatternUtils { private final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen"; public final static String PASSWORD_TYPE_KEY = "lockscreen.password_type"; private final Context mContext; private final ContentResolver mContentResolver; private DevicePolicyManager mDevicePolicyManager; private static String sLockPatternFilename; Loading @@ -104,6 +105,7 @@ public class LockPatternUtils { * @param contentResolver Used to look up and save settings. */ public LockPatternUtils(Context context) { mContext = context; mContentResolver = context.getContentResolver(); mDevicePolicyManager = (DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE); Loading @@ -126,10 +128,6 @@ public class LockPatternUtils { return mDevicePolicyManager.getMinimumPasswordLength(); } public int getActiveMinimumPasswordLength() { return mDevicePolicyManager.getActiveMinimumPasswordLength(); } /** * Gets the device policy password mode. If the mode is non-specific, returns * MODE_PATTERN which allows the user to choose anything. Loading @@ -154,10 +152,6 @@ public class LockPatternUtils { * * @return */ public int getActivePasswordMode() { return mDevicePolicyManager.getActivePasswordMode(); } public void reportFailedPasswordAttempt() { mDevicePolicyManager.reportFailedPasswordAttempt(); } Loading Loading @@ -278,6 +272,16 @@ public class LockPatternUtils { return getBoolean(PATTERN_EVER_CHOSEN_KEY); } /** * Clear any lock pattern or password. */ public void clearLock() { saveLockPassword(null, LockPatternUtils.MODE_PATTERN); setLockPatternEnabled(false); saveLockPattern(null); setLong(PASSWORD_TYPE_KEY, MODE_PATTERN); } /** * Save a lock pattern. * @param pattern The new pattern to save. Loading @@ -295,11 +299,13 @@ public class LockPatternUtils { raf.write(hash, 0, hash.length); } raf.close(); if (pattern != null) { setBoolean(PATTERN_EVER_CHOSEN_KEY, true); setLong(PASSWORD_TYPE_KEY, MODE_PATTERN); if (pattern != null && isDevicePolicyActive()) { setActivePasswordState(DevicePolicyManager.PASSWORD_MODE_UNSPECIFIED, pattern.size()); DevicePolicyManager dpm = (DevicePolicyManager)mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); dpm.setActivePasswordState( DevicePolicyManager.PASSWORD_MODE_SOMETHING, pattern.size()); } } catch (FileNotFoundException fnfe) { // Cant do much, unless we want to fail over to using the settings provider Loading @@ -314,9 +320,8 @@ public class LockPatternUtils { * Save a lock password. * @param password The password to save */ public void saveLockPassword(String password) { public void saveLockPassword(String password, int mode) { // Compute the hash boolean numericHint = password != null ? TextUtils.isDigitsOnly(password) : false; final byte[] hash = LockPatternUtils.passwordToHash(password); try { // Write the hash to file Loading @@ -328,10 +333,15 @@ public class LockPatternUtils { raf.write(hash, 0, hash.length); } raf.close(); setLong(PASSWORD_TYPE_KEY, numericHint ? MODE_PIN : MODE_PASSWORD); if (password != null && isDevicePolicyActive()) { setActivePasswordState(numericHint ? DevicePolicyManager.PASSWORD_MODE_NUMERIC : DevicePolicyManager.PASSWORD_MODE_ALPHANUMERIC, password.length()); if (password != null) { int textMode = TextUtils.isDigitsOnly(password) ? MODE_PIN : MODE_PASSWORD; if (textMode > mode) { mode = textMode; } setLong(PASSWORD_TYPE_KEY, mode); DevicePolicyManager dpm = (DevicePolicyManager)mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); dpm.setActivePasswordState(mode, password.length()); } } catch (FileNotFoundException fnfe) { // Cant do much, unless we want to fail over to using the settings provider Loading Loading @@ -554,6 +564,7 @@ public class LockPatternUtils { } private boolean getBoolean(String systemSettingKey) { // STOPSHIP: these need to be moved to secure settings! return 1 == android.provider.Settings.System.getInt( mContentResolver, Loading @@ -561,6 +572,7 @@ public class LockPatternUtils { } private void setBoolean(String systemSettingKey, boolean enabled) { // STOPSHIP: these need to be moved to secure settings! android.provider.Settings.System.putInt( mContentResolver, systemSettingKey, Loading @@ -568,10 +580,12 @@ public class LockPatternUtils { } private long getLong(String systemSettingKey, long def) { // STOPSHIP: these need to be moved to secure settings! return android.provider.Settings.System.getLong(mContentResolver, systemSettingKey, def); } private void setLong(String systemSettingKey, long value) { // STOPSHIP: these need to be moved to secure settings! android.provider.Settings.System.putLong(mContentResolver, systemSettingKey, value); } Loading Loading
api/current.xml +66 −31 Original line number Diff line number Diff line Loading @@ -20208,7 +20208,7 @@ deprecated="not deprecated" visibility="public" > <method name="getActiveMinimumPasswordLength" <method name="getCurrentFailedPasswordAttempts" return="int" abstract="false" native="false" Loading @@ -20219,8 +20219,8 @@ visibility="public" > </method> <method name="getActivePasswordMode" return="int" <method name="getMaximumTimeToLock" return="long" abstract="false" native="false" synchronized="false" Loading @@ -20230,7 +20230,7 @@ visibility="public" > </method> <method name="getCurrentFailedPasswordAttempts" <method name="getMinimumPasswordLength" return="int" abstract="false" native="false" Loading @@ -20241,8 +20241,8 @@ visibility="public" > </method> <method name="getMaximumTimeToLock" return="long" <method name="getPasswordMode" return="int" abstract="false" native="false" synchronized="false" Loading @@ -20252,8 +20252,8 @@ visibility="public" > </method> <method name="getMinimumPasswordLength" return="int" <method name="isActivePasswordSufficient" return="boolean" abstract="false" native="false" synchronized="false" Loading @@ -20263,8 +20263,8 @@ visibility="public" > </method> <method name="getPasswordMode" return="int" <method name="isAdminActive" return="boolean" abstract="false" native="false" synchronized="false" Loading @@ -20273,9 +20273,11 @@ deprecated="not deprecated" visibility="public" > <parameter name="who" type="android.content.ComponentName"> </parameter> </method> <method name="isAdminActive" return="boolean" <method name="lockNow" return="void" abstract="false" native="false" synchronized="false" Loading @@ -20284,8 +20286,6 @@ deprecated="not deprecated" visibility="public" > <parameter name="who" type="android.content.ComponentName"> </parameter> </method> <method name="removeActiveAdmin" return="void" Loading @@ -20300,6 +20300,19 @@ <parameter name="who" type="android.content.ComponentName"> </parameter> </method> <method name="resetPassword" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="password" type="java.lang.String"> </parameter> </method> <method name="setMaximumTimeToLock" return="void" abstract="false" Loading Loading @@ -20395,7 +20408,7 @@ type="int" transient="false" volatile="false" value="2000" value="3000" static="true" final="true" deprecated="not deprecated" Loading @@ -20406,40 +20419,29 @@ type="int" transient="false" volatile="false" value="1000" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="PASSWORD_MODE_UNSPECIFIED" type="int" transient="false" volatile="false" value="0" value="2000" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="WIPE_EXTERNAL_STORAGE" <field name="PASSWORD_MODE_SOMETHING" type="int" transient="false" volatile="false" value="2" value="1000" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="WIPE_LOW_LEVEL_FORMAT" <field name="PASSWORD_MODE_UNSPECIFIED" type="int" transient="false" volatile="false" value="1" value="0" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -53548,6 +53550,17 @@ <parameter name="stroke" type="android.gesture.GestureStroke"> </parameter> </method> <method name="clone" return="java.lang.Object" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="describeContents" return="int" abstract="false" Loading Loading @@ -54737,6 +54750,17 @@ <parameter name="t" type="long"> </parameter> </constructor> <method name="clone" return="java.lang.Object" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <field name="timestamp" type="long" transient="false" Loading Loading @@ -55061,6 +55085,17 @@ visibility="public" > </method> <method name="clone" return="java.lang.Object" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="computeOrientedBoundingBox" return="android.gesture.OrientedBoundingBox" abstract="false"
core/java/android/app/DevicePolicyManager.java +73 −41 Original line number Diff line number Diff line Loading @@ -79,9 +79,10 @@ public class DevicePolicyManager { * Activity action: have the user enter a new password. This activity * should be launched after using {@link #setPasswordMode(ComponentName, int)} * or {@link #setMinimumPasswordLength(ComponentName, int)} to have the * user enter a new password that meets the current requirements. If the * current password is sufficient, the activity will exit immediately without * being displayed to the user. Upon receiving a result from this activity, * user enter a new password that meets the current requirements. You can * use {@link #isActivePasswordSufficient()} to determine whether you need * to have the user select a new password in order to meet the current * constraints. Upon being resumed from this activity, * you can check the new password characteristics to see if they are * sufficient. */ Loading Loading @@ -122,21 +123,31 @@ public class DevicePolicyManager { /** * Constant for {@link #setPasswordMode}: the policy has no requirements * for the password. * for the password. Note that mode constants are ordered so that higher * values are more restrictive. */ public static final int PASSWORD_MODE_UNSPECIFIED = 0; /** * Constant for {@link #setPasswordMode}: the policy requires some kind * of password, but doesn't care what it is. Note that mode constants * are ordered so that higher values are more restrictive. */ public static final int PASSWORD_MODE_SOMETHING = 1000; /** * Constant for {@link #setPasswordMode}: the user must have at least a * numeric password. * numeric password. Note that mode constants are ordered so that higher * values are more restrictive. */ public static final int PASSWORD_MODE_NUMERIC = 1000; public static final int PASSWORD_MODE_NUMERIC = 2000; /** * Constant for {@link #setPasswordMode}: the user must have at least an * alphanumeric password. * alphanumeric password. Note that mode constants are ordered so that higher * values are more restrictive. */ public static final int PASSWORD_MODE_ALPHANUMERIC = 2000; public static final int PASSWORD_MODE_ALPHANUMERIC = 3000; /** * Called by an application that is administering the device to set the Loading @@ -147,10 +158,15 @@ public class DevicePolicyManager { * take place immediately. To prompt the user for a new password, use * {@link #ACTION_SET_NEW_PASSWORD} after setting this value. * * <p>Mode constants are ordered so that higher values are more restrictive; * thus the highest requested mode constant (between the policy set here, * the user's preference, and any other considerations) is the one that * is in effect. * * @param admin Which {@link DeviceAdmin} this request is associated with. * @param mode The new desired mode. One of * {@link #PASSWORD_MODE_UNSPECIFIED}, {@link #PASSWORD_MODE_NUMERIC}, * or {@link #PASSWORD_MODE_ALPHANUMERIC}. * {@link #PASSWORD_MODE_UNSPECIFIED}, {@link #PASSWORD_MODE_SOMETHING}, * {@link #PASSWORD_MODE_NUMERIC}, or {@link #PASSWORD_MODE_ALPHANUMERIC}. */ public void setPasswordMode(ComponentName admin, int mode) { if (mService != null) { Loading @@ -177,21 +193,6 @@ public class DevicePolicyManager { return PASSWORD_MODE_UNSPECIFIED; } /** * Retrieve the password mode associated with the last password the * user selected. */ public int getActivePasswordMode() { if (mService != null) { try { return mService.getActivePasswordMode(); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } return PASSWORD_MODE_UNSPECIFIED; } /** * Called by an application that is administering the device to set the * minimum allowed password length. After setting this, the user Loading Loading @@ -234,18 +235,22 @@ public class DevicePolicyManager { } /** * Retrieve the password length associated with the last password the * user selected. * Determine whether the current password the user has set is sufficient * to meet the policy requirements (mode, minimum length) that have been * requested. * * @return Returns true if the password meets the current requirements, * else false. */ public int getActiveMinimumPasswordLength() { public boolean isActivePasswordSufficient() { if (mService != null) { try { return mService.getActiveMinimumPasswordLength(); return mService.isActivePasswordSufficient(); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } return 0; return false; } /** Loading @@ -263,6 +268,30 @@ public class DevicePolicyManager { return -1; } /** * Force a new password on the user. This takes effect immediately. The * given password must meet the current password minimum length constraint * or it will be rejected. The given password will be accepted regardless * of the current password mode, automatically adjusting the password mode * higher if needed. (The string you give here is acceptable for any mode; * if it contains only digits, that is still an acceptable alphanumeric * password.) * * @param password The new password for the user. * @return Returns true if the password was applied, or false if it is * not acceptable for the current constraints. */ public boolean resetPassword(String password) { if (mService != null) { try { return mService.resetPassword(password); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } return false; } /** * Called by an application that is administering the device to set the * maximum time for user activity until the device will lock. This limits Loading Loading @@ -298,22 +327,25 @@ public class DevicePolicyManager { } /** * Constant for {@link #wipeData}: perform a low-level format of data * storage. * Make the device lock immediately, as if the lock screen timeout has * expired at the point of this call. */ public static final int WIPE_LOW_LEVEL_FORMAT = 0x0001; /** * Constant for {@link #wipeData}: also wipe any external storage. */ public static final int WIPE_EXTERNAL_STORAGE = 0x0002; public void lockNow() { if (mService != null) { try { mService.lockNow(); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } } } /** * Ask the user date be wiped. This will cause the device to reboot, * erasing all user data while next booting up. * erasing all user data while next booting up. External storage such * as SD cards will not be erased. * * @param flags Bit mask of additional options: currently * {@link #WIPE_LOW_LEVEL_FORMAT} and {@link #WIPE_EXTERNAL_STORAGE}. * @param flags Bit mask of additional options: currently must be 0. */ public void wipeData(int flags) { if (mService != null) { Loading
core/java/android/app/IDevicePolicyManager.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -26,17 +26,20 @@ import android.content.ComponentName; interface IDevicePolicyManager { void setPasswordMode(in ComponentName who, int mode); int getPasswordMode(); int getActivePasswordMode(); void setMinimumPasswordLength(in ComponentName who, int length); int getMinimumPasswordLength(); int getActiveMinimumPasswordLength(); boolean isActivePasswordSufficient(); int getCurrentFailedPasswordAttempts(); boolean resetPassword(String password); void setMaximumTimeToLock(in ComponentName who, long timeMs); long getMaximumTimeToLock(); void lockNow(); void wipeData(int flags); void setActiveAdmin(in ComponentName policyReceiver); Loading
core/java/android/os/IPowerManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ interface IPowerManager void setPokeLock(int pokey, IBinder lock, String tag); int getSupportedWakeLockFlags(); void setStayOnSetting(int val); void setMaximumScreenOffTimeount(int timeMs); void preventScreenOn(boolean prevent); boolean isScreenOn(); void reboot(String reason); Loading
core/java/com/android/internal/widget/LockPatternUtils.java +36 −22 Original line number Diff line number Diff line Loading @@ -79,9 +79,9 @@ public class LockPatternUtils { * pin = digit-only password * password = alphanumeric password */ public static final int MODE_PATTERN = 0; public static final int MODE_PIN = 1; public static final int MODE_PASSWORD = 2; public static final int MODE_PATTERN = DevicePolicyManager.PASSWORD_MODE_SOMETHING; public static final int MODE_PIN = DevicePolicyManager.PASSWORD_MODE_NUMERIC; public static final int MODE_PASSWORD = DevicePolicyManager.PASSWORD_MODE_ALPHANUMERIC; /** * The minimum number of dots the user must include in a wrong pattern Loading @@ -95,6 +95,7 @@ public class LockPatternUtils { private final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen"; public final static String PASSWORD_TYPE_KEY = "lockscreen.password_type"; private final Context mContext; private final ContentResolver mContentResolver; private DevicePolicyManager mDevicePolicyManager; private static String sLockPatternFilename; Loading @@ -104,6 +105,7 @@ public class LockPatternUtils { * @param contentResolver Used to look up and save settings. */ public LockPatternUtils(Context context) { mContext = context; mContentResolver = context.getContentResolver(); mDevicePolicyManager = (DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE); Loading @@ -126,10 +128,6 @@ public class LockPatternUtils { return mDevicePolicyManager.getMinimumPasswordLength(); } public int getActiveMinimumPasswordLength() { return mDevicePolicyManager.getActiveMinimumPasswordLength(); } /** * Gets the device policy password mode. If the mode is non-specific, returns * MODE_PATTERN which allows the user to choose anything. Loading @@ -154,10 +152,6 @@ public class LockPatternUtils { * * @return */ public int getActivePasswordMode() { return mDevicePolicyManager.getActivePasswordMode(); } public void reportFailedPasswordAttempt() { mDevicePolicyManager.reportFailedPasswordAttempt(); } Loading Loading @@ -278,6 +272,16 @@ public class LockPatternUtils { return getBoolean(PATTERN_EVER_CHOSEN_KEY); } /** * Clear any lock pattern or password. */ public void clearLock() { saveLockPassword(null, LockPatternUtils.MODE_PATTERN); setLockPatternEnabled(false); saveLockPattern(null); setLong(PASSWORD_TYPE_KEY, MODE_PATTERN); } /** * Save a lock pattern. * @param pattern The new pattern to save. Loading @@ -295,11 +299,13 @@ public class LockPatternUtils { raf.write(hash, 0, hash.length); } raf.close(); if (pattern != null) { setBoolean(PATTERN_EVER_CHOSEN_KEY, true); setLong(PASSWORD_TYPE_KEY, MODE_PATTERN); if (pattern != null && isDevicePolicyActive()) { setActivePasswordState(DevicePolicyManager.PASSWORD_MODE_UNSPECIFIED, pattern.size()); DevicePolicyManager dpm = (DevicePolicyManager)mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); dpm.setActivePasswordState( DevicePolicyManager.PASSWORD_MODE_SOMETHING, pattern.size()); } } catch (FileNotFoundException fnfe) { // Cant do much, unless we want to fail over to using the settings provider Loading @@ -314,9 +320,8 @@ public class LockPatternUtils { * Save a lock password. * @param password The password to save */ public void saveLockPassword(String password) { public void saveLockPassword(String password, int mode) { // Compute the hash boolean numericHint = password != null ? TextUtils.isDigitsOnly(password) : false; final byte[] hash = LockPatternUtils.passwordToHash(password); try { // Write the hash to file Loading @@ -328,10 +333,15 @@ public class LockPatternUtils { raf.write(hash, 0, hash.length); } raf.close(); setLong(PASSWORD_TYPE_KEY, numericHint ? MODE_PIN : MODE_PASSWORD); if (password != null && isDevicePolicyActive()) { setActivePasswordState(numericHint ? DevicePolicyManager.PASSWORD_MODE_NUMERIC : DevicePolicyManager.PASSWORD_MODE_ALPHANUMERIC, password.length()); if (password != null) { int textMode = TextUtils.isDigitsOnly(password) ? MODE_PIN : MODE_PASSWORD; if (textMode > mode) { mode = textMode; } setLong(PASSWORD_TYPE_KEY, mode); DevicePolicyManager dpm = (DevicePolicyManager)mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); dpm.setActivePasswordState(mode, password.length()); } } catch (FileNotFoundException fnfe) { // Cant do much, unless we want to fail over to using the settings provider Loading Loading @@ -554,6 +564,7 @@ public class LockPatternUtils { } private boolean getBoolean(String systemSettingKey) { // STOPSHIP: these need to be moved to secure settings! return 1 == android.provider.Settings.System.getInt( mContentResolver, Loading @@ -561,6 +572,7 @@ public class LockPatternUtils { } private void setBoolean(String systemSettingKey, boolean enabled) { // STOPSHIP: these need to be moved to secure settings! android.provider.Settings.System.putInt( mContentResolver, systemSettingKey, Loading @@ -568,10 +580,12 @@ public class LockPatternUtils { } private long getLong(String systemSettingKey, long def) { // STOPSHIP: these need to be moved to secure settings! return android.provider.Settings.System.getLong(mContentResolver, systemSettingKey, def); } private void setLong(String systemSettingKey, long value) { // STOPSHIP: these need to be moved to secure settings! android.provider.Settings.System.putLong(mContentResolver, systemSettingKey, value); } Loading