android.content.Intent#FilterComparison ( )源码实例Demo

下面列出了android.content.Intent#FilterComparison ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: ServiceRecord.java
ServiceRecord(ActivityManagerService ams,
        BatteryStatsImpl.Uid.Pkg.Serv servStats, ComponentName name,
        Intent.FilterComparison intent, ServiceInfo sInfo, boolean callerIsFg,
        Runnable restarter) {
    this.ams = ams;
    this.stats = servStats;
    this.name = name;
    shortName = name.flattenToShortString();
    this.intent = intent;
    serviceInfo = sInfo;
    appInfo = sInfo.applicationInfo;
    packageName = sInfo.applicationInfo.packageName;
    processName = sInfo.processName;
    permission = sInfo.permission;
    exported = sInfo.exported;
    this.restarter = restarter;
    createRealTime = SystemClock.elapsedRealtime();
    lastActivity = SystemClock.uptimeMillis();
    userId = UserHandle.getUserId(appInfo.uid);
    createdFromFg = callerIsFg;
}
 
源代码2 项目: android_9.0.0_r45   文件: ServiceRecord.java
public AppBindRecord retrieveAppBindingLocked(Intent intent,
        ProcessRecord app) {
    Intent.FilterComparison filter = new Intent.FilterComparison(intent);
    IntentBindRecord i = bindings.get(filter);
    if (i == null) {
        i = new IntentBindRecord(this, filter);
        bindings.put(filter, i);
    }
    AppBindRecord a = i.apps.get(app);
    if (a != null) {
        return a;
    }
    a = new AppBindRecord(this, i, app);
    i.apps.put(app, a);
    return a;
}
 
