Merge "Revert "Add logging to debug HSUM in LauncherApps#pinShortcuts"" into main
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index ee15bec..023f765 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -92,7 +92,6 @@
 import android.multiuser.Flags;
 import android.net.Uri;
 import android.os.Binder;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IInterface;
@@ -215,7 +214,7 @@
 
     @VisibleForTesting
     static class LauncherAppsImpl extends ILauncherApps.Stub {
-        private static final boolean DEBUG = Build.IS_DEBUGGABLE;
+        private static final boolean DEBUG = false;
         private static final String TAG = "LauncherAppsService";
         private static final String NAMESPACE_MULTIUSER = "multiuser";
         private static final String FLAG_NON_SYSTEM_ACCESS_TO_HIDDEN_PROFILES =
@@ -496,28 +495,8 @@
 
         private boolean canAccessProfile(int callingUid, int callingUserId, int callingPid,
                 int targetUserId, String message) {
-            if (DEBUG) {
-                final AndroidPackage callingPackage =
-                        mPackageManagerInternal.getPackage(callingUid);
-                final String callingPackageName = callingPackage == null
-                        ? null : callingPackage.getPackageName();
-                Slog.v(TAG, "canAccessProfile called by " + callingPackageName
-                        + " for user " + callingUserId
-                        + " requesting to access user "
-                        + targetUserId + " when invoking " + message);
-            }
-            if (targetUserId == callingUserId) {
-                if (DEBUG) {
-                    Slog.v(TAG, message + " passed canAccessProfile for targetuser"
-                        + targetUserId + " because it is the same as the calling user");
-                }
-                return true;
-            }
+            if (targetUserId == callingUserId) return true;
             if (injectHasInteractAcrossUsersFullPermission(callingPid, callingUid)) {
-              if (DEBUG) {
-                    Slog.v(TAG, message + " passed because calling process"
-                        + "has permission to interact across users");
-                }
                 return true;
             }
 
@@ -535,25 +514,11 @@
 
             if (isHiddenProfile(UserHandle.of(targetUserId))
                     && !canAccessHiddenProfile(callingUid, callingPid)) {
-                Slog.w(TAG, message + " for hidden profile user " + targetUserId
-                        + " from " + callingUserId + " not allowed");
-
                 return false;
             }
 
-            final boolean ret = mUserManagerInternal.isProfileAccessible(
-                    callingUserId, targetUserId, message, true);
-            if (DEBUG) {
-                final AndroidPackage callingPackage =
-                        mPackageManagerInternal.getPackage(callingUid);
-                final String callingPackageName = callingPackage == null
-                        ? null : callingPackage.getPackageName();
-                Slog.v(TAG, "canAccessProfile returned " + ret + " for " + callingPackageName
-                        + " for user " + callingUserId
-                        + " requesting to access user "
-                        + targetUserId + " when invoking " + message);
-            }
-            return ret;
+            return mUserManagerInternal.isProfileAccessible(callingUserId, targetUserId,
+                    message, true);
         }
 
         private boolean isHiddenProfile(UserHandle targetUser) {
@@ -1376,10 +1341,6 @@
         @Override
         public void pinShortcuts(String callingPackage, String packageName, List<String> ids,
                 UserHandle targetUser) {
-            if (DEBUG) {
-                Slog.v(TAG, "pinShortcuts: " + callingPackage + " is pinning shortcuts from "
-                        + packageName + " for user " + targetUser);
-            }
             if (!mShortcutServiceInternal
                     .areShortcutsSupportedOnHomeScreen(targetUser.getIdentifier())) {
                 // Requires strict ACCESS_SHORTCUTS permission for user-profiles with items
@@ -1390,11 +1351,6 @@
             }
             ensureShortcutPermission(callingPackage);
             if (!canAccessProfile(targetUser.getIdentifier(), "Cannot pin shortcuts")) {
-                if (DEBUG) {
-                    Slog.v(TAG, "pinShortcuts: " + callingPackage
-                            + " is pinning shortcuts from " + packageName
-                            + " for user " + targetUser + " but cannot access profile");
-                }
                 return;
             }
 
diff --git a/services/core/java/com/android/server/pm/ShortcutLauncher.java b/services/core/java/com/android/server/pm/ShortcutLauncher.java
index d65e30b..045d4db 100644
--- a/services/core/java/com/android/server/pm/ShortcutLauncher.java
+++ b/services/core/java/com/android/server/pm/ShortcutLauncher.java
@@ -42,7 +42,6 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * Launcher information used by {@link ShortcutService}.
@@ -129,15 +128,9 @@
      */
     public void pinShortcuts(@UserIdInt int packageUserId,
             @NonNull String packageName, @NonNull List<String> ids, boolean forPinRequest) {
-        if (ShortcutService.DEBUG) {
-            Slog.v(TAG, "ShortcutLauncher#pinShortcuts: pin shortcuts from " + packageName
-                    + " with userId=" + packageUserId + " shortcutIds="
-                    + ids.stream().collect(Collectors.joining(", ", "[", "]")));
-        }
         final ShortcutPackage packageShortcuts =
                 mShortcutUser.getPackageShortcutsIfExists(packageName);
         if (packageShortcuts == null) {
-            Slog.w(TAG, "ShortcutLauncher#pinShortcuts packageShortcuts is null");
             return; // No need to instantiate.
         }
 
@@ -162,10 +155,6 @@
                 final String id = ids.get(i);
                 final ShortcutInfo si = packageShortcuts.findShortcutById(id);
                 if (si == null) {
-                    if (ShortcutService.DEBUG) {
-                        Slog.w(TAG, "ShortcutLauncher#pinShortcuts: cannot pin "
-                                + id + " because it does not exist");
-                    }
                     continue;
                 }
                 if (si.isDynamic() || si.isLongLived()
@@ -185,13 +174,6 @@
                         }
                     }
                 }
-                if (ShortcutService.DEBUG) {
-                    Slog.v(TAG, "ShortcutLauncher#pinShortcuts: "
-                            + " newSet: " + newSet.stream().collect(
-                                    Collectors.joining(", ", "[", "]"))
-                            + " floatingSet: " + floatingSet.stream().collect(
-                                    Collectors.joining(", ", "[", "]")));
-                }
                 mPinnedShortcuts.put(up, newSet);
             }
         }
diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java
index c9ad498..60056eb 100644
--- a/services/core/java/com/android/server/pm/ShortcutPackage.java
+++ b/services/core/java/com/android/server/pm/ShortcutPackage.java
@@ -729,11 +729,6 @@
             }
             pinnedShortcuts.addAll(pinned);
         });
-        if (ShortcutService.DEBUG) {
-            Slog.v(TAG, "ShortcutPackage#refreshPinnedFlags: "
-                    + " pinnedShortcuts: " + pinnedShortcuts.stream().collect(
-                            Collectors.joining(", ", "[", "]")));
-        }
         // Secondly, update the pinned state if necessary.
         final List<ShortcutInfo> pinned = findAll(pinnedShortcuts);
         if (pinned != null) {
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index ea495c9..a3ff195 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -169,7 +169,7 @@
 public class ShortcutService extends IShortcutService.Stub {
     static final String TAG = "ShortcutService";
 
-    static final boolean DEBUG = Build.IS_DEBUGGABLE; // STOPSHIP if true
+    static final boolean DEBUG = false; // STOPSHIP if true
     static final boolean DEBUG_LOAD = false; // STOPSHIP if true
     static final boolean DEBUG_PROCSTATE = false; // STOPSHIP if true
     static final boolean DEBUG_REBOOT = Build.IS_DEBUGGABLE;
@@ -3206,11 +3206,6 @@
         public void pinShortcuts(int launcherUserId,
                 @NonNull String callingPackage, @NonNull String packageName,
                 @NonNull List<String> shortcutIds, int userId) {
-            if (DEBUG) {
-                Slog.v(TAG, "pinShortcuts: " + callingPackage + ", with userId=" + launcherUserId
-                        + ", is trying to pin shortcuts from " + packageName
-                        + " with userId=" + userId);
-            }
             // Calling permission must be checked by LauncherAppsImpl.
             Preconditions.checkStringNotEmpty(packageName, "packageName");
             Objects.requireNonNull(shortcutIds, "shortcutIds");
@@ -3235,11 +3230,6 @@
                                     && !si.isDeclaredInManifest(),
                             ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO,
                             callingPackage, launcherUserId, false);
-                } else {
-                    if (DEBUG) {
-                        Slog.w(TAG, "specified package " + packageName + ", with userId=" + userId
-                        + ", doesn't exist.");
-                    }
                 }
                 // Get list of shortcuts that will get unpinned.
                 ArraySet<String> oldPinnedIds = launcher.getPinnedShortcutIds(packageName, userId);
@@ -5458,17 +5448,6 @@
      */
     private List<ShortcutInfo> prepareChangedShortcuts(ArraySet<String> changedIds,
             ArraySet<String> newIds, List<ShortcutInfo> deletedList, final ShortcutPackage ps) {
-        if (DEBUG) {
-            Slog.v(TAG, "prepareChangedShortcuts: "
-                + " changedIds=" + (changedIds == null
-                        ? "n/a" : changedIds.stream().collect(Collectors.joining(", ", "[", "]")))
-                + " newIds=" + (newIds == null
-                        ? "n/a" : newIds.stream().collect(Collectors.joining(", ", "[", "]")))
-                + " deletedList=" + (deletedList == null
-                        ? "n/a" : deletedList.stream().map(ShortcutInfo::getId).collect(
-                                Collectors.joining(", ", "[", "]")))
-                + " ps=" + (ps == null ? "n/a" : ps.getPackageName()));
-        }
         if (ps == null) {
             // This can happen when package restore is not finished yet.
             return null;