Java Code Examples for android.content.Intent#FilterComparison

The following examples show how to use android.content.Intent#FilterComparison . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: android_9.0.0_r45   File: ServiceRecord.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source Project: android_9.0.0_r45   File: ServiceRecord.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
@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);
    }
}
 
Example 4
/** @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);
    }
}
 
Example 5
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);
    }
}
 
Example 6
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);
        }
    }
}
 
Example 7
Source Project: springreplugin   File: ServiceRecord.java    License: Apache License 2.0 5 votes vote down vote up
ServiceRecord(ComponentName cn, Intent.FilterComparison fi, ServiceInfo si) {
    name = cn;
    plugin = cn.getPackageName();
    className = cn.getClassName();
    shortName = name.flattenToShortString();
    intent = fi;
    serviceInfo = si;
}
 
Example 8
Source Project: springreplugin   File: ServiceRecord.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
IntentBindRecord(ServiceRecord _service, Intent.FilterComparison _intent) {
    service = _service;
    intent = _intent;
}
 
Example 10
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);
    }
}
 
Example 11
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);
    }
}
 
Example 12
RemoteViewsCacheKey(Intent.FilterComparison filter, int widgetId) {
    this.filter = filter;
    this.widgetId = widgetId;
}
 
Example 13
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;
}
 
Example 14
Source Project: springreplugin   File: IntentBindRecord.java    License: Apache License 2.0 4 votes vote down vote up
IntentBindRecord(ServiceRecord service, Intent.FilterComparison intent) {
    this.service = service;
    this.intent = intent;
}