version:6.9
fix: update:增加app通过类名启动
This commit is contained in:
@@ -16,8 +16,8 @@ android {
|
|||||||
applicationId "com.uiui.aios"
|
applicationId "com.uiui.aios"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 59
|
versionCode 60
|
||||||
versionName "6.8"
|
versionName "6.9"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,18 @@ package com.uiui.aios.bean;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class DesktopIcon implements Serializable , Parcelable {
|
public class DesktopIcon implements Serializable, Parcelable {
|
||||||
private static final long serialVersionUID = 3358230413497783708L;
|
private static final long serialVersionUID = 3358230413497783708L;
|
||||||
|
|
||||||
String packageName;
|
String packageName;
|
||||||
|
String className;
|
||||||
Drawable icon;
|
Drawable icon;
|
||||||
String lable;
|
String lable;
|
||||||
int position;
|
int position;
|
||||||
@@ -59,6 +61,14 @@ public class DesktopIcon implements Serializable , Parcelable {
|
|||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClassName() {
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassName(String className) {
|
||||||
|
this.className = className;
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable getIcon() {
|
public Drawable getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
@@ -83,22 +93,24 @@ public class DesktopIcon implements Serializable , Parcelable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DesktopIcon creatDesktopIcon(Context context, ApplicationInfo applicationInfo) {
|
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo) {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
DesktopIcon desktopIcon = new DesktopIcon();
|
DesktopIcon desktopIcon = new DesktopIcon();
|
||||||
desktopIcon.setPackageName(applicationInfo.packageName);
|
desktopIcon.setPackageName(resolveInfo.activityInfo.packageName);
|
||||||
desktopIcon.setIcon(applicationInfo.loadIcon(pm));
|
desktopIcon.setClassName(resolveInfo.activityInfo.name);
|
||||||
desktopIcon.setLable(applicationInfo.loadLabel(pm).toString());
|
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
||||||
|
desktopIcon.setLable(resolveInfo.loadLabel(pm).toString());
|
||||||
desktopIcon.setPosition(0);
|
desktopIcon.setPosition(0);
|
||||||
return desktopIcon;
|
return desktopIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DesktopIcon creatDesktopIcon(Context context, ApplicationInfo applicationInfo, int position) {
|
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo, int position) {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
DesktopIcon desktopIcon = new DesktopIcon();
|
DesktopIcon desktopIcon = new DesktopIcon();
|
||||||
desktopIcon.setPackageName(applicationInfo.packageName);
|
desktopIcon.setPackageName(resolveInfo.activityInfo.packageName);
|
||||||
desktopIcon.setIcon(applicationInfo.loadIcon(pm));
|
desktopIcon.setClassName(resolveInfo.activityInfo.name);
|
||||||
desktopIcon.setLable(applicationInfo.loadLabel(pm).toString());
|
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
||||||
|
desktopIcon.setLable(resolveInfo.loadLabel(pm).toString());
|
||||||
desktopIcon.setPosition(position);
|
desktopIcon.setPosition(position);
|
||||||
return desktopIcon;
|
return desktopIcon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,14 +193,14 @@ public class AppListFragment extends BaseFragment {
|
|||||||
ToastUtil.show("电话功能被禁用");
|
ToastUtil.show("电话功能被禁用");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName());
|
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
||||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||||
SendRunningApp(getActivity());
|
SendRunningApp(getActivity());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName());
|
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
||||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||||
SendRunningApp(getActivity());
|
SendRunningApp(getActivity());
|
||||||
@@ -211,6 +211,7 @@ public class AppListFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onLongClick(View v, int index) {
|
public void onLongClick(View v, int index) {
|
||||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||||
|
if (desktopIcon == null) return;
|
||||||
String pkg = desktopIcon.getPackageName();
|
String pkg = desktopIcon.getPackageName();
|
||||||
Log.e(TAG, "onLongClick: " + pkg);
|
Log.e(TAG, "onLongClick: " + pkg);
|
||||||
switch (pkg) {
|
switch (pkg) {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import java.text.Collator;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -50,7 +49,7 @@ public class ApkUtils {
|
|||||||
this.add("com.sprd.sprdnote");
|
this.add("com.sprd.sprdnote");
|
||||||
this.add("com.android.deskclock");
|
this.add("com.android.deskclock");
|
||||||
this.add("com.android.email");
|
this.add("com.android.email");
|
||||||
this.add("com.android.calendar");
|
// this.add("com.android.calendar");
|
||||||
this.add("com.android.uiuios");
|
this.add("com.android.uiuios");
|
||||||
this.add("com.uiui.os");
|
this.add("com.uiui.os");
|
||||||
this.add("com.uiui.health");
|
this.add("com.uiui.health");
|
||||||
@@ -80,6 +79,7 @@ public class ApkUtils {
|
|||||||
this.add("com.jxw.launcher");
|
this.add("com.jxw.launcher");
|
||||||
this.add("com.tencent.android.qqdownloader");
|
this.add("com.tencent.android.qqdownloader");
|
||||||
this.add("com.alldocube.store");
|
this.add("com.alldocube.store");
|
||||||
|
this.add("com.android.calendar");
|
||||||
}};
|
}};
|
||||||
private static HashSet<String> allHintPackage = new HashSet<String>() {{
|
private static HashSet<String> allHintPackage = new HashSet<String>() {{
|
||||||
this.add("com.android.uiuios");
|
this.add("com.android.uiuios");
|
||||||
@@ -150,8 +150,7 @@ public class ApkUtils {
|
|||||||
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
// 查询所有已经安装的应用程序
|
// 查询所有已经安装的应用程序
|
||||||
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除,但还有安装目录的
|
List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||||
ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
|
|
||||||
|
|
||||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||||
@@ -169,66 +168,58 @@ public class ApkUtils {
|
|||||||
if (!TextUtils.isEmpty(appListString)) {
|
if (!TextUtils.isEmpty(appListString)) {
|
||||||
packageList = new ArrayList<>(Arrays.asList(appListString.split(",")));
|
packageList = new ArrayList<>(Arrays.asList(appListString.split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
int setting_other_appInstaller = Settings.Global.getInt(context.getContentResolver(), "setting_other_appInstaller", 1);
|
int setting_other_appInstaller = Settings.Global.getInt(context.getContentResolver(), "setting_other_appInstaller", 1);
|
||||||
|
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||||
for (ApplicationInfo app : appInfos) {
|
String pkg = resolveInfo.activityInfo.packageName;
|
||||||
if (appIsDisable(context, app.packageName)) {
|
if (appIsDisable(context, pkg)) {
|
||||||
Log.e(TAG, "queryFilterAppInfo: disable = " + app.packageName);
|
Log.e(TAG, "queryFilterAppInfo: disable = " + pkg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) > 0)//通过flag排除系统应用,会将电话、短信也排除掉
|
if (isSystemApp(context, pkg))//通过flag排除系统应用,会将电话、短信也排除掉
|
||||||
{
|
{
|
||||||
if (showPackageName.contains(app.packageName)) {
|
if (showPackageName.contains(pkg)) {
|
||||||
applicationInfos.add(app);
|
resolveInfos.add(resolveInfo);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (setting_other_appInstaller == 0) {//不显示自己安装的
|
if (setting_other_appInstaller == 0) {//不显示自己安装的
|
||||||
if (packageList.contains(app.packageName)){
|
if (packageList.contains(pkg)) {
|
||||||
applicationInfos.add(app);
|
resolveInfos.add(resolveInfo);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
|
if (allowPackages.contains(pkg) && !excludePackageName.contains(pkg)) {
|
||||||
applicationInfos.add(app);
|
resolveInfos.add(resolveInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
||||||
applicationInfos.removeIf(applicationInfo -> "com.uiui.city".equals(applicationInfo.packageName));
|
resolveInfos.removeIf(resolveInfo -> "com.uiui.city".equals(resolveInfo.activityInfo.packageName));
|
||||||
// applicationInfos.removeIf(applicationInfo -> "com.uiui.sn".equals(applicationInfo.packageName));
|
// resolveInfos.removeIf(applicationInfo -> "com.uiui.sn".equals(applicationInfo.packageName));
|
||||||
}
|
}
|
||||||
applicationInfos.sort(new Comparator<ApplicationInfo>() {
|
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||||
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
|
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
|
||||||
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
|
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
applicationInfos.sort(new Comparator<ApplicationInfo>() {
|
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
public int compare(ResolveInfo o1, ResolveInfo o2) {
|
||||||
if ((o1.flags & ApplicationInfo.FLAG_SYSTEM) <= (o2.flags & ApplicationInfo.FLAG_SYSTEM)) {
|
try {
|
||||||
|
if ((pm.getApplicationInfo(o1.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM) <= (pm.getApplicationInfo(o2.activityInfo.packageName, 0).flags & ApplicationInfo.FLAG_SYSTEM)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ArrayList<DesktopIcon> desktopIcons = new ArrayList<>();
|
ArrayList<DesktopIcon> desktopIcons = new ArrayList<>();
|
||||||
HashMap<String, ApplicationInfo> infoHashMap = new HashMap<>();
|
for (ResolveInfo applicationInfo : resolveInfos) {
|
||||||
for (ApplicationInfo applicationInfo : applicationInfos) {
|
|
||||||
infoHashMap.put(applicationInfo.packageName, applicationInfo);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < defaultSort.size(); i++) {
|
|
||||||
ApplicationInfo info = infoHashMap.get(defaultSort.get(i));
|
|
||||||
if (info != null) {
|
|
||||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, info, i));
|
|
||||||
infoHashMap.remove(defaultSort.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ApplicationInfo applicationInfo : infoHashMap.values()) {
|
|
||||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||||
}
|
}
|
||||||
DesktopIcon exitIcon = new DesktopIcon();
|
DesktopIcon exitIcon = new DesktopIcon();
|
||||||
@@ -244,6 +235,18 @@ public class ApkUtils {
|
|||||||
return pm.getApplicationEnabledSetting(pkg) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
return pm.getApplicationEnabledSetting(pkg) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSystemApp(Context context, String pkg) {
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
|
ApplicationInfo applicationInfo = null;
|
||||||
|
try {
|
||||||
|
applicationInfo = pm.getApplicationInfo(pkg, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (applicationInfo == null) return false;
|
||||||
|
return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean disableApp(Context context, String pkg) {
|
public static boolean disableApp(Context context, String pkg) {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
try {
|
try {
|
||||||
@@ -319,6 +322,20 @@ public class ApkUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean openPackage(Context context, String packageName, String className) {
|
||||||
|
if (TextUtils.isEmpty(className)) {
|
||||||
|
return openPackage(context, packageName);
|
||||||
|
}
|
||||||
|
ComponentName cn = new ComponentName(packageName, className);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setComponent(cn);
|
||||||
|
if (context != null) {
|
||||||
|
context.startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static Context getPackageContext(Context context, String packageName) {
|
public static Context getPackageContext(Context context, String packageName) {
|
||||||
Context pkgContext = null;
|
Context pkgContext = null;
|
||||||
if (context.getPackageName().equals(packageName)) {
|
if (context.getPackageName().equals(packageName)) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class IconUtils {
|
|||||||
this.add("com.android.deskclock");//时钟
|
this.add("com.android.deskclock");//时钟
|
||||||
this.add("com.android.dialer");//电话
|
this.add("com.android.dialer");//电话
|
||||||
this.add("com.android.dialer");//电话
|
this.add("com.android.dialer");//电话
|
||||||
this.add("com.android.gallery3d");//图库
|
// this.add("com.android.gallery3d");//图库
|
||||||
this.add("com.android.mms");//信息
|
this.add("com.android.mms");//信息
|
||||||
this.add("com.android.mms.ui");//信息
|
this.add("com.android.mms.ui");//信息
|
||||||
this.add("com.android.messaging");//信息
|
this.add("com.android.messaging");//信息
|
||||||
@@ -60,7 +60,7 @@ public class IconUtils {
|
|||||||
this.add("com_android_deskclock");
|
this.add("com_android_deskclock");
|
||||||
this.add("com_android_dialer");
|
this.add("com_android_dialer");
|
||||||
this.add("com_android_dialer");
|
this.add("com_android_dialer");
|
||||||
this.add("com_android_gallery3d_app");
|
// this.add("com_android_gallery3d_app");
|
||||||
this.add("com_android_mms_ui");
|
this.add("com_android_mms_ui");
|
||||||
this.add("com_android_mms_ui");
|
this.add("com_android_mms_ui");
|
||||||
this.add("com_android_mms_ui");
|
this.add("com_android_mms_ui");
|
||||||
|
|||||||
Reference in New Issue
Block a user