@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 public static UserHandleCompat myUserHandle() {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
     return new UserHandleCompat(android.os.Process.myUserHandle());
   } else {
     return new UserHandleCompat();
   }
 }
示例#2
0
 private void sendBroadcast(String code, String status, String payload) {
   Intent broadcastIntent = new Intent();
   broadcastIntent.setAction(Constants.SYSTEM_APP_ACTION_RESPONSE);
   broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
   broadcastIntent.putExtra(Constants.CODE, code);
   broadcastIntent.putExtra(Constants.STATUS, status);
   broadcastIntent.putExtra(Constants.PAYLOAD, payload);
   context.sendBroadcastAsUser(broadcastIntent, android.os.Process.myUserHandle());
 }
 /**
  * Mix in "encryption minimums" to any given quality value. This prevents users from downgrading
  * the pattern/pin/password to a level below the minimums.
  *
  * <p>ASSUMPTION: Setting quality is sufficient (e.g. minimum lengths will be set
  * appropriately.)
  */
 private int upgradeQualityForEncryption(int quality) {
   // Don't upgrade quality for secondary users. Encryption requirements don't apply.
   if (!Process.myUserHandle().equals(UserHandle.OWNER)) return quality;
   int encryptionStatus = mDPM.getStorageEncryptionStatus();
   boolean encrypted =
       (encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE)
           || (encryptionStatus == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVATING);
   if (encrypted) {
     if (quality < CryptKeeperSettings.MIN_PASSWORD_QUALITY) {
       quality = CryptKeeperSettings.MIN_PASSWORD_QUALITY;
     }
   }
   return quality;
 }
 /**
  * @hide for reuse by CertInstaller and Settings.
  *     <p>Caller should call unbindService on the result when finished.
  */
 @WorkerThread
 public static KeyChainConnection bind(@NonNull Context context) throws InterruptedException {
   return bindAsUser(context, Process.myUserHandle());
 }