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

Commit 83fa7a82 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Handle locale change and pacakge change in different way" into nyc-mr1-dev

parents 82d88643 4e6cef49
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -67,10 +67,4 @@ public abstract class ShortcutServiceInternal {

    public abstract boolean hasShortcutHostPermission(int launcherUserId,
            @NonNull String callingPackage);

    /**
     * Called by AM when the system locale changes *within the AM lock*.  ABSOLUTELY do not take
     * any locks in this method.
     */
    public abstract void onSystemLocaleChangedNoLock();
}
+0 −10
Original line number Diff line number Diff line
@@ -140,7 +140,6 @@ import android.content.pm.PermissionInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.ShortcutServiceInternal;
import android.content.pm.UserInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
@@ -18865,15 +18864,6 @@ public final class ActivityManagerService extends ActivityManagerNative
                        null, AppOpsManager.OP_NONE, null, false, false,
                        MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
                if ((changes&ActivityInfo.CONFIG_LOCALE) != 0) {
                    // Tell the shortcut manager that the system locale changed.  It needs to know
                    // it before any other apps receive ACTION_LOCALE_CHANGED, which is why
                    // we "push" from here, rather than having the service listen to the broadcast.
                    final ShortcutServiceInternal shortcutService =
                            LocalServices.getService(ShortcutServiceInternal.class);
                    if (shortcutService != null) {
                        shortcutService.onSystemLocaleChangedNoLock();
                    }
                    intent = new Intent(Intent.ACTION_LOCALE_CHANGED);
                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                    if (!mProcessesReady) {
+57 −18
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.server.pm.ShortcutService.ShortcutOperation;
import com.android.server.pm.ShortcutService.Stats;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -437,8 +438,6 @@ class ShortcutPackage extends ShortcutPackageItem {
     * locale changes.
     */
    public int getApiCallCount() {
        mShortcutUser.resetThrottlingIfNeeded();

        final ShortcutService s = mShortcutUser.mService;

        // Reset the counter if:
@@ -598,7 +597,37 @@ class ShortcutPackage extends ShortcutPackageItem {
    }

    /**
     * Called when the package is updated or added.
     * @return false if any of the target activities are no longer enabled.
     */
    private boolean areAllActivitiesStillEnabled() {
        if (mShortcuts.size() == 0) {
            return true;
        }
        final ShortcutService s = mShortcutUser.mService;

        // Normally the number of target activities is 1 or so, so no need to use a complex
        // structure like a set.
        final ArrayList<ComponentName> checked = new ArrayList<>(4);

        for (int i = mShortcuts.size() - 1; i >= 0; i--) {
            final ShortcutInfo si = mShortcuts.valueAt(i);
            final ComponentName activity = si.getActivity();

            if (checked.contains(activity)) {
                continue; // Already checked.
            }
            checked.add(activity);

            if (!s.injectIsActivityEnabledAndExported(activity, getOwnerUserId())) {
                return false;
            }
        }
        return true;
    }

    /**
     * Called when the package may be added or updated, or its activities may be disabled, and
     * if so, rescan the package and do the necessary stuff.
     *
     * Add case:
     * - Publish manifest shortcuts.
@@ -606,24 +635,36 @@ class ShortcutPackage extends ShortcutPackageItem {
     * Update case:
     * - Re-publish manifest shortcuts.
     * - If there are shortcuts with resources (icons or strings), update their timestamps.
     * - Disable shortcuts whose target activities are disabled.
     *
     * @return TRUE if any shortcuts have been changed.
     */
    public boolean handlePackageAddedOrUpdated(boolean isNewApp, boolean forceRescan) {
        final PackageInfo pi = mShortcutUser.mService.getPackageInfo(
    public boolean rescanPackageIfNeeded(boolean isNewApp, boolean forceRescan) {
        final ShortcutService s = mShortcutUser.mService;
        final long start = s.injectElapsedRealtime();

        final PackageInfo pi;
        try {
            pi = mShortcutUser.mService.getPackageInfo(
                    getPackageName(), getPackageUserId());
            if (pi == null) {
                return false; // Shouldn't happen.
            }

            if (!isNewApp && !forceRescan) {
            // Make sure the version code or last update time has changed.
            // Otherwise, nothing to do.
            if (getPackageInfo().getVersionCode() >= pi.versionCode
                    && getPackageInfo().getLastUpdateTime() >= pi.lastUpdateTime) {
                // Return if the package hasn't changed, ie:
                // - version code hasn't change
                // - lastUpdateTime hasn't change
                // - all target activities are still enabled.
                if ((getPackageInfo().getVersionCode() >= pi.versionCode)
                        && (getPackageInfo().getLastUpdateTime() >= pi.lastUpdateTime)
                        && areAllActivitiesStillEnabled()) {
                    return false;
                }
            }
        } finally {
            s.logDurationStat(Stats.PACKAGE_UPDATE_CHECK, start);
        }

        // Now prepare to publish manifest shortcuts.
        List<ShortcutInfo> newManifestShortcutList = null;
@@ -654,8 +695,6 @@ class ShortcutPackage extends ShortcutPackageItem {

        getPackageInfo().updateVersionInfo(pi);

        final ShortcutService s = mShortcutUser.mService;

        boolean changed = false;

        // For existing shortcuts, update timestamps if they have any resources.
@@ -1001,7 +1040,7 @@ class ShortcutPackage extends ShortcutPackageItem {
            }
        }
        if (changed) {
            s.scheduleSaveUser(getPackageUserId());
            s.packageShortcutsChanged(getPackageName(), getPackageUserId());
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ abstract class ShortcutPackageItem {
        mPackageInfo = Preconditions.checkNotNull(packageInfo);
    }

    public ShortcutUser getUser() {
        return mShortcutUser;
    }

    /**
     * ID of the user who actually has this package running on.  For {@link ShortcutPackage},
     * this is the same thing as {@link #getOwnerUserId}, but if it's a {@link ShortcutLauncher} and
+115 −103

File changed.

Preview size limit exceeded, changes collapsed.

Loading