From 5a1ab2ef859d956c3dd5a26fc6b3c1064a1eb444 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 5 Jul 2017 13:45:50 -0700 Subject: [PATCH] Salt packageNameHash with unique user identifier Bug: 62676166 Change-Id: I10b301b50e0198aeb52c1c437b9a84aaf323ef66 --- .../launcher3/logging/UserEventDispatcher.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index edbb88c934..e28a97ad86 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -20,6 +20,7 @@ import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.os.SystemClock; import android.support.annotation.Nullable; import android.util.Log; @@ -40,6 +41,7 @@ import com.android.launcher3.util.LogConfig; import java.util.List; import java.util.Locale; +import java.util.UUID; import static com.android.launcher3.logging.LoggerUtils.newCommandAction; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; @@ -62,13 +64,21 @@ public class UserEventDispatcher { private static final String TAG = "UserEvent"; private static final boolean IS_VERBOSE = FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT); + private static final String UUID_STORAGE = "uuid"; public static UserEventDispatcher newInstance(Context context, boolean isInLandscapeMode, boolean isInMultiWindowMode) { + SharedPreferences sharedPrefs = Utilities.getDevicePrefs(context); + String uuidStr = sharedPrefs.getString(UUID_STORAGE, null); + if (uuidStr == null) { + uuidStr = UUID.randomUUID().toString(); + sharedPrefs.edit().putString(UUID_STORAGE, uuidStr).apply(); + } UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class, context.getApplicationContext(), R.string.user_event_dispatcher_class); ued.mIsInLandscapeMode = isInLandscapeMode; ued.mIsInMultiWindowMode = isInMultiWindowMode; + ued.mUuidStr = uuidStr; return ued; } @@ -116,6 +126,7 @@ public class UserEventDispatcher { private long mActionDurationMillis; private boolean mIsInMultiWindowMode; private boolean mIsInLandscapeMode; + private String mUuidStr; // Used for filling in predictedRank on {@link Target}s. private List mPredictedApps; @@ -137,8 +148,8 @@ public class UserEventDispatcher { ItemInfo itemInfo = (ItemInfo) v.getTag(); event.srcTarget[idx].intentHash = intentHashCode; if (cn != null) { - event.srcTarget[idx].packageNameHash = cn.getPackageName().hashCode(); - event.srcTarget[idx].componentHash = cn.hashCode(); + event.srcTarget[idx].packageNameHash = (mUuidStr + cn.getPackageName()).hashCode(); + event.srcTarget[idx].componentHash = (mUuidStr + cn.flattenToString()).hashCode(); if (mPredictedApps != null) { event.srcTarget[idx].predictedRank = mPredictedApps.indexOf( new ComponentKey(cn, itemInfo.user));