version:5.2
fix: update:修改日常应用,取消通知权限,亮度调整
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
||||
applicationId "com.uiuios.aios"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 42
|
||||
versionName "5.1"
|
||||
versionCode 43
|
||||
versionName "5.2"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public abstract class BaseMainActivity extends BaseActivity implements MainContact.MainView {
|
||||
public abstract class BaseMainActivity extends BaseActivity implements MainContact.MainView ,RemoteManager.ConnectedListener{
|
||||
private static final String TAG = BaseMainActivity.class.getSimpleName();
|
||||
|
||||
private MainPresenter mMainPresenter;
|
||||
@@ -92,6 +92,11 @@ public abstract class BaseMainActivity extends BaseActivity implements MainConta
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
setDefaultDesktop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
@@ -105,6 +110,11 @@ public abstract class BaseMainActivity extends BaseActivity implements MainConta
|
||||
// SystemClock.setCurrentTimeMillis(1662210000000L);//09-03
|
||||
}
|
||||
|
||||
// if (!isNotificationListenersEnabled()) {
|
||||
// ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权");
|
||||
// gotoNotificationAccessSetting(BaseMainActivity.this);
|
||||
// }
|
||||
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
mFragmentTransaction = mFragmentManager.beginTransaction();
|
||||
mFragments = new ArrayList<>();
|
||||
@@ -212,12 +222,7 @@ public abstract class BaseMainActivity extends BaseActivity implements MainConta
|
||||
}
|
||||
};
|
||||
bindAlarmService();
|
||||
RemoteManager.getInstance().setListener(new RemoteManager.ConnectedListener() {
|
||||
@Override
|
||||
public void onConnected() {
|
||||
setDefaultDesktop();
|
||||
}
|
||||
});
|
||||
RemoteManager.setListener(this);
|
||||
}
|
||||
|
||||
private ServiceConnection mAlarmServiceConnection;
|
||||
@@ -349,12 +354,8 @@ public abstract class BaseMainActivity extends BaseActivity implements MainConta
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.e(TAG, "onResume: ");
|
||||
if (!isNotificationListenersEnabled()) {
|
||||
ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权");
|
||||
gotoNotificationAccessSetting(this);
|
||||
} else {
|
||||
getPermission();
|
||||
}
|
||||
|
||||
getPermission();
|
||||
}
|
||||
|
||||
public static final String Launcher3 = "com.android.launcher3";
|
||||
@@ -497,6 +498,7 @@ public abstract class BaseMainActivity extends BaseActivity implements MainConta
|
||||
if (updateDesktopReceiver != null) {
|
||||
unregisterReceiver(updateDesktopReceiver);
|
||||
}
|
||||
RemoteManager.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,7 @@ public class AlarmOpenHelper extends SQLiteOpenHelper {
|
||||
public static final int DATABASE_VERSION = 2;
|
||||
public static final String DATABASE_NAME = "AlarmDatabase.db";
|
||||
// public static final String DATABASE_FILE_NAME = Environment.getExternalStorageDirectory().getPath() + File.separator + DATABASE_NAME;
|
||||
public static final String DATABASE_FILE_NAME = File.separator + DATABASE_NAME;
|
||||
public static final String DATABASE_FILE_NAME = DATABASE_NAME;
|
||||
|
||||
public static final String TABLE_ALARM = " AlarmTable";
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ public class AlarmUtils {
|
||||
private AlarmUtils(Context context) {
|
||||
this.mContext = context;
|
||||
// this.mAlarmOpenHelper = new AlarmOpenHelper(context, AlarmOpenHelper.DATABASE_NAME, null, AlarmOpenHelper.DATABASE_VERSION);
|
||||
this.mAlarmOpenHelper = new AlarmOpenHelper(context, mContext.getExternalCacheDir() + AlarmOpenHelper.DATABASE_FILE_NAME, null, AlarmOpenHelper.DATABASE_VERSION);
|
||||
this.mAlarmOpenHelper = new AlarmOpenHelper(context,
|
||||
context.getExternalCacheDir() + File.separator + AlarmOpenHelper.DATABASE_FILE_NAME,
|
||||
null, AlarmOpenHelper.DATABASE_VERSION);
|
||||
this.mDatabase = mAlarmOpenHelper.getWritableDatabase();
|
||||
this.mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DesktopIcon implements Serializable, Parcelable {
|
||||
@@ -115,4 +120,9 @@ public class DesktopIcon implements Serializable, Parcelable {
|
||||
return desktopIcon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ public class CommonConfig {
|
||||
public static final String LOCK_SCREEN_PASSWORD = "aios_lockScreenPasswordKey";
|
||||
public static final String DEFAULT_PASSWORD = "6666";
|
||||
|
||||
/*应用市场所有包名*/
|
||||
public static final String UIUI_APPSTORE_PACKAGE_LIST = "UIUI_APPSTORE_PACKAGE_LIST_KEY";
|
||||
/*首次进入桌面*/
|
||||
public static final String UIUI_FIRST_OPEN = "uiui_desktop_first_open_key";
|
||||
|
||||
/*是否激活接口请求缓存*/
|
||||
public static final String ACTIVATION_BEAN_KEY = "AIOS_UIUI_ACTIVATION_BEAN_KEY";
|
||||
/*是否激活*/
|
||||
|
||||
@@ -298,6 +298,7 @@ public class AppListFragment extends BaseFragment {
|
||||
case "aios.exit":
|
||||
case "com.uiuios.sn":
|
||||
case "aios.daily.app":
|
||||
case "aios.appstore":
|
||||
break;
|
||||
default:
|
||||
showHideDialog(desktopIcon);
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.ContentObserver;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
@@ -20,12 +21,16 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
@@ -213,8 +218,24 @@ public class ControlFragment extends BaseFragment {
|
||||
startActivity(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS));
|
||||
}
|
||||
});
|
||||
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS),
|
||||
true,
|
||||
mBrightnessObserver
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private ContentObserver mBrightnessObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
super.onChange(selfChange);
|
||||
Log.e("mBrightnessObserver", "onChange: " + Settings.System.getInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 1));
|
||||
}
|
||||
};
|
||||
|
||||
private void initData() {
|
||||
|
||||
}
|
||||
@@ -843,12 +864,21 @@ public class ControlFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
Log.e(TAG, "onProgressChanged: i = " + i);
|
||||
RemoteManager.getInstance().putSystemInt(Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 1, 255);
|
||||
Log.e(TAG, "onProgressChanged: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
Log.e(TAG, "onProgressChanged: percentage = " + percentage);
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
|
||||
if (RemoteManager.isServiceConnected()) {
|
||||
RemoteManager.getInstance().putSystemInt(Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
} else {
|
||||
Window window = getActivity().getWindow();
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
Log.e(TAG, "onProgressChanged: " + i / 255f);
|
||||
lp.screenBrightness = i / 255f;//0.0-1.0
|
||||
window.setAttributes(lp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -903,6 +933,7 @@ public class ControlFragment extends BaseFragment {
|
||||
super.onDestroy();
|
||||
if (mWifiReceiver != null) mContext.unregisterReceiver(mWifiReceiver);
|
||||
if (mTimeUpdateReceiver != null) mContext.unregisterReceiver(mTimeUpdateReceiver);
|
||||
mContext.getContentResolver().unregisterContentObserver(mBrightnessObserver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AppManager {
|
||||
@@ -258,7 +259,6 @@ public class AppManager {
|
||||
return desktopIcons;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<DesktopIcon> getAddDesktopIcon() {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
@@ -281,6 +281,25 @@ public class AppManager {
|
||||
return desktopIcons;
|
||||
}
|
||||
|
||||
public Set<String> getAddDesktopIconSet() {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
// 通过getPackageManager()的queryIntentActivities方法遍历,得到所有能打开的app的packageName
|
||||
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
if (addPackages.contains(resolveInfo.activityInfo.packageName)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
}
|
||||
Set<String> pkgSet = resolveInfos.stream().map(resolveInfo -> resolveInfo.activityInfo.packageName).collect(Collectors.toSet());
|
||||
return pkgSet;
|
||||
}
|
||||
|
||||
|
||||
public void addAddPakcage(String packageName) {
|
||||
this.addPackages.add(packageName);
|
||||
mMMKV.encode(ADD_PACKAGE_KEY, addPackages);
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
public class RemoteManager {
|
||||
private static final String TAG = RemoteManager.class.getSimpleName();
|
||||
@@ -35,6 +36,7 @@ public class RemoteManager {
|
||||
private static RemoteManager sInstance;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
private static boolean mServiceConnected = false;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
private IGetInfoInterface mGetInfoInterface;
|
||||
@@ -51,6 +53,7 @@ public class RemoteManager {
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
|
||||
mGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
||||
mServiceConnected = true;
|
||||
for (ConnectedListener listener : mListeners) {
|
||||
if (listener != null) {
|
||||
listener.onConnected();
|
||||
@@ -71,6 +74,7 @@ public class RemoteManager {
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
|
||||
mGetInfoInterface = null;
|
||||
mServiceConnected = false;
|
||||
bindInfoService();
|
||||
}
|
||||
};
|
||||
@@ -91,19 +95,27 @@ public class RemoteManager {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static boolean isServiceConnected() {
|
||||
return mServiceConnected;
|
||||
}
|
||||
|
||||
public interface ConnectedListener {
|
||||
void onConnected();
|
||||
}
|
||||
|
||||
Set<ConnectedListener> mListeners = new HashSet<>();
|
||||
private static Set<ConnectedListener> mListeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
public void setListener(ConnectedListener listener) {
|
||||
public static void setListener(ConnectedListener listener) {
|
||||
mListeners.add(listener);
|
||||
if (mGetInfoInterface != null) {
|
||||
if (mServiceConnected) {
|
||||
listener.onConnected();
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeListener(ConnectedListener listener) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
private void bindInfoService() {
|
||||
if (mGetInfoInterface == null) {
|
||||
//这是连接aidl服务的代码
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.uiuios.aios.bean.DesktopIcon;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ShortcutPkgInfo extends DesktopIcon implements Serializable {
|
||||
public class ShortcutPkgInfo extends DesktopIcon implements Serializable {
|
||||
private static final long serialVersionUID = -8142340420690477465L;
|
||||
|
||||
String mId;
|
||||
|
||||
@@ -18,9 +18,12 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.QuickAppActivity;
|
||||
import com.uiuios.aios.bean.DesktopIcon;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.manager.AppManager;
|
||||
import com.uiuios.aios.manager.AppStatusManager;
|
||||
import com.uiuios.aios.receiver.InstallResultReceiver;
|
||||
@@ -38,6 +41,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
@@ -155,12 +159,25 @@ public class ApkUtils {
|
||||
this.add("com.uiuios.appstore");
|
||||
}};
|
||||
|
||||
private static List<String> hideApp = new ArrayList<String>() {{
|
||||
this.add("com.uiuios.aios");
|
||||
this.add("com.uiuios.appstore");
|
||||
}};
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
||||
List<String> quickApps = new ArrayList<>(AppManager.getInstance().getAddPackages());
|
||||
MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
String quickAppString = Settings.Global.getString(context.getContentResolver(), QuickAppActivity.QUICK_APP_KEY);
|
||||
List<String> quickApps;
|
||||
if (TextUtils.isEmpty(quickAppString)) {
|
||||
quickApps = new ArrayList<>();
|
||||
} else {
|
||||
List<String> split = new ArrayList<>(Arrays.asList(quickAppString.split(",")));
|
||||
quickApps = split.stream().filter(s -> ApkUtils.isAvailable(context, s)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
@@ -175,17 +192,21 @@ public class ApkUtils {
|
||||
Set<String> allowPackages = new HashSet();
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.packageName);
|
||||
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.name);
|
||||
Log.i(TAG, "queryFilterAppInfo class: " + resolveInfo.activityInfo.name);
|
||||
allowPackages.add(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
String appListString = Settings.System.getString(context.getContentResolver(), "only_jgy_shortcut_list");
|
||||
List<String> packageList = new ArrayList<>();
|
||||
if (!TextUtils.isEmpty(appListString)) {
|
||||
packageList = new ArrayList<>(Arrays.asList(appListString.split(",")));
|
||||
}
|
||||
String pkgString = Settings.Global.getString(context.getContentResolver(), CommonConfig.UIUI_APPSTORE_PACKAGE_LIST);
|
||||
Set<String> pkgSet = new HashSet<>(new ArrayList<>(Arrays.asList(pkgString.split(","))));
|
||||
Log.e(TAG, "queryFilterAppInfo: pkgSet = " + pkgSet);
|
||||
int frist = mmkv.decodeInt(CommonConfig.UIUI_FIRST_OPEN, 0);
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
String pkg = resolveInfo.activityInfo.packageName;
|
||||
if (hideApp.contains(pkg)){
|
||||
Log.e(TAG, "queryFilterAppInfo: hideApp = " + pkg);
|
||||
continue;
|
||||
}
|
||||
if (quickApps.contains(pkg)) {
|
||||
Log.e(TAG, "queryFilterAppInfo: quickApps = " + pkg);
|
||||
continue;
|
||||
}
|
||||
if (appIsDisable(context, pkg)) {
|
||||
@@ -196,56 +217,65 @@ public class ApkUtils {
|
||||
Log.e(TAG, "queryFilterAppInfo: hided = " + pkg);
|
||||
continue;
|
||||
}
|
||||
if (AppManager.getInstance().getAddDesktopIconSet().contains(pkg)) {
|
||||
Log.e(TAG, "queryFilterAppInfo: quick = " + pkg);
|
||||
continue;
|
||||
}
|
||||
if (isSystemApp(context, pkg))//通过flag排除系统应用,会将电话、短信也排除掉
|
||||
{
|
||||
if (showPackageName.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
} else {
|
||||
// int setting_other_appInstaller = Settings.Global.getInt(context.getContentResolver(), "setting_other_appInstaller", 1);
|
||||
// if (setting_other_appInstaller == 0) {//不显示自己安装的
|
||||
// if (packageList.contains(pkg)) {
|
||||
// resolveInfos.add(resolveInfo);
|
||||
// }
|
||||
// } else {
|
||||
if (allowPackages.contains(pkg) && !excludePackageName.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
if (frist == 0) {
|
||||
if (pkgSet.contains(pkg)) {
|
||||
if (allowPackages.contains(pkg) && !excludePackageName.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "queryFilterAppInfo: pkgSet ! contains " + pkg);
|
||||
AppStatusManager.getInstance().addHidedApp(pkg);
|
||||
}
|
||||
} else {
|
||||
if (allowPackages.contains(pkg) && !excludePackageName.contains(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
||||
resolveInfos.removeIf(resolveInfo -> "com.uiui.city".equals(resolveInfo.activityInfo.packageName));
|
||||
// resolveInfos.removeIf(applicationInfo -> "com.uiui.sn".equals(applicationInfo.packageName));
|
||||
}
|
||||
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||
List<ResolveInfo> sort1 = resolveInfos.stream().sorted(new Comparator<ResolveInfo>() {
|
||||
@Override
|
||||
public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
|
||||
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
|
||||
}
|
||||
});
|
||||
// resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||
// @Override
|
||||
// public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||
// try {
|
||||
// if ((pm.getApplicationInfo(o1.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM) <= (pm.getApplicationInfo(o2.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM)) {
|
||||
// return 1;
|
||||
// } else {
|
||||
// return -1;
|
||||
// }
|
||||
// } catch (PackageManager.NameNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
// });
|
||||
}).collect(Collectors.toList());
|
||||
List<ResolveInfo> sort2 = sort1.stream().sorted(new Comparator<ResolveInfo>() {
|
||||
@Override
|
||||
public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||
try {
|
||||
if ((pm.getApplicationInfo(o1.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM) < (pm.getApplicationInfo(o2.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM)) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
ArrayList<DesktopIcon> desktopIcons = new ArrayList<>();
|
||||
for (ResolveInfo applicationInfo : resolveInfos) {
|
||||
for (ResolveInfo applicationInfo : sort2) {
|
||||
if (!excludeClassName.contains(applicationInfo.activityInfo.name)) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||
}
|
||||
}
|
||||
|
||||
List<ShortcutPkgInfo> shortcutPkgInfos = ShortcutUtils.getInstance().getShortcutList();
|
||||
desktopIcons.addAll(shortcutPkgInfos);
|
||||
|
||||
@@ -261,12 +291,13 @@ public class ApkUtils {
|
||||
familyIcon.setPackage("aios.appstore");
|
||||
desktopIcons.add(1, familyIcon);
|
||||
|
||||
DesktopIcon exitIcon = new DesktopIcon();
|
||||
exitIcon.setIcon(context.getDrawable(R.drawable.exit_icon));
|
||||
exitIcon.setTitle("切换系统");
|
||||
exitIcon.setPackage("aios.exit");
|
||||
desktopIcons.add(exitIcon);
|
||||
// DesktopIcon exitIcon = new DesktopIcon();
|
||||
// exitIcon.setIcon(context.getDrawable(R.drawable.exit_icon));
|
||||
// exitIcon.setTitle("切换系统");
|
||||
// exitIcon.setPackage("aios.exit");
|
||||
// desktopIcons.add(exitIcon);
|
||||
|
||||
mmkv.encode(CommonConfig.UIUI_FIRST_OPEN, 1);
|
||||
return desktopIcons;
|
||||
}
|
||||
|
||||
@@ -345,7 +376,7 @@ public class ApkUtils {
|
||||
}
|
||||
|
||||
public static Drawable getAppDrawable(Context context, String pkg) {
|
||||
if (context==null||TextUtils.isEmpty(pkg)){
|
||||
if (context == null || TextUtils.isEmpty(pkg)) {
|
||||
return null;
|
||||
}
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
|
||||
Reference in New Issue
Block a user