Java 类android.appwidget.AppWidgetProviderInfo 实例源码

项目:LaunchEnr    文件:LauncherAppWidgetProviderInfo.java   
public static LauncherAppWidgetProviderInfo fromProviderInfo(Context context,
        AppWidgetProviderInfo info) {
    final LauncherAppWidgetProviderInfo launcherInfo;
    if (info instanceof LauncherAppWidgetProviderInfo) {
        launcherInfo = (LauncherAppWidgetProviderInfo) info;
    } else {

        // In lieu of a public super copy constructor, we first write the AppWidgetProviderInfo
        // into a parcel, and then construct a new LauncherAppWidgetProvider info from the
        // associated super parcel constructor. This allows us to copy non-public members without
        // using reflection.
        Parcel p = Parcel.obtain();
        info.writeToParcel(p, 0);
        p.setDataPosition(0);
        launcherInfo = new LauncherAppWidgetProviderInfo(p);
        p.recycle();
    }
    launcherInfo.initSpans(context);
    return launcherInfo;
}
项目:SimpleUILauncher    文件:AppWidgetResizeFrame.java   
public boolean beginResizeIfPointInRegion(int x, int y) {
    boolean horizontalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0;
    boolean verticalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0;

    mLeftBorderActive = (x < mTouchTargetWidth) && horizontalActive;
    mRightBorderActive = (x > getWidth() - mTouchTargetWidth) && horizontalActive;
    mTopBorderActive = (y < mTouchTargetWidth + mTopTouchRegionAdjustment) && verticalActive;
    mBottomBorderActive = (y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment)
            && verticalActive;

    boolean anyBordersActive = mLeftBorderActive || mRightBorderActive
            || mTopBorderActive || mBottomBorderActive;

    mBaselineWidth = getMeasuredWidth();
    mBaselineHeight = getMeasuredHeight();
    mBaselineX = getLeft();
    mBaselineY = getTop();

    if (anyBordersActive) {
        mLeftHandle.setAlpha(mLeftBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
        mRightHandle.setAlpha(mRightBorderActive ? 1.0f :DIMMED_HANDLE_ALPHA);
        mTopHandle.setAlpha(mTopBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
        mBottomHandle.setAlpha(mBottomBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
    }
    return anyBordersActive;
}
项目:LaunchEnr    文件:SearchWidgetProvider.java   
/**
 * -     * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
 * -     * provided by the same package which is set to be global search activity.
 * -     * If widgetCategory is not supported, or no such widget is found, returns the first widget
 * -     * provided by the package.
 * -
 */
public static AppWidgetProviderInfo get(Context context) {
    SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    ComponentName searchComponent = searchManager.getGlobalSearchActivity();
    if (searchComponent == null) return null;
    String providerPkg = searchComponent.getPackageName();

    AppWidgetProviderInfo defaultWidgetForSearchPackage = null;

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
        if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
            if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
                return info;
            } else if (defaultWidgetForSearchPackage == null) {
                defaultWidgetForSearchPackage = info;
            }
        }
    }
    return defaultWidgetForSearchPackage;
}
项目:LaunchTime    文件:Widget.java   
private AppWidgetHostView configureWidget(Intent data) {
    // Get the selected widget information
    Bundle extras = data.getExtras();
    int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidgetInfo.configure != null) {
        // If the widget wants to be configured then start its configuration activity
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        mParent.startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
    } else {
        // Otherwise simply create it
        return createWidget(data);
    }
    return null;
}
项目:LaunchTime    文件:Widget.java   
public ComponentName getComponentNameFromIntent(Intent data) {
    if (data!=null) {
        Bundle extras = data.getExtras();
        if (extras!=null) {
            int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);

            if (appWidgetId != -1) {

                AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
                if (appWidgetInfo != null) {
                    return appWidgetInfo.provider;
                }
            }
        }
    }
    return null;
}
项目:SimpleUILauncher    文件:QsbContainerView.java   
/**
 * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
 * provided by the same package which is set to be global search activity.
 * If widgetCategory is not supported, or no such widget is found, returns the first widget
 * provided by the package.
 */
