|
6 | 6 | import android.app.smartspace.SmartspaceTargetEvent; |
7 | 7 | import android.app.smartspace.uitemplatedata.TapAction; |
8 | 8 | import android.content.ActivityNotFoundException; |
| 9 | +import android.content.ComponentName; |
9 | 10 | import android.content.ContentUris; |
10 | 11 | import android.content.Context; |
11 | 12 | import android.content.Intent; |
|
30 | 31 | import java.util.Map; |
31 | 32 |
|
32 | 33 | public abstract class BcSmartSpaceUtil { |
| 34 | + private static final String GSA_PACKAGE = "com.google.android.googlequicksearchbox"; |
| 35 | + private static final String GSA_WEATHER_ACTIVITY = "com.google.android.apps.search.weather.WeatherExportedActivity"; |
33 | 36 | public static final Map<Integer, Integer> FEATURE_TYPE_TO_SECONDARY_CARD_RESOURCE_MAP; |
34 | 37 | public static FalsingManager sFalsingManager; |
35 | 38 |
|
@@ -64,6 +67,21 @@ public final boolean onInteraction(View view, PendingIntent pendingIntent, Remot |
64 | 67 | } |
65 | 68 | } |
66 | 69 |
|
| 70 | + // Workaround for Google weather |
| 71 | + private static boolean hijackIntent(SmartspaceTarget target, BcSmartspaceDataPlugin.IntentStarter intentStarter, View view) { |
| 72 | + if (view instanceof IcuDateTextView) { |
| 73 | + // Ensure we don't change date view |
| 74 | + return false; |
| 75 | + } |
| 76 | + if (target != null && target.getFeatureType() == target.FEATURE_WEATHER) { |
| 77 | + Intent intent = new Intent().setComponent(new ComponentName(GSA_PACKAGE, GSA_WEATHER_ACTIVITY)) |
| 78 | + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 79 | + intentStarter.startIntent(view, intent, true); |
| 80 | + return true; |
| 81 | + } |
| 82 | + return false; |
| 83 | + } |
| 84 | + |
67 | 85 | public static class DefaultIntentStarter implements BcSmartspaceDataPlugin.IntentStarter { |
68 | 86 | public final String tag; |
69 | 87 |
|
@@ -180,7 +198,7 @@ public static void setOnClickListener(View view, SmartspaceTarget target, Smarts |
180 | 198 | BcSmartspaceCardLogger.log(BcSmartspaceEvent.SMARTSPACE_CARD_CLICK, loggingInfo); |
181 | 199 | } |
182 | 200 |
|
183 | | - if (!isNoIntent) { |
| 201 | + if (!isNoIntent && !hijackIntent(target, intentStarter, v)) { |
184 | 202 | intentStarter.startFromAction(action, v, showOnLockscreen); |
185 | 203 | } |
186 | 204 |
|
@@ -216,7 +234,7 @@ public static void setOnClickListener(View view, SmartspaceTarget target, TapAct |
216 | 234 | } |
217 | 235 |
|
218 | 236 | BcSmartspaceDataPlugin.IntentStarter intentStarter = getIntentStarter(eventNotifier, tag); |
219 | | - if (tapAction.getIntent() != null || tapAction.getPendingIntent() != null) { |
| 237 | + if ((tapAction.getIntent() != null || tapAction.getPendingIntent() != null) && !hijackIntent(target, intentStarter, v)) { |
220 | 238 | intentStarter.startFromAction(tapAction, v, showOnLockscreen); |
221 | 239 | } |
222 | 240 |
|
|
0 commit comments