Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02be488a authored by seokgyun.hong's avatar seokgyun.hong Committed by Yuncheol Heo
Browse files

Handle AppWarnings per-user per-display

Previously, AppWarning dialogs were not handled per-user per-display
and that caused the following issues:

- AppWarning dialogs were managed based on the default display and the
  system user. Therefore, all the warning dialogs were only shown on
  the default display even if it's for the app running on the secondary
  display.
  In addition, it could only receive Intent.ACTION_CLOSE_SYSTEM_DIALOGS
  delivered to the system user regardless of who the actual user is.
- The warning dialog could be shown to the only one user at a time.
  In 'MUMD'(multi-user on multiple displays), each warning dialog should
  be shown to each user independently, but it wasn't.
- The flags that determine whether to hide the warning dialog were
  handled per package, but not per user. As a result, flags set by
  one user for specific package were also applied to other users.

To fix these, ensure that the warning dialogs are handled per-user and
per-display for MUMD devices. Please note that handling the warning
dialogs per-user per-display is only applicable to the devices that
enable the visible background users.

Bug: 296334639
Test: Manual test
(cherry picked from https://partner-android-review.googlesource.com/q/commit:1e099c7254ab802b747595b1180ee39b9a1674ba)

Change-Id: I3cdad53172748c452a941b8a798c3a799d9028c0
parent 1699048d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -886,6 +886,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            mRecentTasks.onSystemReadyLocked();
            mTaskSupervisor.onSystemReady();
            mActivityClientController.onSystemReady();
            mAppWarnings.onSystemReady();
            // TODO(b/258792202) Cleanup once ASM is ready to launch
            ActivitySecurityModelFeatureFlags.initialize(mContext.getMainExecutor());
            mGrammaticalManagerInternal = LocalServices.getService(
@@ -6360,7 +6361,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        public void onPackageDataCleared(String name, int userId) {
            synchronized (mGlobalLock) {
                mCompatModePackages.handlePackageDataClearedLocked(name);
                mAppWarnings.onPackageDataCleared(name);
                mAppWarnings.onPackageDataCleared(name, userId);
                mPackageConfigPersister.onPackageDataCleared(name, userId);
            }
        }
@@ -6368,7 +6369,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        @Override
        public void onPackageUninstalled(String name, int userId) {
            synchronized (mGlobalLock) {
                mAppWarnings.onPackageUninstalled(name);
                mAppWarnings.onPackageUninstalled(name, userId);
                mCompatModePackages.handlePackageUninstalledLocked(name);
                mPackageConfigPersister.onPackageUninstall(name, userId);
            }
+336 −92

File changed.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ import com.android.internal.R;

class DeprecatedAbiDialog extends AppWarnings.BaseDialog {
    DeprecatedAbiDialog(final AppWarnings manager, Context context,
            ApplicationInfo appInfo) {
        super(manager, appInfo.packageName);
            ApplicationInfo appInfo, int userId) {
        super(manager, context, appInfo.packageName, userId);

        final PackageManager pm = context.getPackageManager();
        final CharSequence label = appInfo.loadSafeLabel(pm,
@@ -41,7 +41,7 @@ class DeprecatedAbiDialog extends AppWarnings.BaseDialog {
        final AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .setPositiveButton(R.string.ok, (dialog, which) ->
                    manager.setPackageFlag(
                            mPackageName, AppWarnings.FLAG_HIDE_DEPRECATED_ABI, true))
                            mUserId, mPackageName, AppWarnings.FLAG_HIDE_DEPRECATED_ABI, true))
                .setMessage(message)
                .setTitle(label);

+3 −3
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ import com.android.server.utils.AppInstallerUtil;
class DeprecatedTargetSdkVersionDialog extends AppWarnings.BaseDialog {

    DeprecatedTargetSdkVersionDialog(final AppWarnings manager, Context context,
            ApplicationInfo appInfo) {
        super(manager, appInfo.packageName);
            ApplicationInfo appInfo, int userId) {
        super(manager, context, appInfo.packageName, userId);

        final PackageManager pm = context.getPackageManager();
        final CharSequence label = appInfo.loadSafeLabel(pm,
@@ -44,7 +44,7 @@ class DeprecatedTargetSdkVersionDialog extends AppWarnings.BaseDialog {
        final AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .setPositiveButton(R.string.ok, (dialog, which) ->
                    manager.setPackageFlag(
                            mPackageName, AppWarnings.FLAG_HIDE_DEPRECATED_SDK, true))
                            mUserId, mPackageName, AppWarnings.FLAG_HIDE_DEPRECATED_SDK, true))
                .setMessage(message)
                .setTitle(label);

+3 −3
Original line number Diff line number Diff line
@@ -32,8 +32,8 @@ import com.android.server.utils.AppInstallerUtil;
class UnsupportedCompileSdkDialog extends AppWarnings.BaseDialog {

    UnsupportedCompileSdkDialog(final AppWarnings manager, Context context,
            ApplicationInfo appInfo) {
        super(manager, appInfo.packageName);
            ApplicationInfo appInfo, int userId) {
        super(manager, context, appInfo.packageName, userId);

        final PackageManager pm = context.getPackageManager();
        final CharSequence label = appInfo.loadSafeLabel(pm,
@@ -68,6 +68,6 @@ class UnsupportedCompileSdkDialog extends AppWarnings.BaseDialog {
        final CheckBox alwaysShow = mDialog.findViewById(R.id.ask_checkbox);
        alwaysShow.setChecked(true);
        alwaysShow.setOnCheckedChangeListener((buttonView, isChecked) -> manager.setPackageFlag(
                mPackageName, AppWarnings.FLAG_HIDE_COMPILE_SDK, !isChecked));
                mUserId, mPackageName, AppWarnings.FLAG_HIDE_COMPILE_SDK, !isChecked));
    }
}
Loading