Commit 1cefb2d6 by lihuaikun

fix

parent 89ace990
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -86,13 +86,13 @@ public class ListenerAppService extends Service {
} else if (checkAppRunnable.getStatus() == AsyncTask.Status.PENDING) {
checkAppRunnable.executeOnExecutor(executors);
}
}else {
} else {
checkAppRunnable = new CheckAppAsyncTask(this, getApplicationContext());
checkAppRunnable.executeOnExecutor(executors);
}
// Logger.e(TAG,"POST_RUNNABLE RUN");
}else {
} else {
// Logger.e(TAG,"POST_RUNNABLE notRUN");
}
......@@ -217,21 +217,23 @@ public class ListenerAppService extends Service {
Logger.e(TAG, action);
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
Logger.e(TAG, action + "\t" + reason);
if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
// "Home键被监听"
if (!LauncherManager.getInstance().isForceLock()) {
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
} else {
if (!LauncherManager.getInstance().getExitState()) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
Logger.e(TAG, action + "\t" + reason);
if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
// "Home键被监听"
if (!LauncherManager.getInstance().isForceLock()) {
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
} else {
// LauncherManager.getInstance().relockScreen();
}
} else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
if (!LauncherManager.getInstance().isForceLock()) {
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
} else {
}
} else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
if (!LauncherManager.getInstance().isForceLock()) {
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
} else {
// LauncherManager.getInstance().relockScreen();
}
}
}
}
......@@ -239,7 +241,7 @@ public class ListenerAppService extends Service {
active = false;
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
if (!LauncherManager.getInstance().isForceLock()){
if (!LauncherManager.getInstance().isForceLock()) {
LauncherManager.getInstance().lockScreenNormal(getApplicationContext());
}
......@@ -271,9 +273,12 @@ public class ListenerAppService extends Service {
protected Integer doInBackground(Void... voids) {
Logger.e(TAG,"doInBackground\t");
Logger.e(TAG, "doInBackground\t");
long currentMills = System.currentTimeMillis();
if (LauncherManager.getInstance().getExitState())
return -1;
List<UsageStats> stats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST, currentMills - TIME, currentMills);
//取得当前在前台的app,即当前运行的app
......@@ -307,9 +312,6 @@ public class ListenerAppService extends Service {
lastUseAppControlTimeStamp = currentMills;
if (topActivity.equals(context.getPackageName()))
return -1;
......
......@@ -94,7 +94,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
@Override
public boolean onUnbind(Intent intent) {
LauncherManager.getInstance().changeExitState(false);
permissionGetter.stop();
return super.onUnbind(intent);
}
......@@ -136,14 +135,12 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
* 权限完成后的操作 此处无法使用当前的context去startActivity
*/
public void finish() {
// if (){
// }
}
@Override
public void onDestroy() {
LauncherManager.getInstance().changeExitState(false);
permissionGetter.stop();
super.onDestroy();
}
......
......@@ -71,11 +71,11 @@ public class AccessibilityNodeOperateUtil {
if (child == null)
continue;
// Logger.e(TAG, child.getViewIdResourceName() + "\t" + child.getChildCount() + "child child\t" + child.toString());
Logger.e(TAG, child.getViewIdResourceName() + "\t" + child.getChildCount() + "child child\t" + child.toString());
if (child.getContentDescription() != null && child.getContentDescription().toString().equals(text)) {
// Logger.e(TAG, "find equal \t" + child.toString());
Logger.e(TAG, "find equal \t" + child.toString());
return child;
}
......@@ -90,7 +90,7 @@ public class AccessibilityNodeOperateUtil {
}
if (child.getContentDescription().toString().equals(text)) {
// Logger.e(TAG, "find equal \t" + child.toString());
Logger.e(TAG, "find equal \t" + child.toString());
return child;
}
......@@ -113,7 +113,7 @@ public class AccessibilityNodeOperateUtil {
if (childNode.getText() == null)
continue;
if (childNode.getText().toString().equals(text)) {
// Logger.e(TAG, "find equal \t" + childNode.toString());
Logger.e(TAG, "find equal \t" + childNode.toString());
return childNode;
}
}
......
......@@ -65,6 +65,11 @@ public class GeneralAutoGetPermission extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
}
......
......@@ -3,6 +3,7 @@ package com.android.launcher3.auto_get_permission.honor;
import android.accessibilityservice.AccessibilityService;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
......@@ -20,7 +21,7 @@ import static com.android.launcher3.auto_get_permission.AccessibilityNodeOperate
public class HonorAutoPermissionGetter extends BaseAutoGetPermission {
private static final String TAG="HonorAutoPermissionGetter";
private static final String TAG = "HonorAutoPermissionGetter";
public HonorAutoPermissionGetter(PermissionOpenAccessiblityService service) {
super(service);
......@@ -56,7 +57,7 @@ public class HonorAutoPermissionGetter extends BaseAutoGetPermission {
} else {
sleep();
}
}else if ("com.android.settings.DeviceAdminAdd".equals(event.getClassName().toString())) {
} else if ("com.android.settings.DeviceAdminAdd".equals(event.getClassName().toString())) {
AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeByIdEqualText(sourceNode, "com.android.settings:id/action_button", "激活");
// List<AccessibilityNodeInfo> nodeInfoList = sourceNode.findAccessibilityNodeInfosByViewId("com.android.settings:id/action_button");
......@@ -78,8 +79,13 @@ public class HonorAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode=event.getSource();
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity".equals(event.getClassName())) {
......@@ -308,7 +314,7 @@ public class HonorAutoPermissionGetter extends BaseAutoGetPermission {
} else {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
}
}
......@@ -446,7 +452,7 @@ public class HonorAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestCloseUSB(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode=event.getSource();
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.Settings$DevelopmentSettingsActivity".equals(event.getClassName())) {
// oppo也是这个页面
......@@ -554,7 +560,11 @@ public class HonorAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestDefaultLauncher(AccessibilityEvent event) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
showToastLong("华为8.0以上的设备不支持更换桌面哦");
finish();
return;
}
if ("com.android.settings.HWSettings".equals(event.getClassName())) {
AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeEqual(nodeInfo, "应用和通知");
if (performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
......
......@@ -30,6 +30,11 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
// 魅族 权限管理 ->后台管理-> 打开应用开关
......
......@@ -53,6 +53,11 @@ public class NokiaAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode=event.getSource();
......
......@@ -90,6 +90,11 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.applications.InstalledAppDetailsTop".equals(event.getClassName())) {
......
......@@ -7,6 +7,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import com.android.launcher3.accessibility.PermissionOpenAccessiblityService;
import com.android.launcher3.auto_get_permission.BaseAutoGetPermission;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.SystemUtils;
import java.util.List;
......@@ -18,6 +19,7 @@ import static com.android.launcher3.auto_get_permission.AccessibilityNodeOperate
public class SamsungAutoPermissionGetter extends BaseAutoGetPermission {
private static final String TAG = "SamsungAutoPermissionGetter";
public SamsungAutoPermissionGetter(PermissionOpenAccessiblityService service) {
super(service);
......@@ -76,6 +78,44 @@ public class SamsungAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
// 三星 自动运行应用程序 -> 打开应用开关 -> 电池管理 -> 未监视的应用程序 -> 添加应用
if ("com.samsung.android.sm.score.ui.ScoreBoardActivity".equals(event.getClassName().toString())) {
AccessibilityNodeInfo sourceNode = event.getSource();
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, "自动运行应用程序");
if (accessibilityNodeInfo1 != null && accessibilityNodeInfo1.getParent() != null) {
accessibilityNodeInfo1.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
}
}
if ("com.samsung.android.sm.autorun.ui.AutoRunActivity".equals(event.getClassName().toString())) {
AccessibilityNodeInfo sourceNode = event.getSource();
getChildNodeEqual(sourceNode, appName);
AccessibilityNodeInfo frameLayoutNode = sourceNode.findAccessibilityNodeInfosByViewId("com.samsung.android.sm_cn:id/active_applications_detail").get(0).getParent().getParent();
// frameLayoutNode.getCollectionInfo()'
// for ()
//
Logger.e(TAG, sourceNode.findAccessibilityNodeInfosByViewId("com.samsung.android.sm_cn:id/app_name").size() + "");
//
// Logger.e(TAG, "\t" + sourceNode.findAccessibilityNodeInfosByViewId("com.samsung.android.sm_cn:id/active_applications_detail").get(0).getParent().getChildCount());
// AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, appName);
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeByIdEqualText(sourceNode, "com.samsung.android.sm_cn:id/app_name", appName);
accessibilityNodeInfo1.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
}
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
// 三星 自动运行应用程序 -> 打开应用开关 -> 电池管理 -> 未监视的应用程序 -> 添加应用
......@@ -338,7 +378,7 @@ public class SamsungAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestNotificationPermission(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode=event.getSource();
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.Settings$NotificationAccessSettingsActivity".equals(event.getClassName())) {
AccessibilityNodeInfo targetApp = getChildNodeEqual(sourceNode, appName);
......@@ -393,7 +433,7 @@ public class SamsungAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestDefaultLauncher(AccessibilityEvent event) {
AccessibilityNodeInfo nodeInfo=event.getSource();
AccessibilityNodeInfo nodeInfo = event.getSource();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
if ("com.android.settings.applications.InstalledAppDetailsTop".equals(event.getClassName())) {
......
......@@ -27,6 +27,11 @@ public class VivoAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
}
......
......@@ -431,6 +431,11 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
......
......@@ -111,7 +111,7 @@ public class FirstInitWorkSpaceTask {
// 拨号 联系人( "", ) 短信 相机 浏览器
public static final String[] HOTSEAT_APP_PACKAGENAME = {"com.samsung.android.dialer|com.android.dialer|com.samsung.android.contacts|com.android.contacts", "com.samsung.android.messaging|com.android.mms", "com.sec.android.app.sbrowser|com.android.browser|com.heytap.browser", "com.sec.android.app.camera|com.android.camera2|com.meizu.media.camera|com.oppo.camera"};
public static final String[] HOTSEAT_APP_PACKAGENAME = {"com.samsung.android.dialer|com.android.dialer|com.samsung.android.contacts|com.android.contacts", "com.samsung.android.messaging|com.android.mms", "com.sec.android.app.sbrowser|com.android.browser|com.heytap.browser", "com.sec.android.app.camera|com.android.camera2|com.meizu.media.camera|com.oppo.camera|com.huawei.camera"};
public static final String[] NEED_FILTER_PACKAGE_NAME = {};
......
......@@ -47,7 +47,7 @@ public class KToast {
// 配置一些默认的参数
mWindowParams = new WindowManager.LayoutParams();
mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.width = WindowManager.LayoutParams.MATCH_PARENT;
mWindowParams.format = PixelFormat.TRANSLUCENT;
// mWindowParams.windowAnimations = android.R.style.Animation_Toast;
// mWindowParams.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
......
......@@ -170,7 +170,30 @@ public class PermissionUtil {
}
public static void gotoBatteryOptimize(Context context) {
/**
* 判断是否有自启动权限
* @param context
* @return
*/
public static boolean checkAutoStartUp(Context context) {
PackageManager pm=context.getPackageManager();
boolean haveStartup = false;
try {
PackageInfo pkgInfo = pm
.getPackageInfo(context.getPackageName(), PackageManager.GET_RECEIVERS
| PackageManager.GET_META_DATA);// 通过包名,返回包信息
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
haveStartup = pm.checkPermission(
"android.permission.RECEIVE_BOOT_COMPLETED", context.getPackageName()) == PackageManager.PERMISSION_GRANTED;
return haveStartup;
}
public static void gotoAutoStartUpSettings(Context context) {
Intent intent = new Intent();
......@@ -227,6 +250,25 @@ public class PermissionUtil {
}
public static void gotoBatteryOptimize(Context context) {
requestIgnoreBatteryOptimizations(context);
}
public static void requestIgnoreBatteryOptimizations(Context context) {
try {
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 检测电池优化是否开启 三星不支持
*
......
......@@ -139,8 +139,6 @@ public class PackageManageActivity extends Activity {
//
//
// LauncherManager.getInstance().setCurrentWorkMode(ColumnDef.TimeManager.WORK_DAY);
LauncherManager.getInstance().setInterceptSystemSetting(false);
handler.sendEmptyMessage(0);
}
});
......@@ -198,8 +196,10 @@ public class PackageManageActivity extends Activity {
new Thread(new Runnable() {
@Override
public void run() {
// LauncherManager.getInstance().forceLockScreen(PackageManageActivity.this, 1*60);
PermissionUtil.gotoBatteryOptimize(getApplicationContext());
LauncherManager.getInstance().changeExitState(true);
LauncherManager.getInstance().setInterceptSystemSetting(false);
// handler.sendEmptyMessage(3);
}
}).start();
......@@ -274,4 +274,6 @@ public class PackageManageActivity extends Activity {
onResume();
}
}
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