Loading core/res/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -483,6 +483,7 @@ <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABLE" /> <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNAVAILABLE" /> <protected-broadcast android:name="com.android.server.pm.DISABLE_QUIET_MODE_AFTER_UNLOCK" /> <protected-broadcast android:name="com.android.server.am.ACTION_RESET_DEMO" /> Loading services/core/java/com/android/server/pm/UserManagerService.java +44 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.app.AppGlobals; import android.app.IActivityManager; import android.app.IStopUserCallback; import android.app.KeyguardManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -331,6 +332,27 @@ public class UserManagerService extends IUserManager.Stub { private final LockPatternUtils mLockPatternUtils; private final String ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK = "com.android.server.pm.DISABLE_QUIET_MODE_AFTER_UNLOCK"; private final BroadcastReceiver mDisableQuietModeCallback = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK.equals(intent.getAction())) { final IntentSender target = intent.getParcelableExtra(Intent.EXTRA_INTENT); final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_ID, 0); setQuietModeEnabled(userHandle, false); if (target != null) { try { mContext.startIntentSender(target, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { /* ignore */ } } } } }; /** * Whether all users should be created ephemeral. */ Loading Loading @@ -425,6 +447,9 @@ public class UserManagerService extends IUserManager.Stub { } maybeInitializeDemoMode(UserHandle.USER_SYSTEM); mContext.registerReceiver(mDisableQuietModeCallback, new IntentFilter(ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK), null, mHandler); } @Override Loading Loading @@ -714,6 +739,7 @@ public class UserManagerService extends IUserManager.Stub { @Override public boolean trySetQuietModeDisabled(int userHandle, IntentSender target) { checkManageUsersPermission("silence profile"); if (StorageManager.isUserKeyUnlocked(userHandle) || !mLockPatternUtils.isSecure(userHandle)) { // if the user is already unlocked, no need to show a profile challenge Loading @@ -734,9 +760,24 @@ public class UserManagerService extends IUserManager.Stub { if (unlockIntent == null) { return false; } final Intent callBackIntent = new Intent( ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK); if (target != null) { unlockIntent.putExtra(Intent.EXTRA_INTENT, target); } callBackIntent.putExtra(Intent.EXTRA_INTENT, target); } callBackIntent.putExtra(Intent.EXTRA_USER_ID, userHandle); callBackIntent.setPackage(mContext.getPackageName()); callBackIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); final PendingIntent pendingIntent = PendingIntent.getBroadcast( mContext, 0, callBackIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); // After unlocking the challenge, it will disable quiet mode and run the original // intentSender unlockIntent.putExtra(Intent.EXTRA_INTENT, pendingIntent.getIntentSender()); unlockIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); mContext.startActivity(unlockIntent); } finally { Loading Loading
core/res/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -483,6 +483,7 @@ <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_AVAILABLE" /> <protected-broadcast android:name="android.intent.action.MANAGED_PROFILE_UNAVAILABLE" /> <protected-broadcast android:name="com.android.server.pm.DISABLE_QUIET_MODE_AFTER_UNLOCK" /> <protected-broadcast android:name="com.android.server.am.ACTION_RESET_DEMO" /> Loading
services/core/java/com/android/server/pm/UserManagerService.java +44 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.app.AppGlobals; import android.app.IActivityManager; import android.app.IStopUserCallback; import android.app.KeyguardManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -331,6 +332,27 @@ public class UserManagerService extends IUserManager.Stub { private final LockPatternUtils mLockPatternUtils; private final String ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK = "com.android.server.pm.DISABLE_QUIET_MODE_AFTER_UNLOCK"; private final BroadcastReceiver mDisableQuietModeCallback = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK.equals(intent.getAction())) { final IntentSender target = intent.getParcelableExtra(Intent.EXTRA_INTENT); final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_ID, 0); setQuietModeEnabled(userHandle, false); if (target != null) { try { mContext.startIntentSender(target, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { /* ignore */ } } } } }; /** * Whether all users should be created ephemeral. */ Loading Loading @@ -425,6 +447,9 @@ public class UserManagerService extends IUserManager.Stub { } maybeInitializeDemoMode(UserHandle.USER_SYSTEM); mContext.registerReceiver(mDisableQuietModeCallback, new IntentFilter(ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK), null, mHandler); } @Override Loading Loading @@ -714,6 +739,7 @@ public class UserManagerService extends IUserManager.Stub { @Override public boolean trySetQuietModeDisabled(int userHandle, IntentSender target) { checkManageUsersPermission("silence profile"); if (StorageManager.isUserKeyUnlocked(userHandle) || !mLockPatternUtils.isSecure(userHandle)) { // if the user is already unlocked, no need to show a profile challenge Loading @@ -734,9 +760,24 @@ public class UserManagerService extends IUserManager.Stub { if (unlockIntent == null) { return false; } final Intent callBackIntent = new Intent( ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK); if (target != null) { unlockIntent.putExtra(Intent.EXTRA_INTENT, target); } callBackIntent.putExtra(Intent.EXTRA_INTENT, target); } callBackIntent.putExtra(Intent.EXTRA_USER_ID, userHandle); callBackIntent.setPackage(mContext.getPackageName()); callBackIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); final PendingIntent pendingIntent = PendingIntent.getBroadcast( mContext, 0, callBackIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); // After unlocking the challenge, it will disable quiet mode and run the original // intentSender unlockIntent.putExtra(Intent.EXTRA_INTENT, pendingIntent.getIntentSender()); unlockIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); mContext.startActivity(unlockIntent); } finally { Loading