Skip to content

Commit f0765da

Browse files
Remove Client-Side Package Checksum
Summary: In this diff, we deprecate the client side Package Checksum being sent to Meta. Reviewed By: KylinChang Differential Revision: D70637187 fbshipit-source-id: 1b67aa28c42571e5a43038667fb99e2506f9e010
1 parent f1b6f83 commit f0765da

File tree

3 files changed

+0
-56
lines changed

3 files changed

+0
-56
lines changed

facebook-core/src/main/java/com/facebook/appevents/AppEventsConstants.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ object AppEventsConstants {
210210
/** Parameter key used to specify source application package. */
211211
const val EVENT_PARAM_SOURCE_APPLICATION = "fb_mobile_launch_source"
212212

213-
/** Parameter key used to specify package fingerprint. */
214-
const val EVENT_PARAM_PACKAGE_FP = "fb_mobile_pckg_fp"
215-
216213
// Parameter values
217214
/** Yes-valued parameter value to be used with parameter keys that need a Yes/No value */
218215
const val EVENT_PARAM_VALUE_YES = "1"

facebook-core/src/main/java/com/facebook/appevents/internal/SessionLogger.kt

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@ package com.facebook.appevents.internal
1111
import android.content.Context
1212
import android.os.Bundle
1313
import android.text.format.DateUtils
14-
import com.facebook.FacebookSdk
1514
import com.facebook.LoggingBehavior
1615
import com.facebook.appevents.AppEventsConstants
1716
import com.facebook.appevents.AppEventsLogger
1817
import com.facebook.appevents.InternalAppEventsLogger
19-
import com.facebook.appevents.internal.HashUtils.computeChecksum
2018
import com.facebook.internal.Logger.Companion.log
2119
import com.facebook.internal.instrument.crashshield.AutoHandleExceptions
2220
import java.util.Locale
2321

2422
@AutoHandleExceptions
2523
internal object SessionLogger {
26-
private const val PACKAGE_CHECKSUM = "PCKGCHKSUM"
2724
private val TAG = SessionLogger::class.java.canonicalName
2825
private val INACTIVE_SECONDS_QUANTA =
2926
longArrayOf(
@@ -58,9 +55,6 @@ internal object SessionLogger {
5855
val sourAppInfoStr = sourceApplicationInfo?.toString() ?: "Unclassified"
5956
val eventParams = Bundle()
6057
eventParams.putString(AppEventsConstants.EVENT_PARAM_SOURCE_APPLICATION, sourAppInfoStr)
61-
eventParams.putString(
62-
AppEventsConstants.EVENT_PARAM_PACKAGE_FP, computePackageChecksum(context)
63-
)
6458
val logger = InternalAppEventsLogger.createInstance(activityName, appId, null)
6559
logger.logEvent(AppEventsConstants.EVENT_NAME_ACTIVATED_APP, eventParams)
6660
if (InternalAppEventsLogger.getFlushBehavior() != AppEventsLogger.FlushBehavior.EXPLICIT_ONLY) {
@@ -124,37 +118,4 @@ internal object SessionLogger {
124118
}
125119
return quantaIndex
126120
}
127-
128-
private fun computePackageChecksum(context: Context): String? {
129-
return try {
130-
// First, try to check if package hash already computed
131-
val pm = context.packageManager
132-
val packageVersion = pm.getPackageInfo(context.packageName, 0).versionName
133-
val packageHashSharedPrefKey = PACKAGE_CHECKSUM + ";" + packageVersion
134-
val preferences =
135-
context.getSharedPreferences(
136-
FacebookSdk.APP_EVENT_PREFERENCES,
137-
Context.MODE_PRIVATE
138-
)
139-
var packageHash = preferences.getString(packageHashSharedPrefKey, null)
140-
if (packageHash != null && packageHash.length == 32) {
141-
return packageHash
142-
}
143-
// Second, try to get the checksum through Android S checksum API
144-
val androidPackageManagerChecksum =
145-
HashUtils.computeChecksumWithPackageManager(context, null)
146-
packageHash =
147-
if (androidPackageManagerChecksum != null) {
148-
androidPackageManagerChecksum
149-
} else {
150-
// Finally, compute checksum and cache it.
151-
val ai = pm.getApplicationInfo(context.packageName, 0)
152-
computeChecksum(ai.sourceDir)
153-
}
154-
preferences.edit().putString(packageHashSharedPrefKey, packageHash).apply()
155-
packageHash
156-
} catch (e: Exception) {
157-
null
158-
}
159-
}
160121
}

facebook-core/src/test/kotlin/com/facebook/appevents/internal/SessionLoggerTest.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,4 @@ class SessionLoggerTest : FacebookPowerMockTestCase() {
176176
)
177177
.isEqualTo(fbMobileTimeBetweenSessions)
178178
}
179-
180-
@Test
181-
fun `test logActivateApp will log EVENT_NAME_ACTIVATED_APP event and package checksum`() {
182-
SessionLogger.logActivateApp(activityName, null, appId, mockContext)
183-
184-
verify(mockInternalAppEventsLogger)
185-
.logEvent(
186-
eq(AppEventsConstants.EVENT_NAME_ACTIVATED_APP),
187-
bundleArgumentCaptor.capture()
188-
)
189-
val capturedBundle = bundleArgumentCaptor.firstValue
190-
assertThat(capturedBundle.getString(AppEventsConstants.EVENT_PARAM_PACKAGE_FP))
191-
.isEqualTo(mockChecksum)
192-
}
193179
}

0 commit comments

Comments
 (0)