diff options
author | Stephen Bird <sbird@cyngn.com> | 2016-04-05 18:03:28 -0700 |
---|---|---|
committer | Stephen Bird <sbird@cyngn.com> | 2016-04-21 11:50:45 -0700 |
commit | 2366dedf13357f115b3569d8b2a15a0f7cb7b349 (patch) | |
tree | 355cb87d65220ca8889140f73b1f9040a98e449c | |
parent | 9e8223e417c84266a804ee377921b3479bb873e5 (diff) | |
download | android_packages_apps_Dialer-2366dedf13357f115b3569d8b2a15a0f7cb7b349.tar.gz android_packages_apps_Dialer-2366dedf13357f115b3569d8b2a15a0f7cb7b349.tar.bz2 android_packages_apps_Dialer-2366dedf13357f115b3569d8b2a15a0f7cb7b349.zip |
Improvements to Nudges
- Fix bugs found in test cases
- Make nudge lookup more performant
- Make nudge metrics work
Change-Id: I1e75dc3a2bdda5cc5763c327bfd1b94c6aa6e735
7 files changed, 213 insertions, 142 deletions
diff --git a/AndroidManifest_cm.xml b/AndroidManifest_cm.xml index 330f28563..737d6e046 100644 --- a/AndroidManifest_cm.xml +++ b/AndroidManifest_cm.xml @@ -32,9 +32,7 @@ <meta-data android:name="com.cyanogen.ambient.analytics.key" android:value="6l2dXt9DFioFa1Mfb4eZsM9l87Rl9hp1UL75tO9w"/> - <receiver android:name=".incall.CallMethodStatusReceiver" - android:enabled="true" - android:exported="true"> + <receiver android:name=".incall.CallMethodStatusReceiver"> <intent-filter> <action android:name="cyanogen.ambient.core.plugin.incall.action.plugin_status_changed"/> </intent-filter> @@ -43,9 +41,9 @@ <receiver android:name=".discovery.DiscoverySignalReceiver"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> - </intent-filter> - <intent-filter> <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> + <action android:name="com.android.dialer.discovery.DiscoverySignalReceiver.ON_SHOW" /> + <action android:name="com.android.dialer.discovery.DiscoverySignalReceiver.ON_DISMISS" /> </intent-filter> </receiver> diff --git a/src/com/android/dialer/discovery/DiscoveryEventHandler.java b/src/com/android/dialer/discovery/DiscoveryEventHandler.java index e2734c87e..ff09f7a0e 100644 --- a/src/com/android/dialer/discovery/DiscoveryEventHandler.java +++ b/src/com/android/dialer/discovery/DiscoveryEventHandler.java @@ -24,11 +24,16 @@ import com.cyanogen.ambient.discovery.NudgeServices; import com.cyanogen.ambient.discovery.nudge.NotificationNudge; import com.cyanogen.ambient.discovery.nudge.Nudge; import com.cyanogen.ambient.discovery.util.NudgeKey; +import com.cyanogen.ambient.discovery.results.NudgablePluginsResult; import com.cyanogen.ambient.incall.InCallApi; import com.cyanogen.ambient.incall.InCallServices; import com.cyanogen.ambient.incall.results.InCallProviderInfoResult; import com.cyanogen.ambient.incall.results.PluginStatusResult; +import com.cyanogen.ambient.incall.results.InstalledPluginsResult; + import com.cyanogen.ambient.plugin.PluginStatus; +import com.cyanogen.ambient.common.api.ResultCallback; + import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -37,164 +42,202 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * A small, lean, nudge'r. For loading data from mods that can provide nudges. + * + * All Dialer nudge events route through here, and if found worthy, will send a nudge to + * the Discovery Nudge Service in ModCore. + */ public class DiscoveryEventHandler { private static final String TAG = "DiscoveryEventHandler"; - private static final boolean DEBUG_STATUS = false; - - public static void getNudgeProvidersWithKey(final Context context, final String key) { - getNudgeProvidersWithKey(context, key, false); - } - public static void getNudgeProvidersWithKey(final Context context, final String key, final - boolean isTesting) { - // Spin up a new thread to make the needed calls to ambient. - new Thread(new Runnable() { - @Override - public void run() { - AmbientApiClient client = AmbientConnection.CLIENT.get(context); - ArrayList<NotificationNudge> nudges = getNudges(client, context, key, - isTesting); - sendNudgeRequestToDiscovery(client, nudges); - } - }).start(); - } + private Context mContext; + private AmbientApiClient mClient; + private HashMap<String, Bundle> availableNudges = new HashMap<String, Bundle>(); + private List<ComponentName> plugins = new ArrayList<ComponentName>(); - private static void sendNudgeRequestToDiscovery(AmbientApiClient client, - ArrayList<NotificationNudge> nudges) { + // Key for this instance + private static String mKey; - for (NotificationNudge nn : nudges) { - DiscoveryManagerServices.DiscoveryManagerApi.publishNudge(client, nn); - } + public DiscoveryEventHandler(Context context) { + mContext = context; + mClient = AmbientConnection.CLIENT.get(context); } - private static ArrayList<NotificationNudge> getNudges(AmbientApiClient client, Context context, - String key, boolean isTesting) { - - Map nudgePlugins = - NudgeServices.NudgeApi.getAvailableNudgesForKey(client, key).await().components; - - ArrayList<NotificationNudge> notificationNudges = new ArrayList<>(); - - if (nudgePlugins == null) { - return notificationNudges; - } - - InCallApi api = InCallServices.getInstance(); + public void getNudgeProvidersWithKey(final String key) { + getNudgeProvidersWithKey(key, false); + } - List<ComponentName> plugins = api.getInstalledPlugins(client).await().components; + /* package */ void getNudgeProvidersWithKey(final String key, final boolean isTesting) { + mKey = key; + getAvailableNudgesForKey(key, isTesting); + getInstalledPlugins(); + } - HashMap<String, Bundle> availableNudges = new HashMap<>(); + private void getAvailableNudgesForKey(final String key, final boolean isTesting) { + NudgeServices.NudgeApi.getAvailableNudgesForKey(mClient, key) + .setResultCallback(new ResultCallback<NudgablePluginsResult>() { + @Override + public void onResult(NudgablePluginsResult plugins) { + Map nudgePlugins = plugins.components; + if (nudgePlugins == null || nudgePlugins.size() == 0) { + return; + } + for (Object entry : nudgePlugins.entrySet()) { + Map.Entry<ComponentName, Bundle> theEntry + = (Map.Entry<ComponentName, Bundle>) entry; - for (Object entry : nudgePlugins.entrySet()) { - Map.Entry<ComponentName, Bundle> theEntry = (Map.Entry<ComponentName, Bundle>) entry; - availableNudges.put(theEntry.getKey().getPackageName(), theEntry.getValue()); - } + Bundle b = theEntry.getValue(); - if (plugins != null && plugins.size() > 0) { + if (validateShouldShowNudge(key, b) && !isTesting) { + // Nudge not yet ready for this item. + continue; + } - for (ComponentName component : plugins) { + availableNudges.put(theEntry.getKey().getPackageName(), b); + } - if (availableNudges.containsKey(component.getPackageName())) { + getStatusWhenReady(); + } + }); + } - PluginStatusResult statusResult = - api.getPluginStatus(client, component).await(); - Bundle b = availableNudges.get(component.getPackageName()); + /** + * Get installed plugins + */ + private void getInstalledPlugins() { + InCallServices.getInstance().getInstalledPlugins(mClient) + .setResultCallback(new ResultCallback<InstalledPluginsResult>() { + @Override + public void onResult(InstalledPluginsResult installedPluginsResult) { + plugins = installedPluginsResult.components; - if (validateShouldShowNudge(key, context, b) && !isTesting) { - // Nudge not yet ready for this item. - continue; + if (plugins == null || plugins.size() == 0) { + return; + } + getStatusWhenReady(); } + }); + } - if (DEBUG_STATUS || (statusResult.status != PluginStatus.DISABLED && - statusResult.status != PluginStatus.UNAVAILABLE)) { - - Bitmap notificationIcon = null; + /** + * Get our plugin enabled status + * @param cn + */ + private void getCallMethodStatus(final ComponentName cn) { + InCallServices.getInstance().getPluginStatus(mClient, cn) + .setResultCallback(new ResultCallback<PluginStatusResult>() { + @Override + public void onResult(PluginStatusResult pluginStatusResult) { + + boolean pluginIsApplicable = pluginStatusResult.status != PluginStatus.DISABLED + && pluginStatusResult.status != PluginStatus.UNAVAILABLE; + + if (!pluginIsApplicable) { + plugins.remove(cn); + return; + } - InCallProviderInfoResult providerInfo = - api.getProviderInfo(client, component).await(); + getCallMethodIcon(cn); + } + }); + } + private void getCallMethodIcon(final ComponentName cn) { + InCallServices.getInstance().getProviderInfo(mClient, cn) + .setResultCallback(new ResultCallback<InCallProviderInfoResult>() { + @Override + public void onResult(InCallProviderInfoResult providerInfo) { if (providerInfo != null && providerInfo.inCallProviderInfo != null) { try { - Resources pluginResources = context.getPackageManager() - .getResourcesForApplication(component.getPackageName()); + Resources pluginResources = mContext.getPackageManager() + .getResourcesForApplication(cn.getPackageName()); Drawable d = pluginResources.getDrawable( providerInfo.inCallProviderInfo.getBrandIcon(), null); - notificationIcon = ImageUtils.drawableToBitmap(d); + createNudge(cn, ImageUtils.drawableToBitmap(d)); } catch (Resources.NotFoundException e) { - Log.e(TAG, "Unable to retrieve icon for plugin: " + component); + Log.e(TAG, "Unable to retrieve icon for plugin: " + cn); } catch (PackageManager.NameNotFoundException e) { - Log.e(TAG, "Plugin isn't installed: " + component); + Log.e(TAG, "Plugin isn't installed: " + cn); } } + } + }); + } - NotificationNudge nn = new NotificationNudge(component.getPackageName(), - Nudge.Type.IMMEDIATE, - b.getString(NudgeKey.NUDGE_PARAM_TITLE), - b.getString(NudgeKey.NOTIFICATION_PARAM_BODY)); - - if (notificationIcon != null) { - nn.setLargeIcon(notificationIcon); - } - - Parcelable[] actions = - b.getParcelableArray(NudgeKey.NOTIFICATION_PARAM_NUDGE_ACTIONS); + private void getStatusWhenReady() { + if (plugins == null || plugins.size() == 0 + || availableNudges == null || availableNudges.size() == 0) { + // Not ready or never will be, just bail man. + return; + } + for (ComponentName cn : plugins) { + if (availableNudges.containsKey(cn.getPackageName())) { + getCallMethodStatus(cn); + } + } + } - for (Parcelable action : actions) { - NotificationNudge.Button button = (NotificationNudge.Button) action; - nn.addButton(button); - } + private void createNudge(ComponentName component, Bitmap notificationIcon) { + Bundle b = availableNudges.get(component.getPackageName()); - Intent intent = new Intent(context, DiscoverySignalReceiver.class); - intent.setAction(DiscoverySignalReceiver.DISCOVERY_NUDGE_SHOWN); - - String nudgeID; - try { - MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); - messageDigest.update(b.getString(NudgeKey.NOTIFICATION_PARAM_BODY) - .getBytes()); - nudgeID = new String(messageDigest.digest()); - } catch (NoSuchAlgorithmException e) { - Log.e(TAG, "No Algo, defaulting to unknown", e); - nudgeID = "unkown"; - } - intent.putExtra(DiscoverySignalReceiver.NUDGE_ID, nudgeID); + String title = b.getString(NudgeKey.NUDGE_PARAM_TITLE); + String body = b.getString(NudgeKey.NOTIFICATION_PARAM_BODY); + Parcelable[] actions = b.getParcelableArray(NudgeKey.NOTIFICATION_PARAM_NUDGE_ACTIONS); - intent.putExtra(DiscoverySignalReceiver.NUDGE_KEY, key); + NotificationNudge nn = new NotificationNudge(component.getPackageName(), + Nudge.Type.IMMEDIATE, title, body); - intent.putExtra(DiscoverySignalReceiver.NUDGE_COMPONENT, - component.flattenToShortString()); + for (Parcelable action : actions) { + NotificationNudge.Button button = (NotificationNudge.Button) action; + nn.addButton(button); + } - PendingIntent pendingIntent = PendingIntent.getBroadcast( - context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + nn.setLargeIcon(notificationIcon); + nn.setOnShowIntent(buildActionIntent(body, + DiscoverySignalReceiver.DISCOVERY_NUDGE_SHOWN, component)); + nn.setContentIntent(buildActionIntent(body, + DiscoverySignalReceiver.DISCOVERY_NUDGE_DISMISS, component)); - nn.setOnShowIntent(pendingIntent); + DiscoveryManagerServices.DiscoveryManagerApi.publishNudge(mClient, nn); + } - notificationNudges.add(nn); - } - } - } + private PendingIntent buildActionIntent(String body, String action, ComponentName component) { + Intent intent = new Intent(action); + String nudgeID; + try { + MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); + messageDigest.update(body.getBytes()); + nudgeID = new String(messageDigest.digest()); + } catch (NoSuchAlgorithmException e) { + Log.e(TAG, "No Algo, defaulting to unknown", e); + nudgeID = "unknown"; } - return notificationNudges; - } + intent.putExtra(DiscoverySignalReceiver.NUDGE_ID, nudgeID); + intent.putExtra(DiscoverySignalReceiver.NUDGE_KEY, mKey); + intent.putExtra(DiscoverySignalReceiver.NUDGE_COMPONENT, component.flattenToShortString()); - private static boolean validateShouldShowNudge(String key, Context c, Bundle b) { + return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); + } - boolean checkCount = false; + private boolean validateShouldShowNudge(String key, Bundle b) { + boolean checkCount; - SharedPreferences preferences = c.getSharedPreferences(DialtactsActivity.SHARED_PREFS_NAME, - Context.MODE_PRIVATE); + SharedPreferences preferences = mContext.getSharedPreferences(DialtactsActivity + .SHARED_PREFS_NAME, Context.MODE_PRIVATE); int count = 0; + // The count starts at 1 here because this is the first time we've seen this item. if (key.equals(NudgeKey.NOTIFICATION_INTERNATIONAL_CALL)) { - count = preferences.getInt(CallMethodUtils.PREF_INTERNATIONAL_CALLS, 0); + count = preferences.getInt(CallMethodUtils.PREF_INTERNATIONAL_CALLS, 1); } else if (key.equals(NudgeKey.NOTIFICATION_WIFI_CALL)) { - count = preferences.getInt(CallMethodUtils.PREF_WIFI_CALL, 0); + count = preferences.getInt(CallMethodUtils.PREF_WIFI_CALL, 1); } checkCount = @@ -203,7 +246,6 @@ public class DiscoveryEventHandler { // return true if nudge should be shown return checkCount; - } } diff --git a/src/com/android/dialer/discovery/DiscoveryService.java b/src/com/android/dialer/discovery/DiscoveryService.java index 6713aa97a..d208b1c1b 100644 --- a/src/com/android/dialer/discovery/DiscoveryService.java +++ b/src/com/android/dialer/discovery/DiscoveryService.java @@ -3,6 +3,7 @@ package com.android.dialer.discovery; import android.app.IntentService; import android.content.Intent; import android.net.ConnectivityManager; +import android.text.TextUtils; import com.android.dialer.discovery.DiscoveryEventHandler; import com.cyanogen.ambient.discovery.util.NudgeKey; @@ -19,15 +20,18 @@ public class DiscoveryService extends IntentService { @Override protected void onHandleIntent(Intent intent) { String action = intent.getAction(); + String nudgeKey = null; switch (action) { case ConnectivityManager.CONNECTIVITY_ACTION: - DiscoveryEventHandler.getNudgeProvidersWithKey(getApplicationContext(), - NudgeKey.NOTIFICATION_ROAMING); + nudgeKey = NudgeKey.NOTIFICATION_ROAMING; break; case Intent.ACTION_NEW_OUTGOING_CALL: - DiscoveryEventHandler.getNudgeProvidersWithKey(getApplicationContext(), - NudgeKey.NOTIFICATION_INTERNATIONAL_CALL); + nudgeKey = NudgeKey.NOTIFICATION_INTERNATIONAL_CALL; break; } + if (!TextUtils.isEmpty(nudgeKey)) { + new DiscoveryEventHandler(getApplicationContext()).getNudgeProvidersWithKey(nudgeKey); + } + } } diff --git a/src/com/android/dialer/discovery/DiscoverySignalReceiver.java b/src/com/android/dialer/discovery/DiscoverySignalReceiver.java index 770609918..1a3362d46 100644 --- a/src/com/android/dialer/discovery/DiscoverySignalReceiver.java +++ b/src/com/android/dialer/discovery/DiscoverySignalReceiver.java @@ -9,6 +9,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.TelephonyManager; +import android.text.TextUtils; import android.util.Log; import com.android.contacts.common.GeoUtil; import com.android.dialer.DialtactsActivity; @@ -40,9 +41,20 @@ public class DiscoverySignalReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); + String nudgeId = intent.getStringExtra(NUDGE_ID); + String nudgeKey = intent.getStringExtra(NUDGE_KEY); + + ComponentName nudgeComponent = null; + if (intent.hasExtra(NUDGE_COMPONENT) + && !TextUtils.isEmpty(intent.getStringExtra(NUDGE_COMPONENT))) { + + nudgeComponent + = ComponentName.unflattenFromString(intent.getStringExtra(NUDGE_COMPONENT)); + + } + switch (action) { case ConnectivityManager.CONNECTIVITY_ACTION: ConnectivityManager connManager = (ConnectivityManager) @@ -70,10 +82,10 @@ public class DiscoverySignalReceiver extends BroadcastReceiver { } break; case DISCOVERY_NUDGE_SHOWN: - String nudgeId = intent.getStringExtra(NUDGE_ID); - String nudgeKey = intent.getStringExtra(NUDGE_KEY); - ComponentName nudgeComponent = - ComponentName.unflattenFromString(intent.getStringExtra(NUDGE_COMPONENT)); + if (nudgeComponent == null) { + Log.e(TAG, "The nudge component is null, not counting as a nudge event"); + return; + } SharedPreferences sp = context.getSharedPreferences(NUDGE_SHARED_PREF, Context.MODE_PRIVATE); @@ -92,26 +104,38 @@ public class DiscoverySignalReceiver extends BroadcastReceiver { editor.putLong(timeKey, System.currentTimeMillis()); editor.apply(); - InCallMetricsHelper.Events event; - if (nudgeKey.equals(NudgeKey.NOTIFICATION_INTERNATIONAL_CALL)) { - event = InCallMetricsHelper.Events.NUDGE_EVENT_INTL; - } else { - event = InCallMetricsHelper.Events.NUDGE_EVENT_ROAMING; - } - - InCallMetricsHelper.increaseCountOfMetric(nudgeComponent, event, - InCallMetricsHelper.Categories.DISCOVERY_NUDGES, + recordDiscoveryCount(nudgeComponent, nudgeKey, InCallMetricsHelper.Parameters.COUNT); break; - case DISCOVERY_NUDGE_DISMISS: + } + + } + private void recordDiscoveryCount(ComponentName componentName, String nudgeKey, + InCallMetricsHelper.Parameters param) { + InCallMetricsHelper.Events event = null; + switch(nudgeKey) { + case NudgeKey.NOTIFICATION_INTERNATIONAL_CALL: + event = InCallMetricsHelper.Events.NUDGE_EVENT_INTL; + break; + case NudgeKey.NOTIFICATION_WIFI_CALL: + event = InCallMetricsHelper.Events.NUDGE_EVENT_WIFI; + break; + case NudgeKey.NOTIFICATION_ROAMING: + event = InCallMetricsHelper.Events.NUDGE_EVENT_ROAMING; break; } + if (event != null) { + InCallMetricsHelper.increaseCountOfMetric(componentName, event, + InCallMetricsHelper.Categories.DISCOVERY_NUDGES, + param); + } } - public boolean isMaybeInternationalNumber(Context context, String number) { + + private boolean isMaybeInternationalNumber(Context context, String number) { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); String currentCountryIso = GeoUtil.getCurrentCountryIso(context); diff --git a/src/com/android/dialer/discovery/NudgeItem.java b/src/com/android/dialer/discovery/NudgeItem.java index 1aacd82a6..748d3af72 100644 --- a/src/com/android/dialer/discovery/NudgeItem.java +++ b/src/com/android/dialer/discovery/NudgeItem.java @@ -58,13 +58,13 @@ public class NudgeItem { public String getTimeKey() { String[] key = getBaseKey(); key[DATA] = TIME; - return Joiner.on(InCallMetricsHelper.DELIMIT).join(key); + return Joiner.on(InCallMetricsHelper.DELIMIT).skipNulls().join(key); } public String getWinKey() { String[] key = getBaseKey(); key[DATA] = NUDGE_ENABLED_PLUGIN; - return Joiner.on(InCallMetricsHelper.DELIMIT).join(key); + return Joiner.on(InCallMetricsHelper.DELIMIT).skipNulls().join(key); } /** @@ -73,7 +73,7 @@ public class NudgeItem { public String getCountKey() { String[] key = getBaseKey(); key[DATA] = InCallMetricsHelper.Parameters.COUNT.value(); - return Joiner.on(InCallMetricsHelper.DELIMIT).join(key); + return Joiner.on(InCallMetricsHelper.DELIMIT).skipNulls().join(key); } public static String getKeyType(String[] array) { diff --git a/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java b/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java index a1f12c0ed..6508f4e67 100644 --- a/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java +++ b/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java @@ -137,7 +137,8 @@ public class WifiCallStatusNudgeListener { int currentCount = preferences.getInt(CallMethodUtils.PREF_WIFI_CALL, 0); preferences.edit().putInt(CallMethodUtils.PREF_WIFI_CALL, ++currentCount).apply(); - DiscoveryEventHandler.getNudgeProvidersWithKey(mContext, NudgeKey.NOTIFICATION_WIFI_CALL); + new DiscoveryEventHandler(mContext).getNudgeProvidersWithKey( + NudgeKey.NOTIFICATION_WIFI_CALL); } private static void callOnWifiFailure() { diff --git a/src/com/android/dialer/incall/InCallMetricsHelper.java b/src/com/android/dialer/incall/InCallMetricsHelper.java index b663b5d4d..76733726b 100644 --- a/src/com/android/dialer/incall/InCallMetricsHelper.java +++ b/src/com/android/dialer/incall/InCallMetricsHelper.java @@ -56,6 +56,7 @@ public class InCallMetricsHelper { public enum Events { NUDGE_EVENT_INTL("NUDGE_EVENT_INTL"), // TODO + NUDGE_EVENT_WIFI("NUDGE_EVENT_INTL"), // TODO NUDGE_EVENT_ROAMING("NUDGE_EVENT_ROAMING"), // TODO CALL_PROVIDER_VIDEO("CALL_PROVIDER_VIDEO"), //DONE CALL_PROVIDER_PSTN("CALL_PROVIDER_PSTN"), //DONE @@ -101,7 +102,8 @@ public class InCallMetricsHelper { COUNT_AUTOMATIC("COUNT_AUTOMATIC"), COUNT_MANUAL("COUNT_MANUAL"), COUNT("COUNT"), - COUNT_INTERACTIONS("COUNT_INTERACTIONS"); + COUNT_INTERACTIONS("COUNT_INTERACTIONS"), + COUNT_DISMISS("COUNT_DISMISS"); private String mValue; Parameters(String s) { @@ -132,7 +134,7 @@ public class InCallMetricsHelper { InCallMetricsHelper helper = getInstance(); helper.mContext = context; - AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, InCallMetricsReceiver.class); PendingIntent pi = PendingIntent.getService(context, 0, i, 0); @@ -185,7 +187,7 @@ public class InCallMetricsHelper { } @VisibleForTesting - /* package */ static String buildKey(ComponentName componentName, Categories category, + public static String buildKey(ComponentName componentName, Categories category, Events action, Parameters parameter) { return componentName.flattenToShortString() + DELIMIT + category.value() + DELIMIT + |