diff options
5 files changed, 37 insertions, 21 deletions
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index 391065787683..b794f9cdbc79 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -21,6 +21,7 @@ import android.annotation.RequiresPermission; import android.app.trust.ITrustManager; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.os.Binder; import android.os.RemoteException; @@ -44,6 +45,7 @@ public class KeyguardManager { private IWindowManager mWM; private ITrustManager mTrustManager; private IUserManager mUserManager; + private Context mContext; /** * Intent used to prompt user for device credentials. @@ -86,8 +88,12 @@ public class KeyguardManager { Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_DESCRIPTION, description); - // For security reasons, only allow this to come from system settings. - intent.setPackage("com.android.settings"); + if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) { + intent.setPackage("com.google.android.apps.wearable.settings"); + } else { + // For security reasons, only allow this to come from system settings. + intent.setPackage("com.android.settings"); + } return intent; } @@ -108,8 +114,12 @@ public class KeyguardManager { intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_DESCRIPTION, description); intent.putExtra(Intent.EXTRA_USER_ID, userId); - // For security reasons, only allow this to come from system settings. - intent.setPackage("com.android.settings"); + if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) { + intent.setPackage("com.google.android.apps.wearable.settings"); + } else { + // For security reasons, only allow this to come from system settings. + intent.setPackage("com.android.settings"); + } return intent; } @@ -191,7 +201,8 @@ public class KeyguardManager { } - KeyguardManager() { + KeyguardManager(Context context) { + mContext = context; mWM = WindowManagerGlobal.getWindowManagerService(); mTrustManager = ITrustManager.Stub.asInterface( ServiceManager.getService(Context.TRUST_SERVICE)); diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 55744b935f51..4c9b9778d7b5 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -320,10 +320,10 @@ final class SystemServiceRegistry { }}); registerService(Context.KEYGUARD_SERVICE, KeyguardManager.class, - new StaticServiceFetcher<KeyguardManager>() { + new CachedServiceFetcher<KeyguardManager>() { @Override - public KeyguardManager createService() { - return new KeyguardManager(); + public KeyguardManager createService(ContextImpl ctx) { + return new KeyguardManager(ctx); }}); registerService(Context.LAYOUT_INFLATER_SERVICE, LayoutInflater.class, diff --git a/core/res/res/values-watch/themes_device_defaults.xml b/core/res/res/values-watch/themes_device_defaults.xml index aa1594d46516..4d210f6e2f9f 100644 --- a/core/res/res/values-watch/themes_device_defaults.xml +++ b/core/res/res/values-watch/themes_device_defaults.xml @@ -114,6 +114,7 @@ a similar way. <item name="windowAnimationStyle">@style/Animation.InputMethod</item> <item name="imeFullscreenBackground">?colorBackground</item> <item name="imeExtractEnterAnimation">@anim/input_method_extract_enter</item> + <item name="windowSwipeToDismiss">false</item> </style> <!-- DeviceDefault theme for dialog windows and activities. In contrast to Material, the @@ -314,7 +315,7 @@ a similar way. <item name="colorPrimary">@color/primary_device_default_dark</item> <item name="colorPrimaryDark">@color/primary_dark_device_default_dark</item> <item name="colorAccent">@color/accent_device_default_dark</item> - <item name="colorBackground">?attr/colorBackgroundFloating</item> + <item name="colorBackground">@color/background_device_default_dark</item> <item name="colorBackgroundFloating">@color/background_floating_device_default_dark</item> <item name="colorBackgroundCacheHint">@color/background_cache_hint_selector_device_default</item> <item name="colorButtonNormal">@color/button_normal_device_default_dark</item> diff --git a/core/res/res/values-watch/themes_material.xml b/core/res/res/values-watch/themes_material.xml index 84bc25f26db4..0cf398b11085 100644 --- a/core/res/res/values-watch/themes_material.xml +++ b/core/res/res/values-watch/themes_material.xml @@ -37,6 +37,7 @@ please see styles_device_defaults.xml. <item name="windowAnimationStyle">@style/Animation.InputMethod</item> <item name="imeFullscreenBackground">?colorBackground</item> <item name="imeExtractEnterAnimation">@anim/input_method_extract_enter</item> + <item name="windowSwipeToDismiss">false</item> </style> <!-- Override behaviour to set the theme colours for dialogs, keep them the same. --> diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java index a4430ea04a8d..203d2474fca1 100644 --- a/services/core/java/com/android/server/LockSettingsService.java +++ b/services/core/java/com/android/server/LockSettingsService.java @@ -240,21 +240,29 @@ public class LockSettingsService extends ILockSettings.Stub { if (DEBUG) Slog.v(TAG, "Parent does not have a screen lock"); return; } + // Do not tie when the parent has no SID (but does have a screen lock). + // This can only happen during an upgrade path where SID is yet to be + // generated when the user unlocks for the first time. + try { + if (getGateKeeperService().getSecureUserId(parentId) == 0) { + return; + } + } catch (RemoteException e) { + Slog.e(TAG, "Failed to talk to GateKeeper service", e); + return; + } if (DEBUG) Slog.v(TAG, "Tie managed profile to parent now!"); byte[] randomLockSeed = new byte[] {}; try { randomLockSeed = SecureRandom.getInstance("SHA1PRNG").generateSeed(40); String newPassword = String.valueOf(HexEncoding.encode(randomLockSeed)); - tieProfileLockToParent(managedUserId, newPassword); setLockPasswordInternal(newPassword, managedUserPassword, managedUserId); // We store a private credential for the managed user that's unlocked by the primary // account holder's credential. As such, the user will never be prompted to enter this // password directly, so we always store a password. setLong(LockPatternUtils.PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC, managedUserId); - } catch (KeyStoreException e) { - // Bug: 32490092 - Slog.e(TAG, "Not able to set keys to keystore", e); + tieProfileLockToParent(managedUserId, newPassword); } catch (NoSuchAlgorithmException | RemoteException e) { Slog.e(TAG, "Fail to tie managed profile", e); // Nothing client can do to fix this issue, so we do not throw exception out @@ -775,7 +783,6 @@ public class LockSettingsService extends ILockSettings.Stub { } private void unlockChildProfile(int profileHandle) throws RemoteException { - if (DEBUG) Slog.v(TAG, "Unlock child profile"); try { doVerifyPassword(getDecryptedPasswordForTiedProfile(profileHandle), false, 0 /* no challenge */, profileHandle, null /* progressCallback */); @@ -1035,7 +1042,7 @@ public class LockSettingsService extends ILockSettings.Stub { } } - private void tieProfileLockToParent(int userId, String password) throws KeyStoreException { + private void tieProfileLockToParent(int userId, String password) { if (DEBUG) Slog.v(TAG, "tieProfileLockToParent for user: " + userId); byte[] randomLockSeed = password.getBytes(StandardCharsets.UTF_8); byte[] encryptionResult; @@ -1077,7 +1084,7 @@ public class LockSettingsService extends ILockSettings.Stub { keyStore.deleteEntry(LockPatternUtils.PROFILE_KEY_NAME_ENCRYPT + userId); } } catch (CertificateException | UnrecoverableKeyException - | IOException | BadPaddingException | IllegalBlockSizeException + | IOException | BadPaddingException | IllegalBlockSizeException | KeyStoreException | NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException e) { throw new RuntimeException("Failed to encrypt key", e); } @@ -1219,11 +1226,7 @@ public class LockSettingsService extends ILockSettings.Stub { } finally { if (managedUserId != -1 && managedUserDecryptedPassword != null) { if (DEBUG) Slog.v(TAG, "Restore tied profile lock"); - try { - tieProfileLockToParent(managedUserId, managedUserDecryptedPassword); - } catch (KeyStoreException e) { - throw new RuntimeException("Failed to tie profile lock", e); - } + tieProfileLockToParent(managedUserId, managedUserDecryptedPassword); } } } |