Bug Fixes

Bug Fixes
master
Abdul Mannan Saeed 2023-02-26 21:39:28 +05:00
parent 7be82ffbdb
commit cb9df8c06b
6 changed files with 194 additions and 144 deletions

View File

@ -17,6 +17,8 @@ import org.torproject.android.service.wrapper.orbotLocalConstants;
import static com.hiddenservices.onionservices.constants.constants.CONST_EXTERNAL_SHORTCUT_COMMAND_ERASE; import static com.hiddenservices.onionservices.constants.constants.CONST_EXTERNAL_SHORTCUT_COMMAND_ERASE;
import static com.hiddenservices.onionservices.constants.keys.EXTERNAL_SHORTCUT_COMMAND; import static com.hiddenservices.onionservices.constants.keys.EXTERNAL_SHORTCUT_COMMAND;
import java.util.concurrent.Callable;
public class externalShortcutController extends AppCompatActivity { public class externalShortcutController extends AppCompatActivity {
/* Initialize */ /* Initialize */
@ -42,7 +44,7 @@ public class externalShortcutController extends AppCompatActivity {
setContentView(R.layout.popup_data_cleared_shortcut); setContentView(R.layout.popup_data_cleared_shortcut);
panicExitInvoked(); panicExitInvoked();
helperMethod.onDelayHandler(this, 3000, () -> { helperMethod.onDelayHandler(this, 3000, () -> {
finishAndRemoveTask(); externalShortcutController.this.finishAndRemoveTask();
android.os.Process.killProcess(android.os.Process.myPid()); android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1); System.exit(1);
return null; return null;

View File

@ -15,6 +15,7 @@ import androidx.appcompat.app.AppCompatActivity;
import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.dataModel.geckoDataModel; import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.dataModel.geckoDataModel;
import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.downloadManager.geckoDownloadManager; import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.downloadManager.geckoDownloadManager;
import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.geckoSession; import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.geckoSession;
import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.helperClasses.permissionHandler;
import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeEnums; import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeEnums;
import com.hiddenservices.onionservices.constants.status; import com.hiddenservices.onionservices.constants.status;
import com.hiddenservices.onionservices.constants.strings; import com.hiddenservices.onionservices.constants.strings;
@ -32,6 +33,7 @@ import org.mozilla.geckoview.WebResponse;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable;
public class contentDelegate implements GeckoSession.ContentDelegate { public class contentDelegate implements GeckoSession.ContentDelegate {
@ -103,40 +105,19 @@ public class contentDelegate implements GeckoSession.ContentDelegate {
@UiThread @UiThread
@Override @Override
public void onExternalResponse(@NonNull GeckoSession session, @NonNull WebResponse response) { public void onExternalResponse(@NonNull GeckoSession session, @NonNull WebResponse response) {
Dexter.withContext(mContext.get()) permissionHandler.getInstance().checkPermission((Callable<Void>) () -> {
.withPermissions( try {
Manifest.permission.CAMERA, if (response.headers.containsKey("Content-Disposition")) {
Manifest.permission.READ_CONTACTS, mDownloadManager.downloadFile(response, mGeckoSession, mContext.get(), mEvent);
Manifest.permission.MEDIA_CONTENT_CONTROL, } else if (response.headers.containsKey("Content-Type")) {
Manifest.permission.MANAGE_MEDIA, mDownloadManager.downloadFile(response, mGeckoSession, mContext.get(), mEvent);
Manifest.permission.ACCESS_MEDIA_LOCATION, }
Manifest.permission.READ_MEDIA_AUDIO, } catch (ActivityNotFoundException e) {
Manifest.permission.READ_MEDIA_VIDEO, mEvent.invokeObserver(Arrays.asList(response, mGeckoDataModel.mSessionID), homeEnums.eGeckoCallback.ON_HANDLE_EXTERNAL_INTENT);
Manifest.permission.READ_MEDIA_IMAGES, mGeckoSession.stop();
Manifest.permission.MANAGE_EXTERNAL_STORAGE, }
Manifest.permission.READ_EXTERNAL_STORAGE, return null;
Manifest.permission.WRITE_EXTERNAL_STORAGE, });
Manifest.permission.RECORD_AUDIO
).withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
try {
if (response.headers.containsKey("Content-Disposition")) {
mDownloadManager.downloadFile(response, mGeckoSession, mContext.get(), mEvent);
} else if (response.headers.containsKey("Content-Type")) {
mDownloadManager.downloadFile(response, mGeckoSession, mContext.get(), mEvent);
}
} catch (ActivityNotFoundException e) {
mEvent.invokeObserver(Arrays.asList(response, mGeckoDataModel.mSessionID), homeEnums.eGeckoCallback.ON_HANDLE_EXTERNAL_INTENT);
mGeckoSession.stop();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
}
}).check();
} }
@UiThread @UiThread

View File

@ -0,0 +1,102 @@
package com.hiddenservices.onionservices.appManager.homeManager.geckoManager.helperClasses;
import static com.hiddenservices.onionservices.pluginManager.pluginEnums.eMessageManager.M_OPEN_CICADA;
import android.Manifest;
import android.os.Build;
import androidx.appcompat.app.AppCompatActivity;
import com.hiddenservices.onionservices.pluginManager.pluginController;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.DexterBuilder;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
public class permissionHandler {
private WeakReference<AppCompatActivity> mContext;
public static permissionHandler ourInstance = new permissionHandler();
/*Initializations*/
public static permissionHandler getInstance() {
return ourInstance;
}
public void onInitPermissionHandler(WeakReference<AppCompatActivity> pContext){
mContext = pContext;
}
public void checkPermission(Callable<Void> pMethodParam){
DexterBuilder.Permission mPermission = Dexter.withContext(mContext.get());
DexterBuilder.MultiPermissionListener mListener;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
mListener = mPermission.withPermissions(
Manifest.permission.CAMERA,
Manifest.permission.READ_CONTACTS,
Manifest.permission.MEDIA_CONTENT_CONTROL,
Manifest.permission.MANAGE_MEDIA,
Manifest.permission.ACCESS_MEDIA_LOCATION,
Manifest.permission.READ_MEDIA_AUDIO,
Manifest.permission.READ_MEDIA_VIDEO,
Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.MANAGE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO);
}
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
mListener = mPermission.withPermissions(
Manifest.permission.CAMERA,
Manifest.permission.READ_CONTACTS,
Manifest.permission.MEDIA_CONTENT_CONTROL,
Manifest.permission.MANAGE_MEDIA,
Manifest.permission.ACCESS_MEDIA_LOCATION,
Manifest.permission.MANAGE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO);
}
else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
mListener = mPermission.withPermissions(
Manifest.permission.CAMERA,
Manifest.permission.READ_CONTACTS,
Manifest.permission.MEDIA_CONTENT_CONTROL,
Manifest.permission.ACCESS_MEDIA_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO
);
}else {
mListener = mPermission.withPermissions(
Manifest.permission.CAMERA,
Manifest.permission.READ_CONTACTS,
Manifest.permission.MEDIA_CONTENT_CONTROL,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO
);
}
mListener.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
try {
pMethodParam.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(this), M_OPEN_CICADA);
}
}).check();
}
}

View File

@ -61,6 +61,7 @@ import androidx.lifecycle.OnLifecycleEvent;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.hiddenservices.onionservices.appManager.activityContextManager; import com.hiddenservices.onionservices.appManager.activityContextManager;
import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.helperClasses.permissionHandler;
import com.hiddenservices.onionservices.appManager.unproxiedConnectionManager.unproxiedConnectionController; import com.hiddenservices.onionservices.appManager.unproxiedConnectionManager.unproxiedConnectionController;
import com.hiddenservices.onionservices.appManager.bookmarkManager.bookmarkSettings.bookmarkSettingController; import com.hiddenservices.onionservices.appManager.bookmarkManager.bookmarkSettings.bookmarkSettingController;
import com.hiddenservices.onionservices.appManager.bookmarkManager.bookmarkHome.bookmarkController; import com.hiddenservices.onionservices.appManager.bookmarkManager.bookmarkHome.bookmarkController;
@ -263,6 +264,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
status.sSettingIsAppRunning = true; status.sSettingIsAppRunning = true;
initPreFixes(); initPreFixes();
initBundle(); initBundle();
permissionHandler.getInstance().onInitPermissionHandler(new WeakReference(this));
if(!status.mThemeApplying){ if(!status.mThemeApplying){
initTor(); initTor();
} }
@ -2131,31 +2133,13 @@ public class homeController extends AppCompatActivity implements ComponentCallba
handler.postDelayed(() -> mGeckoView.clearFocus(), 500); handler.postDelayed(() -> mGeckoView.clearFocus(), 500);
} }
} else if (requestCode == 115) { } else if (requestCode == 115) {
Dexter.withContext(this) permissionHandler.getInstance().checkPermission(new Callable<Void>() {
.withPermissions( @Override
Manifest.permission.CAMERA, public Void call() throws Exception {
Manifest.permission.READ_CONTACTS, mGeckoClient.onUploadRequest(resultCode, data);
Manifest.permission.MEDIA_CONTENT_CONTROL, return null;
Manifest.permission.MANAGE_MEDIA, }
Manifest.permission.ACCESS_MEDIA_LOCATION, });
Manifest.permission.READ_MEDIA_AUDIO,
Manifest.permission.READ_MEDIA_VIDEO,
Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.MANAGE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO
).withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
mGeckoClient.onUploadRequest(resultCode, data);
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) {
}
}).check();
} else { } else {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }
@ -2477,6 +2461,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
} }
} else if (menuId == R.id.menu29) { } else if (menuId == R.id.menu29) {
pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(this), pluginEnums.eMessageManager.M_TOR_SWITCH); pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(this), pluginEnums.eMessageManager.M_TOR_SWITCH);
pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(this), pluginEnums.eMessageManager.M_TOR_SWITCH);
} else if (menuId == R.id.menuItem25) { } else if (menuId == R.id.menuItem25) {
String mFileName = DownloadUtils.guessFileName(null, "", mGeckoClient.getSession().getCurrentURL(), null); String mFileName = DownloadUtils.guessFileName(null, "", mGeckoClient.getSession().getCurrentURL(), null);

View File

@ -66,7 +66,13 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
this.mContext = new WeakReference(pContext); this.mContext = new WeakReference(pContext);
this.mEvent = pEvent; this.mEvent = pEvent;
this.mFileName = pFileName; if(pFileName.contains("/")){
pFileName = pFileName.substring(pFileName.lastIndexOf("/")+1);
}
if(pFileName.contains("?")){
pFileName = pFileName.substring(0, pFileName.lastIndexOf("?"));
}
this.mFileName = helperMethod.createRandomID().substring(0,5) + pFileName;
this.mURL = pURL; this.mURL = pURL;
this.mNotificationID = pNotificationID; this.mNotificationID = pNotificationID;
this.mBroadcastReciever = pBroadcastReciever; this.mBroadcastReciever = pBroadcastReciever;
@ -122,12 +128,17 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
} }
boolean mRequestRunning = false;
@Override @Override
protected String doInBackground(String... f_url) { protected String doInBackground(String... f_url) {
int mRequestCode = 0; int mRequestCode = 0;
OutputStream mOutputStream; OutputStream mOutputStream;
InputStream mInputStream; InputStream mInputStream;
if(!mRequestRunning){
mRequestRunning = true;
}else {
return "";
}
try { try {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
String fURL = f_url[0]; String fURL = f_url[0];
@ -135,14 +146,10 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
HttpURLConnection conection; HttpURLConnection conection;
Proxy proxy; Proxy proxy;
if (helperMethod.getDomainName(fURL).contains(".onion")) { if (helperMethod.getDomainName(fURL).contains(".onion")) {
if (orbotLocalConstants.mSOCKSPort == -1) { proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved("localhost", orbotLocalConstants.mSOCKSPort));
proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved("localhost", orbotLocalConstants.mSOCKSPort)); conection = (HttpURLConnection) url.openConnection(proxy);
conection = (HttpURLConnection) url.openConnection(proxy);
} else {
conection = (HttpURLConnection) url.openConnection();
}
} else { } else {
if (orbotLocalConstants.mSOCKSPort == -1) { if (status.sTorBrowsing) {
Proxy mProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", orbotLocalConstants.mHTTPPort)); Proxy mProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", orbotLocalConstants.mHTTPPort));
URLConnection mURLConnection = new URI(fURL).toURL().openConnection(mProxy); URLConnection mURLConnection = new URI(fURL).toURL().openConnection(mProxy);
conection = (HttpURLConnection) mURLConnection; conection = (HttpURLConnection) mURLConnection;
@ -167,19 +174,31 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
StrongHttpsClient httpclient = new StrongHttpsClient(mContext.get()); StrongHttpsClient httpclient = new StrongHttpsClient(mContext.get());
if (helperMethod.getDomainName(f_url[0]).contains(".onion")) { if(status.sTorBrowsing){
httpclient.useProxy(true, "SOCKS", "127.0.0.1", orbotLocalConstants.mSOCKSPort); httpclient.useProxy(true, "SOCKS", "127.0.0.1", orbotLocalConstants.mSOCKSPort);
} else { HttpGet httpget = new HttpGet(urlEncoded);
httpclient.useProxy(false, "SOCKS", "127.0.0.1", orbotLocalConstants.mSOCKSPort); HttpResponse response = httpclient.execute(httpget);
mInputStream = response.getEntity().getContent();
mRequestCode = response.getStatusLine().getStatusCode();
mOutputStream = new FileOutputStream(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/" + mFileName);
float lenghtOfFile = response.getEntity().getContentLength();
readStream(mInputStream, mOutputStream, lenghtOfFile);
}else {
HttpURLConnection conection;
String fURL = f_url[0];
URLConnection mURLConnection = new URI(fURL).toURL().openConnection();
conection = (HttpURLConnection) mURLConnection;
conection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0");
conection.setRequestProperty("Accept", "*/*");
conection.connect();
mRequestCode = conection.getResponseCode();
mInputStream = conection.getInputStream();
mOutputStream = new FileOutputStream(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/" + mFileName);
int lenghtOfFile = conection.getContentLength();
readStream(mInputStream, mOutputStream, lenghtOfFile);
} }
HttpGet httpget = new HttpGet(urlEncoded);
HttpResponse response = httpclient.execute(httpget);
mInputStream = response.getEntity().getContent();
mRequestCode = response.getStatusLine().getStatusCode();
mOutputStream = new FileOutputStream(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/" + mFileName);
float lenghtOfFile = response.getEntity().getContentLength();
readStream(mInputStream, mOutputStream, lenghtOfFile);
} }
} catch (Exception ex) { } catch (Exception ex) {
if (mRequestCode != 200 && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (mRequestCode != 200 && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@ -188,6 +207,7 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
onBackgroundException(mRequestCode); onBackgroundException(mRequestCode);
} }
mRequestRunning = false;
return null; return null;
} }
@ -215,30 +235,6 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
mNotificationBuilder.setPriority(Notification.PRIORITY_LOW); mNotificationBuilder.setPriority(Notification.PRIORITY_LOW);
mNotifyManager.notify(mNotificationID, mNotificationBuilder.build()); mNotifyManager.notify(mNotificationID, mNotificationBuilder.build());
DownloadManager dm = (DownloadManager) mContext.get().getSystemService(Context.DOWNLOAD_SERVICE);
String mPath = (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator + mFileName).replace("File//", "content://");
File mFile = new File(mPath);
/* Create Dwonload Complete Destination */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Uri uri = FileProvider.getUriForFile(mContext.get(), "com.hiddenservices.onionservices.provider", mFile);
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Downloads.TITLE, mFileName);
contentValues.put(MediaStore.Downloads.DISPLAY_NAME, mFileName);
contentValues.put(MediaStore.Downloads.SIZE, mDownloadByte);
contentValues.put(MediaStore.Downloads.MIME_TYPE, helperMethod.getMimeType(uri.toString(), mContext.get()));
contentValues.put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS + File.separator + mFileName + "_" + helperMethod.createRandomID().substring(0, 5));
ContentResolver database = mContext.get().getContentResolver();
database.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues);
} else {
Uri uri = FileProvider.getUriForFile(mContext.get(), "com.hiddenservices.onionservices.provider", mFile);
String mime = helperMethod.getMimeType(uri.toString(), mContext.get());
if (mime != null) {
dm.addCompletedDownload(mFileName, mURL, false, mime, mFile.getAbsolutePath(), mFile.length(), false);
}
}
} }
@ -300,6 +296,7 @@ public class downloadReciever extends AsyncTask<String, Integer, String> {
pOutputStream.write(mData, 0, mCurrentReadCount); pOutputStream.write(mData, 0, mCurrentReadCount);
} }
mNotifyManager.cancel(mNotificationID);
onPostExecute(""); onPostExecute("");
return true; return true;
} }

View File

@ -1,6 +1,7 @@
package com.hiddenservices.onionservices.pluginManager; package com.hiddenservices.onionservices.pluginManager;
import android.Manifest; import android.Manifest;
import android.content.ActivityNotFoundException;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -8,6 +9,8 @@ import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.hiddenservices.onionservices.appManager.activityContextManager; import com.hiddenservices.onionservices.appManager.activityContextManager;
import com.hiddenservices.onionservices.appManager.homeManager.geckoManager.helperClasses.permissionHandler;
import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeEnums;
import com.hiddenservices.onionservices.appManager.unproxiedConnectionManager.unproxiedConnectionController; import com.hiddenservices.onionservices.appManager.unproxiedConnectionManager.unproxiedConnectionController;
import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeController; import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeController;
import com.hiddenservices.onionservices.appManager.orbotLogManager.orbotLogController; import com.hiddenservices.onionservices.appManager.orbotLogManager.orbotLogController;
@ -36,6 +39,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.Callable;
import static com.hiddenservices.onionservices.constants.constants.CONST_BRIDGES; import static com.hiddenservices.onionservices.constants.constants.CONST_BRIDGES;
import static com.hiddenservices.onionservices.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_CLICKED; import static com.hiddenservices.onionservices.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_CLICKED;
@ -233,49 +237,28 @@ public class pluginController {
return null; return null;
}); });
} else if (pEventType.equals(M_DOWNLOAD_SINGLE) || pEventType.equals(M_DOWNLOAD_FILE) || pEventType.equals(M_DOWNLOAD_FILE_MANUAL)) { } else if (pEventType.equals(M_DOWNLOAD_SINGLE) || pEventType.equals(M_DOWNLOAD_FILE) || pEventType.equals(M_DOWNLOAD_FILE_MANUAL)) {
Dexter.withContext(mHomeController.get()) permissionHandler.getInstance().checkPermission((Callable<Void>) () -> {
.withPermissions( if(pEventType.equals(M_DOWNLOAD_SINGLE)){
Manifest.permission.CAMERA, if (pData != null) {
Manifest.permission.READ_CONTACTS, if (pData.size() < 3) {
Manifest.permission.MEDIA_CONTENT_CONTROL, ((homeController) mHomeController.get()).onManualDownload(pData.get(0).toString());
Manifest.permission.MANAGE_MEDIA, } else {
Manifest.permission.ACCESS_MEDIA_LOCATION, if (pData.get(2).toString().startsWith("https://data") || pData.get(2).toString().startsWith("http://data")) {
Manifest.permission.READ_MEDIA_AUDIO, ((homeController) mHomeController.get()).onManualDownload(pData.get(2).toString().replace("https://", "").replace("http://", ""));
Manifest.permission.READ_MEDIA_VIDEO, } else {
Manifest.permission.READ_MEDIA_IMAGES, ((homeController) mHomeController.get()).onManualDownloadFileName(pData.get(2).toString(), (String) pData.get(0));
Manifest.permission.MANAGE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.RECORD_AUDIO
).withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) {
if(pEventType.equals(M_DOWNLOAD_SINGLE)){
if (pData != null) {
if (pData.size() < 3) {
((homeController) mHomeController.get()).onManualDownload(pData.get(0).toString());
} else {
if (pData.get(2).toString().startsWith("https://data") || pData.get(2).toString().startsWith("http://data")) {
((homeController) mHomeController.get()).onManualDownload(pData.get(2).toString().replace("https://", "").replace("http://", ""));
} else {
((homeController) mHomeController.get()).onManualDownloadFileName(pData.get(2).toString(), (String) pData.get(0));
}
}
}
}
if(pEventType.equals(M_DOWNLOAD_FILE)){
((homeController) mHomeController.get()).onDownloadFile();
}
if(pEventType.equals(M_DOWNLOAD_FILE_MANUAL)){
((homeController) mHomeController.get()).onManualDownload(pData.get(0).toString());
} }
} }
}
@Override }
public void onPermissionRationaleShouldBeShown(List<PermissionRequest> list, PermissionToken permissionToken) { if(pEventType.equals(M_DOWNLOAD_FILE)){
onMessageManagerInvoke(Collections.singletonList(this), M_OPEN_CICADA); ((homeController) mHomeController.get()).onDownloadFile();
} }
}).check(); if(pEventType.equals(M_DOWNLOAD_FILE_MANUAL)){
((homeController) mHomeController.get()).onManualDownload(pData.get(0).toString());
}
return null;
});
} else if (pEventType.equals(M_CANCEL_WELCOME)) { } else if (pEventType.equals(M_CANCEL_WELCOME)) {
status.sSettingIsWelcomeEnabled = false; status.sSettingIsWelcomeEnabled = false;