Merge "Remove restricted uitls methods for cross-profile calendar." into qt-dev
am: ee187db646

Change-Id: Idbff4d15021cc35f2872d914e8cb5dc2763282c5
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java
index 93f6a94..9a41f1d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java
@@ -38,7 +38,6 @@
 import android.text.Spanned;
 import android.text.style.ForegroundColorSpan;
 import android.text.style.ImageSpan;
-import android.util.Log;
 import android.view.MenuItem;
 import android.widget.TextView;
 
@@ -47,7 +46,6 @@
 import com.android.internal.widget.LockPatternUtils;
 
 import java.util.List;
-import java.util.Set;
 
 /**
  * Utility class to host methods usable in adding a restricted padlock icon and showing admin
@@ -310,43 +308,6 @@
         return null;
     }
 
-    /**
-     * @param userId user id of a managed profile.
-     * @return profile owner admin if cross profile calendar is disallowed.
-     */
-    public static EnforcedAdmin getCrossProfileCalendarEnforcingAdmin(Context context, int userId) {
-        final Context managedProfileContext = createPackageContextAsUser(
-                context, userId);
-        final DevicePolicyManager dpm = managedProfileContext.getSystemService(
-                DevicePolicyManager.class);
-        if (dpm == null) {
-            return null;
-        }
-        final EnforcedAdmin admin = getProfileOwner(context, userId);
-        if (admin == null) {
-            return null;
-        }
-        final Set<String> packages = dpm.getCrossProfileCalendarPackages();
-        if (packages != null && packages.isEmpty()) {
-            return admin;
-        }
-        return null;
-    }
-
-    /**
-     * @param userId user id of a managed profile.
-     * @return a context created from the given context for the given user, or null if it fails.
-     */
-    private static Context createPackageContextAsUser(Context context, int userId) {
-        try {
-            return context.createPackageContextAsUser(
-                    context.getPackageName(), 0 /* flags */, UserHandle.of(userId));
-        } catch (PackageManager.NameNotFoundException e) {
-            Log.e(LOG_TAG, "Failed to create user context", e);
-        }
-        return null;
-    }
-
     public static EnforcedAdmin checkIfAccessibilityServiceDisallowed(Context context,
             String packageName, int userId) {
         DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(