Java Code Examples for android.content.ComponentName#equals()

The following examples show how to use android.content.ComponentName#equals() . 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 File: PreviewMediaFragment.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onServiceConnected(ComponentName component, IBinder service) {
    if (getActivity() != null) {
        if (component.equals(
                new ComponentName(getActivity(), MediaService.class))) {
            Log_OC.d(TAG, "Media service connected");
            mMediaServiceBinder = (MediaServiceBinder) service;
            if (mMediaServiceBinder != null) {
                prepareMediaController();
                playAudio();    // do not wait for the touch of nobody to play audio

                Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");

            }
            else {
                Log_OC.e(TAG, "Unexpected response from MediaService while binding");
            }
        }
    }
}
 
Example 2
Source File: RecognitionServiceManager.java    From speechutils with Apache License 2.0 6 votes vote down vote up
/**
 * @return true iff a RecognitionService with the given component name is installed
 */
public static boolean isRecognitionServiceInstalled(PackageManager pm, ComponentName componentName) {
    List<ResolveInfo> services = pm.queryIntentServices(
            new Intent(RecognitionService.SERVICE_INTERFACE), 0);
    for (ResolveInfo ri : services) {
        ServiceInfo si = ri.serviceInfo;
        if (si == null) {
            Log.i("serviceInfo == null");
            continue;
        }
        if (componentName.equals(new ComponentName(si.packageName, si.name))) {
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: PreviewImageActivity.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onServiceConnected(ComponentName component, IBinder service) {

    if (component.equals(new ComponentName(PreviewImageActivity.this,
            FileDownloader.class))) {
        mDownloaderBinder = (FileDownloaderBinder) service;
        if (mRequestWaitingForBinder) {
            mRequestWaitingForBinder = false;
            Log_OC.d(TAG, "Simulating reselection of current page after connection " +
                    "of download binder");
            onPageSelected(mViewPager.getCurrentItem());
        }

    } else if (component.equals(new ComponentName(PreviewImageActivity.this,
            FileUploader.class))) {
        Log_OC.d(TAG, "Upload service connected");
        mUploaderBinder = (FileUploaderBinder) service;
    } else {
        return;
    }

}
 
Example 4
Source File: VolumeAccessibilityService.java    From Noyze with Apache License 2.0 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LOGI(TAG, "--onStartComment(" + intent + ", " + flags + ", " + startId + ')');
    // If this app is sending us a request, show the volume panel!
    ComponentName thisComponent = new ComponentName(getApplicationContext(), getClass());
    if (intent != null && thisComponent.equals(intent.getComponent())) {
        mLastNotificationEventTime = System.currentTimeMillis();
        if (null != mVolumePanel) {
            mVolumePanel.reveal();
        }
    }
    return super.onStartCommand(intent, flags, startId);
}
 
Example 5
Source File: ServiceManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 选择匹配的ServiceInfo
 *
 * @param pluginIntent 插件的Intent
 * @return ServiceInfo
 */
private ServiceInfo selectPluginService(Intent pluginIntent) {
    for (ComponentName componentName : mServiceInfoMap.keySet()) {
        if (componentName.equals(pluginIntent.getComponent())) {
            return mServiceInfoMap.get(componentName);
        }
    }
    return null;
}
 
Example 6
Source File: QuickRow.java    From LaunchTime with GNU General Public License v3.0 5 votes vote down vote up
public void processQuickApps(List<AppLauncher> launchers) {
    List<AppLauncher> quickRowApps = new ArrayList<>();
    final List<ComponentName> quickRowOrder = db().getAppCategoryOrder(QUICK_ROW_CAT);

    boolean newstuff = DefaultApps.checkDefaultApps(mQuickRow.getContext(), launchers, quickRowOrder);

    for (ComponentName compname: quickRowOrder) {

        //Log.d("Quick", compname.flattenToString());
        AppLauncher app = null;
        for (AppLauncher a: launchers) {
            if (compname.equals(a.getComponentName())) {
                app = a;
                break;
            }
        }
        if (app==null) {
            //Log.d("Quick", "Not found: " + compname.flattenToString());
          newstuff = true; //app could have been uninstalled
        } else if (compname.equals(app.getComponentName())) {
            //Log.d("Quick", "Found: " + compname.flattenToString());
           // AppLauncher qapp = AppLauncher.createAppLauncher(app, true);
            quickRowApps.add(app);

        }

    }
    if (newstuff) db().setAppCategoryOrder(QUICK_ROW_CAT, quickRowApps);
}
 
Example 7
Source File: PreviewImageActivity.java    From Cirrus_depricated with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onServiceDisconnected(ComponentName component) {
    if (component.equals(new ComponentName(PreviewImageActivity.this,
            FileDownloader.class))) {
        Log_OC.d(TAG, "Download service suddenly disconnected");
        mDownloaderBinder = null;
    } else if (component.equals(new ComponentName(PreviewImageActivity.this,
            FileUploader.class))) {
        Log_OC.d(TAG, "Upload service suddenly disconnected");
        mUploaderBinder = null;
    }
}
 
Example 8
Source File: VolumeAccessibilityService.java    From Noyze with Apache License 2.0 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LOGI(TAG, "--onStartComment(" + intent + ", " + flags + ", " + startId + ')');
    // If this app is sending us a request, show the volume panel!
    ComponentName thisComponent = new ComponentName(getApplicationContext(), getClass());
    if (intent != null && thisComponent.equals(intent.getComponent())) {
        mLastNotificationEventTime = System.currentTimeMillis();
        if (null != mVolumePanel) {
            mVolumePanel.reveal();
        }
    }
    return super.onStartCommand(intent, flags, startId);
}
 
Example 9
Source File: LauncherModel.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
private ArrayList<ItemInfo> getItemInfoForComponentName(final ComponentName cname,
        final UserHandleCompat user) {
    ItemInfoFilter filter  = new ItemInfoFilter() {
        @Override
        public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {
            if (info.user == null) {
                return cn.equals(cname);
            } else {
                return cn.equals(cname) && info.user.equals(user);
            }
        }
    };
    return filterItemInfos(sBgItemsIdMap.values(), filter);
}
 
Example 10
Source File: ConditionProviders.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public IConditionProvider findConditionProvider(ComponentName component) {
    if (component == null) return null;
    for (ManagedServiceInfo service : getServices()) {
        if (component.equals(service.component)) {
            return provider(service);
        }
    }
    return null;
}
 
Example 11
Source File: ZenModeConditions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean isAutomaticActive(ComponentName component) {
    if (component == null) return false;
    final ZenModeConfig config = mHelper.getConfig();
    if (config == null) return false;
    for (ZenRule rule : config.automaticRules.values()) {
        if (component.equals(rule.component) && rule.isAutomaticActive()) {
            return true;
        }
    }
    return false;
}
 
Example 12
Source File: FileDisplayActivity.java    From Cirrus_depricated with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onServiceDisconnected(ComponentName component) {
    if (component.equals(new ComponentName(FileDisplayActivity.this,
            FileDownloader.class))) {
        Log_OC.d(TAG, "Download service disconnected");
        mDownloaderBinder = null;
    } else if (component.equals(new ComponentName(FileDisplayActivity.this,
            FileUploader.class))) {
        Log_OC.d(TAG, "Upload service disconnected");
        mUploaderBinder = null;
    }
}
 
Example 13
Source File: FileActivity.java    From Cirrus_depricated with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onServiceDisconnected(ComponentName component) {
    if (component.equals(new ComponentName(FileActivity.this, OperationsService.class))) {
        Log_OC.d(TAG, "Operations service disconnected");
        mOperationsServiceBinder = null;
        // TODO whatever could be waiting for the service is unbound
    }
}
 
Example 14
Source File: IMEHelper.java    From brailleback with Apache License 2.0 5 votes vote down vote up
/** Determines, from system settings, if {@code imeClass} is the default input method. */
public static boolean isInputMethodDefault(Context contextArg, Class<?> imeClass) {
  final ComponentName imeComponentName = new ComponentName(contextArg, imeClass);
  final String defaultIMEId =
      Settings.Secure.getString(
          contextArg.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);

      return defaultIMEId != null && imeComponentName.equals(
              ComponentName.unflattenFromString(defaultIMEId));
  }
 
Example 15
Source File: ServiceWatcher.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onServiceDisconnected(ComponentName component) {
    synchronized (mLock) {
        if (D) Log.d(mTag, component + " disconnected");

        if (component.equals(mBoundComponent)) {
            mBoundService = null;
        }
    }
}
 
Example 16
Source File: ServiceWatcher.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onServiceConnected(ComponentName component, IBinder binder) {
    synchronized (mLock) {
        if (component.equals(mBoundComponent)) {
            if (D) Log.d(mTag, component + " connected");
            mBoundService = binder;
            if (mHandler !=null && mNewServiceWork != null) {
                mHandler.post(mNewServiceWork);
            }
        } else {
            Log.w(mTag, "unexpected onServiceConnected: " + component);
        }
    }
}
 
Example 17
Source File: ServiceManager20.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * 选择匹配的ServiceInfo
 *
 * @param pluginIntent 插件的Intent
 * @return ServiceInfo
 */
private ServiceInfo selectPluginService(Intent pluginIntent) {
    for (ComponentName componentName : mServiceInfoMap.keySet()) {
        if (componentName.equals(pluginIntent.getComponent())) {
            return mServiceInfoMap.get(componentName);
        }
    }
    return null;
}
 
Example 18
Source File: LauncherModel.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
/**
 * Make an ShortcutInfo object for a shortcut that is an application.
 * 
 * If c is not null, then it will be used to fill in missing data like the
 * title and icon.
 */
public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent,
		Context context, Cursor c, int iconIndex, int titleIndex,
		HashMap<Object, CharSequence> labelCache) {
	ComponentName componentName = intent.getComponent();
	final ShortcutInfo info = new ShortcutInfo();
	if (componentName != null
			&& !isValidPackageComponent(manager, componentName)) {
		return null;
	} else {
		try {
			PackageInfo pi = manager.getPackageInfo(
					componentName.getPackageName(), 0);
			info.initFlagsAndFirstInstallTime(pi);
		} catch (NameNotFoundException e) {

		}
	}

	Bitmap icon = null;
	ResolveInfo resolveInfo = null;
	ComponentName oldComponent = intent.getComponent();
	Intent newIntent = new Intent(intent.getAction(), null);
	newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
	newIntent.setPackage(oldComponent.getPackageName());
	List<ResolveInfo> infos = manager.queryIntentActivities(newIntent, 0);
	for (ResolveInfo i : infos) {
		ComponentName cn = new ComponentName(i.activityInfo.packageName,
				i.activityInfo.name);
		if (cn.equals(oldComponent)) {
			resolveInfo = i;
		}
	}
	if (resolveInfo == null) {
		resolveInfo = manager.resolveActivity(intent, 0);
	}
	if (resolveInfo != null) {
		icon = mIconCache.getIcon(componentName, resolveInfo, labelCache);
	}
	// the db
	if (icon == null) {
		if (c != null) {
			icon = getIconFromCursor(c, iconIndex, context);
		}
	}
	// the fallback icon
	if (icon == null) {
		icon = getFallbackIcon();
		info.usingFallbackIcon = true;
	}
	info.setIcon(icon);

	// from the resource
	if (resolveInfo != null) {
		ComponentName key = LauncherModel
				.getComponentNameFromResolveInfo(resolveInfo);
		if (labelCache != null && labelCache.containsKey(key)) {
			info.title = labelCache.get(key);
		} else {
			info.title = resolveInfo.activityInfo.loadLabel(manager);
			if (labelCache != null) {
				labelCache.put(key, info.title);
			}
		}
	}
	// from the db
	if (info.title == null) {
		if (c != null) {
			info.title = c.getString(titleIndex);
		}
	}
	// fall back to the class name of the activity
	if (info.title == null) {
		info.title = componentName.getClassName();
	}
	info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
	return info;
}
 
