summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java76
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java4
-rw-r--r--core/java/com/android/internal/midi/MidiFramer.java51
-rw-r--r--core/java/com/android/internal/statusbar/IStatusBar.aidl2
-rw-r--r--core/java/com/android/internal/statusbar/IStatusBarService.aidl2
-rw-r--r--core/java/com/android/internal/util/ImageUtils.java2
-rw-r--r--core/java/com/android/internal/widget/LockPatternUtils.java237
7 files changed, 153 insertions, 221 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index a6c39e6..e347faa 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -307,7 +307,7 @@ public class ChooserActivity extends ResolverActivity {
ResolveListAdapter createAdapter(Context context, Intent[] initialIntents,
List<ResolveInfo> rList, int launchedFromUid, boolean filterLastUsed) {
final ChooserListAdapter adapter = new ChooserListAdapter(context, initialIntents, rList,
- launchedFromUid, filterLastUsed);
+ launchedFromUid, filterLastUsed, mCallerChooserTargets);
if (DEBUG) Log.d(TAG, "Adapter created; querying services");
queryTargetServices(adapter);
return adapter;
@@ -315,45 +315,70 @@ public class ChooserActivity extends ResolverActivity {
class ChooserTargetInfo implements TargetInfo {
private final TargetInfo mSourceInfo;
+ private final ResolveInfo mBackupResolveInfo;
private final ChooserTarget mChooserTarget;
private final Drawable mDisplayIcon;
+ public ChooserTargetInfo(ChooserTarget target) {
+ this(null, target);
+ }
+
public ChooserTargetInfo(TargetInfo sourceInfo, ChooserTarget chooserTarget) {
mSourceInfo = sourceInfo;
mChooserTarget = chooserTarget;
mDisplayIcon = new BitmapDrawable(getResources(), chooserTarget.getIcon());
+
+ if (sourceInfo != null) {
+ mBackupResolveInfo = null;
+ } else {
+ mBackupResolveInfo = getPackageManager().resolveActivity(getResolvedIntent(), 0);
+ }
}
@Override
public Intent getResolvedIntent() {
final Intent targetIntent = mChooserTarget.getIntent();
- return targetIntent != null ? targetIntent : mSourceInfo.getResolvedIntent();
+ if (targetIntent != null) {
+ return targetIntent;
+ } else if (mSourceInfo != null) {
+ return mSourceInfo.getResolvedIntent();
+ }
+ return getTargetIntent();
}
@Override
public ComponentName getResolvedComponentName() {
- return mSourceInfo.getResolvedComponentName();
+ if (mSourceInfo != null) {
+ return mSourceInfo.getResolvedComponentName();
+ } else if (mBackupResolveInfo != null) {
+ return new ComponentName(mBackupResolveInfo.activityInfo.packageName,
+ mBackupResolveInfo.activityInfo.name);
+ }
+ return null;
+ }
+
+ private Intent getFillInIntent() {
+ return mSourceInfo != null ? mSourceInfo.getResolvedIntent() : getTargetIntent();
}
@Override
public boolean start(Activity activity, Bundle options) {
- return mChooserTarget.sendIntent(activity, mSourceInfo.getResolvedIntent());
+ return mChooserTarget.sendIntent(activity, getFillInIntent());
}
@Override
public boolean startAsCaller(Activity activity, Bundle options, int userId) {
- return mChooserTarget.sendIntentAsCaller(activity, mSourceInfo.getResolvedIntent(),
- userId);
+ return mChooserTarget.sendIntentAsCaller(activity, getFillInIntent(), userId);
}
@Override
public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
- return mChooserTarget.sendIntentAsUser(activity, mSourceInfo.getResolvedIntent(), user);
+ return mChooserTarget.sendIntentAsUser(activity, getFillInIntent(), user);
}
@Override
public ResolveInfo getResolveInfo() {
- return mSourceInfo.getResolveInfo();
+ return mSourceInfo != null ? mSourceInfo.getResolveInfo() : mBackupResolveInfo;
}
@Override
@@ -363,7 +388,7 @@ public class ChooserActivity extends ResolverActivity {
@Override
public CharSequence getExtendedInfo() {
- return mSourceInfo.getExtendedInfo();
+ return mSourceInfo != null ? mSourceInfo.getExtendedInfo() : null;
}
@Override
@@ -374,10 +399,17 @@ public class ChooserActivity extends ResolverActivity {
public class ChooserListAdapter extends ResolveListAdapter {
private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>();
+ private final List<ChooserTargetInfo> mCallerTargets = new ArrayList<>();
public ChooserListAdapter(Context context, Intent[] initialIntents, List<ResolveInfo> rList,
- int launchedFromUid, boolean filterLastUsed) {
+ int launchedFromUid, boolean filterLastUsed, ChooserTarget[] callerChooserTargets) {
super(context, initialIntents, rList, launchedFromUid, filterLastUsed);
+
+ if (callerChooserTargets != null) {
+ for (ChooserTarget target : callerChooserTargets) {
+ mCallerTargets.add(new ChooserTargetInfo(target));
+ }
+ }
}
@Override
@@ -407,23 +439,25 @@ public class ChooserActivity extends ResolverActivity {
@Override
public int getCount() {
- int count = super.getCount();
- if (mServiceTargets != null) {
- count += mServiceTargets.size();
- }
- return count;
+ return super.getCount() + mServiceTargets.size() + mCallerTargets.size();
}
@Override
public TargetInfo getItem(int position) {
int offset = 0;
- if (mServiceTargets != null) {
- final int serviceTargetCount = mServiceTargets.size();
- if (position < serviceTargetCount) {
- return mServiceTargets.get(position);
- }
- offset += serviceTargetCount;
+
+ final int callerTargetCount = mCallerTargets.size();
+ if (position < callerTargetCount) {
+ return mCallerTargets.get(position);
}
+ offset += callerTargetCount;
+
+ final int serviceTargetCount = mServiceTargets.size();
+ if (position - offset < serviceTargetCount) {
+ return mServiceTargets.get(position - offset);
+ }
+ offset += serviceTargetCount;
+
return super.getItem(position - offset);
}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 7f51d92..8dd7836 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -376,6 +376,10 @@ public class ResolverActivity extends Activity implements AdapterView.OnItemClic
}
}
+ public Intent getTargetIntent() {
+ return mIntent;
+ }
+
private String getReferrerPackageName() {
final Uri referrer = getReferrer();
if (referrer != null && "android-app".equals(referrer.getScheme())) {
diff --git a/core/java/com/android/internal/midi/MidiFramer.java b/core/java/com/android/internal/midi/MidiFramer.java
index 53d71bb..1a7fa0b 100644
--- a/core/java/com/android/internal/midi/MidiFramer.java
+++ b/core/java/com/android/internal/midi/MidiFramer.java
@@ -17,6 +17,7 @@
package com.android.internal.midi;
import android.media.midi.MidiReceiver;
+import android.util.Log;
import java.io.IOException;
@@ -38,6 +39,7 @@ public class MidiFramer extends MidiReceiver {
private int mCount;
private int mRunningStatus;
private int mNeeded;
+ private boolean mInSysEx;
public MidiFramer(MidiReceiver receiver) {
mReceiver = receiver;
@@ -52,12 +54,14 @@ public class MidiFramer extends MidiReceiver {
}
/*
- * @see android.midi.MidiReceiver#onPost(byte[], int, int, long)
+ * @see android.midi.MidiReceiver#onReceive(byte[], int, int, long)
*/
@Override
public void onReceive(byte[] data, int offset, int count, long timestamp)
throws IOException {
// Log.i(TAG, formatMidiData(data, offset, count));
+ int sysExStartOffset = (mInSysEx ? offset : -1);
+
for (int i = 0; i < count; i++) {
int b = data[offset] & 0xFF;
if (b >= 0x80) { // status byte?
@@ -66,27 +70,50 @@ public class MidiFramer extends MidiReceiver {
mCount = 1;
mNeeded = MidiConstants.getBytesPerMessage(b) - 1;
} else if (b < 0xF8) { // system common?
- mBuffer[0] = (byte) b;
- mRunningStatus = 0;
- mCount = 1;
- mNeeded = MidiConstants.getBytesPerMessage(b) - 1;
+ if (b == 0xF0 /* SysEx Start */) {
+ // Log.i(TAG, "SysEx Start");
+ mInSysEx = true;
+ sysExStartOffset = offset;
+ } else if (b == 0xF7 /* SysEx End */) {
+ // Log.i(TAG, "SysEx End");
+ if (mInSysEx) {
+ mReceiver.sendWithTimestamp(data, sysExStartOffset,
+ offset - sysExStartOffset, timestamp);
+ mInSysEx = false;
+ sysExStartOffset = -1;
+ }
+ } else {
+ mBuffer[0] = (byte) b;
+ mRunningStatus = 0;
+ mCount = 1;
+ mNeeded = MidiConstants.getBytesPerMessage(b) - 1;
+ }
} else { // real-time?
// Single byte message interleaved with other data.
mReceiver.sendWithTimestamp(data, offset, 1, timestamp);
}
} else { // data byte
- mBuffer[mCount++] = (byte) b;
- if (--mNeeded == 0) {
- if (mRunningStatus != 0) {
- mBuffer[0] = (byte) mRunningStatus;
+ // Save SysEx data for SysEx End marker or end of buffer.
+ if (!mInSysEx) {
+ mBuffer[mCount++] = (byte) b;
+ if (--mNeeded == 0) {
+ if (mRunningStatus != 0) {
+ mBuffer[0] = (byte) mRunningStatus;
+ }
+ mReceiver.sendWithTimestamp(mBuffer, 0, mCount, timestamp);
+ mNeeded = MidiConstants.getBytesPerMessage(mBuffer[0]) - 1;
+ mCount = 1;
}
- mReceiver.sendWithTimestamp(mBuffer, 0, mCount, timestamp);
- mNeeded = MidiConstants.getBytesPerMessage(mBuffer[0]) - 1;
- mCount = 1;
}
}
++offset;
}
+
+ // send any accumulatedSysEx data
+ if (sysExStartOffset >= 0) {
+ mReceiver.sendWithTimestamp(data, sysExStartOffset,
+ offset - sysExStartOffset, timestamp);
+ }
}
}
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index 2b0d244..9f99f62 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -24,7 +24,7 @@ oneway interface IStatusBar
{
void setIcon(int index, in StatusBarIcon icon);
void removeIcon(int index);
- void disable(int state);
+ void disable(int state1, int state2);
void animateExpandNotificationsPanel();
void animateExpandSettingsPanel();
void animateCollapsePanels();
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 87e0603..663c838 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -28,6 +28,8 @@ interface IStatusBarService
void collapsePanels();
void disable(int what, IBinder token, String pkg);
void disableForUser(int what, IBinder token, String pkg, int userId);
+ void disable2(int what, IBinder token, String pkg);
+ void disable2ForUser(int what, IBinder token, String pkg, int userId);
void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription);
void setIconVisibility(String slot, boolean visible);
void removeIcon(String slot);
diff --git a/core/java/com/android/internal/util/ImageUtils.java b/core/java/com/android/internal/util/ImageUtils.java
index 7d56e9e..a0d0b20 100644
--- a/core/java/com/android/internal/util/ImageUtils.java
+++ b/core/java/com/android/internal/util/ImageUtils.java
@@ -66,7 +66,7 @@ public class ImageUtils {
COMPACT_BITMAP_SIZE, COMPACT_BITMAP_SIZE, Bitmap.Config.ARGB_8888
);
mTempCompactBitmapCanvas = new Canvas(mTempCompactBitmap);
- mTempCompactBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mTempCompactBitmapPaint = new Paint();
mTempCompactBitmapPaint.setFilterBitmap(true);
}
mTempMatrix.reset();
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 1096e34..3d23986 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -17,9 +17,11 @@
package com.android.internal.widget;
import android.Manifest;
+import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
+import android.bluetooth.BluetoothClass;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -142,11 +144,6 @@ public class LockPatternUtils {
private DevicePolicyManager mDevicePolicyManager;
private ILockSettings mLockSettingsService;
- private final boolean mMultiUserMode;
-
- // The current user is set by KeyguardViewMediator and shared by all LockPatternUtils.
- private static volatile int sCurrentUserId = UserHandle.USER_NULL;
-
public DevicePolicyManager getDevicePolicyManager() {
if (mDevicePolicyManager == null) {
mDevicePolicyManager =
@@ -171,12 +168,6 @@ public class LockPatternUtils {
public LockPatternUtils(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
-
- // If this is being called by the system or by an application like keyguard that
- // has permision INTERACT_ACROSS_USERS, then LockPatternUtils will operate in multi-user
- // mode where calls are for the current user rather than the user of the calling process.
- mMultiUserMode = context.checkCallingOrSelfPermission(
- Manifest.permission.INTERACT_ACROSS_USERS_FULL) == PackageManager.PERMISSION_GRANTED;
}
private ILockSettings getLockSettings() {
@@ -188,93 +179,55 @@ public class LockPatternUtils {
return mLockSettingsService;
}
- public int getRequestedMinimumPasswordLength() {
- return getDevicePolicyManager().getPasswordMinimumLength(null, getCurrentOrCallingUserId());
+ public int getRequestedMinimumPasswordLength(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumLength(null, userId);
}
/**
* Gets the device policy password mode. If the mode is non-specific, returns
* MODE_PATTERN which allows the user to choose anything.
*/
- public int getRequestedPasswordQuality() {
- return getDevicePolicyManager().getPasswordQuality(null, getCurrentOrCallingUserId());
- }
-
- public int getRequestedPasswordHistoryLength() {
- return getRequestedPasswordHistoryLength(getCurrentOrCallingUserId());
+ public int getRequestedPasswordQuality(int userId) {
+ return getDevicePolicyManager().getPasswordQuality(null, userId);
}
private int getRequestedPasswordHistoryLength(int userId) {
return getDevicePolicyManager().getPasswordHistoryLength(null, userId);
}
- public int getRequestedPasswordMinimumLetters() {
- return getDevicePolicyManager().getPasswordMinimumLetters(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumLetters(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumLetters(null, userId);
}
- public int getRequestedPasswordMinimumUpperCase() {
- return getDevicePolicyManager().getPasswordMinimumUpperCase(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumUpperCase(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumUpperCase(null, userId);
}
- public int getRequestedPasswordMinimumLowerCase() {
- return getDevicePolicyManager().getPasswordMinimumLowerCase(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumLowerCase(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumLowerCase(null, userId);
}
- public int getRequestedPasswordMinimumNumeric() {
- return getDevicePolicyManager().getPasswordMinimumNumeric(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumNumeric(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumNumeric(null, userId);
}
- public int getRequestedPasswordMinimumSymbols() {
- return getDevicePolicyManager().getPasswordMinimumSymbols(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumSymbols(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumSymbols(null, userId);
}
- public int getRequestedPasswordMinimumNonLetter() {
- return getDevicePolicyManager().getPasswordMinimumNonLetter(null,
- getCurrentOrCallingUserId());
+ public int getRequestedPasswordMinimumNonLetter(int userId) {
+ return getDevicePolicyManager().getPasswordMinimumNonLetter(null, userId);
}
- public void reportFailedPasswordAttempt() {
- int userId = getCurrentOrCallingUserId();
+ public void reportFailedPasswordAttempt(int userId) {
getDevicePolicyManager().reportFailedPasswordAttempt(userId);
getTrustManager().reportUnlockAttempt(false /* authenticated */, userId);
getTrustManager().reportRequireCredentialEntry(userId);
}
- public void reportSuccessfulPasswordAttempt() {
- getDevicePolicyManager().reportSuccessfulPasswordAttempt(getCurrentOrCallingUserId());
- getTrustManager().reportUnlockAttempt(true /* authenticated */,
- getCurrentOrCallingUserId());
- }
-
- public void setCurrentUser(int userId) {
- sCurrentUserId = userId;
- }
-
- public int getCurrentUser() {
- if (sCurrentUserId != UserHandle.USER_NULL) {
- // Someone is regularly updating using setCurrentUser() use that value.
- return sCurrentUserId;
- }
- try {
- return ActivityManagerNative.getDefault().getCurrentUser().id;
- } catch (RemoteException re) {
- return UserHandle.USER_OWNER;
- }
- }
-
- private int getCurrentOrCallingUserId() {
- if (mMultiUserMode) {
- // TODO: This is a little inefficient. See if all users of this are able to
- // handle USER_CURRENT and pass that instead.
- return getCurrentUser();
- } else {
- return UserHandle.getCallingUserId();
- }
+ public void reportSuccessfulPasswordAttempt(int userId) {
+ getDevicePolicyManager().reportSuccessfulPasswordAttempt(userId);
+ getTrustManager().reportUnlockAttempt(true /* authenticated */, userId);
}
/**
@@ -286,8 +239,7 @@ public class LockPatternUtils {
* @param challenge The challenge to verify against the pattern
* @return the attestation that the challenge was verified, or null.
*/
- public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge) {
- final int userId = getCurrentOrCallingUserId();
+ public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge, int userId) {
try {
return getLockSettings().verifyPattern(patternToString(pattern), challenge, userId);
} catch (RemoteException re) {
@@ -301,8 +253,7 @@ public class LockPatternUtils {
* @param pattern The pattern to check.
* @return Whether the pattern matches the stored one.
*/
- public boolean checkPattern(List<LockPatternView.Cell> pattern) {
- final int userId = getCurrentOrCallingUserId();
+ public boolean checkPattern(List<LockPatternView.Cell> pattern, int userId) {
try {
return getLockSettings().checkPattern(patternToString(pattern), userId);
} catch (RemoteException re) {
@@ -319,8 +270,7 @@ public class LockPatternUtils {
* @param challenge The challenge to verify against the password
* @return the attestation that the challenge was verified, or null.
*/
- public byte[] verifyPassword(String password, long challenge) {
- final int userId = getCurrentOrCallingUserId();
+ public byte[] verifyPassword(String password, long challenge, int userId) {
try {
return getLockSettings().verifyPassword(password, challenge, userId);
} catch (RemoteException re) {
@@ -334,8 +284,7 @@ public class LockPatternUtils {
* @param password The password to check.
* @return Whether the password matches the stored one.
*/
- public boolean checkPassword(String password) {
- final int userId = getCurrentOrCallingUserId();
+ public boolean checkPassword(String password, int userId) {
try {
return getLockSettings().checkPassword(password, userId);
} catch (RemoteException re) {
@@ -348,8 +297,7 @@ public class LockPatternUtils {
* Note that this also clears vold's copy of the password.
* @return Whether the vold password matches or not.
*/
- public boolean checkVoldPassword() {
- final int userId = getCurrentOrCallingUserId();
+ public boolean checkVoldPassword(int userId) {
try {
return getLockSettings().checkVoldPassword(userId);
} catch (RemoteException re) {
@@ -364,8 +312,7 @@ public class LockPatternUtils {
* @param password The password to check.
* @return Whether the password matches any in the history.
*/
- public boolean checkPasswordHistory(String password) {
- int userId = getCurrentOrCallingUserId();
+ public boolean checkPasswordHistory(String password, int userId) {
String passwordHashString = new String(
passwordToHash(password, userId), StandardCharsets.UTF_8);
String passwordHistory = getString(PASSWORD_HISTORY_KEY, userId);
@@ -374,7 +321,7 @@ public class LockPatternUtils {
}
// Password History may be too long...
int passwordHashLength = passwordHashString.length();
- int passwordHistoryLength = getRequestedPasswordHistoryLength();
+ int passwordHistoryLength = getRequestedPasswordHistoryLength(userId);
if(passwordHistoryLength == 0) {
return false;
}
@@ -416,16 +363,8 @@ public class LockPatternUtils {
*
* @return True if the user has ever chosen a pattern.
*/
- public boolean isPatternEverChosen() {
- return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, getCurrentOrCallingUserId());
- }
-
- /**
- * Used by device policy manager to validate the current password
- * information it has.
- */
- public int getActivePasswordQuality() {
- return getActivePasswordQuality(getCurrentOrCallingUserId());
+ public boolean isPatternEverChosen(int userId) {
+ return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, userId);
}
/**
@@ -448,10 +387,6 @@ public class LockPatternUtils {
return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
}
- public void clearLock() {
- clearLock(getCurrentOrCallingUserId());
- }
-
/**
* Clear any lock pattern or password.
*/
@@ -479,16 +414,6 @@ public class LockPatternUtils {
}
/**
- * Disable showing lock screen at all when the DevicePolicyManager allows it.
- * This is only meaningful if pattern, pin or password are not set.
- *
- * @param disable Disables lock screen when true
- */
- public void setLockScreenDisabled(boolean disable) {
- setLockScreenDisabled(disable, getCurrentOrCallingUserId());
- }
-
- /**
* Disable showing lock screen at all for a given user.
* This is only meaningful if pattern, pin or password are not set.
*
@@ -505,21 +430,16 @@ public class LockPatternUtils {
*
* @return true if lock screen is disabled
*/
- public boolean isLockScreenDisabled() {
- return !isSecure() &&
- getBoolean(DISABLE_LOCKSCREEN_KEY, false, getCurrentOrCallingUserId());
+ public boolean isLockScreenDisabled(int userId) {
+ return !isSecure(userId) &&
+ getBoolean(DISABLE_LOCKSCREEN_KEY, false, userId);
}
/**
* Save a lock pattern.
* @param pattern The new pattern to save.
- * @param savedPattern The previously saved pattern, or null if none
+ * @param userId the user whose pattern is to be saved.
*/
- public void saveLockPattern(List<LockPatternView.Cell> pattern,
- String savedPattern) {
- this.saveLockPattern(pattern, savedPattern, getCurrentOrCallingUserId());
- }
-
public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) {
this.saveLockPattern(pattern, null, userId);
}
@@ -588,8 +508,7 @@ public class LockPatternUtils {
updateCryptoUserInfo(userId);
}
- public void setOwnerInfoEnabled(boolean enabled) {
- int userId = getCurrentOrCallingUserId();
+ public void setOwnerInfoEnabled(boolean enabled, int userId) {
setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled, userId);
updateCryptoUserInfo(userId);
}
@@ -598,11 +517,7 @@ public class LockPatternUtils {
return getString(LOCK_SCREEN_OWNER_INFO, userId);
}
- public boolean isOwnerInfoEnabled() {
- return isOwnerInfoEnabled(getCurrentOrCallingUserId());
- }
-
- private boolean isOwnerInfoEnabled(int userId) {
+ public boolean isOwnerInfoEnabled(int userId) {
return getBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, false, userId);
}
@@ -724,21 +639,10 @@ public class LockPatternUtils {
/**
* Save a lock password. Does not ensure that the password is as good
* as the requested mode, but will adjust the mode to be as good as the
- * pattern.
+ * password.
* @param password The password to save
* @param savedPassword The previously saved lock password, or null if none
* @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
- */
- public void saveLockPassword(String password, String savedPassword, int quality) {
- saveLockPassword(password, savedPassword, quality, getCurrentOrCallingUserId());
- }
-
- /**
- * Save a lock password. Does not ensure that the password is as good
- * as the requested mode, but will adjust the mode to be as good as the
- * pattern.
- * @param password The password to save
- * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
* @param userHandle The userId of the user to change the password for
*/
public void saveLockPassword(String password, String savedPassword, int quality,
@@ -865,16 +769,6 @@ public class LockPatternUtils {
}
/**
- * Retrieves the quality mode we're in.
- * {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
- *
- * @return stored password quality
- */
- public int getKeyguardStoredPasswordQuality() {
- return getKeyguardStoredPasswordQuality(getCurrentOrCallingUserId());
- }
-
- /**
* Retrieves the quality mode for {@param userHandle}.
* {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)}
*
@@ -997,13 +891,6 @@ public class LockPatternUtils {
}
/**
- * @return Whether the lock screen is secured.
- */
- public boolean isSecure() {
- return isSecure(getCurrentOrCallingUserId());
- }
-
- /**
* @param userId the user for which to report the value
* @return Whether the lock screen is secured.
*/
@@ -1012,13 +899,6 @@ public class LockPatternUtils {
return isLockPatternEnabled(mode, userId) || isLockPasswordEnabled(mode, userId);
}
- /**
- * @return Whether the lock password is enabled
- */
- public boolean isLockPasswordEnabled() {
- return isLockPasswordEnabled(getCurrentOrCallingUserId());
- }
-
public boolean isLockPasswordEnabled(int userId) {
return isLockPasswordEnabled(getKeyguardStoredPasswordQuality(userId), userId);
}
@@ -1035,10 +915,6 @@ public class LockPatternUtils {
/**
* @return Whether the lock pattern is enabled
*/
- public boolean isLockPatternEnabled() {
- return isLockPatternEnabled(getCurrentOrCallingUserId());
- }
-
public boolean isLockPatternEnabled(int userId) {
return isLockPatternEnabled(getKeyguardStoredPasswordQuality(userId), userId);
}
@@ -1051,16 +927,14 @@ public class LockPatternUtils {
/**
* @return Whether the visible pattern is enabled.
*/
- public boolean isVisiblePatternEnabled() {
- return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, getCurrentOrCallingUserId());
+ public boolean isVisiblePatternEnabled(int userId) {
+ return getBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, false, userId);
}
/**
* Set whether the visible pattern is enabled.
*/
- public void setVisiblePatternEnabled(boolean enabled) {
- int userId = getCurrentOrCallingUserId();
-
+ public void setVisiblePatternEnabled(boolean enabled, int userId) {
setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId);
// Update for crypto if owner
@@ -1095,9 +969,9 @@ public class LockPatternUtils {
* pattern until the deadline has passed.
* @return the chosen deadline.
*/
- public long setLockoutAttemptDeadline() {
+ public long setLockoutAttemptDeadline(int userId) {
final long deadline = SystemClock.elapsedRealtime() + FAILED_ATTEMPT_TIMEOUT_MS;
- setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, getCurrentOrCallingUserId());
+ setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, userId);
return deadline;
}
@@ -1106,8 +980,8 @@ public class LockPatternUtils {
* attempt to enter his/her lock pattern, or 0 if the user is welcome to
* enter a pattern.
*/
- public long getLockoutAttemptDeadline() {
- final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, getCurrentOrCallingUserId());
+ public long getLockoutAttemptDeadline(int userId) {
+ final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, userId);
final long now = SystemClock.elapsedRealtime();
if (deadline < now || deadline > (now + FAILED_ATTEMPT_TIMEOUT_MS)) {
return 0L;
@@ -1166,21 +1040,12 @@ public class LockPatternUtils {
}
}
- public void setPowerButtonInstantlyLocks(boolean enabled) {
- setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, getCurrentOrCallingUserId());
- }
-
- public boolean getPowerButtonInstantlyLocks() {
- return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true,
- getCurrentOrCallingUserId());
- }
-
- public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents) {
- setEnabledTrustAgents(activeTrustAgents, getCurrentOrCallingUserId());
+ public void setPowerButtonInstantlyLocks(boolean enabled, int userId) {
+ setBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, enabled, userId);
}
- public List<ComponentName> getEnabledTrustAgents() {
- return getEnabledTrustAgents(getCurrentOrCallingUserId());
+ public boolean getPowerButtonInstantlyLocks(int userId) {
+ return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true, userId);
}
public void setEnabledTrustAgents(Collection<ComponentName> activeTrustAgents, int userId) {
@@ -1192,7 +1057,7 @@ public class LockPatternUtils {
sb.append(cn.flattenToShortString());
}
setString(ENABLED_TRUST_AGENTS, sb.toString(), userId);
- getTrustManager().reportEnabledTrustAgentsChanged(getCurrentOrCallingUserId());
+ getTrustManager().reportEnabledTrustAgentsChanged(userId);
}
public List<ComponentName> getEnabledTrustAgents(int userId) {
@@ -1228,7 +1093,7 @@ public class LockPatternUtils {
}
public void setCredentialRequiredToDecrypt(boolean required) {
- if (getCurrentUser() != UserHandle.USER_OWNER) {
+ if (ActivityManager.getCurrentUser() != UserHandle.USER_OWNER) {
Log.w(TAG, "Only device owner may call setCredentialRequiredForDecrypt()");
return;
}