use of android.content.IntentFilter in project platform_frameworks_base by android.
the class RemoteDisplayProviderWatcher method start.
public void start() {
if (!mRunning) {
mRunning = true;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addAction(Intent.ACTION_PACKAGE_RESTARTED);
filter.addDataScheme("package");
mContext.registerReceiverAsUser(mScanPackagesReceiver, new UserHandle(mUserId), filter, null, mHandler);
// Scan packages.
// Also has the side-effect of restarting providers if needed.
mHandler.post(mScanPackagesRunnable);
}
}
use of android.content.IntentFilter in project platform_frameworks_base by android.
the class LockdownVpnTracker method initLocked.
private void initLocked() {
Slog.d(TAG, "initLocked()");
mVpn.setEnableTeardown(false);
final IntentFilter resetFilter = new IntentFilter(ACTION_LOCKDOWN_RESET);
mContext.registerReceiver(mResetReceiver, resetFilter, CONNECTIVITY_INTERNAL, null);
try {
// TODO: support non-standard port numbers
mNetService.setFirewallEgressDestRule(mProfile.server, 500, true);
mNetService.setFirewallEgressDestRule(mProfile.server, 4500, true);
mNetService.setFirewallEgressDestRule(mProfile.server, 1701, true);
} catch (RemoteException e) {
throw new RuntimeException("Problem setting firewall rules", e);
}
handleStateChangedLocked();
}
use of android.content.IntentFilter in project platform_frameworks_base by android.
the class Settings method applyDefaultPreferredActivityLPw.
private void applyDefaultPreferredActivityLPw(PackageManagerService service, Intent intent, int flags, ComponentName cn, String scheme, PatternMatcher ssp, IntentFilter.AuthorityEntry auth, PatternMatcher path, int userId) {
flags = service.updateFlagsForResolve(flags, userId, intent);
List<ResolveInfo> ri = service.mActivities.queryIntent(intent, intent.getType(), flags, 0);
if (PackageManagerService.DEBUG_PREFERRED)
Log.d(TAG, "Queried " + intent + " results: " + ri);
int systemMatch = 0;
int thirdPartyMatch = 0;
if (ri != null && ri.size() > 1) {
boolean haveAct = false;
ComponentName haveNonSys = null;
ComponentName[] set = new ComponentName[ri.size()];
for (int i = 0; i < ri.size(); i++) {
ActivityInfo ai = ri.get(i).activityInfo;
set[i] = new ComponentName(ai.packageName, ai.name);
if ((ai.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
if (ri.get(i).match >= thirdPartyMatch) {
// want to set a preferred app for this intent.
if (PackageManagerService.DEBUG_PREFERRED)
Log.d(TAG, "Result " + ai.packageName + "/" + ai.name + ": non-system!");
haveNonSys = set[i];
break;
}
} else if (cn.getPackageName().equals(ai.packageName) && cn.getClassName().equals(ai.name)) {
if (PackageManagerService.DEBUG_PREFERRED)
Log.d(TAG, "Result " + ai.packageName + "/" + ai.name + ": default!");
haveAct = true;
systemMatch = ri.get(i).match;
} else {
if (PackageManagerService.DEBUG_PREFERRED)
Log.d(TAG, "Result " + ai.packageName + "/" + ai.name + ": skipped");
}
}
if (haveNonSys != null && thirdPartyMatch < systemMatch) {
// If we have a matching third party app, but its match is not as
// good as the built-in system app, then we don't want to actually
// consider it a match because presumably the built-in app is still
// the thing we want users to see by default.
haveNonSys = null;
}
if (haveAct && haveNonSys == null) {
IntentFilter filter = new IntentFilter();
if (intent.getAction() != null) {
filter.addAction(intent.getAction());
}
if (intent.getCategories() != null) {
for (String cat : intent.getCategories()) {
filter.addCategory(cat);
}
}
if ((flags & MATCH_DEFAULT_ONLY) != 0) {
filter.addCategory(Intent.CATEGORY_DEFAULT);
}
if (scheme != null) {
filter.addDataScheme(scheme);
}
if (ssp != null) {
filter.addDataSchemeSpecificPart(ssp.getPath(), ssp.getType());
}
if (auth != null) {
filter.addDataAuthority(auth);
}
if (path != null) {
filter.addDataPath(path);
}
if (intent.getType() != null) {
try {
filter.addDataType(intent.getType());
} catch (IntentFilter.MalformedMimeTypeException ex) {
Slog.w(TAG, "Malformed mimetype " + intent.getType() + " for " + cn);
}
}
PreferredActivity pa = new PreferredActivity(filter, systemMatch, set, cn, true);
editPreferredActivitiesLPw(userId).addFilter(pa);
} else if (haveNonSys == null) {
StringBuilder sb = new StringBuilder();
sb.append("No component ");
sb.append(cn.flattenToShortString());
sb.append(" found setting preferred ");
sb.append(intent);
sb.append("; possible matches are ");
for (int i = 0; i < set.length; i++) {
if (i > 0)
sb.append(", ");
sb.append(set[i].flattenToShortString());
}
Slog.w(TAG, sb.toString());
} else {
Slog.i(TAG, "Not setting preferred " + intent + "; found third party match " + haveNonSys.flattenToShortString());
}
} else {
Slog.w(TAG, "No potential matches found for " + intent + " while setting preferred " + cn.flattenToShortString());
}
}
use of android.content.IntentFilter in project platform_frameworks_base by android.
the class UserManagerService method systemReady.
void systemReady() {
mAppOpsService = IAppOpsService.Stub.asInterface(ServiceManager.getService(Context.APP_OPS_SERVICE));
synchronized (mRestrictionsLock) {
applyUserRestrictionsLR(UserHandle.USER_SYSTEM);
}
UserInfo currentGuestUser = findCurrentGuestUser();
if (currentGuestUser != null && !hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, currentGuestUser.id)) {
// If a guest user currently exists, apply the DISALLOW_CONFIG_WIFI option
// to it, in case this guest was created in a previous version where this
// user restriction was not a default guest restriction.
setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, true, currentGuestUser.id);
}
mContext.registerReceiver(mDisableQuietModeCallback, new IntentFilter(ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK), null, mHandler);
}
use of android.content.IntentFilter in project platform_frameworks_base by android.
the class HotspotTile method setListening.
@Override
public void setListening(boolean listening) {
if (mListening == listening)
return;
mListening = listening;
if (listening) {
mController.addCallback(mCallback);
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
refreshState();
} else {
mController.removeCallback(mCallback);
}
mAirplaneMode.setListening(listening);
}
Aggregations