public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) {
    SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    ComponentName searchComponent = searchManager.getGlobalSearchActivity();
    if (searchComponent == null) return null;
    String providerPkg = searchComponent.getPackageName();

    AppWidgetProviderInfo defaultWidgetForSearchPackage = null;

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
        if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
            if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
                return info;
            } else if (defaultWidgetForSearchPackage == null) {
                defaultWidgetForSearchPackage = info;
            }
        }
    }
    return defaultWidgetForSearchPackage;
}
项目:FlickLauncher    文件:QsbContainerView.java   
/**
 * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
 * provided by the same package which is set to be global search activity.
 * If widgetCategory is not supported, or no such widget is found, returns the first widget
 * provided by the package.
 */
public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) {
    SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    ComponentName searchComponent = searchManager.getGlobalSearchActivity();
    if (searchComponent == null) return null;
    String providerPkg = searchComponent.getPackageName();

    AppWidgetProviderInfo defaultWidgetForSearchPackage = null;

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
        if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
            if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
                return info;
            } else if (defaultWidgetForSearchPackage == null) {
                defaultWidgetForSearchPackage = info;
            }
        }
    }
    return defaultWidgetForSearchPackage;
}
项目:LaunchEnr    文件:AppWidgetManagerCompatVO.java   
@Override
public List<AppWidgetProviderInfo> getAllProviders(@Nullable PackageUserKey packageUser) {
    if (packageUser == null) {
        return super.getAllProviders(null);
    }
    return mAppWidgetManager.getInstalledProvidersForPackage(packageUser.mPackageName,
            packageUser.mUser);
}
项目:LaunchEnr    文件:PinItemRequestCompat.java   
public AppWidgetProviderInfo getAppWidgetProviderInfo(Context context) {
    try {
        return (AppWidgetProviderInfo) mObject.getClass()
                .getDeclaredMethod("getAppWidgetProviderInfo", Context.class)
                .invoke(mObject, context);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:LaunchEnr    文件:AppWidgetManagerCompatVL.java   
@Override
public void startConfigActivity(AppWidgetProviderInfo info, int widgetId, Activity activity,
        AppWidgetHost host, int requestCode) {
    try {
        host.startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
    } catch (ActivityNotFoundException | SecurityException e) {
        Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
    }
}
项目:LaunchEnr    文件:AppWidgetManagerCompatVL.java   
@Override
public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandle user) {
    for (AppWidgetProviderInfo info : mAppWidgetManager
            .getInstalledProvidersForProfile(user)) {
        if (info.provider.equals(provider)) {
            return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
        }
    }
    return null;
}
项目:LaunchEnr    文件:AppWidgetManagerCompatVL.java   
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
    HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        for (AppWidgetProviderInfo info :
                mAppWidgetManager.getInstalledProvidersForProfile(user)) {
            result.put(new ComponentKey(info.provider, user), info);
        }
    }
    return result;
}
项目:LaunchEnr    文件:WidgetsModel.java   
/**
 * @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
 *                    only widgets and shortcuts associated with the package/user are.
 */
