Commit 52e58a56 by 郑鹏

修复bug,适配机型

parent 7ac1bdac
...@@ -73,6 +73,7 @@ dependencies { ...@@ -73,6 +73,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.17' implementation 'io.reactivex.rxjava2:rxjava:2.2.17'
implementation 'com.elvishew:xlog:1.6.1' implementation 'com.elvishew:xlog:1.6.1'
//implementation 'com.blankj:utilcode:1.22.7'
} }
protobuf { protobuf {
...@@ -102,7 +103,7 @@ ext { ...@@ -102,7 +103,7 @@ ext {
GITHUB_REPO_PATH = "../../androidlibrary" GITHUB_REPO_PATH = "../../androidlibrary"
PUBLISH_GROUP_ID = 'cn.dankal.android' PUBLISH_GROUP_ID = 'cn.dankal.android'
PUBLISH_ARTIFACT_ID = 'launcher' PUBLISH_ARTIFACT_ID = 'launcher'
PUBLISH_VERSION = '1.4.1.1' PUBLISH_VERSION = '1.4.4.5'
} }
uploadArchives { uploadArchives {
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
android:fullBackupContent="@xml/backupscheme" android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true" android:fullBackupOnly="true"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:resizeableActivity="false"
android:largeHeap="@bool/config_largeHeap" android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"> android:restoreAnyVersion="true">
...@@ -68,20 +69,24 @@ ...@@ -68,20 +69,24 @@
android:enabled="true" android:enabled="true"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:resizeableActivity="true" android:resizeableActivity="false"
android:resumeWhilePausing="true" android:resumeWhilePausing="true"
android:screenOrientation="unspecified" android:screenOrientation="unspecified"
android:stateNotNeeded="true" android:stateNotNeeded="true"
android:taskAffinity="" android:taskAffinity=""
android:windowSoftInputMode="adjustPan"> android:windowSoftInputMode="adjustPan">
<intent-filter> <intent-filter>
<category android:name="android.intent.category.HOME" /> <!-- <category android:name="android.intent.category.HOME" />-->
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY" /> <category android:name="android.intent.category.MONKEY" />
<category android:name="android.intent.category.LAUNCHER_APP" /> <category android:name="android.intent.category.LAUNCHER_APP" />
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="com.dankal.launcher"/>
</intent-filter>
</activity> <!-- Intent received used to install shortcuts from other applications --> </activity> <!-- Intent received used to install shortcuts from other applications -->
<receiver <receiver
android:name=".InstallShortcutReceiver" android:name=".InstallShortcutReceiver"
...@@ -99,7 +104,6 @@ ...@@ -99,7 +104,6 @@
<receiver android:name=".AppWidgetsRestoredReceiver"> <receiver android:name=".AppWidgetsRestoredReceiver">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_HOST_RESTORED" /> <action android:name="android.appwidget.action.APPWIDGET_HOST_RESTORED" />
a
</intent-filter> </intent-filter>
</receiver> </receiver>
...@@ -184,6 +188,7 @@ ...@@ -184,6 +188,7 @@
<service <service
android:name=".accessibility.FloatWindowService" android:name=".accessibility.FloatWindowService"
android:process=":lock"></service> <!-- 设备管理 --> android:process=":lock"></service> <!-- 设备管理 -->
<receiver <receiver
android:name=".accessibility.DeviceReceiver" android:name=".accessibility.DeviceReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN"> android:permission="android.permission.BIND_DEVICE_ADMIN">
......
...@@ -27,7 +27,7 @@ import com.android.launcher3.util.ContentWriter; ...@@ -27,7 +27,7 @@ import com.android.launcher3.util.ContentWriter;
/** /**
* Represents an item in the launcher. * Represents an item in the launcher.
*/ */
public class ItemInfo { public class ItemInfo implements Cloneable {
public static final int NO_ID = -1; public static final int NO_ID = -1;
...@@ -207,4 +207,14 @@ public class ItemInfo { ...@@ -207,4 +207,14 @@ public class ItemInfo {
return false; return false;
} }
@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
} }
...@@ -4,12 +4,15 @@ import android.content.BroadcastReceiver; ...@@ -4,12 +4,15 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import com.android.launcher3.Launcher;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.debug.CustomDialog; import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.manager.LauncherManager; import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.util.PermissionUtil; import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import com.android.launcher3.util.UIExecutor; import com.android.launcher3.util.UIExecutor;
/** /**
...@@ -36,7 +39,7 @@ public class AutoRunReceiver extends BroadcastReceiver { ...@@ -36,7 +39,7 @@ public class AutoRunReceiver extends BroadcastReceiver {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//重启之后启动桌面 LauncherManager.getInstance().setInterceptSystemSetting(true);//重新拦截系统设置
LauncherManager.getInstance().backLauncherHome(mContext.getApplicationContext()); LauncherManager.getInstance().backLauncherHome(mContext.getApplicationContext());
} }
} }
......
...@@ -136,14 +136,12 @@ public class PermissionOpenAccessiblityService extends AccessibilityService { ...@@ -136,14 +136,12 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
if (SystemUtils.isVIVO()) {
return;
}
permissionGetter.operateAccessibilityEvent(event); permissionGetter.operateAccessibilityEvent(event);
} }
/* if (SystemUtils.isMEIZU()) {//处理魅族桌面
handlerMeizhuDefaultDesktop(event);
}*/
} }
private boolean mIsSelectDefaultUse = false; private boolean mIsSelectDefaultUse = false;
...@@ -163,7 +161,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService { ...@@ -163,7 +161,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
if (mIsSelectDefaultUse) { if (mIsSelectDefaultUse) {
AccessibilityNodeInfo nodeInfo = event.getSource(); AccessibilityNodeInfo nodeInfo = event.getSource();
if (nodeInfo.getText().equals("倍知守护孩子端")) { if (nodeInfo.getText().equals("倍知守护孩子端")) {
Log.i("zzzzzzzzzzzzzzzzzzzz", "默认桌面设置成功");
PermissionUtil.mIsDefaultDesktop = true; PermissionUtil.mIsDefaultDesktop = true;
mIsSelectDefaultUse = false; mIsSelectDefaultUse = false;
} }
...@@ -196,6 +193,7 @@ public class PermissionOpenAccessiblityService extends AccessibilityService { ...@@ -196,6 +193,7 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
Log.i(TAG_TOW, "showDialog:" + info.canOpenPopup()); Log.i(TAG_TOW, "showDialog:" + info.canOpenPopup());
Log.i(TAG_TOW, "Text:" + info.getText()); Log.i(TAG_TOW, "Text:" + info.getText());
Log.i(TAG_TOW, "windowId:" + info.getWindowId()); Log.i(TAG_TOW, "windowId:" + info.getWindowId());
Log.i(TAG_TOW, "id:" + info.getViewIdResourceName());
} else { } else {
for (int i = 0; i < info.getChildCount(); i++) { for (int i = 0; i < info.getChildCount(); i++) {
if (info.getChild(i) != null) { if (info.getChild(i) != null) {
...@@ -211,7 +209,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService { ...@@ -211,7 +209,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
//判断当前界面 //判断当前界面
if (event.getPackageName().equals("android")) { if (event.getPackageName().equals("android")) {
Log.i("qqqqqqqqqqqqqqqqqqqq", "在系统界面");
PermissionUtil.isSystemUI = true; PermissionUtil.isSystemUI = true;
} else { } else {
PermissionUtil.isSystemUI = false; PermissionUtil.isSystemUI = false;
......
...@@ -82,7 +82,8 @@ public abstract class BaseAutoGetPermission { ...@@ -82,7 +82,8 @@ public abstract class BaseAutoGetPermission {
toast = null; toast = null;
} }
toast = new KToast(service.getApplicationContext()); toast = new KToast(service.getApplicationContext());
showToastLongTow("辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面"); if (!SystemUtils.isVIVO())
showToastLongTow("辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面");
} }
private boolean isFinish = false; private boolean isFinish = false;
...@@ -133,6 +134,7 @@ public abstract class BaseAutoGetPermission { ...@@ -133,6 +134,7 @@ public abstract class BaseAutoGetPermission {
if (event.getSource() == null) if (event.getSource() == null)
return; return;
if (PermissionUtil.checkAutoStartUp(getApplicationContext())) { if (PermissionUtil.checkAutoStartUp(getApplicationContext())) {
PermissionUtil.putAutoStartUp(getApplicationContext());
Log.i("reqeustAutoStartUp", "已经有了自启动"); Log.i("reqeustAutoStartUp", "已经有了自启动");
resetStep(); resetStep();
} else { } else {
...@@ -268,6 +270,7 @@ public abstract class BaseAutoGetPermission { ...@@ -268,6 +270,7 @@ public abstract class BaseAutoGetPermission {
if (step == STEP_REQUEST_AUTO_STARTUP) { if (step == STEP_REQUEST_AUTO_STARTUP) {
if (PermissionUtil.checkAutoStartUp(getApplicationContext())) { if (PermissionUtil.checkAutoStartUp(getApplicationContext())) {
PermissionUtil.putAutoStartUp(getApplicationContext());
resetStep(); resetStep();
} else { } else {
// if (SystemUtils.isNOKIA()) { // if (SystemUtils.isNOKIA()) {
......
...@@ -275,7 +275,6 @@ public class GeneralAutoGetPermission extends BaseAutoGetPermission { ...@@ -275,7 +275,6 @@ public class GeneralAutoGetPermission extends BaseAutoGetPermission {
if (alwaysBtnList != null && alwaysBtnList.size() > 0) { if (alwaysBtnList != null && alwaysBtnList.size() > 0) {
alwaysBtnList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK); alwaysBtnList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
} }
// AccessibilityNodeInfo alwaysBtn = getChildNodeByIdEqualText(nodeInfo, "android:id/button_always"); // AccessibilityNodeInfo alwaysBtn = getChildNodeByIdEqualText(nodeInfo, "android:id/button_always");
} }
} }
......
package com.android.launcher3.auto_get_permission.oppo; package com.android.launcher3.auto_get_permission.oppo;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import com.android.launcher3.accessibility.PermissionOpenAccessiblityService; import com.android.launcher3.accessibility.PermissionOpenAccessiblityService;
import com.android.launcher3.auto_get_permission.AccessibilityNodeOperateUtil;
import com.android.launcher3.auto_get_permission.BaseAutoGetPermission; import com.android.launcher3.auto_get_permission.BaseAutoGetPermission;
import com.android.launcher3.util.Logger; import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil; import com.android.launcher3.util.PermissionUtil;
...@@ -18,9 +21,11 @@ import static com.android.launcher3.auto_get_permission.AccessibilityNodeOperate ...@@ -18,9 +21,11 @@ import static com.android.launcher3.auto_get_permission.AccessibilityNodeOperate
public class OppoAutoPermissionGetter extends BaseAutoGetPermission { public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
public static final String TAG = "OppoAutoPermissionGetter"; public static final String TAG = "OppoAutoPermissionGetter";
private boolean mIsActivation = false; private boolean mIsActivation = false;
private PermissionOpenAccessiblityService mPermissionOpenAccessiblityService;
public OppoAutoPermissionGetter(PermissionOpenAccessiblityService service) { public OppoAutoPermissionGetter(PermissionOpenAccessiblityService service) {
super(service); super(service);
mPermissionOpenAccessiblityService = service;
} }
@Override @Override
...@@ -103,6 +108,28 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission { ...@@ -103,6 +108,28 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override @Override
public void reqeustAutoStartUp(AccessibilityEvent event) { public void reqeustAutoStartUp(AccessibilityEvent event) {
if (Build.DISPLAY.equals("PAFM00_11_F.12")) {//应用管理,自启动管理
AccessibilityNodeInfo sourceNode = event.getSource();
if (sourceNode == null) {
return;
}
if ("com.coloros.settings.feature.homepage.ColorSettingsHomepageActivity".equals(event.getClassName())) {
showToastLong("搜索“自启动”,进入自启动列表页面,开启“倍知守护孩子”自启动");
/* AccessibilityNodeInfo rootInActiveWindow = mPermissionOpenAccessiblityService.getRootInActiveWindow(); //获取当前展示的窗口
if (rootInActiveWindow != null) {//查找自滚动到开发人员选项中的显示布局边界点击开关
List<AccessibilityNodeInfo> accessibilityNodeInfos = scrollDeveloperCllick("应用管理", "android:id/title", rootInActiveWindow);
if (accessibilityNodeInfos != null && accessibilityNodeInfos.size()>0) {
AccessibilityNodeInfo accessibilityNodeInfo=
sleepShort();
} else {
showToastLong("请点击【系统安全】");
}
}*/
return;
}
return;
}
Log.i("reqeustAutoStartUp", "开始自启动权限"); Log.i("reqeustAutoStartUp", "开始自启动权限");
AccessibilityNodeInfo sourceNode = event.getSource(); AccessibilityNodeInfo sourceNode = event.getSource();
Log.i("reqeustAutoStartUp", "自启动,当前界面:" + event.getClassName()); Log.i("reqeustAutoStartUp", "自启动,当前界面:" + event.getClassName());
...@@ -161,6 +188,20 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission { ...@@ -161,6 +188,20 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
// getChildNodeEqual(sourceNode, "允许其他应用自动启动"); // getChildNodeEqual(sourceNode, "允许其他应用自动启动");
AccessibilityNodeInfo batterySaveNode2 = getChildNodeEqual(sourceNode, "允许自动启动");
if (batterySaveNode2 != null && batterySaveNode2.getParent() != null && !batterySaveNode2.isChecked()) {
batterySaveNode2.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
}
AccessibilityNodeInfo batterySaveNode3 = getChildNodeEqual(sourceNode, "允许其他应用关联启动");
if (batterySaveNode3 != null && batterySaveNode3.getParent() != null && !batterySaveNode2.isChecked()) {
batterySaveNode3.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
}
AccessibilityNodeInfo batterySaveNode = getChildNodeEqual(sourceNode, "耗电保护"); AccessibilityNodeInfo batterySaveNode = getChildNodeEqual(sourceNode, "耗电保护");
Log.i("reqeustAutoStartUp", "耗电保护"); Log.i("reqeustAutoStartUp", "耗电保护");
...@@ -184,7 +225,6 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission { ...@@ -184,7 +225,6 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
} }
} }
} }
} }
@Override @Override
...@@ -537,7 +577,53 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission { ...@@ -537,7 +577,53 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
} }
}
}
private boolean isOpen = false;//防止开启后多次点击
/**
* 滑动直到控件显示后,触发点击事件
*
* @param text 查找的控件显示的内容
* @param listId 滚动的容器id
*/
public List<AccessibilityNodeInfo> scrollDeveloperCllick(String text, String listId, AccessibilityNodeInfo rootInActiveWindow) {
if (rootInActiveWindow != null) {
List<AccessibilityNodeInfo> item = rootInActiveWindow.findAccessibilityNodeInfosByText(text); //根据关键字查找某控件元素
List<AccessibilityNodeInfo> list = rootInActiveWindow.findAccessibilityNodeInfosByViewId(listId); //根据resource id 查找容器元素;判断关键字查找出的元素是否在该容器元素中;
if (item == null || item.size() == 0) { // 关键字元素不存在,则滚动容器元素
if (list != null && list.size() > 0) {
AccessibilityNodeInfo parent = list.get(0).getParent().getParent();
if (parent != null) {
for (int i = 0; i < list.size(); i++) {
if (parent.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD)) {
scrollDeveloperCllick("应用管理", "android:id/title", rootInActiveWindow);
isOpen = true;
}
return null;
}
}
}
} else {
if (list != null) {
for (int i = 0; i < list.size(); i++) {
String s = list.get(i).getParent().getChild(0).getText().toString();
if (!TextUtils.isEmpty(s) && s.equals(text) && isOpen) {
list.get(i).performAction(AccessibilityNodeInfo.ACTION_CLICK);
isOpen = false;
break;
}
}
}
}
return item;
} }
return null;
} }
} }
package com.android.launcher3.debug; package com.android.launcher3.debug;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.BaseActivity; import com.android.launcher3.BaseActivity;
import com.android.launcher3.R; import com.android.launcher3.R;
......
package com.android.launcher3.floatingwindow;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import androidx.annotation.CallSuper;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import static android.content.Context.WINDOW_SERVICE;
/**
* Author: roczheng
* Date: 2020/7/6
* Time: 11:51
* Description:
*/
public abstract class AbsFloatBase {
public static final String TAG = "AbsFloatBase";
static final int FULLSCREEN_TOUCHABLE = 1;
static final int FULLSCREEN_NOT_TOUCHABLE = 2;
static final int WRAP_CONTENT_TOUCHABLE = 3;
static final int WRAP_CONTENT_NOT_TOUCHABLE = 4;
WindowManager.LayoutParams mLayoutParams;
View mInflate;
Context mContext;
WindowManager mWindowManager;
private boolean mAdded;
//设置隐藏时是否是INVISIBLE
private boolean mInvisibleNeed = false;
private boolean mRequestFocus = false;
int mGravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
int mViewMode = WRAP_CONTENT_NOT_TOUCHABLE;
Handler mHandler = new Handler(Looper.getMainLooper());
public AbsFloatBase(Context context) {
mContext = context;
create();
}
/**
* 设置隐藏View的方式是否为Invisible,默认为Gone
*
* @param invisibleNeed 是否是Invisible
*/
public void setInvisibleNeed(boolean invisibleNeed) {
mInvisibleNeed = invisibleNeed;
}
/**
* 悬浮窗是否需要获取焦点,通常获取焦点后,悬浮窗可以和软键盘发生交互,被覆盖的应用失去焦点。
* 例如:游戏将失去背景音乐
*
* @param requestFocus
*/
public void requestFocus(boolean requestFocus) {
mRequestFocus = requestFocus;
}
@CallSuper
public void create() {
mWindowManager = (WindowManager) mContext.getApplicationContext().getSystemService(WINDOW_SERVICE);
}
@CallSuper
public synchronized void show() {
if (mInflate == null)
throw new IllegalStateException("FloatView can not be null");
if (mAdded) {
mInflate.setVisibility(View.VISIBLE);
return;
}
getLayoutParam(mViewMode);
mInflate.setVisibility(View.VISIBLE);
try {
mWindowManager.addView(mInflate, mLayoutParams);
mAdded = true;
} catch (Exception e) {
Log.e(TAG, "添加悬浮窗失败!!!!!!请检查悬浮窗权限");
// Toast.makeText(mContext, "添加悬浮窗失败!!!!!!请检查悬浮窗权限", Toast.LENGTH_SHORT).show();
onAddWindowFailed(e);
}
}
@CallSuper
public void hide() {
if (mInflate != null) {
mInflate.setVisibility(View.INVISIBLE);
}
}
@CallSuper
public void gone() {
if (mInflate != null) {
mInflate.setVisibility(View.GONE);
}
}
@CallSuper
public void remove() {
if (mInflate != null && mWindowManager != null) {
if (mInflate.isAttachedToWindow()) {
mWindowManager.removeView(mInflate);
}
mAdded = false;
}
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
}
@CallSuper
protected View inflate(@LayoutRes int layout) {
mInflate = View.inflate(mContext, layout, null);
return mInflate;
}
protected abstract void onAddWindowFailed(Exception e);
@SuppressWarnings("unchecked")
protected <T extends View> T findView(@IdRes int id) {
if (mInflate != null) {
return (T) mInflate.findViewById(id);
}
return null;
}
/**
* 获取悬浮窗LayoutParam
*
* @param mode
*/
protected void getLayoutParam(int mode) {
switch (mode) {
case FULLSCREEN_TOUCHABLE:
mLayoutParams = FloatWindowParamManager.getFloatLayoutParam(true, true);
break;
case FULLSCREEN_NOT_TOUCHABLE:
mLayoutParams = FloatWindowParamManager.getFloatLayoutParam(true, false);
break;
case WRAP_CONTENT_NOT_TOUCHABLE:
mLayoutParams = FloatWindowParamManager.getFloatLayoutParam(false, false);
break;
case WRAP_CONTENT_TOUCHABLE:
mLayoutParams = FloatWindowParamManager.getFloatLayoutParam(false, true);
break;
}
if (mRequestFocus) {
mLayoutParams.flags = mLayoutParams.flags & ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
}
mLayoutParams.gravity = mGravity;
}
/**
* 获取可见性
*
* @return
*/
public boolean getVisibility() {
if (mInflate != null && mInflate.getVisibility() == View.VISIBLE) {
return true;
} else {
return false;
}
}
/**
* 改变可见性
*/
public void toggleVisibility() {
if (mInflate != null) {
if (getVisibility()) {
if (mInvisibleNeed) {
hide();
} else {
gone();
}
} else {
show();
}
}
}
}
package com.android.launcher3.floatingwindow;
import android.content.Context;
import android.text.Html;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import com.android.launcher3.R;
/**
* Author: roczheng
* Date: 2020/7/6
* Time: 11:51
* Description:
*/
public class FloatPermissionDetectView extends AbsFloatBase {
int mStartY;
int mTouchStartY;
int mTouchCurrentY;
private String mTipText;
public FloatPermissionDetectView(Context context, String tipText) {
super(context);
this.mTipText = tipText;
}
@Override
public void create() {
super.create();
mViewMode = WRAP_CONTENT_TOUCHABLE;
mGravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
inflate(R.layout.dialog_permission_tip_ui);
findView(R.id.tv_close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
remove();
}
});
mInflate.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mTouchStartY = (int) event.getRawY();
mStartY = (int) event.getY();
break;
case MotionEvent.ACTION_MOVE:
mTouchCurrentY = (int) event.getRawY();
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) mInflate.getLayoutParams();
layoutParams.y += mTouchCurrentY - mTouchStartY;
mWindowManager.updateViewLayout(mInflate, layoutParams);
mTouchStartY = mTouchCurrentY;
}
return true;
}
});
}
@Override
public synchronized void show() {
super.show();
TextView tvContent = findView(R.id.tv_content);
tvContent.setText(Html.fromHtml(mTipText));
}
@Override
protected void onAddWindowFailed(Exception e) {
}
}
package com.android.launcher3.floatingwindow;
import android.os.Build;
import android.text.TextUtils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import androidx.annotation.StringDef;
/**
* @author sun on 2018/7/5.
*/
public class RomUtils {
private static final String TAG = "RomUtils";
static final String ROM_MIUI = "MIUI";
static final String ROM_EMUI = "EMUI";
static final String ROM_VIVO = "VIVO";
static final String ROM_OPPO = "OPPO";
static final String ROM_FLYME = "FLYME";
static final String ROM_SMARTISAN = "SMARTISAN";
static final String ROM_QIKU = "QIKU";
static final String ROM_LETV = "LETV";
static final String ROM_LENOVO = "LENOVO";
static final String ROM_NUBIA = "NUBIA";
static final String ROM_ZTE = "ZTE";
static final String ROM_COOLPAD = "COOLPAD";
static final String ROM_UNKNOWN = "UNKNOWN";
@StringDef({
ROM_MIUI, ROM_EMUI, ROM_VIVO, ROM_OPPO, ROM_FLYME,
ROM_SMARTISAN, ROM_QIKU, ROM_LETV, ROM_LENOVO, ROM_ZTE,
ROM_COOLPAD, ROM_UNKNOWN
})
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.SOURCE)
public @interface RomName {
}
private static final String SYSTEM_VERSION_MIUI = "ro.miui.ui.version.name";
private static final String SYSTEM_VERSION_EMUI = "ro.build.version.emui";
private static final String SYSTEM_VERSION_VIVO = "ro.vivo.os.version";
private static final String SYSTEM_VERSION_OPPO = "ro.build.version.opporom";
private static final String SYSTEM_VERSION_FLYME = "ro.build.display.id";
private static final String SYSTEM_VERSION_SMARTISAN = "ro.smartisan.version";
private static final String SYSTEM_VERSION_LETV = "ro.letv.eui";
private static final String SYSTEM_VERSION_LENOVO = "ro.lenovo.lvp.version";
private static String getSystemProperty(String propName) {
return SystemProperties.get(propName, null);
}
@RomName
public static String getRomName() {
if (isMiuiRom()) {
return ROM_MIUI;
}
if (isHuaweiRom()) {
return ROM_EMUI;
}
if (isVivoRom()) {
return ROM_VIVO;
}
if (isOppoRom()) {
return ROM_OPPO;
}
if (isMeizuRom()) {
return ROM_FLYME;
}
if (isSmartisanRom()) {
return ROM_SMARTISAN;
}
if (is360Rom()) {
return ROM_QIKU;
}
if (isLetvRom()) {
return ROM_LETV;
}
if (isLenovoRom()) {
return ROM_LENOVO;
}
if (isZTERom()) {
return ROM_ZTE;
}
if (isCoolPadRom()) {
return ROM_COOLPAD;
}
return ROM_UNKNOWN;
}
public static String getDeviceManufacture() {
if (isMiuiRom()) {
return "小米";
}
if (isHuaweiRom()) {
return "华为";
}
if (isVivoRom()) {
return ROM_VIVO;
}
if (isOppoRom()) {
return ROM_OPPO;
}
if (isMeizuRom()) {
return "魅族";
}
if (isSmartisanRom()) {
return "锤子";
}
if (is360Rom()) {
return "奇酷";
}
if (isLetvRom()) {
return "乐视";
}
if (isLenovoRom()) {
return "联想";
}
if (isZTERom()) {
return "中兴";
}
if (isCoolPadRom()) {
return "酷派";
}
return "";
}
public static boolean isMiuiRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_MIUI));
}
public static boolean isHuaweiRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_EMUI));
}
public static boolean isVivoRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_VIVO));
}
public static boolean isOppoRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_OPPO));
}
public static boolean isMeizuRom() {
String meizuFlymeOSFlag = getSystemProperty(SYSTEM_VERSION_FLYME);
return !TextUtils.isEmpty(meizuFlymeOSFlag) && meizuFlymeOSFlag.toUpperCase().contains(ROM_FLYME);
}
public static boolean isSmartisanRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_SMARTISAN));
}
public static boolean is360Rom() {
String manufacturer = Build.MANUFACTURER;
return !TextUtils.isEmpty(manufacturer) && manufacturer.toUpperCase().contains(ROM_QIKU);
}
public static boolean isLetvRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_LETV));
}
public static boolean isLenovoRom() {
return !TextUtils.isEmpty(getSystemProperty(SYSTEM_VERSION_LENOVO));
}
public static boolean isCoolPadRom() {
String model = Build.MODEL;
String fingerPrint = Build.FINGERPRINT;
return (!TextUtils.isEmpty(model) && model.toLowerCase().contains(ROM_COOLPAD))
|| (!TextUtils.isEmpty(fingerPrint) && fingerPrint.toLowerCase().contains(ROM_COOLPAD));
}
public static boolean isZTERom() {
String manufacturer = Build.MANUFACTURER;
String fingerPrint = Build.FINGERPRINT;
return (!TextUtils.isEmpty(manufacturer) && (fingerPrint.toLowerCase().contains(ROM_NUBIA)
|| fingerPrint.toLowerCase().contains(ROM_ZTE)))
|| (!TextUtils.isEmpty(fingerPrint) && (fingerPrint.toLowerCase().contains(ROM_NUBIA)
|| fingerPrint.toLowerCase().contains(ROM_ZTE)));
}
public static boolean isDomesticSpecialRom() {
return RomUtils.isMiuiRom()
|| RomUtils.isHuaweiRom()
|| RomUtils.isMeizuRom()
|| RomUtils.is360Rom()
|| RomUtils.isOppoRom()
|| RomUtils.isVivoRom()
|| RomUtils.isLetvRom()
|| RomUtils.isZTERom()
|| RomUtils.isLenovoRom()
|| RomUtils.isCoolPadRom();
}
public static boolean isSmartisanR1() {
return Build.MODEL.contains("DE106");
}
/**
* Vivo沙雕刘海屏判断
*
* @return
*/
public static boolean isVivoStupidNotch() {
return isVivoX21() || isVivoX21S() || isVivoX23() || isVivoZ1() || isVivoZ3() ||
isVivoY81s() || isVivoY83() || isVivoY85() || isVivoY93() || isVivoY97();
}
public static boolean isVivoX21() {
return Build.MODEL.contains("vivo X21");
}
public static boolean isVivoX21S() {
return Build.MODEL.contains("V1814");
}
public static boolean isVivoX23() {
//X23普通 幻彩版
return Build.MODEL.contains("V1809") || Build.MODEL.contains("V1816");
}
public static boolean isVivoZ1() {
return Build.MODEL.contains("V1730");
}
public static boolean isVivoZ3() {
return Build.MODEL.contains("V1813BA");
}
public static boolean isVivoY81s() {
return Build.MODEL.contains("V1732");
}
public static boolean isVivoY83() {
return Build.MODEL.contains("Y83");
}
public static boolean isVivoY85() {
return Build.MODEL.contains("vivo Y85");
}
public static boolean isVivoY93() {
return Build.MODEL.contains("V1818");
}
public static boolean isVivoY97() {
return Build.MODEL.contains("V1813A") || Build.MODEL.contains("V1813T");
}
public static boolean isHonorV10() {
return Build.MODEL.contains("BKL-AL00");
}
public static boolean isHonor10() {
return Build.MODEL.contains("COL-AL10");
}
public static boolean isMiPad4() {
return TextUtils.equals(Build.MODEL, "MI PAD 4");
}
}
package com.android.launcher3.floatingwindow;
import android.text.TextUtils;
import java.lang.reflect.Method;
/**
* @author sun on 2018/7/5.
*/
public class SystemProperties {
private static final Method getStringProperty = getMethod(getClass("android.os.SystemProperties"));
private static Class<?> getClass(String name) {
try {
Class<?> cls = Class.forName(name);
if (cls == null) {
throw new ClassNotFoundException();
}
return cls;
} catch (ClassNotFoundException e) {
try {
return ClassLoader.getSystemClassLoader().loadClass(name);
} catch (ClassNotFoundException e1) {
return null;
}
}
}
private static Method getMethod(Class<?> clz) {
if (clz == null) return null;
try {
return clz.getMethod("get", String.class);
} catch (Exception e) {
return null;
}
}
public static String get(String key) {
if (getStringProperty != null) {
try {
Object value = getStringProperty.invoke(null, key);
if (value == null) {
return "";
}
return trimToEmpty(value.toString());
} catch (Exception ignored) {
}
}
return "";
}
public static String get(String key, String def) {
if (getStringProperty != null) {
try {
String value = (String) getStringProperty.invoke(null, key);
return defaultString(trimToNull(value), def);
} catch (Exception ignored) {
}
}
return def;
}
private static String defaultString(String str, String defaultStr) {
return str == null ? defaultStr : str;
}
private static String trimToNull(String str) {
String ts = trim(str);
return TextUtils.isEmpty(ts) ? null : ts;
}
private static String trimToEmpty(String str) {
return str == null ? "" : str.trim();
}
private static String trim(String str) {
return str == null ? null : str.trim();
}
}
...@@ -33,9 +33,14 @@ public class Constants { ...@@ -33,9 +33,14 @@ public class Constants {
"com.sec.android.app.camera|com.android.camera2|com.meizu.media.camera|com.huawei.camera", "com.sec.android.app.camera|com.android.camera2|com.meizu.media.camera|com.huawei.camera",
"com.huawei.android.internal.app"}; "com.huawei.android.internal.app"};
//系统应用 //不需要拦截的系统应用
public static final String[] SYSTEM_APP = {"com.android.systemui", "com.samsung.android.packageinstaller|com.android.packageinstaller", "com.samsung.android.incallui|com.android.incallui"}; public static final String[] SYSTEM_APP = {"com.android.systemui",
"com.samsung.android.packageinstaller|com.android.packageinstaller",
"com.samsung.android.incallui|com.android.incallui",
"com.android.permissioncontroller",
"com.android.settings.Settings$WifiSettingsActivity",
"com.android.settings.Settings$AppNotificationSettingsActivity",
"android.app.Notification"};
public static final String ACTION_UPDATE_ICON = "update_icon"; public static final String ACTION_UPDATE_ICON = "update_icon";
......
...@@ -11,6 +11,7 @@ import android.content.Context; ...@@ -11,6 +11,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
...@@ -576,7 +577,6 @@ public class LauncherManager { ...@@ -576,7 +577,6 @@ public class LauncherManager {
context.startActivity(home); context.startActivity(home);
} }
}); });
} }
public void jumpSetting(Context context) { public void jumpSetting(Context context) {
...@@ -914,4 +914,23 @@ public class LauncherManager { ...@@ -914,4 +914,23 @@ public class LauncherManager {
Intent intent = new Intent(context, SearchAppCanUseActivity.class); Intent intent = new Intent(context, SearchAppCanUseActivity.class);
context.startActivity(intent); context.startActivity(intent);
} }
/**
* 打开倍知守护app
*/
public void openApplication(Context context) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName cn = new ComponentName("cn.dankal.bzshchild", "cn.dankal.bzshchild.ui.SplashActivity");
intent.setComponent(cn);
Uri uri = Uri.parse("cn.dankal.bzshchild.ui.SplashActivity");
/*ComponentName cn = new ComponentName("com.dankal.dankal_launcher", "com.dankal.dankal_launcher.PackageManageActivity");
intent.setComponent(cn);
Uri uri = Uri.parse("com.dankal.dankal_launcher.PackageManageActivity");*/
intent.setData(uri);
context.startActivity(intent);
}
} }
...@@ -45,8 +45,8 @@ public class TimeModeManager { ...@@ -45,8 +45,8 @@ public class TimeModeManager {
private long LockScreenEndTime; private long LockScreenEndTime;
private int currentWorkModel; private int currentWorkModel;
private PackageManager packageManager; private PackageManager packageManager;
// 退出管制 可自由使用任何app // true 退出管制 可自由使用任何app
private boolean exitProtect = false; private boolean exitProtect = true;
// 当天(从00:00开始)各类型的app已经使用的总时长 // 当天(从00:00开始)各类型的app已经使用的总时长
private Map<Integer, Long> appTypeUseTimestamp; private Map<Integer, Long> appTypeUseTimestamp;
...@@ -474,6 +474,7 @@ public class TimeModeManager { ...@@ -474,6 +474,7 @@ public class TimeModeManager {
public boolean isExitProtect() { public boolean isExitProtect() {
exitProtect = configSaver.getExitState();
return exitProtect; return exitProtect;
} }
......
...@@ -299,10 +299,30 @@ public class LoaderResults { ...@@ -299,10 +299,30 @@ public class LoaderResults {
}); });
} }
private ItemInfo mCopyItemInfo;
private void bindWorkspaceItems(final ArrayList<ItemInfo> workspaceItems, private void bindWorkspaceItems(final ArrayList<ItemInfo> workspaceItems,
final ArrayList<LauncherAppWidgetInfo> appWidgets, final ArrayList<LauncherAppWidgetInfo> appWidgets,
final Executor executor) { final Executor executor) {
/* //处理一次,新增倍知守护的copy对象
for (ItemInfo itemInfo : workspaceItems) {
if (itemInfo != null) {
Log.i("app_icon_info===", itemInfo.title.toString());
String name = itemInfo.title.toString();
if (name.equals("倍知守护孩子端")) {
itemInfo.title = "我是你爸爸";
itemInfo.contentDescription = "我是你爸爸";
mCopyItemInfo = (ItemInfo) itemInfo.clone();
mCopyItemInfo.title = "我是你妈妈";
mCopyItemInfo.contentDescription = "我是你妈妈";
}
}
}
if (mCopyItemInfo != null) {
workspaceItems.add(mCopyItemInfo);
}*/
// Bind the workspace items // Bind the workspace items
int N = workspaceItems.size(); int N = workspaceItems.size();
for (int i = 0; i < N; i += ITEMS_CHUNK) { for (int i = 0; i < N; i += ITEMS_CHUNK) {
......
...@@ -34,6 +34,7 @@ import com.android.launcher3.LauncherModel.CallbackTask; ...@@ -34,6 +34,7 @@ import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks; import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.SessionCommitReceiver; import com.android.launcher3.SessionCommitReceiver;
import com.android.launcher3.ShortcutInfo; import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities; import com.android.launcher3.Utilities;
...@@ -57,6 +58,9 @@ import java.util.Collections; ...@@ -57,6 +58,9 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import static com.android.launcher3.Launcher.APP_COPY_NAME;
import static com.android.launcher3.Launcher.APP_COPY_PACKAGE_NAME;
/** /**
* Handles updates due to changes in package manager (app installed/updated/removed) * Handles updates due to changes in package manager (app installed/updated/removed)
* or when a user availability changes. * or when a user availability changes.
...@@ -109,6 +113,21 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { ...@@ -109,6 +113,21 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
ShortcutInfo shortcutInfo = appsList.data.get(appsList.data.size() - 1).makeShortcut(); ShortcutInfo shortcutInfo = appsList.data.get(appsList.data.size() - 1).makeShortcut();
//添加备份
if (packages[i].equals(APP_COPY_PACKAGE_NAME)) {
if (findQueryExist(appsList.data, packages[i])) {
return;
}
shortcutInfo.title = APP_COPY_NAME;
shortcutInfo.disabledMessage = APP_COPY_NAME;
/* Intent.ShortcutIconResource shortcutIconResource
= Intent.ShortcutIconResource.fromContext(context, R.mipmap.logo);
shortcutInfo.iconResource = shortcutIconResource;*/
ComponentName componentName = new ComponentName(APP_COPY_PACKAGE_NAME, APP_COPY_PACKAGE_NAME);
shortcutInfo.intent.setComponent(componentName);
}
addShortcutInfoArrays.add(shortcutInfo); addShortcutInfoArrays.add(shortcutInfo);
// Automatically add homescreen icon for work profile apps for below O device. // Automatically add homescreen icon for work profile apps for below O device.
...@@ -377,4 +396,20 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { ...@@ -377,4 +396,20 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
} }
} }
/**
* 查找当前app是否存在
*
* @param appsList
* @param aPackage
* @return
*/
private boolean findQueryExist(ArrayList<AppInfo> appsList, String aPackage) {
for (AppInfo appInfo : appsList) {
if (appInfo.componentName.getPackageName().equals(aPackage)) {
return true;
}
}
return false;
}
} }
...@@ -59,6 +59,7 @@ import java.util.Map; ...@@ -59,6 +59,7 @@ import java.util.Map;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_MASK; import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_MASK;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO; import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO;
import static com.android.launcher3.Launcher.APP_COPY_PACKAGE_NAME;
import static com.android.launcher3.LauncherSettings.BaseLauncherColumns.ITEM_TYPE_APPLICATION; import static com.android.launcher3.LauncherSettings.BaseLauncherColumns.ITEM_TYPE_APPLICATION;
/** /**
...@@ -277,7 +278,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan ...@@ -277,7 +278,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
if (componentName == null) if (componentName == null)
return false; return false;
if (componentName.getPackageName().equals(mLauncher.getPackageName())) { if (componentName.getPackageName().equals(mLauncher.getPackageName())
|| componentName.getPackageName().equals(APP_COPY_PACKAGE_NAME)) {//真实包,和capy包
boolean enable = LauncherManager.getInstance().getUninstallEnable(); boolean enable = LauncherManager.getInstance().getUninstallEnable();
Logger.e("uninstallDisableApp", enable + ""); Logger.e("uninstallDisableApp", enable + "");
//是否拦截系统设置 //是否拦截系统设置
......
...@@ -20,12 +20,14 @@ import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER; ...@@ -20,12 +20,14 @@ import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_QUIET_USER; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_QUIET_USER;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED;
import static com.android.launcher3.Launcher.APP_COPY_NAME;
import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET; import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET;
import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET; import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Process; import android.os.Process;
...@@ -86,6 +88,12 @@ public class ItemClickHandler { ...@@ -86,6 +88,12 @@ public class ItemClickHandler {
if (tag instanceof ShortcutInfo) { if (tag instanceof ShortcutInfo) {
Logger.e(TAG, "ShortcutInfo"); Logger.e(TAG, "ShortcutInfo");
ShortcutInfo shortcutInfo1 = (ShortcutInfo) tag;
if (shortcutInfo1.title.equals(APP_COPY_NAME)){
LauncherManager.getInstance().openApplication(v.getContext().getApplicationContext());
return;
}
if (!LauncherManager.getInstance().getExitState()) { if (!LauncherManager.getInstance().getExitState()) {
ShortcutInfo shortcutInfo = (ShortcutInfo) tag; ShortcutInfo shortcutInfo = (ShortcutInfo) tag;
...@@ -96,6 +104,11 @@ public class ItemClickHandler { ...@@ -96,6 +104,11 @@ public class ItemClickHandler {
return; return;
} }
if (shortcutInfo.title.equals(APP_COPY_NAME)){
LauncherManager.getInstance().openApplication(v.getContext().getApplicationContext());
return;
}
ManagementInfo appinfo = LauncherManager.getInstance().getManageAppInfo(packageName); ManagementInfo appinfo = LauncherManager.getInstance().getManageAppInfo(packageName);
if (!packageName.equals(Constants.SYSTEM_SETTING_APP)) { if (!packageName.equals(Constants.SYSTEM_SETTING_APP)) {
if (!LauncherManager.getInstance().isSafePackageName(packageName) && !LauncherManager.getInstance().isSystemPackageName(packageName)) { if (!LauncherManager.getInstance().isSafePackageName(packageName) && !LauncherManager.getInstance().isSystemPackageName(packageName)) {
......
...@@ -134,4 +134,18 @@ public class SystemUtils { ...@@ -134,4 +134,18 @@ public class SystemUtils {
return line; return line;
} }
/**
* 获取当前手机系统版本号
*
* @return 系统版本号
*/
public static String getSystemVersion() {
return android.os.Build.VERSION.RELEASE;
}
public static int getSystemVersionCode(){
return android.os.Build.VERSION.SDK_INT;
}
} }
...@@ -26,11 +26,11 @@ public class TimeConfigSaver { ...@@ -26,11 +26,11 @@ public class TimeConfigSaver {
private static final String UNINSTALL = "uninstall"; private static final String UNINSTALL = "uninstall";
private static final String EXIT="exit"; private static final String EXIT = "exit";
public TimeConfigSaver(Context context) { public TimeConfigSaver(Context context) {
sharedPreferences = context.getSharedPreferences("app_config", Context.MODE_PRIVATE); sharedPreferences = context.getApplicationContext().getSharedPreferences("app_config", Context.MODE_PRIVATE);
} }
public void save(Map<Integer, TimeConfig> appConfig) { public void save(Map<Integer, TimeConfig> appConfig) {
...@@ -104,7 +104,7 @@ public class TimeConfigSaver { ...@@ -104,7 +104,7 @@ public class TimeConfigSaver {
return sharedPreferences.getInt(WORK_MODE, ColumnDef.TimeManager.WORK_DAY); return sharedPreferences.getInt(WORK_MODE, ColumnDef.TimeManager.WORK_DAY);
} }
public void putUninstallEnable(boolean enable){ public void putUninstallEnable(boolean enable) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(UNINSTALL, enable); editor.putBoolean(UNINSTALL, enable);
...@@ -113,21 +113,21 @@ public class TimeConfigSaver { ...@@ -113,21 +113,21 @@ public class TimeConfigSaver {
} }
public boolean getUninstallEnable(){ public boolean getUninstallEnable() {
return sharedPreferences.getBoolean(UNINSTALL,false); return sharedPreferences.getBoolean(UNINSTALL, false);
} }
public void putExitState(boolean enable){ public void putExitState(boolean enable) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(EXIT, enable); editor.putString(EXIT, enable ? "a" : "b");
editor.apply(); editor.apply();
} }
public boolean getExitState(){ public boolean getExitState() {
return sharedPreferences.getBoolean(EXIT,false); return sharedPreferences.getString(EXIT, "a").equals("a");
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#88000000">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="@null"
android:text="关闭"
android:textColor="#ffffff"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:textSize="16sp"
android:text="提示文字,需要什么什么权限等等"
android:textColor="@color/color_white" />
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
...@@ -40,4 +40,7 @@ ...@@ -40,4 +40,7 @@
<color name="all_apps_bg_hand_fill_dark">#9AA0A6</color> <color name="all_apps_bg_hand_fill_dark">#9AA0A6</color>
<color name="color_white">#ffffff</color> <color name="color_white">#ffffff</color>
<color name="color_FFC537">#FFC537</color>
</resources> </resources>
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<device-admin <device-admin
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies> <uses-policies>
<limit-password />
<!-- 限制密码类型 -->
<watch-login /> <watch-login />
<!-- 监控登录尝试 --> <!-- 监控登录尝试 -->
<limit-password />
<!-- 限制密码类型 -->
<reset-password /> <reset-password />
<!-- 重置密码 --> <!-- 重置密码 -->
<force-lock /> <force-lock />
......
...@@ -46,5 +46,6 @@ dependencies { ...@@ -46,5 +46,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(':Launcher3') implementation project(':Launcher3')
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
// api 'cn.dankal.android:launcher:1.0.4' // api 'cn.dankal.android:launcher:1.0.4'
} }
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
android:name="android.permission.SET_ACTIVITY_WATCHER" android:name="android.permission.SET_ACTIVITY_WATCHER"
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application <application
android:name=".MyApplication" android:name=".MyApplication"
...@@ -18,46 +20,82 @@ ...@@ -18,46 +20,82 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:largeHeap="@bool/config_largeHeap" android:largeHeap="@bool/config_largeHeap"
android:resizeableActivity="false"
android:restoreAnyVersion="true" android:restoreAnyVersion="true"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/LauncherTheme" android:theme="@style/LauncherTheme"
tools:replace="android:icon" tools:ignore="GoogleAppIndexingWarning"
tools:ignore="GoogleAppIndexingWarning"> tools:replace="android:icon">
<activity android:name=".PermissionSettingActivity"></activity>
<!-- <!--
Main launcher activity. When extending only change the name, and keep all the <activity
attributes and intent filters the same android:name=".test.Acitivity1"
--> android:excludeFromRecents="true"
<!-- The settings activity. When extending keep the intent filter present --> android:exported="false"
android:finishOnTaskLaunch="false"
android:launchMode="singleInstance" />
<activity <activity
android:name=".PackageManageActivity" android:name=".test.MainAliasActivity"
android:autoRemoveFromRecents="true" android:enabled="false"
android:theme="@android:style/Theme.DeviceDefault.Settings"> android:icon="@drawable/icon"
android:label=""
android:targetActivity=".Acitivity1">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
-->
<!-- <activity-alias <activity
android:name=".NewActivity1" android:name=".EntranceMainActivity"
android:enabled="true" android:launchMode="singleTask"
android:label="Alias1" android:screenOrientation="portrait">
android:icon="@mipmap/ic_launcher_round"
android:targetActivity=".PackageManageActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias>--> </activity>
<activity android:name=".PermissionSettingActivity">
<!--
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<data
android:host="PermissionSettingActivity"
android:scheme="com.dankal.dankal_launchery"
tools:ignore="AppLinkUrlError" />
&lt;!&ndash; <category android:name="android.intent.category.LAUNCHER" />&ndash;&gt;
</intent-filter>
-->
</activity>
<!--
Main launcher activity. When extending only change the name, and keep all the
attributes and intent filters the same
-->
<!-- The settings activity. When extending keep the intent filter present -->
<activity
android:name=".PackageManageActivity"
android:theme="@android:style/Theme.DeviceDefault.Settings" />
<!--
<activity-alias
android:name=".NewActivity1"
android:enabled="true"
android:label="Alias1"
android:icon="@mipmap/ic_launcher_round"
android:targetActivity=".PackageManageActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
-->
<activity <activity
android:name=".SetActivity" android:name=".SetActivity"
android:exported="true"></activity> android:exported="true" />
<service <service
android:name="com.android.launcher3.accessibility.PermissionOpenAccessiblityService" android:name="com.android.launcher3.accessibility.PermissionOpenAccessiblityService"
...@@ -72,6 +110,24 @@ ...@@ -72,6 +110,24 @@
android:name="android.accessibilityservice" android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" /> android:resource="@xml/accessibility_service_config" />
</service> </service>
<receiver android:name=".TestReceive">
<intent-filter>
<action android:name="android.intent.action.CLOSE_SYSTEM_DIALOGS" />
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
</receiver>
<!-- <receiver android:description="@string/device_admin_description"
android:label="@string/device_admin_label"
android:name="com.broaddeep.safe.module.guard.deviceadmin.DeviceAdmin"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin"/>
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
</intent-filter>
</receiver>-->
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.dankal;
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
/**
* Author: roczheng
* Date: 2020/7/15
* Time: 20:16
* Description:
*/
public class DeviceAdmin extends DeviceAdminReceiver
{
public DeviceAdmin()
{
}
public CharSequence onDisableRequested(Context context, Intent intent)
{
return context.getString(0x7f1000b8);
}
public void onDisabled(Context context, Intent intent)
{
super.onDisabled(context, intent);
}
public void onEnabled(Context context, Intent intent)
{
super.onEnabled(context, intent);
}
}
package com.dankal.dankal_launcher;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
/**
* Author: roczheng
* Date: 2020/7/6
* Time: 10:49
* Description:
*/
public class CustomDialog extends Dialog implements View.OnClickListener {
private Context mContext;
private int[] mListenedItem;
private int mResource;
private View mDialogView;
//默认比例
private int mScreenWidth = 4;
private int mDialogWidth = 3;
public CustomDialog(Context context, int resource, int[] listenedItem) {
super(context, R.style.NormalDialogStyle);//加载dialog的样式
this.mContext = context;
this.mListenedItem = listenedItem;
this.mResource = resource;
}
public CustomDialog(Context context, View view, int[] listenedItem) {
super(context, R.style.NormalDialogStyle);//加载dialog的样式
this.mContext = context;
this.mListenedItem = listenedItem;
this.mDialogView = view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mDialogView != null) {
setContentView(mDialogView);
} else if (mResource != 0) {
mDialogView = LayoutInflater.from(mContext).inflate(mResource, null);
setContentView(mDialogView);
}
Window dialogWindow = getWindow();
dialogWindow.setGravity(Gravity.CENTER);//设置dialog显示居中
//dialogWindow.setWindowAnimations();设置动画效果
WindowManager windowManager = ((Activity) mContext).getWindowManager();
Display display = windowManager.getDefaultDisplay();
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.width = display.getWidth() * mDialogWidth / mScreenWidth;
getWindow().setAttributes(lp);
setCanceledOnTouchOutside(true);
for (int id : mListenedItem) {
findViewById(id).setOnClickListener(this);
}
}
public View getDialogView() {
return mDialogView;
}
private OnCenterItemClickListener listener;
public interface OnCenterItemClickListener {
void OnCenterItemClick(CustomDialog dialog, View view);
}
public void setOnCenterItemClickListener(OnCenterItemClickListener listener) {
this.listener = listener;
}
@Override
public void onClick(View v) {
dismiss();//注意:我在这里加了这句话,表示只要按任何一个控件的id,弹窗都会消失,不管是确定还是取消。
if (listener != null)
listener.OnCenterItemClick(this, v);
}
/**
* 设置屏幕宽度和对话框的比例
*
* @param screenWidth
* @param dialogWidth
*/
public void setProportion(int screenWidth, int dialogWidth) {
this.mScreenWidth = screenWidth;
this.mDialogWidth = dialogWidth;
}
}
package com.dankal.dankal_launcher;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.android.launcher3.util.PermissionUtil;
public class EntranceMainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_entrance_main);
try {
startActivity(new Intent(EntranceMainActivity.this,PackageManageActivity.class));
}catch (Exception e){
e.printStackTrace();
PermissionUtil.initLauncherIconIsShow(this,true);
}
finish();
}
}
...@@ -21,14 +21,17 @@ import android.view.accessibility.AccessibilityEvent; ...@@ -21,14 +21,17 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.android.launcher3.accessibility.DeviceReceiver;
import com.android.launcher3.accessibility.StopRunReceiver; import com.android.launcher3.accessibility.StopRunReceiver;
import com.android.launcher3.manager.ColumnDef; import com.android.launcher3.manager.ColumnDef;
import com.android.launcher3.manager.Constants;
import com.android.launcher3.manager.LauncherManager; import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.manager.ManagementInfo; import com.android.launcher3.manager.ManagementInfo;
import com.android.launcher3.model.TimeConfig; import com.android.launcher3.model.TimeConfig;
import com.android.launcher3.util.KToast; import com.android.launcher3.util.KToast;
import com.android.launcher3.util.Logger; import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil; import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -38,6 +41,10 @@ import java.util.Date; ...@@ -38,6 +41,10 @@ import java.util.Date;
import java.util.List; import java.util.List;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import static com.android.launcher3.Launcher.APP_COPY_PACKAGE_NAME;
import static com.android.launcher3.manager.LauncherManager.getContext;
public class PackageManageActivity extends Activity { public class PackageManageActivity extends Activity {
...@@ -118,8 +125,8 @@ public class PackageManageActivity extends Activity { ...@@ -118,8 +125,8 @@ public class PackageManageActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_package_manage); setContentView(R.layout.activity_package_manage);
LauncherManager.getInstance().changeExitState(true); /*LauncherManager.getInstance().changeExitState(true);
LauncherManager.getInstance().setInterceptSystemSetting(false); LauncherManager.getInstance().setInterceptSystemSetting(false);*/
tvAdd = findViewById(R.id.tv_add); tvAdd = findViewById(R.id.tv_add);
...@@ -131,6 +138,13 @@ public class PackageManageActivity extends Activity { ...@@ -131,6 +138,13 @@ public class PackageManageActivity extends Activity {
toast = new KToast(this.getApplicationContext()); toast = new KToast(this.getApplicationContext());
findViewById(R.id.tv_start_app).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
}
});
tvAdd.setOnClickListener(new View.OnClickListener() { tvAdd.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -150,6 +164,26 @@ public class PackageManageActivity extends Activity { ...@@ -150,6 +164,26 @@ public class PackageManageActivity extends Activity {
// handler.sendEmptyMessageDelayed(2,2000); // handler.sendEmptyMessageDelayed(2,2000);
LauncherManager.getInstance().jumpDebugInfo(PackageManageActivity.this); LauncherManager.getInstance().jumpDebugInfo(PackageManageActivity.this);
//PermissionUtil.initLauncherIconIsShow(PackageManageActivity.this, false);
}
});
findViewById(R.id.tv_is_user).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//LauncherManager.getInstance().jumpSearchAppCanUse(PackageManageActivity.this);
/**
* 更新图标
*/
/* Intent intent = new Intent();
intent.setAction(Constants.ACTION_UPDATE_ICON);
intent.putExtra(Constants.EXTRA_PACKAGE, "我是你爸爸");
sendBroadcast(intent);*/
Intent intent = new Intent(Constants.ACTION_UPDATE_ICON);
intent.putExtra(Constants.EXTRA_PACKAGE, APP_COPY_PACKAGE_NAME);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
} }
}); });
...@@ -210,7 +244,6 @@ public class PackageManageActivity extends Activity { ...@@ -210,7 +244,6 @@ public class PackageManageActivity extends Activity {
public void run() { public void run() {
// PermissionUtil.gotoBatteryOptimize(getApplicationContext()); // PermissionUtil.gotoBatteryOptimize(getApplicationContext());
LauncherManager.getInstance().changeExitState(true); LauncherManager.getInstance().changeExitState(true);
LauncherManager.getInstance().setInterceptSystemSetting(false); LauncherManager.getInstance().setInterceptSystemSetting(false);
} }
...@@ -235,12 +268,13 @@ public class PackageManageActivity extends Activity { ...@@ -235,12 +268,13 @@ public class PackageManageActivity extends Activity {
//LauncherManager.getInstance().getUninstallEnable() //LauncherManager.getInstance().getUninstallEnable()
LauncherManager.getInstance().changeUninstallEnable(true); /* LauncherManager.getInstance().changeUninstallEnable(true);
String msg = "辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面"; String msg = "辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面";
toast.setText(msg); toast.setText(msg);
toast.show(); toast.show();
toast.show(); toast.show();*/
LauncherManager.getInstance().changeUninstallEnable(true);
} }
}); });
//findViewById(R.id.tv_is_uninstall).setOnLongClickListener(); //findViewById(R.id.tv_is_uninstall).setOnLongClickListener();
...@@ -264,6 +298,14 @@ public class PackageManageActivity extends Activity { ...@@ -264,6 +298,14 @@ public class PackageManageActivity extends Activity {
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent); startActivity(intent);
/* ComponentName componentName = new ComponentName(PackageManageActivity.this, DeviceReceiver.class);
DevicePolicyManager devicepolicymanager = (DevicePolicyManager) PackageManageActivity.this.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (devicepolicymanager != null && !devicepolicymanager.isAdminActive(componentName)) {
Intent intent = new Intent("android.app.action.ADD_DEVICE_ADMIN");
intent.putExtra("android.app.extra.DEVICE_ADMIN", componentName);
startActivityForResult(intent, 1);
}*/
} }
}); });
...@@ -315,7 +357,11 @@ public class PackageManageActivity extends Activity { ...@@ -315,7 +357,11 @@ public class PackageManageActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
//隐藏图标 //隐藏图标
//PermissionUtil.initLauncherIconIsShow(PackageManageActivity.this, false); //PermissionUtil.initLauncherIconIsShow(PackageManageActivity.this, false);
PermissionUtil.jumpStartInterface(PackageManageActivity.this); // PermissionUtil.jumpStartInterface(PackageManageActivity.this);
Intent intent = new Intent(Constants.ACTION_UPDATE_ICON);
intent.putExtra(Constants.EXTRA_PACKAGE, APP_COPY_PACKAGE_NAME);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
} }
}); });
} }
......
package com.dankal.dankal_launcher; package com.dankal.dankal_launcher;
import android.app.Activity; import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -10,5 +12,6 @@ public class SetActivity extends Activity { ...@@ -10,5 +12,6 @@ public class SetActivity extends Activity {
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.set_ac); setContentView(R.layout.set_ac);
} }
} }
package com.dankal.dankal_launcher;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
/**
* Author: roczheng
* Date: 2020/7/10
* Time: 17:37
* Description:
*/
public class TestReceive extends BroadcastReceiver {
final String SYSTEM_DIALOG_REASON_KEY = "reason";
final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
final String SYSTEM_DIALOG_REASON_GESTURE_KEY = "fs_gesture";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
Log.i("TestReceive", "Home键监听");
} else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {//多任务监听
Log.i("TestReceive", "多任务按钮监听");
} else if (reason.equals(SYSTEM_DIALOG_REASON_GESTURE_KEY)) {
Log.i("TestReceive", "手势");
}
}
} else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
Log.i("TestReceive", "ACTION_SCREEN_OFF");
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
Log.i("TestReceive", "ACTION_USER_PRESENT");
}
}
}
...@@ -15,6 +15,7 @@ import android.text.TextUtils; ...@@ -15,6 +15,7 @@ import android.text.TextUtils;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import com.android.launcher3.util.PermissionUtil; import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.UIExecutor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -45,18 +46,23 @@ public class WindowPermissionCheck { ...@@ -45,18 +46,23 @@ public class WindowPermissionCheck {
int resultCode, int resultCode,
Intent data, Intent data,
OnWindowPermissionListener onWindowPermissionListener) { OnWindowPermissionListener onWindowPermissionListener) {
if (requestCode == 0) { UIExecutor.postRunableDelay(new Runnable() {//延迟1秒处理判断,否则部分手机canDrawOverlays一直为false
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M @Override
&& !Settings.canDrawOverlays(activity)) { public void run() {
if (requestCode == 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(activity)) {
// Toast.makeText(activity.getApplicationContext(), "授权失败", Toast.LENGTH_SHORT).show(); // Toast.makeText(activity.getApplicationContext(), "授权失败", Toast.LENGTH_SHORT).show();
if (onWindowPermissionListener != null) if (onWindowPermissionListener != null)
onWindowPermissionListener.onFailure(); onWindowPermissionListener.onFailure();
} else { } else {
// Toast.makeText(activity.getApplicationContext(), "授权成功", Toast.LENGTH_SHORT).show(); // Toast.makeText(activity.getApplicationContext(), "授权成功", Toast.LENGTH_SHORT).show();
if (onWindowPermissionListener != null) if (onWindowPermissionListener != null)
onWindowPermissionListener.onSuccess(); onWindowPermissionListener.onSuccess();
}
}
} }
} },1000);
} }
public static boolean isServiceON(Context context, String className) { public static boolean isServiceON(Context context, String className) {
......
package com.dankal.dankal_launcher.test;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.dankal.dankal_launcher.R;
public class Acitivity1 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_acitivity1);
}
}
package com.dankal.dankal_launcher.test;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.dankal.dankal_launcher.R;
public class MainAliasActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_alias);
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".test.Acitivity1">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EntranceMainActivity">
<Button
android:id="@+id/btn_listent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="监听"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".test.MainAliasActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
android:id="@+id/jump_setting" android:id="@+id/jump_setting"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="跳转设置" android:text="退出管制"
android:textSize="22sp"></TextView> android:textSize="22sp"></TextView>
<TextView <TextView
...@@ -82,6 +82,19 @@ ...@@ -82,6 +82,19 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="22sp" android:textSize="22sp"
android:text="切换图标"/> android:text="添加快捷方式"/>
<TextView
android:id="@+id/tv_is_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="跳转查询app是否可用"/>
<TextView
android:id="@+id/tv_start_app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="启动桌面"/>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestActivity">
<Button
android:id="@+id/btn_listent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="监听" />
</LinearLayout>
\ No newline at end of file
...@@ -12,4 +12,12 @@ ...@@ -12,4 +12,12 @@
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
</style> </style>
<style name="NormalDialogStyle" parent="android:Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:scrollHorizontally">true</item>
</style>
</resources> </resources>
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package cn.zp.test;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("cn.zp.test.test", appContext.getPackageName());
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.zp.test" />
<resources>
<string name="app_name">Test</string>
</resources>
package cn.zp.test;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
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