Skip to content
Open
Changes from all 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 @@ -56,8 +56,6 @@ public class OpenFilePlugin implements MethodCallHandler

private int REQUEST_CODE_FOR_DIR = 0x111;

private static final String TYPE_STRING_APK = "application/vnd.android.package-archive";

@Override
public void onMethodCall(MethodCall call, @NonNull Result result) {
isResultSubmitted = false;
Expand Down Expand Up @@ -112,10 +110,6 @@ private void doOpen() {

}
}
if (TYPE_STRING_APK.equals(mimeType)) {
openApkFile();
return;
}
startActivity();
}

Expand Down Expand Up @@ -166,24 +160,6 @@ private void startActivity() {
result(type, message);
}

private void openApkFile() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !canInstallApk()) {
result(-3, "Permission denied: " + Manifest.permission.REQUEST_INSTALL_PACKAGES);
} else {
startActivity();
}
}

@RequiresApi(api = Build.VERSION_CODES.O)
private boolean canInstallApk() {
try {
return activity.getPackageManager().canRequestPackageInstalls();
} catch (SecurityException e) {
e.printStackTrace();
return false;
}
}

private void result(int type, String message) {
if (result != null && !isResultSubmitted) {
Map<String, Object> map = MapUtil.createMap(type, message);
Expand Down