public ArrayList<WidgetItem> update(Context context, @Nullable PackageUserKey packageUser) {

    final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
    try {
        PackageManager pm = context.getPackageManager();
        InvariantDeviceProfile idp = LauncherAppState.getIDP(context);

        // Widgets
        AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
        for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(packageUser)) {
            widgetsAndShortcuts.add(new WidgetItem(LauncherAppWidgetProviderInfo
                    .fromProviderInfo(context, widgetInfo), pm, idp));
        }

        // Shortcuts
        for (ShortcutConfigActivityInfo info : LauncherAppsCompat.getInstance(context)
                .getCustomShortcutActivityList(packageUser)) {
            widgetsAndShortcuts.add(new WidgetItem(info));
        }
        setWidgetsAndShortcuts(widgetsAndShortcuts, context, packageUser);
    } catch (Exception e) {
        if (Utilities.isBinderSizeError(e)) {
            // the returned value may be incomplete and will not be refreshed until the next
            // time Launcher starts.
            // TODO: after figuring out a repro step, introduce a dirty bit to check when
            // onResume is called to refresh the widget provider list.
        } else {
            throw e;
        }
    }
    return widgetsAndShortcuts;
}
项目:LaunchEnr    文件:LauncherAppWidgetHostView.java   
@Override
public AppWidgetProviderInfo getAppWidgetInfo() {
    AppWidgetProviderInfo info = super.getAppWidgetInfo();
    if (info != null && !(info instanceof LauncherAppWidgetProviderInfo)) {
        throw new IllegalStateException("Launcher widget must have"
                + " LauncherAppWidgetProviderInfo");
    }
    return info;
}
项目:LaunchEnr    文件:LauncherAppWidgetHostView.java   
private Advanceable getAdvanceable() {
    AppWidgetProviderInfo info = getAppWidgetInfo();
    if (info == null || info.autoAdvanceViewId == NO_ID || !mIsAttachedToWindow) {
        return null;
    }
    View v = findViewById(info.autoAdvanceViewId);
    return (v instanceof Advanceable) ? (Advanceable) v : null;
}
项目:LaunchEnr    文件:LauncherAccessibilityDelegate.java   
private ArrayList<Integer> getSupportedResizeActions(View host, LauncherAppWidgetInfo info) {
    ArrayList<Integer> actions = new ArrayList<>();

    AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo();
    if (providerInfo == null) {
        return actions;
    }

    CellLayout layout = (CellLayout) host.getParent().getParent();
    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) {
        if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) ||
                layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {
            actions.add(R.string.action_increase_width);
        }

        if (info.spanX > info.minSpanX && info.spanX > 1) {
            actions.add(R.string.action_decrease_width);
        }
    }

    if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) {
        if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) ||
                layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) {
            actions.add(R.string.action_increase_height);
        }

        if (info.spanY > info.minSpanY && info.spanY > 1) {
            actions.add(R.string.action_decrease_height);
        }
    }
    return actions;
}
项目:LaunchEnr    文件:LauncherAppWidgetHost.java   
@Override
protected LauncherAppWidgetHostView onCreateView(Context context, int appWidgetId,
        AppWidgetProviderInfo appWidget) {
    LauncherAppWidgetHostView view = new LauncherAppWidgetHostView(context);
    mViews.put(appWidgetId, view);
    return view;
}
项目:LaunchEnr    文件:Workspace.java   
public void widgetsRestored(final ArrayList<LauncherAppWidgetInfo> changedInfo) {
    if (!changedInfo.isEmpty()) {
        DeferredWidgetRefresh widgetRefresh = new DeferredWidgetRefresh(changedInfo,
                mLauncher.getAppWidgetHost());

        LauncherAppWidgetInfo item = changedInfo.get(0);
        final AppWidgetProviderInfo widgetInfo;
        if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
            widgetInfo = AppWidgetManagerCompat
                    .getInstance(mLauncher).findProvider(item.providerName, item.user);
        } else {
            widgetInfo = AppWidgetManagerCompat.getInstance(mLauncher)
                    .getAppWidgetInfo(item.appWidgetId);
        }

        if (widgetInfo != null) {
            // Re-inflate the widgets which have changed status
            widgetRefresh.run();
        } else {
            // widgetRefresh will automatically run when the packages are updated.
            // For now just update the progress bars
            mapOverItems(MAP_NO_RECURSE, new ItemOperator() {
                @Override
                public boolean evaluate(ItemInfo info, View view) {
                    if (view instanceof PendingAppWidgetHostView
                            && changedInfo.contains(info)) {
                        ((LauncherAppWidgetInfo) info).installProgress = 100;
                        ((PendingAppWidgetHostView) view).applyState();
                    }
                    // process all the shortcuts
                    return false;
                }
            });
        }
    }
}
项目:LaunchEnr    文件:AppWidgetResizeFrame.java   
public boolean beginResizeIfPointInRegion(int x, int y) {
    boolean horizontalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0;
    boolean verticalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0;

    mLeftBorderActive = (x < mTouchTargetWidth) && horizontalActive;
    mRightBorderActive = (x > getWidth() - mTouchTargetWidth) && horizontalActive;
    mTopBorderActive = (y < mTouchTargetWidth + mTopTouchRegionAdjustment) && verticalActive;
    mBottomBorderActive = (y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment)
            && verticalActive;

    boolean anyBordersActive = mLeftBorderActive || mRightBorderActive
            || mTopBorderActive || mBottomBorderActive;

    if (anyBordersActive) {
        mDragHandles[INDEX_LEFT].setAlpha(mLeftBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
        mDragHandles[INDEX_RIGHT].setAlpha(mRightBorderActive ? 1.0f :DIMMED_HANDLE_ALPHA);
        mDragHandles[INDEX_TOP].setAlpha(mTopBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
        mDragHandles[INDEX_BOTTOM].setAlpha(mBottomBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
    }

    if (mLeftBorderActive) {
        mDeltaXRange.set(-getLeft(), getWidth() - 2 * mTouchTargetWidth);
    } else if (mRightBorderActive) {
        mDeltaXRange.set(2 * mTouchTargetWidth - getWidth(), mDragLayer.getWidth() - getRight());
    } else {
        mDeltaXRange.set(0, 0);
    }
    mBaselineX.set(getLeft(), getRight());

    if (mTopBorderActive) {
        mDeltaYRange.set(-getTop(), getHeight() - 2 * mTouchTargetWidth);
    } else if (mBottomBorderActive) {
        mDeltaYRange.set(2 * mTouchTargetWidth - getHeight(), mDragLayer.getHeight() - getBottom());
    } else {
        mDeltaYRange.set(0, 0);
    }
    mBaselineY.set(getTop(), getBottom());

    return anyBordersActive;
}
项目:LaunchEnr    文件:InstallShortcutReceiver.java   
/**
 * Initializes a PendingInstallShortcutInfo to represent a launcher target.
 */
PendingInstallShortcutInfo(
        AppWidgetProviderInfo info, int widgetId, Context context) {
    activityInfo = null;
    shortcutInfo = null;
    providerInfo = info;

    data = null;
    mContext = context;
    user = info.getProfile();

    launchIntent = new Intent().setComponent(info.provider)
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    label = info.label;
}
项目:sflauncher    文件:MainActivity.java   
/**
 * Launches a dialog of app widgets to select from.
 */
void selectWidget() {
    AlertDialog.Builder d = new AlertDialog.Builder(MainActivity.this);
    d.setTitle("Choose widget");
    ListView g = new ListView(MainActivity.this);
    final List<AppWidgetProviderInfo> providers = mAppWidgetManager.getInstalledProviders();
    g.setAdapter(new WidgetAdapter(this, providers));
    d.setView(g);
    final AlertDialog dialog = d.show();
    g.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            dialog.dismiss();
            ComponentName name = providers.get(position).provider;
            int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
            boolean result = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, name);
            if (result) {
                configureWidget(appWidgetId);
            } else {
                Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, name);
                startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
            }
        }
    });
}
项目:sflauncher    文件:MainActivity.java   
/**
 * Sets up a widget that the user has selected.
 */