源代码3 项目: android_9.0.0_r45   文件: RemoteViewsService.java
@Override
public IBinder onBind(Intent intent) {
    synchronized (sLock) {
        Intent.FilterComparison fc = new Intent.FilterComparison(intent);
        RemoteViewsFactory factory = null;
        boolean isCreated = false;
        if (!sRemoteViewFactories.containsKey(fc)) {
            factory = onGetViewFactory(intent);
            sRemoteViewFactories.put(fc, factory);
            factory.onCreate();
            isCreated = false;
        } else {
            factory = sRemoteViewFactories.get(fc);
            isCreated = true;
        }
        return new RemoteViewsFactoryAdapter(factory, isCreated);
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: AdapterViewAnimator.java
/** @hide **/
@Override
public void setRemoteViewsAdapter(Intent intent, boolean isAsync) {
    // Ensure that we don't already have a RemoteViewsAdapter that is bound to an existing
    // service handling the specified intent.
    if (mRemoteViewsAdapter != null) {
        Intent.FilterComparison fcNew = new Intent.FilterComparison(intent);
        Intent.FilterComparison fcOld = new Intent.FilterComparison(
                mRemoteViewsAdapter.getRemoteViewsServiceIntent());
        if (fcNew.equals(fcOld)) {
            return;
        }
    }
    mDeferNotifyDataSetChanged = false;
    // Otherwise, create a new RemoteViewsAdapter for binding
    mRemoteViewsAdapter = new RemoteViewsAdapter(getContext(), intent, this, isAsync);
    if (mRemoteViewsAdapter.isDataReady()) {
        setAdapter(mRemoteViewsAdapter);
    }
}
 
源代码5 项目: android_9.0.0_r45   文件: RemoteViewsAdapter.java
public void saveRemoteViewsCache() {
    final RemoteViewsCacheKey key = new RemoteViewsCacheKey(
            new Intent.FilterComparison(mIntent), mAppWidgetId);

    synchronized(sCachedRemoteViewsCaches) {
        // If we already have a remove runnable posted for this key, remove it.
        if (sRemoteViewsCacheRemoveRunnables.containsKey(key)) {
            sCacheRemovalQueue.removeCallbacks(sRemoteViewsCacheRemoveRunnables.get(key));
            sRemoteViewsCacheRemoveRunnables.remove(key);
        }

        int metaDataCount = 0;
        int numRemoteViewsCached = 0;
        synchronized (mCache.mMetaData) {
            metaDataCount = mCache.mMetaData.count;
        }
        synchronized (mCache) {
            numRemoteViewsCached = mCache.mIndexRemoteViews.size();
        }
        if (metaDataCount > 0 && numRemoteViewsCached > 0) {
            sCachedRemoteViewsCaches.put(key, mCache);
        }

        Runnable r = () -> {
            synchronized (sCachedRemoteViewsCaches) {
                if (sCachedRemoteViewsCaches.containsKey(key)) {
                    sCachedRemoteViewsCaches.remove(key);
                }
                if (sRemoteViewsCacheRemoveRunnables.containsKey(key)) {
                    sRemoteViewsCacheRemoveRunnables.remove(key);
                }
            }
        };
        sRemoteViewsCacheRemoveRunnables.put(key, r);
        sCacheRemovalQueue.postDelayed(r, REMOTE_VIEWS_CACHE_DURATION);
    }
}
 
源代码6 项目: android_9.0.0_r45   文件: RemoteViewsService.java
public void onDestroy(Intent intent) {
    synchronized (sLock) {
        Intent.FilterComparison fc = new Intent.FilterComparison(intent);
        if (RemoteViewsService.sRemoteViewFactories.containsKey(fc)) {
            RemoteViewsFactory factory = RemoteViewsService.sRemoteViewFactories.get(fc);
            try {
                factory.onDestroy();
            } catch (Exception ex) {
                Thread t = Thread.currentThread();
                Thread.getDefaultUncaughtExceptionHandler().uncaughtException(t, ex);
            }
            RemoteViewsService.sRemoteViewFactories.remove(fc);
        }
    }
}
 
源代码7 项目: springreplugin   文件: ServiceRecord.java
ServiceRecord(ComponentName cn, Intent.FilterComparison fi, ServiceInfo si) {
    name = cn;
    plugin = cn.getPackageName();
    className = cn.getClassName();
    shortName = name.flattenToShortString();
    intent = fi;
    serviceInfo = si;
}
 
源代码8 项目: springreplugin   文件: ServiceRecord.java
public ProcessBindRecord retrieveAppBindingLocked(Intent intent, ProcessRecord app) {
    Intent.FilterComparison filter = new Intent.FilterComparison(intent);
    IntentBindRecord i = bindings.get(filter);
    if (i == null) {
        i = new IntentBindRecord(this, filter);
        bindings.put(filter, i);
    }
    ProcessBindRecord a = i.apps.get(app);
    if (a != null) {
        return a;
    }
    a = new ProcessBindRecord(this, i, app);
    i.apps.put(app, a);
    return a;
}
 
源代码9 项目: android_9.0.0_r45   文件: IntentBindRecord.java
IntentBindRecord(ServiceRecord _service, Intent.FilterComparison _intent) {
    service = _service;
    intent = _intent;
}
 
源代码10 项目: android_9.0.0_r45   文件: ActiveServices.java
void publishServiceLocked(ServiceRecord r, Intent intent, IBinder service) {
    final long origId = Binder.clearCallingIdentity();
    try {
        if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "PUBLISHING " + r
                + " " + intent + ": " + service);
        if (r != null) {
            Intent.FilterComparison filter
                    = new Intent.FilterComparison(intent);
            IntentBindRecord b = r.bindings.get(filter);
            if (b != null && !b.received) {
                b.binder = service;
                b.requested = true;
                b.received = true;
                for (int conni=r.connections.size()-1; conni>=0; conni--) {
                    ArrayList<ConnectionRecord> clist = r.connections.valueAt(conni);
                    for (int i=0; i<clist.size(); i++) {
                        ConnectionRecord c = clist.get(i);
                        if (!filter.equals(c.binding.intent.intent)) {
                            if (DEBUG_SERVICE) Slog.v(
                                    TAG_SERVICE, "Not publishing to: " + c);
                            if (DEBUG_SERVICE) Slog.v(
                                    TAG_SERVICE, "Bound intent: " + c.binding.intent.intent);
                            if (DEBUG_SERVICE) Slog.v(
                                    TAG_SERVICE, "Published intent: " + intent);
                            continue;
                        }
                        if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Publishing to: " + c);
                        try {
                            c.conn.connected(r.name, service, false);
                        } catch (Exception e) {
                            Slog.w(TAG, "Failure sending service " + r.name +
                                  " to connection " + c.conn.asBinder() +
                                  " (in " + c.binding.client.processName + ")", e);
                        }
                    }
                }
            }

            serviceDoneExecutingLocked(r, mDestroyingServices.contains(r), false);
        }
    } finally {
        Binder.restoreCallingIdentity(origId);
    }
}
 
源代码11 项目: android_9.0.0_r45   文件: ActiveServices.java
void unbindFinishedLocked(ServiceRecord r, Intent intent, boolean doRebind) {
    final long origId = Binder.clearCallingIdentity();
    try {
        if (r != null) {
            Intent.FilterComparison filter
                    = new Intent.FilterComparison(intent);
            IntentBindRecord b = r.bindings.get(filter);
            if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "unbindFinished in " + r
                    + " at " + b + ": apps="
                    + (b != null ? b.apps.size() : 0));

            boolean inDestroying = mDestroyingServices.contains(r);
            if (b != null) {
                if (b.apps.size() > 0 && !inDestroying) {
                    // Applications have already bound since the last
                    // unbind, so just rebind right here.
                    boolean inFg = false;
                    for (int i=b.apps.size()-1; i>=0; i--) {
                        ProcessRecord client = b.apps.valueAt(i).client;
                        if (client != null && client.setSchedGroup
                                != ProcessList.SCHED_GROUP_BACKGROUND) {
                            inFg = true;
                            break;
                        }
                    }
                    try {
                        requestServiceBindingLocked(r, b, inFg, true);
                    } catch (TransactionTooLargeException e) {
                        // Don't pass this back to ActivityThread, it's unrelated.
                    }
                } else {
                    // Note to tell the service the next time there is
                    // a new client.
                    b.doRebind = true;
                }
            }

            serviceDoneExecutingLocked(r, inDestroying, false);
        }
    } finally {
        Binder.restoreCallingIdentity(origId);
    }
}
 
