Adding isDemoUser method in userManager

Change-Id: I0ad2c0e7bfac5eff5e5c95c3e533840921a67dc3
diff --git a/src/com/android/launcher3/compat/UserManagerCompat.java b/src/com/android/launcher3/compat/UserManagerCompat.java
index 29ed5d9..ecf596f 100644
--- a/src/com/android/launcher3/compat/UserManagerCompat.java
+++ b/src/com/android/launcher3/compat/UserManagerCompat.java
@@ -58,4 +58,6 @@
     public abstract long getUserCreationTime(UserHandleCompat user);
     public abstract boolean isQuietModeEnabled(UserHandleCompat user);
     public abstract boolean isUserUnlocked(UserHandleCompat user);
+
+    public abstract boolean isDemoUser();
 }
diff --git a/src/com/android/launcher3/compat/UserManagerCompatV16.java b/src/com/android/launcher3/compat/UserManagerCompatV16.java
index e678ffa..9bd4567 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatV16.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatV16.java
@@ -60,4 +60,9 @@
     public boolean isUserUnlocked(UserHandleCompat user) {
         return true;
     }
+
+    @Override
+    public boolean isDemoUser() {
+        return false;
+    }
 }
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVN.java b/src/com/android/launcher3/compat/UserManagerCompatVN.java
index 771d141..be32323 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVN.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVN.java
@@ -20,11 +20,11 @@
 import android.content.Context;
 import android.os.Build;
 
+import com.android.launcher3.Utilities;
+
 @TargetApi(Build.VERSION_CODES.N)
 public class UserManagerCompatVN extends UserManagerCompatVL {
 
-    private static final String TAG = "UserManagerCompatVN";
-
     UserManagerCompatVN(Context context) {
         super(context);
     }
@@ -36,11 +36,15 @@
 
     @Override
     public boolean isUserUnlocked(UserHandleCompat user) {
-        // TODO: Remove the try-catch block when the API permission has been relaxed (b/30475753)
-        try {
-            return mUserManager.isUserUnlocked(user.getUser());
-        } catch (RuntimeException e) {
-            return !isQuietModeEnabled(user);
+        return mUserManager.isUserUnlocked(user.getUser());
+    }
+
+    @Override
+    public boolean isDemoUser() {
+        if (Utilities.isNycMR1OrAbove()) {
+            return mUserManager.isDemoUser();
+        } else {
+            return super.isDemoUser();
         }
     }
 }