Skip to content

fix FileNotFoundException by mkdir before save file; add apk installer to send receiver list #1055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: vxp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
try {
mShareComponents = VPackageManager.get().
queryIntentActivities(new Intent(Intent.ACTION_SEND), type, 0, 0); // multi-user?
mShareComponents.add(0, new ResolveInfo()); // Placeholder for Package Installer
} catch (Throwable ignored) {
}

Expand All @@ -65,10 +66,19 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

mListView.setOnItemClickListener((parent, view, position, id) -> {
try {
ResolveInfo item = mAdapter.getItem(position);
Intent t = new Intent(intent);
t.setComponent(new ComponentName(item.activityInfo.packageName, item.activityInfo.name));
VActivityManager.get().startActivity(t, 0);
if (position == 0) {
Context context = getApplicationContext();
Intent t = new Intent();
t.setComponent(new ComponentName(context, InstallerActivity.class));
t.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
t.setData(intent.getClipData().getItemAt(0).getUri());
context.startActivity(t);
} else {
ResolveInfo item = mAdapter.getItem(position);
Intent t = new Intent(intent);
t.setComponent(new ComponentName(item.activityInfo.packageName, item.activityInfo.name));
VActivityManager.get().startActivity(t, 0);
}
} catch (Throwable e) {
Toast.makeText(getApplicationContext(), R.string.shared_to_vxp_failed, Toast.LENGTH_SHORT).show();
}
Expand Down Expand Up @@ -104,6 +114,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder = (ViewHolder) convertView.getTag();
}

if (position == 0) {
holder.label.setText(R.string.app_installer_label);
holder.icon.setImageResource(R.mipmap.ic_launcher);
return convertView;
}

ResolveInfo item = getItem(position);
PackageManager packageManager = getPackageManager();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public static String getFileFromUri(Context context, Uri packageUri) {
File sharedFileCopy = new File(context.getCacheDir(), packageUri.getLastPathSegment());
try {
inputStream = context.getContentResolver().openInputStream(packageUri);
sharedFileCopy.getParentFile().mkdirs();
outputStream = new FileOutputStream(sharedFileCopy);
byte[] buffer = new byte[1024];
int count;
Expand Down