源代码12 项目: android_9.0.0_r45   文件: RemoteViewsAdapter.java
RemoteViewsCacheKey(Intent.FilterComparison filter, int widgetId) {
    this.filter = filter;
    this.widgetId = widgetId;
}
 
源代码13 项目: springreplugin   文件: PluginServiceServer.java
private ServiceRecord retrieveServiceLocked(Intent service) {
    ComponentName cn = service.getComponent();
    ServiceRecord sr = mServicesByName.get(cn);
    if (sr != null) {
        return sr;
    }
    sr = mServicesByIntent.get(service);
    if (sr != null) {
        return sr;
    }
    String pn = cn.getPackageName();
    String name = cn.getClassName();

    // 看这个Plugin是否可以被打开
    if (!RePlugin.isPluginInstalled(pn)) {
        if (LOGR) {
            LogRelease.e(PLUGIN_TAG, "psm.is: p n ex " + name);
        }
        return null;
    }

    // 开始尝试获取插件的ServiceInfo
    ComponentList col = PluginFactory.queryPluginComponentList(pn);
    if (col == null) {
        if (LOG) {
            Log.e(TAG, "installServiceLocked(): Fetch Component List Error! pn=" + pn);
        }
        return null;
    }
    ServiceInfo si = col.getService(cn.getClassName());
    if (si == null) {
        if (LOG) {
            Log.e(TAG, "installServiceLocked(): Not register! pn=" + pn);
        }
        return null;
    }

    // 构建,放入表中
    Intent.FilterComparison fi = new Intent.FilterComparison(service);
    sr = new ServiceRecord(cn, fi, si);
    mServicesByName.put(cn, sr);
    mServicesByIntent.put(fi, sr);
    return sr;
}
 
源代码14 项目: springreplugin   文件: IntentBindRecord.java
IntentBindRecord(ServiceRecord service, Intent.FilterComparison intent) {
    this.service = service;
    this.intent = intent;
}
 
 方法所在类
 同类方法