summaryrefslogtreecommitdiff
path: root/services/appwidget
diff options
context:
space:
mode:
authorSuprabh Shukla <suprabh@google.com>2018-05-10 15:54:08 -0700
committerSuprabh Shukla <suprabh@google.com>2018-05-11 14:24:54 -0700
commit1ab90a2ed5262633dd1ce9fbddb9b6536f83b441 (patch)
tree5cc7b7730a769c6b2f6b70421bf44913c4eae835 /services/appwidget
parent1b69d7b40661640bbcbe9b456de8b8c21aefee37 (diff)
Fixing user tap on suspended widget
Widgets get masked with separate remove views when suspended. Need to update them with the correct pending intent. Moved around the logic creating the suspended alert activity to make it reusable. Test: Manually, "pm suspend <app-with-widget>", followed by tap on widget Existing tests pass: atest GtsSuspendAppsTestCases atest com.android.server.am.ActivityStartInterceptorTest Bug: 79474038 Change-Id: Ic75ee762434bf92c54bda307e9cb6018f94a914c
Diffstat (limited to 'services/appwidget')
-rw-r--r--services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index f992049ef1fb..8d2d4a31efc5 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -20,6 +20,8 @@ import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
+
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.AlarmManager;
@@ -50,6 +52,7 @@ import android.content.pm.LauncherApps;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.PackageManagerInternal;
import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
@@ -96,6 +99,7 @@ import android.view.WindowManager;
import android.widget.RemoteViews;
import com.android.internal.R;
+import com.android.internal.app.SuspendedAppActivity;
import com.android.internal.app.UnlaunchableAppActivity;
import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.appwidget.IAppWidgetService;
@@ -228,6 +232,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
private AppOpsManager mAppOpsManager;
private KeyguardManager mKeyguardManager;
private DevicePolicyManagerInternal mDevicePolicyManagerInternal;
+ private PackageManagerInternal mPackageManagerInternal;
private SecurityPolicy mSecurityPolicy;
@@ -254,6 +259,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
mKeyguardManager = (KeyguardManager) mContext.getSystemService(KEYGUARD_SERVICE);
mDevicePolicyManagerInternal = LocalServices.getService(DevicePolicyManagerInternal.class);
+ mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
mSaveStateHandler = BackgroundThread.getHandler();
mCallbackHandler = new CallbackHandler(mContext.getMainLooper());
mBackupRestoreController = new BackupRestoreController();
@@ -620,8 +626,17 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
if (provider.maskedBySuspendedPackage) {
UserInfo userInfo = mUserManager.getUserInfo(providerUserId);
showBadge = userInfo.isManagedProfile();
- onClickIntent = mDevicePolicyManagerInternal.createShowAdminSupportIntent(
- providerUserId, true);
+ final String suspendingPackage = mPackageManagerInternal.getSuspendingPackage(
+ providerPackage, providerUserId);
+ if (PLATFORM_PACKAGE_NAME.equals(suspendingPackage)) {
+ onClickIntent = mDevicePolicyManagerInternal.createShowAdminSupportIntent(
+ providerUserId, true);
+ } else {
+ final String dialogMessage = mPackageManagerInternal.getSuspendedDialogMessage(
+ providerPackage, providerUserId);
+ onClickIntent = SuspendedAppActivity.createSuspendedAppInterceptIntent(
+ providerPackage, suspendingPackage, dialogMessage, providerUserId);
+ }
} else if (provider.maskedByQuietProfile) {
showBadge = true;
onClickIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(