Skip to content

Commit 4af05ef

Browse files
adithya2306neobuddy89
authored andcommitted
SystemUI: smartspace: Open google weather on tapping smartspace
Since smartspace weather activity won't open due to caller package (Launcher3) not being google signed, hijack the intent to open the google app's exported weather activity, which behaves in the same fashion. Change-Id: Ic01ede73ab6253bcb301ac794985c3720c5beda3 [cyberknight777: Adapt for BP4A smartspace] Signed-off-by: Cyber Knight <[email protected]> Signed-off-by: Pranav Vashi <[email protected]>
1 parent 05cbfcd commit 4af05ef

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/SystemUI/src/com/google/android/systemui/smartspace/BcSmartSpaceUtil.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.app.smartspace.SmartspaceTargetEvent;
77
import android.app.smartspace.uitemplatedata.TapAction;
88
import android.content.ActivityNotFoundException;
9+
import android.content.ComponentName;
910
import android.content.ContentUris;
1011
import android.content.Context;
1112
import android.content.Intent;
@@ -30,6 +31,8 @@
3031
import java.util.Map;
3132

3233
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";
3336
public static final Map<Integer, Integer> FEATURE_TYPE_TO_SECONDARY_CARD_RESOURCE_MAP;
3437
public static FalsingManager sFalsingManager;
3538

@@ -64,6 +67,21 @@ public final boolean onInteraction(View view, PendingIntent pendingIntent, Remot
6467
}
6568
}
6669

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+
6785
public static class DefaultIntentStarter implements BcSmartspaceDataPlugin.IntentStarter {
6886
public final String tag;
6987

@@ -180,7 +198,7 @@ public static void setOnClickListener(View view, SmartspaceTarget target, Smarts
180198
BcSmartspaceCardLogger.log(BcSmartspaceEvent.SMARTSPACE_CARD_CLICK, loggingInfo);
181199
}
182200

183-
if (!isNoIntent) {
201+
if (!isNoIntent && !hijackIntent(target, intentStarter, v)) {
184202
intentStarter.startFromAction(action, v, showOnLockscreen);
185203
}
186204

@@ -216,7 +234,7 @@ public static void setOnClickListener(View view, SmartspaceTarget target, TapAct
216234
}
217235

218236
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)) {
220238
intentStarter.startFromAction(tapAction, v, showOnLockscreen);
221239
}
222240

0 commit comments

Comments
 (0)