mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-19 04:58:47 -04:00
Clean up !
This commit is contained in:
@@ -23,9 +23,7 @@ package com.aurora.store.download;
|
||||
import android.content.Context;
|
||||
|
||||
import com.aurora.store.model.App;
|
||||
import com.aurora.store.utility.PackageUtil;
|
||||
import com.aurora.store.utility.PathUtil;
|
||||
import com.aurora.store.utility.SplitUtil;
|
||||
import com.aurora.store.utility.TextUtil;
|
||||
import com.aurora.store.utility.Util;
|
||||
import com.dragons.aurora.playstoreapiv2.AndroidAppDeliveryData;
|
||||
@@ -65,23 +63,6 @@ public class RequestBuilder {
|
||||
return request;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Build Simple App Download Request from URL and GroupId
|
||||
* @param Context - Application Context
|
||||
* @param App - App object
|
||||
* @param Url - APK Url
|
||||
* @param groupId - Request GroupId
|
||||
* @return Request
|
||||
*
|
||||
*/
|
||||
|
||||
public static Request buildRequest(Context context, App app, String apkURL, int groupId) {
|
||||
Request request = buildRequest(context, app, apkURL);
|
||||
request.setGroupId(groupId);
|
||||
return request;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Build Bundled App Download Request from URL
|
||||
@@ -127,29 +108,6 @@ public class RequestBuilder {
|
||||
return requestList;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Build Bundled App Download RequestList from SplitList and GroupId
|
||||
* Build Bundled App Download RequestList from SplitList
|
||||
* @param Context - Application Context
|
||||
* @param App - App object
|
||||
* @param List<Split> - List of Split Objects
|
||||
* @param groupId - Request GroupId
|
||||
* @return RequestList
|
||||
*
|
||||
*/
|
||||
|
||||
public static List<Request> buildSplitRequestList(Context context, App app,
|
||||
List<Split> splitList, int id) {
|
||||
List<Request> requestList = new ArrayList<>();
|
||||
for (Split split : splitList) {
|
||||
final Request splitRequest = buildSplitRequest(context, app, split);
|
||||
splitRequest.setGroupId(id);
|
||||
requestList.add(splitRequest);
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Build Obb Download Request from URL
|
||||
@@ -205,35 +163,5 @@ public class RequestBuilder {
|
||||
}
|
||||
return requestList;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Build Bulk RequestList from DeliveryDataList, AppList and GroupId
|
||||
* @param Context - Application Context
|
||||
* @param List<AndroidAppDeliveryData> - List of AndroidAppDeliveryData objects
|
||||
* @param List<App> - List of App Objects
|
||||
* @param groupId - Request GroupId
|
||||
*
|
||||
*/
|
||||
public static List<Request> getBulkRequestList(Context context,
|
||||
List<AndroidAppDeliveryData> deliveryDataList,
|
||||
List<App> appList, int groupId) {
|
||||
List<Request> mRequestList = new ArrayList<>();
|
||||
for (int i = 0; i < deliveryDataList.size(); i++) {
|
||||
final List<Split> splitList = deliveryDataList.get(i).getSplitList();
|
||||
final App app = appList.get(i);
|
||||
if (!splitList.isEmpty()) {
|
||||
mRequestList.addAll(buildSplitRequestList(context, app, splitList, groupId));
|
||||
SplitUtil.addToList(context, app.getPackageName());
|
||||
}
|
||||
mRequestList.add(buildRequest(context, app,
|
||||
deliveryDataList.get(i).getDownloadUrl(), groupId));
|
||||
|
||||
//Add <PackageName,DisplayName> and <PackageName,IconURL> to PseudoMaps
|
||||
PackageUtil.addToPseudoPackageMap(context, app.getPackageName(), app.getDisplayName());
|
||||
PackageUtil.addToPseudoURLMap(context, app.getPackageName(), app.getIconInfo().getUrl());
|
||||
}
|
||||
return mRequestList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.aurora.store.AuroraApplication;
|
||||
import com.aurora.store.Constants;
|
||||
import com.aurora.store.ErrorType;
|
||||
import com.aurora.store.R;
|
||||
import com.aurora.store.adapter.UpdatableAppsAdapter;
|
||||
@@ -52,7 +51,7 @@ import com.aurora.store.task.ObservableDeliveryData;
|
||||
import com.aurora.store.task.UpdatableAppsTask;
|
||||
import com.aurora.store.utility.ContextUtil;
|
||||
import com.aurora.store.utility.Log;
|
||||
import com.aurora.store.utility.PrefUtil;
|
||||
import com.aurora.store.utility.Util;
|
||||
import com.aurora.store.utility.ViewUtil;
|
||||
import com.aurora.store.view.CustomSwipeToRefresh;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -244,6 +243,7 @@ public class UpdatesFragment extends BaseFragment {
|
||||
cancelAllRequests();
|
||||
AuroraApplication.setOngoingUpdateList(new ArrayList<>());
|
||||
AuroraApplication.setOnGoingUpdate(false);
|
||||
Util.clearOldInstallationSessions(context);
|
||||
ContextUtil.runOnUiThread(() -> drawButtons());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ import com.aurora.store.utility.ContextUtil;
|
||||
import com.aurora.store.utility.Log;
|
||||
import com.aurora.store.utility.PackageUtil;
|
||||
import com.aurora.store.utility.PathUtil;
|
||||
import com.aurora.store.utility.SplitUtil;
|
||||
import com.aurora.store.utility.Util;
|
||||
import com.aurora.store.utility.ViewUtil;
|
||||
import com.dragons.aurora.playstoreapiv2.AndroidAppDeliveryData;
|
||||
@@ -299,10 +298,6 @@ public class ActionButton extends AbstractHelper {
|
||||
requestList.addAll(splitList);
|
||||
requestList.addAll(obbList);
|
||||
|
||||
if (!splitList.isEmpty()) {
|
||||
SplitUtil.addToList(context, app.getPackageName());
|
||||
}
|
||||
|
||||
fetchListener = getFetchListener();
|
||||
fetch.addListener(fetchListener);
|
||||
fetch.enqueue(requestList, updatedRequestList ->
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.aurora.store.fragment.preference;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
@@ -17,7 +16,6 @@ import com.aurora.store.Constants;
|
||||
import com.aurora.store.R;
|
||||
import com.aurora.store.activity.SettingsActivity;
|
||||
import com.aurora.store.utility.ContextUtil;
|
||||
import com.aurora.store.utility.Log;
|
||||
import com.aurora.store.utility.PackageUtil;
|
||||
import com.aurora.store.utility.PathUtil;
|
||||
import com.aurora.store.utility.PrefUtil;
|
||||
@@ -110,16 +108,7 @@ public class InstallationFragment extends PreferenceFragmentCompat implements Sh
|
||||
Preference abandonPreference = findPreference(Constants.PREFERENCE_INSTALLATION_ABANDON_SESSION);
|
||||
assert abandonPreference != null;
|
||||
abandonPreference.setOnPreferenceClickListener(preference -> {
|
||||
final PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
|
||||
for (PackageInstaller.SessionInfo sessionInfo : packageInstaller.getMySessions()) {
|
||||
final int sessionId = sessionInfo.getSessionId();
|
||||
try {
|
||||
packageInstaller.abandonSession(sessionInfo.getSessionId());
|
||||
Log.e("Abandoned session id -> %d", sessionId);
|
||||
} catch (Exception e) {
|
||||
Log.e("Unable to abandon session id ->", sessionId);
|
||||
}
|
||||
}
|
||||
Util.clearOldInstallationSessions(context);
|
||||
ContextUtil.toastLong(context, getString(R.string.toast_abandon_sessions));
|
||||
return false;
|
||||
});
|
||||
@@ -145,7 +134,6 @@ public class InstallationFragment extends PreferenceFragmentCompat implements Sh
|
||||
SettingsActivity.shouldRestart = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addUserInfoData(ListPreference listPreference) {
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2019, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.task;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.aurora.store.model.App;
|
||||
import com.dragons.aurora.playstoreapiv2.AndroidAppDeliveryData;
|
||||
import com.dragons.aurora.playstoreapiv2.GooglePlayAPI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BulkDeliveryData extends DeliveryData {
|
||||
private List<AndroidAppDeliveryData> deliveryDataList = new ArrayList<>();
|
||||
|
||||
public BulkDeliveryData(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public List<AndroidAppDeliveryData> getDeliveryData(List<App> appList) throws IOException {
|
||||
GooglePlayAPI api = getApi();
|
||||
for (App app : appList) {
|
||||
purchase(api, app);
|
||||
delivery(api, app);
|
||||
deliveryDataList.add(deliveryData);
|
||||
}
|
||||
return deliveryDataList;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2019, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.store.task;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.aurora.store.api.PlayStoreApiAuthenticator;
|
||||
import com.aurora.store.api.UrlIterator2;
|
||||
import com.aurora.store.iterator.CustomAppListIterator;
|
||||
import com.aurora.store.model.App;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClusterApps extends BaseTask {
|
||||
|
||||
public ClusterApps(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public List<App> getApps(String clusterUrl) throws IOException {
|
||||
List<App> appList = new ArrayList<>();
|
||||
CustomAppListIterator iterator = new CustomAppListIterator(
|
||||
new UrlIterator2(new PlayStoreApiAuthenticator(context).getApi(), clusterUrl));
|
||||
iterator.setGooglePlayApi(new PlayStoreApiAuthenticator(context).getApi());
|
||||
if (!iterator.hasNext()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
while (iterator.hasNext() && appList.isEmpty()) {
|
||||
appList.addAll(iterator.next());
|
||||
}
|
||||
return appList;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import com.aurora.store.model.App;
|
||||
import com.aurora.store.notification.GeneralNotification;
|
||||
import com.aurora.store.utility.Log;
|
||||
import com.aurora.store.utility.PackageUtil;
|
||||
import com.aurora.store.utility.SplitUtil;
|
||||
import com.aurora.store.utility.Util;
|
||||
import com.dragons.aurora.playstoreapiv2.AndroidAppDeliveryData;
|
||||
import com.tonyodev.fetch2.AbstractFetchGroupListener;
|
||||
@@ -56,10 +55,6 @@ public class LiveUpdate extends BaseTask {
|
||||
requestList.addAll(splitList);
|
||||
requestList.addAll(obbList);
|
||||
|
||||
if (!splitList.isEmpty()) {
|
||||
SplitUtil.addToList(context, app.getPackageName());
|
||||
}
|
||||
|
||||
fetchListener = getFetchListener();
|
||||
fetch.addListener(fetchListener);
|
||||
fetch.enqueue(requestList, updatedRequestList ->
|
||||
|
||||
@@ -3,17 +3,30 @@ package com.aurora.store.task;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
|
||||
import com.aurora.store.utility.Util;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class NetworkTask extends ContextWrapper {
|
||||
public NetworkTask(Context base) {
|
||||
super(base);
|
||||
|
||||
private Context context;
|
||||
|
||||
public NetworkTask(Context context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private static OkHttpClient getOkHttpClient(Context context) {
|
||||
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
if (Util.isNetworkProxyEnabled(context))
|
||||
builder.proxy(Util.getNetworkProxy(context));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public String get(String url) throws Exception {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
OkHttpClient client = getOkHttpClient(context);
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
Response response = client.newCall(request).execute();
|
||||
return response.body().string();
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.aurora.store.utility;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SplitUtil {
|
||||
|
||||
private static final String PSEUDO_SPLIT_LIST = "PSEUDO_SPLIT_LIST";
|
||||
|
||||
public static void addToList(Context context, String packageName) {
|
||||
ArrayList<String> splitList = PrefUtil.getListString(context, PSEUDO_SPLIT_LIST);
|
||||
splitList.add(packageName);
|
||||
PrefUtil.putListString(context, PSEUDO_SPLIT_LIST, splitList);
|
||||
}
|
||||
|
||||
public static boolean isSplit(Context context, String packageName) {
|
||||
return PrefUtil.getListString(context, PSEUDO_SPLIT_LIST).contains(packageName);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
@@ -487,4 +488,17 @@ public class Util {
|
||||
}
|
||||
Log.i("Periodic update preferences updated");
|
||||
}
|
||||
|
||||
public static void clearOldInstallationSessions(Context context){
|
||||
final PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
|
||||
for (PackageInstaller.SessionInfo sessionInfo : packageInstaller.getMySessions()) {
|
||||
final int sessionId = sessionInfo.getSessionId();
|
||||
try {
|
||||
packageInstaller.abandonSession(sessionInfo.getSessionId());
|
||||
Log.e("Abandoned session id -> %d", sessionId);
|
||||
} catch (Exception e) {
|
||||
Log.e("Unable to abandon session id ->", sessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user