use of android.content.pm.ResolveInfo in project atlas by alibaba.
the class ExternalComponentIntentResolver method newResult.
@Override
protected ResolveInfo newResult(IntentFilter info, int match) {
try {
Object activity = AtlasHacks.PackageParser$ActivityIntentInfo_activity.get(info);
ActivityInfo ai = (ActivityInfo) activity.getClass().getField("info").get(activity);
if (ai == null) {
return null;
}
final ResolveInfo res = new ResolveInfo();
res.activityInfo = ai;
if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
res.filter = (IntentFilter) info;
}
res.priority = ((IntentFilter) info).getPriority();
res.preferredOrder = 0;
//System.out.println("Result: " + res.activityInfo.className +
// " = " + res.priority);
res.match = match;
res.isDefault = true;
res.labelRes = 0;
res.nonLocalizedLabel = null;
res.icon = 0;
return res;
} catch (Exception e) {
return null;
}
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class UsbResolverActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (!(targetParcelable instanceof Intent)) {
Log.w("UsbResolverActivity", "Target is not an intent: " + targetParcelable);
finish();
return;
}
Intent target = (Intent) targetParcelable;
ArrayList<ResolveInfo> rList = intent.getParcelableArrayListExtra(EXTRA_RESOLVE_INFOS);
CharSequence title = getResources().getText(com.android.internal.R.string.chooseUsbActivity);
super.onCreate(savedInstanceState, target, title, null, rList, true);
CheckBox alwaysUse = (CheckBox) findViewById(com.android.internal.R.id.alwaysUse);
if (alwaysUse != null) {
if (mDevice == null) {
alwaysUse.setText(R.string.always_use_accessory);
} else {
alwaysUse.setText(R.string.always_use_device);
}
}
mDevice = (UsbDevice) target.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (mDevice != null) {
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
} else {
mAccessory = (UsbAccessory) target.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
if (mAccessory == null) {
Log.e(TAG, "no device or accessory");
finish();
return;
}
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
}
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class PhoneWindowManager method createHomeDockIntent.
/**
* Return an Intent to launch the currently active dock app as home. Returns
* null if the standard home should be launched, which is the case if any of the following is
* true:
* <ul>
* <li>The device is not in either car mode or desk mode
* <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false
* <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false
* <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME
* <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME
* </ul>
* @return
*/
Intent createHomeDockIntent() {
Intent intent = null;
// of whether we are actually in a car dock.
if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
intent = mCarDockIntent;
}
} else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
intent = mDeskDockIntent;
}
}
if (intent == null) {
return null;
}
ActivityInfo ai = null;
ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, UserHandle.USER_CURRENT);
if (info != null) {
ai = info.activityInfo;
}
if (ai != null && ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) {
intent = new Intent(intent);
intent.setClassName(ai.packageName, ai.name);
return intent;
}
return null;
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class KeyguardActivityLauncher method wouldLaunchResolverActivity.
private boolean wouldLaunchResolverActivity(Intent intent) {
PackageManager packageManager = getContext().getPackageManager();
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, getLockPatternUtils().getCurrentUser());
List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, getLockPatternUtils().getCurrentUser());
return wouldLaunchResolverActivity(resolved, appList);
}
use of android.content.pm.ResolveInfo in project android_frameworks_base by ParanoidAndroid.
the class AppWidgetServiceImpl method loadAppWidgetListLocked.
void loadAppWidgetListLocked() {
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
try {
List<ResolveInfo> broadcastReceivers = mPm.queryIntentReceivers(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), PackageManager.GET_META_DATA, mUserId);
final int N = broadcastReceivers == null ? 0 : broadcastReceivers.size();
for (int i = 0; i < N; i++) {
ResolveInfo ri = broadcastReceivers.get(i);
addProviderLocked(ri);
}
} catch (RemoteException re) {
// Shouldn't happen, local call
}
}
Aggregations