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

Commit 9fa15007 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add API in AppWidgetServiceImpl" into tm-qpr-dev

parents 6f315fc8 3efbb0d3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -355,6 +355,9 @@ public class AppWidgetProviderInfo implements Parcelable {
    @UnsupportedAppUsage
    public ActivityInfo providerInfo;

    /** @hide */
    public boolean isExtendedFromAppWidgetProvider;

    public AppWidgetProviderInfo() {

    }
@@ -387,6 +390,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        this.providerInfo = in.readTypedObject(ActivityInfo.CREATOR);
        this.widgetFeatures = in.readInt();
        this.descriptionRes = in.readInt();
        this.isExtendedFromAppWidgetProvider = in.readBoolean();
    }

    /**
@@ -510,6 +514,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        out.writeTypedObject(this.providerInfo, flags);
        out.writeInt(this.widgetFeatures);
        out.writeInt(this.descriptionRes);
        out.writeBoolean(this.isExtendedFromAppWidgetProvider);
    }

    @Override
@@ -539,6 +544,7 @@ public class AppWidgetProviderInfo implements Parcelable {
        that.providerInfo = this.providerInfo;
        that.widgetFeatures = this.widgetFeatures;
        that.descriptionRes = this.descriptionRes;
        that.isExtendedFromAppWidgetProvider = this.isExtendedFromAppWidgetProvider;
        return that;
    }

+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ interface IAppWidgetService {
    @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
    boolean bindRemoteViewsService(String callingPackage, int appWidgetId, in Intent intent,
            IApplicationThread caller, IBinder token, IServiceConnection connection, int flags);
    void notifyProviderInheritance(in ComponentName[] componentNames);

    @UnsupportedAppUsage
    int[] getAppWidgetIds(in ComponentName providerComponent);
+35 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.provider.DeviceConfig.NAMESPACE_SYSTEMUI;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
@@ -1472,6 +1473,40 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
        updateAppWidgetIds(callingPackage, appWidgetIds, views, true);
    }

    @Override
    public void notifyProviderInheritance(@Nullable final ComponentName[] componentNames) {
        final int userId = UserHandle.getCallingUserId();
        if (DEBUG) {
            Slog.i(TAG, "notifyProviderInheritance() " + userId);
        }

        if (componentNames == null) {
            return;
        }

        for (ComponentName componentName : componentNames) {
            if (componentName == null) {
                return;
            }
            mSecurityPolicy.enforceCallFromPackage(componentName.getPackageName());
        }
        synchronized (mLock) {
            ensureGroupStateLoadedLocked(userId);

            for (ComponentName componentName : componentNames) {
                final ProviderId providerId = new ProviderId(Binder.getCallingUid(), componentName);
                final Provider provider = lookupProviderLocked(providerId);

                if (provider == null || provider.info == null) {
                    return;
                }

                provider.info.isExtendedFromAppWidgetProvider = true;
            }
            saveGroupStateAsync(userId);
        }
    }

    @Override
    public void notifyAppWidgetViewDataChanged(String callingPackage, int[] appWidgetIds,
            int viewId) {
+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public class AppWidgetXmlUtil {
    private static final String ATTR_WIDGET_CATEGORY = "widget_category";
    private static final String ATTR_WIDGET_FEATURES = "widget_features";
    private static final String ATTR_DESCRIPTION_RES = "description_res";
    private static final String ATTR_PROVIDER_INHERITANCE = "provider_inheritance";
    private static final String ATTR_OS_FINGERPRINT = "os_fingerprint";

    /**
@@ -93,6 +94,7 @@ public class AppWidgetXmlUtil {
        out.attributeInt(null, ATTR_WIDGET_CATEGORY, info.widgetCategory);
        out.attributeInt(null, ATTR_WIDGET_FEATURES, info.widgetFeatures);
        out.attributeInt(null, ATTR_DESCRIPTION_RES, info.descriptionRes);
        out.attributeBoolean(null, ATTR_PROVIDER_INHERITANCE, info.isExtendedFromAppWidgetProvider);
        out.attribute(null, ATTR_OS_FINGERPRINT, Build.FINGERPRINT);
    }

@@ -133,6 +135,8 @@ public class AppWidgetXmlUtil {
        info.widgetCategory = parser.getAttributeInt(null, ATTR_WIDGET_CATEGORY, 0);
        info.widgetFeatures = parser.getAttributeInt(null, ATTR_WIDGET_FEATURES, 0);
        info.descriptionRes = parser.getAttributeInt(null, ATTR_DESCRIPTION_RES, 0);
        info.isExtendedFromAppWidgetProvider = parser.getAttributeBoolean(null,
            ATTR_PROVIDER_INHERITANCE, false);
        return info;
    }
}