Loading packages/SystemUI/res/drawable/ic_delete.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="48.0" android:viewportHeight="48.0"> <path android:fillColor="#ffffffff" android:pathData="M12 38c0 2.21 1.79 4 4 4h16c2.21 0 4,-1.79 4,-4V14H12v24zM38 8h-7l-2,-2H19l-2 2h-7v4h28V8z"/> </vector> packages/SystemUI/res/drawable/ic_person.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="48.0" android:viewportHeight="48.0"> <path android:fillColor="#ffffffff" android:pathData="M24 24c4.42 0 8,-3.59 8,-8 0,-4.42,-3.58,-8,-8,-8s-8 3.58,-8 8c0 4.41 3.58 8 8 8zm0 4c-5.33 0,-16 2.67,-16 8v4h32v-4c0,-5.33,-10.67,-8,-16,-8z"/> </vector> packages/SystemUI/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -830,6 +830,15 @@ <!-- Notification when resuming an existing guest session: Action that continues with the current session [CHAR LIMIT=35] --> <string name="guest_wipe_session_dontwipe">Yes, continue</string> <!-- Title of the notification shown to a new guest user [CHAR LIMIT=60] --> <string name="guest_notification_title">Guest user</string> <!-- Text of the notification shown to a new guest user [CHAR LIMIT=60] --> <string name="guest_notification_text">Remove guest to delete apps and data</string> <!-- Remove action in the notification shown to a new guest user [CHAR LIMIT=30] --> <string name="guest_notification_remove_action">REMOVE GUEST</string> <!-- Title for add user confirmation dialog [CHAR LIMIT=30] --> <string name="user_add_user_title" msgid="2108112641783146007">Add new user?</string> Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +39 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ package com.android.systemui.statusbar.policy; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.Dialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; Loading Loading @@ -63,6 +66,7 @@ public class UserSwitcherController { private static final boolean DEBUG = false; private static final String SIMPLE_USER_SWITCHER_GLOBAL_SETTING = "lockscreenSimpleUserSwitcher"; private static final String ACTION_REMOVE_GUEST = "com.android.systemui.REMOVE_GUEST"; private final Context mContext; private final UserManager mUserManager; Loading @@ -89,6 +93,7 @@ public class UserSwitcherController { filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_STOPPING); filter.addAction(ACTION_REMOVE_GUEST); mContext.registerReceiverAsUser(mReceiver, UserHandle.OWNER, filter, null /* permission */, null /* scheduler */); Loading Loading @@ -296,6 +301,22 @@ public class UserSwitcherController { Log.v(TAG, "Broadcast: a=" + intent.getAction() + " user=" + intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1)); } if (ACTION_REMOVE_GUEST.equals(intent.getAction())) { int currentUser = ActivityManager.getCurrentUser(); UserInfo userInfo = mUserManager.getUserInfo(currentUser); if (userInfo != null && userInfo.isGuest()) { showExitGuestDialog(currentUser); } return; } if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) { final int currentId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); UserInfo userInfo = mUserManager.getUserInfo(currentId); if (userInfo != null && userInfo.isGuest()) { showGuestNotification(currentId); } } if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { if (mExitGuestDialog != null && mExitGuestDialog.isShowing()) { mExitGuestDialog.cancel(); Loading Loading @@ -329,6 +350,24 @@ public class UserSwitcherController { } refreshUsers(forcePictureLoadForId); } private void showGuestNotification(int guestUserId) { PendingIntent removeGuestPI = PendingIntent.getBroadcastAsUser(mContext, 0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.OWNER); Notification notification = new Notification.Builder(mContext) .setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN) .setSmallIcon(R.drawable.ic_person) .setContentTitle(mContext.getString(R.string.guest_notification_title)) .setContentText(mContext.getString(R.string.guest_notification_text)) .setShowWhen(false) .addAction(R.drawable.ic_delete, mContext.getString(R.string.guest_notification_remove_action), removeGuestPI) .build(); NotificationManager.from(mContext).notifyAsUser(null, 0, notification, new UserHandle(guestUserId)); } }; private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) { Loading Loading
packages/SystemUI/res/drawable/ic_delete.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="48.0" android:viewportHeight="48.0"> <path android:fillColor="#ffffffff" android:pathData="M12 38c0 2.21 1.79 4 4 4h16c2.21 0 4,-1.79 4,-4V14H12v24zM38 8h-7l-2,-2H19l-2 2h-7v4h28V8z"/> </vector>
packages/SystemUI/res/drawable/ic_person.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24.0dp" android:height="24.0dp" android:viewportWidth="48.0" android:viewportHeight="48.0"> <path android:fillColor="#ffffffff" android:pathData="M24 24c4.42 0 8,-3.59 8,-8 0,-4.42,-3.58,-8,-8,-8s-8 3.58,-8 8c0 4.41 3.58 8 8 8zm0 4c-5.33 0,-16 2.67,-16 8v4h32v-4c0,-5.33,-10.67,-8,-16,-8z"/> </vector>
packages/SystemUI/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -830,6 +830,15 @@ <!-- Notification when resuming an existing guest session: Action that continues with the current session [CHAR LIMIT=35] --> <string name="guest_wipe_session_dontwipe">Yes, continue</string> <!-- Title of the notification shown to a new guest user [CHAR LIMIT=60] --> <string name="guest_notification_title">Guest user</string> <!-- Text of the notification shown to a new guest user [CHAR LIMIT=60] --> <string name="guest_notification_text">Remove guest to delete apps and data</string> <!-- Remove action in the notification shown to a new guest user [CHAR LIMIT=30] --> <string name="guest_notification_remove_action">REMOVE GUEST</string> <!-- Title for add user confirmation dialog [CHAR LIMIT=30] --> <string name="user_add_user_title" msgid="2108112641783146007">Add new user?</string> Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +39 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ package com.android.systemui.statusbar.policy; import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.Dialog; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; Loading Loading @@ -63,6 +66,7 @@ public class UserSwitcherController { private static final boolean DEBUG = false; private static final String SIMPLE_USER_SWITCHER_GLOBAL_SETTING = "lockscreenSimpleUserSwitcher"; private static final String ACTION_REMOVE_GUEST = "com.android.systemui.REMOVE_GUEST"; private final Context mContext; private final UserManager mUserManager; Loading @@ -89,6 +93,7 @@ public class UserSwitcherController { filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_STOPPING); filter.addAction(ACTION_REMOVE_GUEST); mContext.registerReceiverAsUser(mReceiver, UserHandle.OWNER, filter, null /* permission */, null /* scheduler */); Loading Loading @@ -296,6 +301,22 @@ public class UserSwitcherController { Log.v(TAG, "Broadcast: a=" + intent.getAction() + " user=" + intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1)); } if (ACTION_REMOVE_GUEST.equals(intent.getAction())) { int currentUser = ActivityManager.getCurrentUser(); UserInfo userInfo = mUserManager.getUserInfo(currentUser); if (userInfo != null && userInfo.isGuest()) { showExitGuestDialog(currentUser); } return; } if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) { final int currentId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); UserInfo userInfo = mUserManager.getUserInfo(currentId); if (userInfo != null && userInfo.isGuest()) { showGuestNotification(currentId); } } if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { if (mExitGuestDialog != null && mExitGuestDialog.isShowing()) { mExitGuestDialog.cancel(); Loading Loading @@ -329,6 +350,24 @@ public class UserSwitcherController { } refreshUsers(forcePictureLoadForId); } private void showGuestNotification(int guestUserId) { PendingIntent removeGuestPI = PendingIntent.getBroadcastAsUser(mContext, 0, new Intent(ACTION_REMOVE_GUEST), 0, UserHandle.OWNER); Notification notification = new Notification.Builder(mContext) .setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN) .setSmallIcon(R.drawable.ic_person) .setContentTitle(mContext.getString(R.string.guest_notification_title)) .setContentText(mContext.getString(R.string.guest_notification_text)) .setShowWhen(false) .addAction(R.drawable.ic_delete, mContext.getString(R.string.guest_notification_remove_action), removeGuestPI) .build(); NotificationManager.from(mContext).notifyAsUser(null, 0, notification, new UserHandle(guestUserId)); } }; private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) { Loading