private void configureWidget(int appWidgetId) {
    AppWidgetProviderInfo appWidgetInfo =
            mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    if (appWidgetInfo.configure != null) {
        Intent intent =
                new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
        intent.setComponent(appWidgetInfo.configure);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        startActivityForResult(intent, 1);
    } else {
        createWidget(appWidgetId);
    }
}
项目:sflauncher    文件:MainActivity.java   
/**
 * Creates a new widget for the type the user selected.
 */
public void createWidget(int appWidgetId) {
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
    int height = appWidgetInfo.minHeight;
    float density = getResources().getDisplayMetrics().density;
    if (height < density * 56) height = (int) (density * 56);
    String packageName = appWidgetInfo.provider.getPackageName();
    String className = appWidgetInfo.provider.getClassName();
    Card.WidgetStub w = remakeWidget(appWidgetId, height, Card.Widget.DEFAULT_COLOR, packageName, className);
    for (int i = 0; i < cards.size(); i++) {
        if (cards.get(i) instanceof Card.WidgetStub) {
            Card.WidgetStub ws = (Card.WidgetStub) cards.get(i);
            if (ws.id == w.id) {
                w.color = ws.color;
                w.height = ws.height;
                w.getCardContainer().setLayoutParams(ws.getCardContainer().getLayoutParams());
                cards.remove(i);
                cards.add(i, w);
                w.refreshColor();
                saveCards();
                mAdapter.notifyDataSetChanged();
                return;
            }
        }
    }
    cards.add(w);
    saveCards();
    mAdapter.notifyDataSetChanged();
}
项目:sflauncher    文件:WidgetAdapter.java   
public WidgetAdapter(Context ctx, List<AppWidgetProviderInfo> providers){
    Collections.sort(providers, new Comparator<AppWidgetProviderInfo>() {
        @Override
        public int compare(AppWidgetProviderInfo a, AppWidgetProviderInfo b) {
            return a.label.compareTo(b.label);
        }
    });
    this.ctx = ctx;
    this.providers = providers;
}
项目:LaunchTime    文件:Widget.java   
private AppWidgetHostView createWidgetFromId(int widget_id) {
    AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(widget_id);

   // if (checkBindPermission(widget_id, appWidgetInfo.provider)) return null;

    // Create the host view
    AppWidgetHostView hostView = mAppWidgetHost.createView(mParent, widget_id, appWidgetInfo);
    hostView.setAppWidget(widget_id, appWidgetInfo);

    return hostView;
}
项目:FlickLauncher    文件:Launcher.java   
private void addWidgetToAutoAdvanceIfNeeded(View hostView, AppWidgetProviderInfo appWidgetInfo) {
    if (appWidgetInfo == null || appWidgetInfo.autoAdvanceViewId == -1) return;
    View v = hostView.findViewById(appWidgetInfo.autoAdvanceViewId);
    if (v instanceof Advanceable) {
        mWidgetsToAdvance.put(hostView, appWidgetInfo);
        ((Advanceable) v).fyiWillBeAdvancedByHostKThx();
        updateAutoAdvanceState();
    }
}
项目:FlickLauncher    文件:LauncherAppWidgetProviderInfo.java   
public static LauncherAppWidgetProviderInfo fromProviderInfo(Context context,
        AppWidgetProviderInfo info) {

    // In lieu of a public super copy constructor, we first write the AppWidgetProviderInfo
    // into a parcel, and then construct a new LauncherAppWidgetProvider info from the
    // associated super parcel constructor. This allows us to copy non-public members without
    // using reflection.
    Parcel p = Parcel.obtain();
    info.writeToParcel(p, 0);
    p.setDataPosition(0);
    LauncherAppWidgetProviderInfo lawpi = new LauncherAppWidgetProviderInfo(p);
    p.recycle();
    return lawpi;
}
项目:FlickLauncher    文件:AppWidgetManagerCompatV16.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
        Bundle options) {
    if (Utilities.ATLEAST_JB_MR1) {
        return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider, options);
    } else {
        return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
    }
}
项目:FlickLauncher    文件:AppWidgetManagerCompatV16.java   
@Override
public void startConfigActivity(AppWidgetProviderInfo info, int widgetId, Activity activity,
        AppWidgetHost host, int requestCode) {
    Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
    intent.setComponent(info.configure);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    Utilities.startActivityForResultSafely(activity, intent, requestCode);
}
项目:FlickLauncher    文件:AppWidgetManagerCompatV16.java   
@Override
public LauncherAppWidgetProviderInfo findProvider(
        ComponentName provider, UserHandleCompat user) {
    for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
        if (info.provider.equals(provider)) {
            return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
        }
    }
    return null;
}
项目:FlickLauncher    文件:AppWidgetManagerCompatVL.java   
@Override
public List<AppWidgetProviderInfo> getAllProviders() {
    ArrayList<AppWidgetProviderInfo> providers = new ArrayList<AppWidgetProviderInfo>();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        providers.addAll(mAppWidgetManager.getInstalledProvidersForProfile(user));
    }
    return providers;
}
项目:FlickLauncher    文件:AppWidgetManagerCompatVL.java   
@Override
public void startConfigActivity(AppWidgetProviderInfo info, int widgetId, Activity activity,
        AppWidgetHost host, int requestCode) {
    try {
        host.startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
    } catch (ActivityNotFoundException | SecurityException e) {
        Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
    }
}
项目:FlickLauncher    文件:AppWidgetManagerCompatVL.java   
@Override
public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandleCompat user) {
    for (AppWidgetProviderInfo info : mAppWidgetManager
            .getInstalledProvidersForProfile(user.getUser())) {
        if (info.provider.equals(provider)) {
            return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
        }
    }
    return null;
}
项目:FlickLauncher    文件:AppWidgetManagerCompatVL.java   
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
    HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        UserHandleCompat userHandle = UserHandleCompat.fromUser(user);
        for (AppWidgetProviderInfo info :
                mAppWidgetManager.getInstalledProvidersForProfile(user)) {
            result.put(new ComponentKey(info.provider, userHandle), info);
        }
    }
    return result;
}
项目:FlickLauncher    文件:WidgetsModel.java   
public WidgetsModel updateAndClone(Context context) {
    Preconditions.assertWorkerThread();

    try {
        final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
        // Widgets
        AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
        for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders()) {
            widgetsAndShortcuts.add(new WidgetItem(
                    LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo),
                    widgetManager));
        }

        // Shortcuts
        PackageManager pm = context.getPackageManager();
        for (ResolveInfo info :
                pm.queryIntentActivities(new Intent(Intent.ACTION_CREATE_SHORTCUT), 0)) {
            widgetsAndShortcuts.add(new WidgetItem(info, pm));
        }
        setWidgetsAndShortcuts(widgetsAndShortcuts);
    } catch (Exception e) {
        if (!ProviderConfig.IS_DOGFOOD_BUILD &&
                (e.getCause() instanceof TransactionTooLargeException ||
                        e.getCause() instanceof DeadObjectException)) {
            // the returned value may be incomplete and will not be refreshed until the next
            // time Launcher starts.
            // TODO: after figuring out a repro step, introduce a dirty bit to check when
            // onResume is called to refresh the widget provider list.
        } else {
            throw e;
        }
    }
    return clone();
}
项目:FlickLauncher    文件:LauncherAppWidgetHostView.java   
@Override
public AppWidgetProviderInfo getAppWidgetInfo() {
    AppWidgetProviderInfo info = super.getAppWidgetInfo();
    if (info != null && !(info instanceof LauncherAppWidgetProviderInfo)) {
        throw new IllegalStateException("Launcher widget must have"
                + " LauncherAppWidgetProviderInfo");
    }
    return info;
}
项目:FlickLauncher    文件:LauncherAppWidgetHost.java   
/**
 * Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
 */
