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 Original line Diff line number Diff line
@@ -67,10 +67,4 @@ public abstract class ShortcutServiceInternal {


    public abstract boolean hasShortcutHostPermission(int launcherUserId,
    public abstract boolean hasShortcutHostPermission(int launcherUserId,
            @NonNull String callingPackage);
            @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 Original line Diff line number Diff line
@@ -140,7 +140,6 @@ import android.content.pm.PermissionInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.ShortcutServiceInternal;
import android.content.pm.UserInfo;
import android.content.pm.UserInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
@@ -18865,15 +18864,6 @@ public final class ActivityManagerService extends ActivityManagerNative
                        null, AppOpsManager.OP_NONE, null, false, false,
                        null, AppOpsManager.OP_NONE, null, false, false,
                        MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
                        MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
                if ((changes&ActivityInfo.CONFIG_LOCALE) != 0) {
                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 = new Intent(Intent.ACTION_LOCALE_CHANGED);
                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                    if (!mProcessesReady) {
                    if (!mProcessesReady) {
+57 −18
Original line number Original line 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.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.XmlUtils;
import com.android.server.pm.ShortcutService.ShortcutOperation;
import com.android.server.pm.ShortcutService.ShortcutOperation;
import com.android.server.pm.ShortcutService.Stats;


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

        final ShortcutService s = mShortcutUser.mService;
        final ShortcutService s = mShortcutUser.mService;


        // Reset the counter if:
        // 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:
     * Add case:
     * - Publish manifest shortcuts.
     * - Publish manifest shortcuts.
@@ -606,24 +635,36 @@ class ShortcutPackage extends ShortcutPackageItem {
     * Update case:
     * Update case:
     * - Re-publish manifest shortcuts.
     * - Re-publish manifest shortcuts.
     * - If there are shortcuts with resources (icons or strings), update their timestamps.
     * - 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.
     * @return TRUE if any shortcuts have been changed.
     */
     */
    public boolean handlePackageAddedOrUpdated(boolean isNewApp, boolean forceRescan) {
    public boolean rescanPackageIfNeeded(boolean isNewApp, boolean forceRescan) {
        final PackageInfo pi = mShortcutUser.mService.getPackageInfo(
        final ShortcutService s = mShortcutUser.mService;
        final long start = s.injectElapsedRealtime();

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


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


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


        getPackageInfo().updateVersionInfo(pi);
        getPackageInfo().updateVersionInfo(pi);


        final ShortcutService s = mShortcutUser.mService;

        boolean changed = false;
        boolean changed = false;


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


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


    public ShortcutUser getUser() {
        return mShortcutUser;
    }

    /**
    /**
     * ID of the user who actually has this package running on.  For {@link ShortcutPackage},
     * 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
     * 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