Example 19
Source File: ZenModeConditions.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void evaluateRule(ZenRule rule, ArraySet<Uri> current, ComponentName trigger,
        boolean processSubscriptions) {
    if (rule == null || rule.conditionId == null) return;
    final Uri id = rule.conditionId;
    boolean isSystemCondition = false;
    for (SystemConditionProviderService sp : mConditionProviders.getSystemProviders()) {
        if (sp.isValidConditionId(id)) {
            mConditionProviders.ensureRecordExists(sp.getComponent(), id, sp.asInterface());
            rule.component = sp.getComponent();
            isSystemCondition = true;
        }
    }
    if (!isSystemCondition) {
        final IConditionProvider cp = mConditionProviders.findConditionProvider(rule.component);
        if (DEBUG) Log.d(TAG, "Ensure external rule exists: " + (cp != null) + " for " + id);
        if (cp != null) {
            mConditionProviders.ensureRecordExists(rule.component, id, cp);
        }
    }
    if (rule.component == null) {
        Log.w(TAG, "No component found for automatic rule: " + rule.conditionId);
        rule.enabled = false;
        return;
    }
    if (current != null) {
        current.add(id);
    }
    if (processSubscriptions && ((trigger != null && trigger.equals(rule.component))
            || isSystemCondition)) {
        if (DEBUG) Log.d(TAG, "Subscribing to " + rule.component);
        if (mConditionProviders.subscribeIfNecessary(rule.component, rule.conditionId)) {
            synchronized (mSubscriptions) {
                mSubscriptions.put(rule.conditionId, rule.component);
            }
        } else {
            rule.condition = null;
            if (DEBUG) Log.d(TAG, "zmc failed to subscribe");
        }
    }
    if (rule.condition == null) {
        rule.condition = mConditionProviders.findCondition(rule.component, rule.conditionId);
        if (rule.condition != null && DEBUG) Log.d(TAG, "Found existing condition for: "
                + rule.conditionId);
    }
}
 
Example 20
Source File: Sandman.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Returns true if the specified dock app intent should be started.
 * False if we should dream instead, if appropriate.
 */
public static boolean shouldStartDockApp(Context context, Intent intent) {
    ComponentName name = intent.resolveActivity(context.getPackageManager());
    return name != null && !name.equals(SOMNAMBULATOR_COMPONENT);
}