@Override
protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
    LauncherAppWidgetProviderInfo info = LauncherAppWidgetProviderInfo.fromProviderInfo(
            mLauncher, appWidget);
    super.onProviderChanged(appWidgetId, info);
    // The super method updates the dimensions of the providerInfo. Update the
    // launcher spans accordingly.
    info.initSpans();
}
项目:FlickLauncher    文件:Workspace.java   
public void widgetsRestored(final ArrayList<LauncherAppWidgetInfo> changedInfo) {
    if (!changedInfo.isEmpty()) {
        DeferredWidgetRefresh widgetRefresh = new DeferredWidgetRefresh(changedInfo,
                mLauncher.getAppWidgetHost());

        LauncherAppWidgetInfo item = changedInfo.get(0);
        final AppWidgetProviderInfo widgetInfo;
        if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
            widgetInfo = AppWidgetManagerCompat
                    .getInstance(mLauncher).findProvider(item.providerName, item.user);
        } else {
            widgetInfo = AppWidgetManagerCompat.getInstance(mLauncher)
                    .getAppWidgetInfo(item.appWidgetId);
        }

        if (widgetInfo != null) {
            // Re-inflate the widgets which have changed status
            widgetRefresh.run();
        } else {
            // widgetRefresh will automatically run when the packages are updated.
            // For now just update the progress bars
            mapOverItems(MAP_NO_RECURSE, new ItemOperator() {
                @Override
                public boolean evaluate(ItemInfo info, View view) {
                    if (view instanceof PendingAppWidgetHostView
                            && changedInfo.contains(info)) {
                        ((LauncherAppWidgetInfo) info).installProgress = 100;
                        ((PendingAppWidgetHostView) view).applyState();
                    }
                    // process all the shortcuts
                    return false;
                }
            });
        }
    }
}
项目:XPrivacy    文件:XAppWidgetManager.java   
@Override
protected void after(XParam param) throws Throwable {
    switch (mMethod) {
    case getInstalledProviders:
    case getInstalledProvidersForProfile:
    case Srv_getInstalledProviders:
    case Srv_getInstalledProvidersForProfile:
        if (param.getResult() != null)
            if (isRestricted(param))
                param.setResult(new ArrayList<AppWidgetProviderInfo>());
        break;
    }
}
项目:financisto1-holo    文件:AccountWidget.java   
private static Class getProviderClass(AppWidgetProviderInfo appWidgetInfo) {
    Class widgetProviderClass = AccountWidget.class;
    try {
        widgetProviderClass = Class.forName(appWidgetInfo.provider.getClassName());
    } catch (ClassNotFoundException e) { }
    return widgetProviderClass;
}