Commit 1a853964 by Baoxy

fix: 修复问题

1-1.新添加三方应用到桌面后,点击该应用会提示[安全策略阻止该应用运行],新添加应用不可使用,且会导致学习桌面崩溃并退出;再次进入恢复正常; 1-2.在emui9.1的设备上,存在进入家长设置-桌面图标,在横屏的过程中快速点击屏幕(点击位置始终为[桌面图标]的位置),会自动退出到桌面主页,并且主页图标全部消失(包含切换和常规设置) 1-3.在p10(emui9.1)上偶发添加/删减桌面图标时,桌面图标没有及时同步的问题,退出后重新进入恢复正常;
parent 49e43af6
......@@ -1208,17 +1208,19 @@ public class Launcher extends BaseActivity
@Override
public void activated() {
activationNext();
WorkManager.INSTANCE.enter(Launcher.this);
}
}, false);
}
private void activationNext() {
public static void forceReload(){
LauncherAppState app = LauncherAppState.getInstanceNoCreate();
if (app != null) {
app.getModel().forceReload();
LauncherModel model = app.getModel();
if(model != null){
model.forceReload();
}
}
WorkManager.INSTANCE.enter(this);
}
......
......@@ -80,7 +80,6 @@ import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Provider;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
import com.secspace.lib.common.env.Packages;
import java.io.FileDescriptor;
import java.io.PrintWriter;
......
......@@ -370,13 +370,17 @@ public class DragController implements DragDriver.EventListener, TouchController
@Override
public void onDriverDragEnd(float x, float y) {
DropTarget dropTarget;
Runnable flingAnimation = mFlingToDeleteHelper.getFlingAnimation(mDragObject);
if (flingAnimation != null) {
dropTarget = mFlingToDeleteHelper.getDropTarget();
} else {
dropTarget = findDropTarget((int) x, (int) y, mCoordinatesTemp);
}
Runnable flingAnimation = null;
// 取消快速滑动删除
// Runnable flingAnimation = mFlingToDeleteHelper.getFlingAnimation(mDragObject);
// if (flingAnimation != null) {
// Log.e("TAG1", "onDriverDragEnd: ifififif" );
// dropTarget = mFlingToDeleteHelper.getDropTarget();
// } else {
// Log.e("TAG1", "onDriverDragEnd: elseelse" );
// dropTarget = findDropTarget((int) x, (int) y, mCoordinatesTemp);
// }
dropTarget = findDropTarget((int) x, (int) y, mCoordinatesTemp);
drop(dropTarget, flingAnimation);
endDrag();
......
......@@ -5,15 +5,12 @@ import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.ResolveInfo
import android.os.Bundle
import android.os.Handler
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.LinearLayoutManager.HORIZONTAL
import android.support.v7.widget.LinearLayoutManager.VERTICAL
import android.util.Log
import android.view.View
import com.android.launcher3.BaseActivity
import com.android.launcher3.Launcher
import com.android.launcher3.R
import com.android.launcher3.settings.AppChooseListAdapter
import com.android.launcher3.settings.AppChooseListAdapter.SYSTEM_APP_FLAG
......@@ -36,6 +33,7 @@ class AppChooseActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_app_manager)
LoadingDialog.getInstance(this).show("加载中")
mContext = this
setAndroidNativeLightStatusBar(true)
initView()
......@@ -44,7 +42,6 @@ class AppChooseActivity : BaseActivity() {
fun initView() {
tv_setting_title.setText(R.string.edu_item_icon)
LoadingDialog.getInstance(this).show("加载中")
mAppInfoAdapterSystemApp = AppChooseListAdapter(SYSTEM_APP_FLAG)
mAppInfoAdapterSystemApp?.setItemViewId(R.layout.item_app_choose_list)
val linearLayoutManager = LinearLayoutManager(this, VERTICAL, false)
......@@ -106,11 +103,16 @@ class AppChooseActivity : BaseActivity() {
fun btnClick(view: View?) {
when (view?.id) {
R.id.btn_sure -> {
mAppInfoAdapterSystemApp?.saveResult(mAppContext)
mAppInfoAdapterUserApp?.saveResult(mAppContext)
SwitchInMdm.addDisallowedRunningApp(this)
IntentUtil.startEduLauncher(this)
finish()
GlobalScope.launch (Dispatchers.Main){
LoadingDialog.getInstance(mAppContext).show("请稍后")
mAppInfoAdapterSystemApp?.saveResult(mAppContext)
mAppInfoAdapterUserApp?.saveResult(mAppContext)
SwitchInMdm.addDisallowedRunningApp(mContext)
Launcher.forceReload()
IntentUtil.startEduLauncher(mContext)
LoadingDialog.getInstance(mAppContext).dismiss()
finish()
}
}
R.id.btn_cancel -> {
job?.cancel()
......
......@@ -96,7 +96,6 @@ public class LauncherIcons {
*/
public static Bitmap createBadgedIconBitmap(
Drawable icon, UserHandle user, Context context, int iconAppTargetSdk) {
IconNormalizer normalizer;
float scale = 1f;
if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) {
......@@ -155,23 +154,23 @@ public class LauncherIcons {
float scale = 1f;
if (!FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION) {
normalizer = IconNormalizer.getInstance(context);
if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) {
boolean[] outShape = new boolean[1];
AdaptiveIconDrawable dr = (AdaptiveIconDrawable)
context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
dr.setBounds(0, 0, 1, 1);
scale = normalizer.getScale(icon, iconBounds, dr.getIconMask(), outShape);
if (Utilities.isAtLeastO() && FeatureFlags.LEGACY_ICON_TREATMENT &&
!outShape[0]) {
Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale);
if (wrappedIcon != icon) {
icon = wrappedIcon;
scale = normalizer.getScale(icon, iconBounds, null, null);
}
}
} else {
// if (Utilities.isAtLeastO() && iconAppTargetSdk >= Build.VERSION_CODES.O) {
// boolean[] outShape = new boolean[1];
// AdaptiveIconDrawable dr = (AdaptiveIconDrawable)
// context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
// dr.setBounds(0, 0, 1, 1);
// scale = normalizer.getScale(icon, iconBounds, dr.getIconMask(), outShape);
// if (Utilities.isAtLeastO() && FeatureFlags.LEGACY_ICON_TREATMENT &&
// !outShape[0]) {
// Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale);
// if (wrappedIcon != icon) {
// icon = wrappedIcon;
// scale = normalizer.getScale(icon, iconBounds, null, null);
// }
// }
// } else {
scale = normalizer.getScale(icon, iconBounds, null, null);
}
// }
}
scale = Math.min(scale, ShadowGenerator.getScaleForBounds(iconBounds));
......
......@@ -265,10 +265,10 @@ public class LoaderCursor extends CursorWrapper {
info.intent = newIntent;
mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
if (mIconCache.isDefaultIcon(info.iconBitmap, user)) {
Bitmap icon = loadIcon(info);
info.iconBitmap = icon != null ? icon : info.iconBitmap;
}
// if (mIconCache.isDefaultIcon(info.iconBitmap, user)) {
// Bitmap icon = loadIcon(info);
// info.iconBitmap = icon != null ? icon : info.iconBitmap;
// }
if (lai != null && PackageManagerHelper.isAppSuspended(lai.getApplicationInfo())) {
info.isDisabled = ShortcutInfo.FLAG_DISABLED_SUSPENDED;
......
package com.android.launcher3.settings;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import com.secspace.lib.common.event.RefreshWorkSpaceEvent;
import com.secspace.lib.common.function.SwitchInMdm;
import com.secspace.lib.common.utils.Prefs;
import org.greenrobot.eventbus.EventBus;
import java.util.List;
public class AppInstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
String packageName = intent.getData().getSchemeSpecificPart();
if (!TextUtils.isEmpty(packageName)) {
if (!TextUtils.isEmpty(packageName) && !TextUtils.equals(packageName, context.getPackageName())) {
if (Prefs.isAllowNewApp(context)) {
List<String> pkgs = Prefs.getUserShowAppPkgs(context);
pkgs.add(packageName);
Prefs.setUserShowAppPkgs(context, pkgs);
SwitchInMdm.INSTANCE.addDisallowedRunningApp(context);
EventBus.getDefault().post(new RefreshWorkSpaceEvent());
}
EventBus.getDefault().post(new RefreshWorkSpaceEvent());
}
}
}
}
}
package com.android.launcher3.settings
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import com.android.launcher3.Launcher
import com.secspace.lib.common.event.RefreshWorkSpaceEvent
import com.secspace.lib.common.function.SwitchInMdm.addDisallowedRunningApp
import com.secspace.lib.common.utils.Prefs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
class AppInstallReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_PACKAGE_ADDED) {
val packageName = intent.data?.schemeSpecificPart
if (!TextUtils.isEmpty(packageName)) {
if (!TextUtils.isEmpty(packageName) && !TextUtils.equals(packageName, context.packageName)) {
if (Prefs.isAllowNewApp(context)) {
val pkgs = Prefs.getUserShowAppPkgs(context)
pkgs.add(packageName)
Prefs.setUserShowAppPkgs(context, pkgs)
GlobalScope.launch(Dispatchers.IO) {
addDisallowedRunningApp(context)
}
Launcher.forceReload()
EventBus.getDefault().post(RefreshWorkSpaceEvent())
}
EventBus.getDefault().post(RefreshWorkSpaceEvent())
}
}
}
}
}
\ No newline at end of file
......@@ -74,8 +74,8 @@ object SwitchInMdm: ISwitch() {
}
}
fun addDisallowedRunningApp(context: Context) {
GlobalScope.launch(Dispatchers.IO) {
suspend fun addDisallowedRunningApp(context: Context) {
withContext(Dispatchers.IO) {
val mdmFactoryManager = DpmHelper.getInstance(context).getmMdmFactoryManager()
val pkgsList = Prefs.getUserShowAppPkgs(context)
val resolveInfos: List<ResolveInfo> = context.packageManager.queryIntentActivities(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER), 0)
......@@ -89,6 +89,8 @@ object SwitchInMdm: ISwitch() {
items.add(it.activityInfo.packageName)
}
Log.e(TAG, "ALL:${items}")
val oldApps = mdmFactoryManager.deviceApplicationManager.disallowedRunningApp
mdmFactoryManager.deviceApplicationManager.removeDisallowedRunningApp(oldApps)
items.filter {
!pkgsList.contains(it)
}.let {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment