summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2015-04-13 11:52:18 -0700
committerFyodor Kupolov <fkupolov@google.com>2015-04-14 10:36:53 -0700
commitf4d6ad26636760163083ae84c40d5b19cb6650f6 (patch)
treeb9f06c187fbfd46ce03f23bc35265d5360d1fc76
parentdddc56660a5fe789f57fe54d829f804931cbc975 (diff)
downloadframeworks_base-f4d6ad26636760163083ae84c40d5b19cb6650f6.zip
frameworks_base-f4d6ad26636760163083ae84c40d5b19cb6650f6.tar.gz
frameworks_base-f4d6ad26636760163083ae84c40d5b19cb6650f6.tar.bz2
Display a notification for a new guest
Display a notification for a new guest, which includes information that they are using the device as a guest and how to remove guest. Bug: 16956833 Change-Id: I21711949d3a80eaca47251faa6ee0cf04b5bf3e6
-rw-r--r--packages/SystemUI/res/drawable/ic_delete.xml24
-rw-r--r--packages/SystemUI/res/drawable/ic_person.xml24
-rw-r--r--packages/SystemUI/res/values/strings.xml9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java39
4 files changed, 96 insertions, 0 deletions
diff --git a/packages/SystemUI/res/drawable/ic_delete.xml b/packages/SystemUI/res/drawable/ic_delete.xml
new file mode 100644
index 0000000..4e80ddf
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_delete.xml
@@ -0,0 +1,24 @@
+<!--
+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>
diff --git a/packages/SystemUI/res/drawable/ic_person.xml b/packages/SystemUI/res/drawable/ic_person.xml
new file mode 100644
index 0000000..101911f
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_person.xml
@@ -0,0 +1,24 @@
+<!--
+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>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 779b55e..b73881a 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -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>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index 4ac41a1..194bcfa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -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;
@@ -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;
@@ -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 */);
@@ -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();
@@ -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()) {