Commit 52e58a56 by 郑鹏

修复bug,适配机型

parent 7ac1bdac
......@@ -73,6 +73,7 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.17'
implementation 'com.elvishew:xlog:1.6.1'
//implementation 'com.blankj:utilcode:1.22.7'
}
protobuf {
......@@ -102,7 +103,7 @@ ext {
GITHUB_REPO_PATH = "../../androidlibrary"
PUBLISH_GROUP_ID = 'cn.dankal.android'
PUBLISH_ARTIFACT_ID = 'launcher'
PUBLISH_VERSION = '1.4.1.1'
PUBLISH_VERSION = '1.4.4.5'
}
uploadArchives {
......
......@@ -58,6 +58,7 @@
android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true"
android:hardwareAccelerated="true"
android:resizeableActivity="false"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true">
......@@ -68,20 +69,24 @@
android:enabled="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:resizeableActivity="false"
android:resumeWhilePausing="true"
android:screenOrientation="unspecified"
android:stateNotNeeded="true"
android:taskAffinity=""
android:windowSoftInputMode="adjustPan">
<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.MONKEY" />
<category android:name="android.intent.category.LAUNCHER_APP" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<action android:name="com.dankal.launcher"/>
</intent-filter>
</activity> <!-- Intent received used to install shortcuts from other applications -->
<receiver
android:name=".InstallShortcutReceiver"
......@@ -99,7 +104,6 @@
<receiver android:name=".AppWidgetsRestoredReceiver">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_HOST_RESTORED" />
a
</intent-filter>
</receiver>
......@@ -184,6 +188,7 @@
<service
android:name=".accessibility.FloatWindowService"
android:process=":lock"></service> <!-- 设备管理 -->
<receiver
android:name=".accessibility.DeviceReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN">
......
......@@ -27,7 +27,7 @@ import com.android.launcher3.util.ContentWriter;
/**
* Represents an item in the launcher.
*/
public class ItemInfo {
public class ItemInfo implements Cloneable {
public static final int NO_ID = -1;
......@@ -207,4 +207,14 @@ public class ItemInfo {
return false;
}
@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
}
......@@ -25,6 +25,8 @@ import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.logging.LoggerUtils.newTarget;
import static com.android.launcher3.manager.LauncherManager.getContext;
import static com.android.launcher3.model.PackageUpdatedTask.OP_ADD;
import static com.android.launcher3.model.PackageUpdatedTask.OP_UPDATE;
import android.animation.Animator;
......@@ -83,6 +85,7 @@ import io.reactivex.schedulers.Schedulers;
import android.os.UserManager;
import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
......@@ -123,6 +126,7 @@ import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate;
import com.android.launcher3.manager.Constants;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.manager.ManagementInfo;
import com.android.launcher3.model.ModelWriter;
import com.android.launcher3.model.PackageUpdatedTask;
import com.android.launcher3.notification.NotificationListener;
......@@ -149,6 +153,7 @@ import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SettingsObserver;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.SystemUtils;
import com.android.launcher3.util.Themes;
......@@ -158,6 +163,7 @@ import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.UIExecutor;
import com.android.launcher3.util.UiThreadHelper;
import com.android.launcher3.util.ViewOnDrawExecutor;
import com.android.launcher3.views.DoubleShadowBubbleTextView;
import com.android.launcher3.views.OptionsPopupView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.PendingAddShortcutInfo;
......@@ -185,6 +191,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
public static final String TAG = "Launcher";
static final boolean LOGD = false;
/**
* 备份图标信息
*/
public static final String APP_COPY_NAME = "倍知守护孩子端";
public static final String APP_COPY_PACKAGE_NAME = "cn.dankal.bzshchild.copy";
static final boolean DEBUG_STRICT_MODE = false;
......@@ -253,7 +265,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
// Main container view for the all apps screen.
@Thunk
// AllAppsContainerView mAppsView;
AllAppsContainerView mAppsView;
// AllAppsTransitionController mAllAppsController;
// UI and state for the overview panel
......@@ -294,6 +306,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
// 是否需要刷新桌面图标
private boolean needRefresh = false;
private long mFolderIconId;
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
......@@ -302,6 +316,14 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
case Constants.ACTION_UPDATE_ICON:
String packageName = intent.getStringExtra(Constants.EXTRA_PACKAGE);
if (mModel != null) {
if (packageName.equals(APP_COPY_PACKAGE_NAME)) {//添加另一个入口
DoubleShadowBubbleTextView folderIcon = findDoubleShadowBubbleTextView(mFolderIconId);
// if (folderIcon == null) {
mModel.enqueueModelUpdateTask(new PackageUpdatedTask(OP_ADD, Process.myUserHandle(), packageName));
needRefresh = true;
// }
return;
}
mModel.enqueueModelUpdateTask(new PackageUpdatedTask(OP_UPDATE, Process.myUserHandle(), packageName));
needRefresh = true;
}
......@@ -335,11 +357,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
super.onCreate(savedInstanceState);
if (LauncherManager.mCustomDialog != null) {
/* if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("launch_debug_show", "Launcher_onNewIntent关闭了对话框");
}
Log.i("launch_debug_show", "Launcher_onCreate关闭了对话框");
}*/
TraceHelper.partitionSection("Launcher-onCreate", "super call");
......@@ -431,6 +453,58 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
if (PermissionUtil.isDefaultHome(this)) {
}
PermissionUtil.initLauncherIconIsShow(this, false);
initAPP();
if (PermissionUtil.isAutoStartUp) {
PermissionUtil.putAutoStartUp(this);
}
UIExecutor.postRunableDelay(new Runnable() {
@Override
public void run() {
if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread());
}
}
}, 2000);
}
private long mLastTime;
private void initAPP() {
if (PermissionUtil.isHideHomeIcon(this)) {
if (System.currentTimeMillis() - mLastTime < 6000) {
return;
}
mLastTime = System.currentTimeMillis();
//新增一个图标
UIExecutor.postRunableDelay(new Runnable() {
@Override
public void run() {
//如果是OPPO 安卓10,则不用新增
int version = android.os.Build.VERSION.SDK_INT;
if (SystemUtils.isOPPO() && version == 29) {
return;
}
Intent intent = new Intent(Constants.ACTION_UPDATE_ICON);
intent.putExtra(Constants.EXTRA_PACKAGE, APP_COPY_PACKAGE_NAME);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
}
}, 1500);
//打开倍知守护
/* UIExecutor.postRunableDelay(new Runnable() {
@Override
public void run() {
LauncherManager.getInstance().openApplication(Launcher.this.getApplicationContext());
}
}, 2000);*/
}
}
@Override
......@@ -891,12 +965,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
// Workaround for b/78520668, explicitly trim memory once UI is hidden
onTrimMemory(TRIM_MEMORY_UI_HIDDEN);
if (SystemUtils.isOPPO()) {
/* if (SystemUtils.isOPPO()) {
if (PermissionUtil.isSystemUI) {
Log.i(TAG, "隐藏快捷方式");
PermissionUtil.initLauncherIconIsShow(this, false);
}
}
}*/
}
@Override
......@@ -928,7 +1002,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
}
}, 2000);
LauncherManager.getInstance().changeExitState(false);//开启管制
//LauncherManager.getInstance().changeExitState(false);//开启管制
if (SystemUtils.isOPPO()) {
//刷新页面显示图标
......@@ -937,7 +1011,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override
public void run() {
needRefresh = true;
LauncherManager.getInstance().changeExitState(false);//开启管制
//LauncherManager.getInstance().changeExitState(false);//开启管制
LauncherManager.getInstance().refreshLauncherIconWidget(Launcher.this.getPackageName());
}
}, 2000);
......@@ -1127,7 +1201,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mDropTargetBar = mDragLayer.findViewById(R.id.drop_target_bar);
// Setup Apps
// mAppsView = findViewById(R.id.apps_view);
mAppsView = findViewById(R.id.apps_view);
// Setup the drag controller (drop targets have to be added in reverse order in priority)
mDragController.setMoveTarget(mWorkspace);
......@@ -1251,6 +1325,15 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
});
}
public DoubleShadowBubbleTextView findDoubleShadowBubbleTextView(final long folderIconId) {
return (DoubleShadowBubbleTextView) mWorkspace.getFirstMatch(new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View view) {
return info != null && info.id == folderIconId;
}
});
}
/**
* Add a widget to the workspace.
*
......@@ -1455,6 +1538,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
judgeDialogShow(intent);
DoubleShadowBubbleTextView folderIcon = findDoubleShadowBubbleTextView(mFolderIconId);
if (folderIcon == null) {
initAPP();
}
}
private void judgeDialogShow(Intent intent) {
......@@ -1550,6 +1637,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
//判断是否可卸载
if (LauncherManager.getInstance().getUninstallEnable()) {
PermissionUtil.initLauncherIconIsShow(this, true);
} else {//重启桌面
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
}
}
public LauncherAccessibilityDelegate getAccessibilityDelegate() {
......@@ -1945,6 +2039,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mOnResumeCallback.onLauncherResume();
}
mOnResumeCallback = callback;
Log.i("launch_debug_show", "setOnResumeCallback");
}
/**
......@@ -2049,6 +2144,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mWorkspace.removeExtraEmptyScreen(false, false);
}
private ItemInfo mCopyItemInfo;
/**
* Bind the items start-end from the list.
* <p>
......@@ -2056,6 +2153,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
*/
@Override
public void bindItems(final List<ItemInfo> items, final boolean forceAnimateIcons) {
// Get the list of added items and intersect them with the set of items here
final AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
final Collection<Animator> bounceAnims = new ArrayList<>();
......@@ -2493,6 +2591,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@SuppressLint("CheckResult")
@Override
public void bindShortcutsAdd(ArrayList<ShortcutInfo> added, UserHandle user) {
/* DoubleShadowBubbleTextView folderIcon = findDoubleShadowBubbleTextView(mFolderIconId);
if (folderIcon != null) {
return;
}*/
Log.i("launcher_shortcut", "开始创建快捷方式");
if (!added.isEmpty()) {
/* Observable.fromIterable(added)
......@@ -2696,6 +2799,16 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
// 高清图标
shortcutInfo.usingLowResIcon = false;
if (shortcutInfo.title.equals(APP_COPY_NAME)) {
mFolderIconId = shortcutInfo.id;
//shortcutInfo.iconResource = Intent.ShortcutIconResource.fromContext(Launcher.this, R.mipmap.logo);
/* Intent.ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(Launcher.this, R.mipmap.logo);
iconRes.packageName = shortcutInfo.intent.getComponent().getPackageName();
shortcutInfo.iconResource = iconRes;
shortcutInfo.intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);*/
shortcutInfo.contentDescription = shortcutInfo.title;
shortcutInfo.iconBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.logo);
}
shortcutInfo.onAddToDatabase(writer);
ContentValues values = writer.getValues(getApplicationContext());
......
......@@ -4,12 +4,15 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.util.Log;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import com.android.launcher3.util.UIExecutor;
/**
......@@ -36,7 +39,7 @@ public class AutoRunReceiver extends BroadcastReceiver {
} catch (Exception e) {
e.printStackTrace();
}
//重启之后启动桌面
LauncherManager.getInstance().setInterceptSystemSetting(true);//重新拦截系统设置
LauncherManager.getInstance().backLauncherHome(mContext.getApplicationContext());
}
}
......
......@@ -2,6 +2,7 @@ package com.android.launcher3.accessibility;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
......@@ -13,6 +14,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
......@@ -23,6 +25,7 @@ import android.os.Message;
import android.util.Log;
import android.view.WindowManager;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.manager.ColumnDef;
......@@ -52,6 +55,9 @@ import androidx.core.app.NotificationCompat;
*/
public class ListenerAppService extends Service {
private String notificationId = "launcher_3";
private String notificationName = "1";
public static final String TAG = "ListenerAppService";
public static final int POST_RUNNABLE = 0x1;
......@@ -68,6 +74,8 @@ public class ListenerAppService extends Service {
public static final int APP_CLASS_USE_TIME_OUT = 0x7;
public static final int APP_RESULT_HOME = 0x8;//回到桌面
private static final int TIME = 60 * 1000;
......@@ -75,10 +83,13 @@ public class ListenerAppService extends Service {
private volatile long lastUseAppControlTimeStamp;
private boolean active = true;
private boolean active = true;
private InnerRecevier innerReceiver;
private ExecutorService executors;
private IntentFilter intentFilter;
private NotificationManager notificationManager;
@SuppressLint("HandlerLeak")
......@@ -88,7 +99,6 @@ public class ListenerAppService extends Service {
switch (msg.what) {
case POST_RUNNABLE:
if (active) {
if (!LauncherManager.getInstance().getExitState()) {
if (checkAppRunnable != null) {
if (checkAppRunnable.getStatus() == AsyncTask.Status.FINISHED) {
......@@ -111,7 +121,7 @@ public class ListenerAppService extends Service {
handler.sendEmptyMessageDelayed(POST_RUNNABLE, LOOP_TIME);
break;
case INTERCEPT_SYSTEM_SETTING:
// LauncherManager.getInstance().backLauncherHome(getApplicationContext());
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
LauncherManager.getInstance().jumpSetting(getApplicationContext());
break;
case COIN_USE_TIME_OUT:
......@@ -128,10 +138,10 @@ public class ListenerAppService extends Service {
case APP_LOCKED:
LauncherManager.getInstance().backLauncherHome(getApplicationContext(), Constants.DIALOG_TYPE_LOCKED);
break;
case APP_RESULT_HOME://打开桌面
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
break;
}
}
};
......@@ -152,17 +162,13 @@ public class ListenerAppService extends Service {
//创建广播
innerReceiver = new InnerRecevier();
//动态注册广播
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_USER_PRESENT);
// intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
//启动广播
//intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
//启动广播
registerReceiver(innerReceiver, intentFilter);
// registerReceiver()
Logger.e(TAG, "onCreate");
......@@ -170,7 +176,6 @@ public class ListenerAppService extends Service {
checkAppRunnable = new CheckAppAsyncTask(handler, this);
}
@Override
......@@ -187,15 +192,32 @@ public class ListenerAppService extends Service {
.setEnableVibrate(false) //是否开启震动
.setVisibility(NotificationCompat.VISIBILITY_SECRET); //锁屏界面是否可见
Intent home = new Intent(this, Launcher.class);
home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 200, home, 0);
NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext(), channelBuilder);
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), notificationUtils.getCurrentChannel());
builder.setContentIntent(pendingIntent);
startForeground(1, builder.build());
}
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//创建NotificationChannel
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(notificationId, notificationName, NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
}
startForeground(1, getNotification());
notificationManager.notify(1, getNotification());
handler.sendEmptyMessageDelayed(POST_RUNNABLE, LOOP_TIME);
// usageStatsManager.
......@@ -212,7 +234,7 @@ public class ListenerAppService extends Service {
super.onDestroy();
}
public class InnerRecevier extends BroadcastReceiver {
public class InnerRecevier extends BroadcastReceiver {
final String SYSTEM_DIALOG_REASON_KEY = "reason";
......@@ -220,6 +242,9 @@ public class ListenerAppService extends Service {
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) {
......@@ -227,9 +252,9 @@ public class ListenerAppService extends Service {
Logger.e(TAG, action);
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
if (!LauncherManager.getInstance().getExitState()) {
PermissionUtil.initLauncherIconIsShow(context, false);
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
Logger.e(TAG, action + "\t" + reason);
......@@ -238,27 +263,31 @@ public class ListenerAppService extends Service {
// "Home键被监听"
if (!LauncherManager.getInstance().isForceLock()) {
Log.i("launch_debug_show", "Home键监听");
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
toLauncherPage(context);
} else {
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
toLauncherPage(context);
LauncherManager.getInstance().relockScreen();
}
} else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {//多任务监听
if (!LauncherManager.getInstance().isForceLock()) {
Log.i("launch_debug_show", "多任务按钮监听");
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
toLauncherPage(context);
} else {
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
toLauncherPage(context);
LauncherManager.getInstance().relockScreen();
}
} else if (reason.equals(SYSTEM_DIALOG_REASON_GESTURE_KEY)) {
if (!LauncherManager.getInstance().isForceLock()) {
Log.i("launch_debug_show", "手势");
toLauncherPage(context);
} else {
toLauncherPage(context);
LauncherManager.getInstance().relockScreen();
}
} else if (reason.equals("globalactions")) {//电源键被长按
Log.i("launch_debug_show", "电源键被长按");
}
}
} else {//没有管制,直接显示默认桌面app
PermissionUtil.initLauncherIconIsShow(context, true);
}
} else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
active = false;
......@@ -267,6 +296,7 @@ public class ListenerAppService extends Service {
if (!LauncherManager.getInstance().isForceLock()) {
LauncherManager.getInstance().lockScreenNormal(getApplicationContext());
}
//LauncherManager.getInstance().backLauncherHome(getApplicationContext());
active = true;
}
......@@ -274,13 +304,19 @@ public class ListenerAppService extends Service {
}
private void toLauncherPage(Context context) {
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
}
private void showProgress(Context context) {
if (SystemUtils.isMEIZU()) {
return;
}
try {
if (LauncherManager.mCustomDialog == null) {
LauncherManager.mCustomDialog = new CustomDialog(context, R.layout.activity_clock_alarm);
LauncherManager.mCustomDialog = new CustomDialog(context.getApplicationContext(), R.layout.activity_clock_alarm);
LauncherManager.mCustomDialog.show();
Log.i("launch_debug_show", "显示了进度条");
}
......@@ -314,9 +350,14 @@ public class ListenerAppService extends Service {
Logger.e(TAG, "doInBackground\t");
long currentMills = System.currentTimeMillis();
if (LauncherManager.getInstance().getExitState())
if (LauncherManager.getInstance().getExitState())//当前是退出管制状态
return -1;
//如果关闭了防止卸载则不拦截设置,否则拦截设置
if (LauncherManager.getInstance().getUninstallEnable()) {
return -1;
}
List<UsageStats> stats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST, currentMills - TIME, currentMills);
//取得当前在前台的app,即当前运行的app
......@@ -324,7 +365,7 @@ public class ListenerAppService extends Service {
String topActivity = "";
int j = 0;
for (int i = 0; i < stats.size(); i++) {
if (stats.get(i).getLastTimeUsed() > stats.get(j).getLastTimeUsed()) {
if (stats.get(i).getLastTimeUsed() >= stats.get(j).getLastTimeUsed()) {
j = i;
}
}
......@@ -356,7 +397,6 @@ public class ListenerAppService extends Service {
}
if (LauncherManager.getInstance().isInterceptSystemSetting() && "com.android.settings".equals(topActivity)) {
return INTERCEPT_SYSTEM_SETTING;
}
......@@ -383,8 +423,15 @@ public class ListenerAppService extends Service {
}
}
} else {
//return APP_UNCLASS_TYPE;
return -1;
if (!LauncherManager.getInstance().isInterceptSystemSetting()) {//不拦截设置
return -1;
}
if (SystemUtils.isVIVO()){
//toLauncherPage(context);
registerReceiver(innerReceiver, intentFilter);
}
return APP_RESULT_HOME;
//return -1;
}
}
} else {
......@@ -413,6 +460,25 @@ public class ListenerAppService extends Service {
}*/
}
}
private Notification getNotification() {
Intent home = new Intent(this, Launcher.class);
home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 200, home, 0);
Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(R.mipmap.logo)
.setContentTitle("“倍知守护孩子端”正在运行")
.setContentText("倍知守护孩子端管控中")
.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(notificationId);
}
return builder.build();
}
}
......@@ -136,14 +136,12 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
if (SystemUtils.isVIVO()) {
return;
}
permissionGetter.operateAccessibilityEvent(event);
}
/* if (SystemUtils.isMEIZU()) {//处理魅族桌面
handlerMeizhuDefaultDesktop(event);
}*/
}
private boolean mIsSelectDefaultUse = false;
......@@ -163,7 +161,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
if (mIsSelectDefaultUse) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (nodeInfo.getText().equals("倍知守护孩子端")) {
Log.i("zzzzzzzzzzzzzzzzzzzz", "默认桌面设置成功");
PermissionUtil.mIsDefaultDesktop = true;
mIsSelectDefaultUse = false;
}
......@@ -196,6 +193,7 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
Log.i(TAG_TOW, "showDialog:" + info.canOpenPopup());
Log.i(TAG_TOW, "Text:" + info.getText());
Log.i(TAG_TOW, "windowId:" + info.getWindowId());
Log.i(TAG_TOW, "id:" + info.getViewIdResourceName());
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if (info.getChild(i) != null) {
......@@ -211,7 +209,6 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
//判断当前界面
if (event.getPackageName().equals("android")) {
Log.i("qqqqqqqqqqqqqqqqqqqq", "在系统界面");
PermissionUtil.isSystemUI = true;
} else {
PermissionUtil.isSystemUI = false;
......
......@@ -82,7 +82,8 @@ public abstract class BaseAutoGetPermission {
toast = null;
}
toast = new KToast(service.getApplicationContext());
showToastLongTow("辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面");
if (!SystemUtils.isVIVO())
showToastLongTow("辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面");
}
private boolean isFinish = false;
......@@ -133,6 +134,7 @@ public abstract class BaseAutoGetPermission {
if (event.getSource() == null)
return;
if (PermissionUtil.checkAutoStartUp(getApplicationContext())) {
PermissionUtil.putAutoStartUp(getApplicationContext());
Log.i("reqeustAutoStartUp", "已经有了自启动");
resetStep();
} else {
......@@ -268,6 +270,7 @@ public abstract class BaseAutoGetPermission {
if (step == STEP_REQUEST_AUTO_STARTUP) {
if (PermissionUtil.checkAutoStartUp(getApplicationContext())) {
PermissionUtil.putAutoStartUp(getApplicationContext());
resetStep();
} else {
// if (SystemUtils.isNOKIA()) {
......
......@@ -275,7 +275,6 @@ public class GeneralAutoGetPermission extends BaseAutoGetPermission {
if (alwaysBtnList != null && alwaysBtnList.size() > 0) {
alwaysBtnList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
// AccessibilityNodeInfo alwaysBtn = getChildNodeByIdEqualText(nodeInfo, "android:id/button_always");
}
}
......
package com.android.launcher3.auto_get_permission.oppo;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
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.util.Logger;
import com.android.launcher3.util.PermissionUtil;
......@@ -18,9 +21,11 @@ import static com.android.launcher3.auto_get_permission.AccessibilityNodeOperate
public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
public static final String TAG = "OppoAutoPermissionGetter";
private boolean mIsActivation = false;
private PermissionOpenAccessiblityService mPermissionOpenAccessiblityService;
public OppoAutoPermissionGetter(PermissionOpenAccessiblityService service) {
super(service);
mPermissionOpenAccessiblityService = service;
}
@Override
......@@ -103,6 +108,28 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override
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", "开始自启动权限");
AccessibilityNodeInfo sourceNode = event.getSource();
Log.i("reqeustAutoStartUp", "自启动,当前界面:" + event.getClassName());
......@@ -161,6 +188,20 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
// 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, "耗电保护");
Log.i("reqeustAutoStartUp", "耗电保护");
......@@ -184,7 +225,6 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
}
}
}
}
@Override
......@@ -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;
}
}
......@@ -28,7 +28,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestkDeviceAdmin(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
if (SystemUtils.getMIUIVersion().equals("V10")) {
if (SystemUtils.getMIUIVersion().equals("V10") || SystemUtils.getMIUIVersion().equals("V9")) {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -60,8 +60,6 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
}
return;
} else if ("com.android.settings.SubSettings".equals(event.getClassName())) {
String title = event.getText().toString();
......@@ -185,6 +183,35 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
return;
}
if (TextUtils.equals(title, "[系统安全]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodes.get(0);
AccessibilityNodeInfo systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "设备管理应用");
long time = System.currentTimeMillis();
while (systemSafeBtn == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode != null) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "设备管理应用");
}
if (systemSafeBtn != null && performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
} else {
showToastLong("请点击【系统安全】");
}
}
return;
}
} else if ("com.android.settings.DeviceAdminAdd".equals(event.getClassName().toString())) {
List<AccessibilityNodeInfo> nodeInfoList = sourceNode.findAccessibilityNodeInfosByViewId("com.android.settings:id/restricted_action");
......@@ -215,7 +242,11 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings") &&
!"com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$NotificationAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$DevelopmentSettingsDashboardActivity".equals(event.getClassName().toString()) &&
!"com.miui.appmanager.ApplicationsDetailsActivity".equals(event.getClassName().toString())) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
......@@ -375,6 +406,11 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "com.android.settings:id/name", appName);
}
if (systemSafeBtn == null) {
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", appName);
}
if (systemSafeBtn != null && performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleep();
} else {
......@@ -414,8 +450,25 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
if ("com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd".equals(event.getClassName().toString())){
List<AccessibilityNodeInfo> nodeInfoList = sourceNode.findAccessibilityNodeInfosByViewId("com.android.settings:id/restricted_action");
if (nodeInfoList != null && nodeInfoList.size() > 0 && nodeInfoList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK)) {
sleep();
// resetStep();
return;
} else {
showToastLong("请点击启用/激活此设备管理员");
return;
}
}
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings") &&
!"com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$NotificationAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$DevelopmentSettingsDashboardActivity".equals(event.getClassName().toString()) &&
!"com.miui.appmanager.ApplicationsDetailsActivity".equals(event.getClassName().toString())) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
......@@ -440,6 +493,43 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
sleep();
if (SystemUtils.getMIUIVersion().equals("V9")) {
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodeS != null && listViewNodeS.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodeS.get(0);
AccessibilityNodeInfo targetNode = getChildNodeByIdEqualText(listViewNode, "android:id/title", "更多应用");
if (targetNode == null) {
targetNode = getChildNodeByIdEqualText(listViewNode, "android:id/title", "更多应用");
}
long time = System.currentTimeMillis();
while (targetNode == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode.isScrollable()) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
targetNode = getChildNodeByIdEqualText(listViewNode, "android:id/title", "更多应用");
if (targetNode == null) {
targetNode = getChildNodeByIdEqualText(listViewNode, "android:id/title", "更多应用");
}
}
if (targetNode != null && performAction(targetNode, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
} else {
showToastLong("请点击【更多应用】");
return;
}
}
return;
}
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodeS != null && listViewNodeS.size() > 0) {
......@@ -556,7 +646,8 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
long time = System.currentTimeMillis();
while ((switcherBtnNode == null || switcherBtnNode.size() <= 0) && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (scrollViewNode != null) {
scrollViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
//scrollViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
//switcherBtnNode = scrollViewNode.findAccessibilityNodeInfosByViewId("com.miui.securitycenter:id/am_switch");
sleepShort();
scrollViewNode.refresh();
} else {
......@@ -569,6 +660,10 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
if (switcherBtnNode.get(0) != null) {
if (!switcherBtnNode.get(0).isChecked()) {
if (SystemUtils.getMIUIVersion().equals("V9")) {
showToastLong("请点击【自启动】");
return;
}
if (switcherBtnNode != null && performAction(switcherBtnNode.get(0), AccessibilityNodeInfo.ACTION_CLICK)) {
/* for (int i = 0; i < switcherBtnNode.size(); i++) {
AccessibilityNodeInfo accessibilityNodeInfo = switcherBtnNode.get(i);
......@@ -587,6 +682,8 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
showToastLong("请点击【自启动】");
return;
}
showToastLong("请点击【自启动】");
return;
} else {//已经选择过了
PermissionUtil.isAutoStartUp = true;
}
......@@ -781,6 +878,18 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
sleep();
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings") &&
!"com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$NotificationAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$DevelopmentSettingsDashboardActivity".equals(event.getClassName().toString()) &&
!"com.miui.appmanager.ApplicationsDetailsActivity".equals(event.getClassName().toString())) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
// gotoDeviceAdminPermissionSetting();
return;
}
/* if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
......@@ -799,7 +908,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
if (sourceNode == null) {
return;
}
if (SystemUtils.getMIUIVersion().equals("V10")) {
if (SystemUtils.getMIUIVersion().equals("V10") || SystemUtils.getMIUIVersion().equals("V9")) {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -967,8 +1076,65 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
}
return;
} else if (TextUtils.equals(title, "[系统安全]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodes.get(0);
AccessibilityNodeInfo systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "有权查看使用情况的应用");
long time = System.currentTimeMillis();
while (systemSafeBtn == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode != null) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "有权查看使用情况的应用");
}
if (performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
} else {
showToastLong("请点击【有权查看使用情况的应用】");
return;
}
}
return;
}
} else if ("com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName())) {
sleepLong();
/* List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodes.get(0);
AccessibilityNodeInfo systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", appName);
long time2 = System.currentTimeMillis();
while (systemSafeBtn == null && System.currentTimeMillis() - time2 < MAX_SEARCH_TIME) {
if (listViewNode != null) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", appName);
}
if (performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
} else {
showToastLong("请点击【" + appName + "】");
return;
}
}*/
showToastLong("请点击【" + appName + "】");
return;
}
......@@ -978,6 +1144,8 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
sleepShort();
return;
}
gotoAppUsagePermission();
} else {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
......@@ -1276,18 +1444,20 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
return;
}
}
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings") &&
!"com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$NotificationAccessSettingsActivity".equals(event.getClassName().toString()) &&
!"com.android.settings.Settings$DevelopmentSettingsDashboardActivity".equals(event.getClassName().toString()) &&
!"com.miui.appmanager.ApplicationsDetailsActivity".equals(event.getClassName().toString())) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
// gotoDeviceAdminPermissionSetting();
return;
}
gotoDeveloperChoice();
}
......@@ -1297,7 +1467,10 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
if (sourceNode == null) {
return;
}
if (SystemUtils.getMIUIVersion().equals("V10")) {
if (SystemUtils.getMIUIVersion().equals("V9")) {
return;
}
if (SystemUtils.getMIUIVersion().equals("V10") || SystemUtils.getMIUIVersion().equals("V9")) {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -1421,6 +1594,33 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
}
return;
} else if (TextUtils.equals(title, "[系统安全]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodes.get(0);
AccessibilityNodeInfo systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "通知使用权限");
long time = System.currentTimeMillis();
while (systemSafeBtn == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode != null) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "通知使用权限");
}
if (performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
} else {
showToastLong("请点击【通知使用权限】");
return;
}
}
return;
}
if (TextUtils.equals(title, "[通知使用权]")) {
......
package com.android.launcher3.debug;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.BaseActivity;
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.Manifest;
import android.app.AppOpsManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import android.view.WindowManager;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import androidx.annotation.RequiresApi;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
/**
* @author sun on 2018/7/5.
*/
public class FloatWindowParamManager {
public static final String TAG = "FloatWindowParamManager";
public static boolean checkPermission(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Settings.canDrawOverlays(context);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// return checkOps(context);
}
return true;
}
public static boolean checkOverlayPermission(Context context) {
AppOpsManager appOpsMgr = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
try {
if (appOpsMgr != null) {
int mode = appOpsMgr.checkOpNoThrow("android:system_alert_window",
android.os.Process.myUid(), context.getPackageName());
if (mode == 0) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/* @RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static boolean checkOps(Context context) {
try {
Object object = context.getSystemService(Context.APP_OPS_SERVICE);
if (object == null) {
return false;
}
Class localClass = object.getClass();
Class[] arrayOfClass = new Class[3];
arrayOfClass[0] = Integer.TYPE;
arrayOfClass[1] = Integer.TYPE;
arrayOfClass[2] = String.class;
Method method = localClass.getMethod("checkOp", arrayOfClass);
if (method == null) {
return false;
}
Object[] arrayOfObject1 = new Object[3];
arrayOfObject1[0] = 24;
arrayOfObject1[1] = Binder.getCallingUid();
arrayOfObject1[2] = AppUtils.getAppPackageName();
int m = (Integer) method.invoke(object, arrayOfObject1);
return m == AppOpsManager.MODE_ALLOWED || !RomUtils.isDomesticSpecialRom();
} catch (Exception ignore) {
}
return false;
}*/
private static boolean startActivitySafely(Intent intent, Context context) {
try {
if (isIntentAvailable(intent, context)) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return true;
} else {
return false;
}
} catch (Exception e) {
Log.e(TAG, "启动Activity失败!!!!!!");
return false;
}
}
public static boolean isIntentAvailable(Intent intent, Context context) {
return intent != null && context.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
}
private static boolean applyCommonPermission(Context context) {
try {
Class clazz = Settings.class;
Field field = clazz.getDeclaredField("ACTION_MANAGE_OVERLAY_PERMISSION");
Intent intent = new Intent(field.get(null).toString());
intent.setData(Uri.parse("package:" + context.getPackageName()));
startActivitySafely(intent, context);
return true;
} catch (Exception e) {
return false;
}
}
private static boolean applyCoolpadPermission(Context context) {
Intent intent = new Intent();
intent.setClassName("com.yulong.android.seccenter",
"com.yulong.android.seccenter.dataprotection.ui.AppListActivity");
return startActivitySafely(intent, context);
}
private static boolean applyLenovoPermission(Context context) {
Intent intent = new Intent();
intent.setClassName("com.lenovo.safecenter",
"com.lenovo.safecenter.MainTab.LeSafeMainActivity");
return startActivitySafely(intent, context);
}
private static boolean applyZTEPermission(Context context) {
Intent intent = new Intent();
intent.setAction("com.zte.heartyservice.intent.action.startActivity.PERMISSION_SCANNER");
return startActivitySafely(intent, context);
}
private static boolean applyLetvPermission(Context context) {
Intent intent = new Intent();
intent.setClassName("com.letv.android.letvsafe",
"com.letv.android.letvsafe.AppActivity");
return startActivitySafely(intent, context);
}
private static boolean applyVivoPermission(Context context) {
Intent intent = new Intent();
intent.putExtra("packagename", context.getPackageName());
intent.setAction("com.vivo.permissionmanager");
intent.setClassName("com.vivo.permissionmanager",
"com.vivo.permissionmanager.activity.SoftPermissionDetailActivity");
ComponentName componentName1 = intent.resolveActivity(context.getPackageManager());
if (componentName1 != null) {
return startActivitySafely(intent, context);
}
intent.setAction("com.iqoo.secure");
intent.setClassName("com.iqoo.secure",
"com.iqoo.secure.safeguard.SoftPermissionDetailActivity");
ComponentName componentName2 = intent.resolveActivity(context.getPackageManager());
if (componentName2 != null) {
return startActivitySafely(intent, context);
}
intent.setAction("com.iqoo.secure");
intent.setClassName("com.iqoo.secure", "com.iqoo.secure.MainActivity");
ComponentName componentName3 = intent.resolveActivity(context.getPackageManager());
if (componentName3 != null) {
return startActivitySafely(intent, context);
}
return startActivitySafely(intent, context);
}
private static boolean applyOppoPermission(Context context) {
Intent intent = new Intent();
intent.putExtra("packageName", context.getPackageName());
intent.setAction("com.oppo.safe");
intent.setClassName("com.oppo.safe",
"com.oppo.safe.permission.PermissionAppListActivity");
if (!startActivitySafely(intent, context)) {
intent.setAction("com.color.safecenter");
intent.setClassName("com.color.safecenter",
"com.color.safecenter.permission.floatwindow.FloatWindowListActivity");
if (!startActivitySafely(intent, context)) {
intent.setAction("com.coloros.safecenter");
intent.setClassName("com.coloros.safecenter",
"com.coloros.safecenter.sysfloatwindow.FloatWindowListActivity");
return startActivitySafely(intent, context);
} else {
return true;
}
} else {
return true;
}
}
private static boolean apply360Permission(Context context) {
Intent intent = new Intent();
intent.setClassName("com.android.settings",
"com.android.settings.Settings$OverlaySettingsActivity");
if (!startActivitySafely(intent, context)) {
intent.setClassName("com.qihoo360.mobilesafe",
"com.qihoo360.mobilesafe.ui.index.AppEnterActivity");
return startActivitySafely(intent, context);
} else {
return true;
}
}
private static boolean applyMiuiPermission(Context context) {
Intent intent = new Intent();
intent.setAction("miui.intent.action.APP_PERM_EDITOR");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra("extra_pkgname", context.getPackageName());
return startActivitySafely(intent, context);
}
public static boolean getAppDetailSettingIntent(Context context) {
Intent localIntent = new Intent();
localIntent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
localIntent.setData(Uri.fromParts("package", context.getPackageName(), null));
return startActivitySafely(localIntent, context);
}
private static boolean applyMeizuPermission(Context context) {
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
intent.setClassName("com.meizu.safe",
"com.meizu.safe.security.AppSecActivity");
intent.putExtra("packageName", context.getPackageName());
return startActivitySafely(intent, context);
}
private static boolean applyHuaweiPermission(Context context) {
try {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = new ComponentName("com.huawei.systemmanager",
"com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity");
intent.setComponent(comp);
if (!startActivitySafely(intent, context)) {
comp = new ComponentName("com.huawei.systemmanager",
"com.huawei.notificationmanager.ui.NotificationManagmentActivity");
intent.setComponent(comp);
context.startActivity(intent);
return true;
} else {
return true;
}
} catch (SecurityException e) {
try {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = new ComponentName("com.huawei.systemmanager",
"com.huawei.permissionmanager.ui.MainActivity");
intent.setComponent(comp);
context.startActivity(intent);
return true;
} catch (Exception e1) {
Log.e(TAG, "Huawei跳转失败1" + e1);
return getAppDetailSettingIntent(context);
}
} catch (ActivityNotFoundException e) {
try {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName comp = new ComponentName("com.Android.settings",
"com.android.settings.permission.TabItem");
intent.setComponent(comp);
context.startActivity(intent);
return true;
} catch (Exception e2) {
Log.e(TAG, "Huawei跳转失败2" + e);
return getAppDetailSettingIntent(context);
}
} catch (Exception e) {
return getAppDetailSettingIntent(context);
}
}
private static boolean applySmartisanPermission(Context context) {
Intent intent = new Intent("com.smartisanos.security.action.SWITCHED_PERMISSIONS_NEW");
intent.setClassName("com.smartisanos.security",
"com.smartisanos.security.SwitchedPermissions");
intent.putExtra("index", 17); //有版本差异,不一定定位正确
if (startActivitySafely(intent, context)) {
return true;
} else {
intent = new Intent("com.smartisanos.security.action.SWITCHED_PERMISSIONS");
intent.setClassName("com.smartisanos.security",
"com.smartisanos.security.SwitchedPermissions");
intent.putExtra("permission", new String[]{Manifest.permission.SYSTEM_ALERT_WINDOW});
return startActivitySafely(intent, context);
}
}
public static WindowManager.LayoutParams getFloatLayoutParam(boolean fullScreen, boolean touchAble) {
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
layoutParams.type = TYPE_APPLICATION_OVERLAY;
//刘海屏延伸到刘海里面
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
layoutParams.type = TYPE_TOAST;
} else {
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
}
//layoutParams.packageName = AppUtils.getAppPackageName();
layoutParams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
//Focus会占用屏幕焦点,导致游戏无声
if (touchAble) {
layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
} else {
layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
}
if (fullScreen) {
layoutParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
} else {
layoutParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
}
layoutParams.format = PixelFormat.TRANSPARENT;
return layoutParams;
}
public static boolean tryJumpToPermissionPage(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
switch (RomUtils.getRomName()) {
case RomUtils.ROM_MIUI:
return applyMiuiPermission(context);
case RomUtils.ROM_EMUI:
return applyHuaweiPermission(context);
case RomUtils.ROM_VIVO:
return applyVivoPermission(context);
case RomUtils.ROM_OPPO:
return applyOppoPermission(context);
case RomUtils.ROM_QIKU:
return apply360Permission(context);
case RomUtils.ROM_SMARTISAN:
return applySmartisanPermission(context);
case RomUtils.ROM_COOLPAD:
return applyCoolpadPermission(context);
case RomUtils.ROM_ZTE:
return applyZTEPermission(context);
case RomUtils.ROM_LENOVO:
return applyLenovoPermission(context);
case RomUtils.ROM_LETV:
return applyLetvPermission(context);
default:
return true;
}
} else {
if (RomUtils.isMeizuRom()) {
return getAppDetailSettingIntent(context);
} else if (RomUtils.isVivoRom()) {
return applyVivoPermission(context);
} else if (RomUtils.isMiuiRom()) {
return applyMiuiPermission(context) || getAppDetailSettingIntent(context);
} else {
return applyCommonPermission(context);
}
}
}
}
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 {
"com.sec.android.app.camera|com.android.camera2|com.meizu.media.camera|com.huawei.camera",
"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";
......
......@@ -11,6 +11,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
......@@ -576,7 +577,6 @@ public class LauncherManager {
context.startActivity(home);
}
});
}
public void jumpSetting(Context context) {
......@@ -914,4 +914,23 @@ public class LauncherManager {
Intent intent = new Intent(context, SearchAppCanUseActivity.class);
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 {
private long LockScreenEndTime;
private int currentWorkModel;
private PackageManager packageManager;
// 退出管制 可自由使用任何app
private boolean exitProtect = false;
// true 退出管制 可自由使用任何app
private boolean exitProtect = true;
// 当天(从00:00开始)各类型的app已经使用的总时长
private Map<Integer, Long> appTypeUseTimestamp;
......@@ -474,6 +474,7 @@ public class TimeModeManager {
public boolean isExitProtect() {
exitProtect = configSaver.getExitState();
return exitProtect;
}
......
......@@ -299,10 +299,30 @@ public class LoaderResults {
});
}
private ItemInfo mCopyItemInfo;
private void bindWorkspaceItems(final ArrayList<ItemInfo> workspaceItems,
final ArrayList<LauncherAppWidgetInfo> appWidgets,
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
int N = workspaceItems.size();
for (int i = 0; i < N; i += ITEMS_CHUNK) {
......
......@@ -34,6 +34,7 @@ import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.SessionCommitReceiver;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
......@@ -57,6 +58,9 @@ import java.util.Collections;
import java.util.HashSet;
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)
* or when a user availability changes.
......@@ -109,6 +113,21 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
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);
// Automatically add homescreen icon for work profile apps for below O device.
......@@ -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;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_MASK;
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;
/**
......@@ -277,7 +278,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
if (componentName == null)
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();
Logger.e("uninstallDisableApp", enable + "");
//是否拦截系统设置
......
......@@ -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_SAFEMODE;
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_RECONFIGURE_APPWIDGET;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
......@@ -86,6 +88,12 @@ public class ItemClickHandler {
if (tag instanceof 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()) {
ShortcutInfo shortcutInfo = (ShortcutInfo) tag;
......@@ -96,6 +104,11 @@ public class ItemClickHandler {
return;
}
if (shortcutInfo.title.equals(APP_COPY_NAME)){
LauncherManager.getInstance().openApplication(v.getContext().getApplicationContext());
return;
}
ManagementInfo appinfo = LauncherManager.getInstance().getManageAppInfo(packageName);
if (!packageName.equals(Constants.SYSTEM_SETTING_APP)) {
if (!LauncherManager.getInstance().isSafePackageName(packageName) && !LauncherManager.getInstance().isSystemPackageName(packageName)) {
......
......@@ -10,6 +10,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
......@@ -23,6 +24,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import com.android.launcher3.accessibility.AppManagerAccessiblityService;
import com.android.launcher3.accessibility.DeviceReceiver;
......@@ -45,6 +47,10 @@ public class PermissionUtil {
public static boolean isAutoStartUp = false;
// 临时变量,魅族默认桌面判断
public static boolean mIsDefaultDesktop = false;
// 临时变量 判断耗电优化
public static boolean mIsPowerOptimization = false;
// 临时变量 应用速冻(OPPO)
public static boolean mIsQuickFreeze = false;
public static boolean isSystemUI = false;
......@@ -123,12 +129,17 @@ public class PermissionUtil {
/**
* 检测设备管理器权限
* oppo直接返回true,因为oppo可以在状态栏关闭设备管理器
*
* @param context
* @return
*/
public static boolean checkDeviceAdminPermission(Context context) {
if (SystemUtils.isOPPO()) {
return true;
}
ComponentName componentName = new ComponentName(context, DeviceReceiver.class);
// ((DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE)).
boolean isActive = ((DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE)).isAdminActive(componentName) || isAdminDevice;
......@@ -183,10 +194,61 @@ public class PermissionUtil {
* @return
*/
public static boolean checkAutoStartUp(Context context) {
return isAutoStartUp;
if (isAutoStartUp) {
return true;
}
SharedPreferences sharedPreferences = getSharedPreferences(context);
return sharedPreferences.getBoolean("isAutoStartUp", false);
}
public static void putAutoStartUp(Context context) {
SharedPreferences sharedPreferences = getSharedPreferences(context);
sharedPreferences.edit().putBoolean("isAutoStartUp", true).apply();
}
private static SharedPreferences getSharedPreferences(Context context) {
return context.getApplicationContext().getSharedPreferences("isAutoStartUp", Context.MODE_PRIVATE);
}
/**
* 判断是否忽略高耗电优化
*
* @param context
* @return
*/
public static boolean checkHeightPowerConsumption(Context context) {
if (mIsPowerOptimization) {
return true;
}
SharedPreferences sharedPreferences = getSharedPreferences(context);
return sharedPreferences.getBoolean("isHeightConsumption", false);
}
public static void putHeightPowerConsumption(Context context) {
SharedPreferences sharedPreferences = getSharedPreferences(context);
sharedPreferences.edit().putBoolean("isHeightConsumption", true).apply();
}
/**
* 判断应用速冻
*
* @param context
* @return
*/
public static boolean checkQuickFreeze(Context context) {
if (mIsQuickFreeze) {
return true;
}
SharedPreferences sharedPreferences = getSharedPreferences(context);
return sharedPreferences.getBoolean("isQuickFreeze", false);
}
public static void putQuickFreeze(Context context) {
SharedPreferences sharedPreferences = getSharedPreferences(context);
sharedPreferences.edit().putBoolean("isQuickFreeze", true).apply();
}
/**
* 跳转自启动
......@@ -220,12 +282,18 @@ public class PermissionUtil {
return;
}
} else if (SystemUtils.isOPPO()) {
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
if (Build.DISPLAY.equals("PAFM00_11_F.12")) {//搜索自启动权限
intent = new Intent(Settings.ACTION_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} else {
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
// componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
// intent.setComponent(componentName);
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
try {
......@@ -265,6 +333,10 @@ public class PermissionUtil {
*/
public static boolean checkBatteryOptimize(Context context) {
if (SystemUtils.isMIUI()) {//小米重启之后,又没权限了,fuck
return true;
}
boolean isIgnoring = false;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (powerManager != null) {
......@@ -512,7 +584,7 @@ public class PermissionUtil {
return true;
}
}
return isDefault || SystemUtils.isMIUI() || SystemUtils.isOPPO() || SystemUtils.isHW();
return isDefault || SystemUtils.isMIUI() || SystemUtils.isOPPO() || SystemUtils.isHW() || SystemUtils.isVIVO();
}
/**
......@@ -521,6 +593,9 @@ public class PermissionUtil {
* @param context
*/
public static void gotoDeveloperChoice(Context context) {
if (SystemUtils.isMIUI()) {
Toast.makeText(context, "请关闭USB调试", Toast.LENGTH_LONG).show();
}
try {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
......@@ -715,11 +790,14 @@ public class PermissionUtil {
* 处理图标的显示和隐藏
*/
public static void initLauncherIconIsShow(Context context, boolean isShow) {
ComponentName mDefault = new ComponentName(context, "cn.dankal.bzshchild.ui.SplashActivity");
if (isShow) {
enableComponent(context, mDefault);
} else {
disableComponent(context, mDefault);
if (PermissionUtil.isHideHomeIcon(context)) {
ComponentName mDefault = new ComponentName(context, "cn.dankal.bzshchild.ui.EntranceMainActivity");
//ComponentName mDefault = new ComponentName(context, "com.dankal.dankal_launcher.EntranceMainActivity");
if (isShow) {
enableComponent(context, mDefault);
} else {
disableComponent(context, mDefault);
}
}
}
......@@ -737,7 +815,7 @@ public class PermissionUtil {
}
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
0);
PackageManager.DONT_KILL_APP);
}
/**
......@@ -754,7 +832,7 @@ public class PermissionUtil {
}
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
0);
PackageManager.DONT_KILL_APP);
}
/**
......@@ -854,9 +932,19 @@ public class PermissionUtil {
return;
}
} else if (SystemUtils.isOPPO()) {
if (Build.DISPLAY.equals("PAFM00_11_F.12")) {//搜索自启动权限
intent = new Intent(Settings.ACTION_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} else {
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
} else if (SystemUtils.isVIVO()) {
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
// componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
// intent.setComponent(componentName);
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
......@@ -871,6 +959,40 @@ public class PermissionUtil {
context.startActivity(intent);
Logger.e(TAG, "gotoBatteryOptimize\t" + e.getMessage());
}
PermissionUtil.isAutoStartUp = true;
if (!SystemUtils.isVIVO()) {
PermissionUtil.isAutoStartUp = true;
PermissionUtil.putAutoStartUp(context);
}
}
/**
* 是否需要生成隐藏图标
*/
public static boolean isHideHomeIcon(Context context) {
if (SystemUtils.getSystemVersionCode() > 28) {
if (SystemUtils.isOPPO()) {
return true;
}
return false;
}
if (SystemUtils.isOPPO() || SystemUtils.isHW() || SystemUtils.isMIUI() || SystemUtils.isVIVO()) {
return true;
}
return false;
}
/**
* 跳转电池高耗电
* 已适配(vivo)
*
* @param context
*/
public static void jumpHeightPowerConsumption(Context context) {
Intent intent = new Intent(Settings.ACTION_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
......@@ -134,4 +134,18 @@ public class SystemUtils {
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 {
private static final String UNINSTALL = "uninstall";
private static final String EXIT="exit";
private static final String EXIT = "exit";
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) {
......@@ -104,7 +104,7 @@ public class TimeConfigSaver {
return sharedPreferences.getInt(WORK_MODE, ColumnDef.TimeManager.WORK_DAY);
}
public void putUninstallEnable(boolean enable){
public void putUninstallEnable(boolean enable) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(UNINSTALL, enable);
......@@ -113,21 +113,21 @@ public class TimeConfigSaver {
}
public boolean getUninstallEnable(){
return sharedPreferences.getBoolean(UNINSTALL,false);
public boolean getUninstallEnable() {
return sharedPreferences.getBoolean(UNINSTALL, false);
}
public void putExitState(boolean enable){
public void putExitState(boolean enable) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(EXIT, enable);
editor.putString(EXIT, enable ? "a" : "b");
editor.apply();
}
public boolean getExitState(){
return sharedPreferences.getBoolean(EXIT,false);
public boolean getExitState() {
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 @@
<color name="all_apps_bg_hand_fill_dark">#9AA0A6</color>
<color name="color_white">#ffffff</color>
<color name="color_FFC537">#FFC537</color>
</resources>
......@@ -2,10 +2,10 @@
<device-admin
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<limit-password />
<!-- 限制密码类型 -->
<watch-login />
<!-- 监控登录尝试 -->
<limit-password />
<!-- 限制密码类型 -->
<reset-password />
<!-- 重置密码 -->
<force-lock />
......
......@@ -46,5 +46,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(':Launcher3')
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
// api 'cn.dankal.android:launcher:1.0.4'
}
......@@ -7,6 +7,8 @@
android:name="android.permission.SET_ACTIVITY_WATCHER"
tools:ignore="ProtectedPermissions" />
<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
android:name=".MyApplication"
......@@ -18,46 +20,82 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="@bool/config_largeHeap"
android:resizeableActivity="false"
android:restoreAnyVersion="true"
android:supportsRtl="true"
android:theme="@style/LauncherTheme"
tools:replace="android:icon"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".PermissionSettingActivity"></activity>
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:icon">
<!--
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=".test.Acitivity1"
android:excludeFromRecents="true"
android:exported="false"
android:finishOnTaskLaunch="false"
android:launchMode="singleInstance" />
<activity
android:name=".PackageManageActivity"
android:autoRemoveFromRecents="true"
android:theme="@android:style/Theme.DeviceDefault.Settings">
android:name=".test.MainAliasActivity"
android:enabled="false"
android:icon="@drawable/icon"
android:label=""
android:targetActivity=".Acitivity1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-->
<!-- <activity-alias
android:name=".NewActivity1"
android:enabled="true"
android:label="Alias1"
android:icon="@mipmap/ic_launcher_round"
android:targetActivity=".PackageManageActivity">
<activity
android:name=".EntranceMainActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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
android:name=".SetActivity"
android:exported="true"></activity>
android:exported="true" />
<service
android:name="com.android.launcher3.accessibility.PermissionOpenAccessiblityService"
......@@ -72,6 +110,24 @@
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</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>
</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;
import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.accessibility.DeviceReceiver;
import com.android.launcher3.accessibility.StopRunReceiver;
import com.android.launcher3.manager.ColumnDef;
import com.android.launcher3.manager.Constants;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.manager.ManagementInfo;
import com.android.launcher3.model.TimeConfig;
import com.android.launcher3.util.KToast;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
......@@ -38,6 +41,10 @@ import java.util.Date;
import java.util.List;
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 {
......@@ -118,8 +125,8 @@ public class PackageManageActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_package_manage);
LauncherManager.getInstance().changeExitState(true);
LauncherManager.getInstance().setInterceptSystemSetting(false);
/*LauncherManager.getInstance().changeExitState(true);
LauncherManager.getInstance().setInterceptSystemSetting(false);*/
tvAdd = findViewById(R.id.tv_add);
......@@ -131,6 +138,13 @@ public class PackageManageActivity extends Activity {
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() {
@Override
public void onClick(View v) {
......@@ -150,6 +164,26 @@ public class PackageManageActivity extends Activity {
// handler.sendEmptyMessageDelayed(2,2000);
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 {
public void run() {
// PermissionUtil.gotoBatteryOptimize(getApplicationContext());
LauncherManager.getInstance().changeExitState(true);
LauncherManager.getInstance().setInterceptSystemSetting(false);
}
......@@ -235,12 +268,13 @@ public class PackageManageActivity extends Activity {
//LauncherManager.getInstance().getUninstallEnable()
LauncherManager.getInstance().changeUninstallEnable(true);
/* LauncherManager.getInstance().changeUninstallEnable(true);
String msg = "辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面";
toast.setText(msg);
toast.show();
toast.show();
toast.show();*/
LauncherManager.getInstance().changeUninstallEnable(true);
}
});
//findViewById(R.id.tv_is_uninstall).setOnLongClickListener();
......@@ -264,6 +298,14 @@ public class PackageManageActivity extends Activity {
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
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 {
public void onClick(View v) {
//隐藏图标
//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;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.android.launcher3.debug.DebugInfoActivity;
import com.android.launcher3.debug.SearchAppCanUseActivity;
import com.android.launcher3.accessibility.ListenerAppService;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import com.android.launcher3.floatingwindow.FloatPermissionDetectView;
public class PermissionSettingActivity extends AppCompatActivity {
private AlertDialog.Builder mBuilder;
private int mResultPermissionType = 0;//返回权限类型
private String mTitle = "";
private String mContent = "";
private TestReceive innerReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -28,60 +42,169 @@ public class PermissionSettingActivity extends AppCompatActivity {
protected void onResume() {
super.onResume();
check();
showTip();
}
/**
* 返回回来的时候显示提示
*/
private void showTip() {
//关闭悬浮窗
if (mFloatPermissionDetectView != null) {
mFloatPermissionDetectView.remove();
mFloatPermissionDetectView = null;
}
if (SystemUtils.isVIVO()) {
switch (mResultPermissionType) {
case 1://自启动
if (!PermissionUtil.isAutoStartUp) {
mTitle = "自启动权限";
mContent = "是否已成功设置自启动权限?";
showSureDialog();
}
break;
case 2://电池高耗电优化
if (!PermissionUtil.mIsPowerOptimization) {
mTitle = "高耗电优化";
mContent = "是否已开启高耗电优化?";
showSureDialog();
}
break;
case 3://应用速冻
if (!PermissionUtil.mIsQuickFreeze) {
mTitle = "应用速冻";
mContent = "是否已开启应用速冻?";
showSureDialog();
}
break;
}
}
}
/**
* 权限确认对话框
*/
private void showSureDialog() {
mBuilder = new AlertDialog.Builder(this).setTitle(mTitle).setMessage(mContent)
.setPositiveButton("设置成功", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (mResultPermissionType) {
case 1:
PermissionUtil.putAutoStartUp(PermissionSettingActivity.this);
break;
case 2:
PermissionUtil.putHeightPowerConsumption(PermissionSettingActivity.this);
break;
case 3:
PermissionUtil.putQuickFreeze(PermissionSettingActivity.this);
break;
}
check();
}
}).setNegativeButton("还没有", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
mBuilder.create().show();
}
//激活设备管理
private ConstraintLayout clActivateDeviceManager;
private ImageView ivActivateDeviceManager;
//关闭耗电保护
private ConstraintLayout clClosePower;
private ImageView ivClosePower;
//开启查看应用使用权限
private ConstraintLayout clOpenApplicationPermission;
private ImageView ivOpenApplicationPermission;
//关闭USB测试
private ConstraintLayout clCloseUsbTest;
private ImageView ivCloseUsbTest;
//自启动权限
private ConstraintLayout clSelfStartingPermissions;
private ImageView ivSelfStartingPermissions;
//开启通知栏监听
private ConstraintLayout clOpenNotificationListener;
private ImageView ivOpenNotificationListener;
//开启自启动管理
// private ConstraintLayout clOpenAutoStartManager;
// private ImageView ivOpenAutoStartManager;
//设置默认桌面
private ConstraintLayout clSettingDefaultLauncher;
private ImageView ivSettingDefaultLauncher;
//关闭应用分身
// private ConstraintLayout clCloseApplication;
// private ImageView ivCloseApplication;
private ConstraintLayout clSelfStartingPermissions;
private ImageView ivSelfStartingPermissions;
//关闭应用速冻(oppo)
private ConstraintLayout clCloseQuickFreeze;
private ImageView ivSettingQuickFreeze;
//耗电保护中允许后台运行
private ConstraintLayout clPowerConsumptionProtection;
private ImageView ivPowerConsumptionProtection;
//锁定多任务
private ConstraintLayout clMultitasking;
private ImageView ivMultitasking;
//电池高耗电优化
private ConstraintLayout clHeightPowerConsumption;
private ImageView ivHeightPowerConsumption;
private Button buttonConfirm;
/**
* 悬浮窗提示
*/
private FloatPermissionDetectView mFloatPermissionDetectView;
private void initData() {
LauncherManager.getInstance().setInterceptSystemSetting(false);
LauncherManager.getInstance().changeExitState(true);
ClickAction clickAction = new ClickAction();
clActivateDeviceManager = findViewById(R.id.cl_activate_device_manager);
ivActivateDeviceManager = findViewById(R.id.iv_activate_device_manager);
clClosePower = findViewById(R.id.cl_close_power);
ivClosePower = findViewById(R.id.iv_close_power);
clOpenApplicationPermission = findViewById(R.id.cl_open_application_permission);
ivOpenApplicationPermission = findViewById(R.id.iv_open_application_permission);
clCloseUsbTest = findViewById(R.id.cl_close_usb_test);
ivCloseUsbTest = findViewById(R.id.iv_close_usb_test);
clSelfStartingPermissions = findViewById(R.id.cl_self_starting_permissions);
ivSelfStartingPermissions = findViewById(R.id.iv_self_starting_permissions);
clOpenNotificationListener = findViewById(R.id.cl_open_notification_listener);
ivOpenNotificationListener = findViewById(R.id.iv_open_notification_listener);
// clOpenAutoStartManager = findViewById(R.id.cl_open_auto_start_manager);
// ivOpenAutoStartManager = findViewById(R.id.iv_open_auto_start_manager);
clSettingDefaultLauncher = findViewById(R.id.cl_setting_launcher);
ivSettingDefaultLauncher = findViewById(R.id.iv_setting_launcher);
// clCloseApplication = findViewById(R.id.cl_close_application);
// ivCloseApplication = findViewById(R.id.iv_close_application);
//耗电保护中允许后台运行
clPowerConsumptionProtection = findViewById(R.id.cl_power_consumption_protection);
ivPowerConsumptionProtection = findViewById(R.id.iv_power_consumption_protection);
//应用速冻
clCloseQuickFreeze = findViewById(R.id.cl_apply_quick_freeze);
ivSettingQuickFreeze = findViewById(R.id.iv_apply_quick_freeze);
//锁定多任务
clMultitasking = findViewById(R.id.cl_multitasking);
ivMultitasking = findViewById(R.id.iv_multitasking);
//电池高耗电优化
clHeightPowerConsumption = findViewById(R.id.cl_height_power_consumption);
ivHeightPowerConsumption = findViewById(R.id.iv_height_power_consumption);
buttonConfirm = findViewById(R.id.button_confirm);
buttonConfirm.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -89,144 +212,155 @@ public class PermissionSettingActivity extends AppCompatActivity {
//mPresenter.addTimeSwitch();
LauncherManager.getInstance().setInterceptSystemSetting(true);
LauncherManager.getInstance().changeExitState(false);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
}
});
findViewById(R.id.tv_searchAppCanUseActivity).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(PermissionSettingActivity.this, SearchAppCanUseActivity.class));
}
}
);
findViewById(R.id.tv_debugInfoActivity).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(PermissionSettingActivity.this, DebugInfoActivity.class));
}
}
);
clActivateDeviceManager.setOnClickListener(clickAction);
clClosePower.setOnClickListener(clickAction);
clOpenApplicationPermission.setOnClickListener(clickAction);
clCloseUsbTest.setOnClickListener(clickAction);
clOpenNotificationListener.setOnClickListener(clickAction);
// clOpenAutoStartManager.setOnClickListener(clickAction);
clSettingDefaultLauncher.setOnClickListener(clickAction);
clSelfStartingPermissions.setOnClickListener(clickAction);
ivPowerConsumptionProtection.setOnClickListener(clickAction);
clCloseQuickFreeze.setOnClickListener(clickAction);
clPowerConsumptionProtection.setOnClickListener(clickAction);
clHeightPowerConsumption.setOnClickListener(clickAction);
brandAdapter();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (innerReceiver != null) {
unregisterReceiver(innerReceiver);
}
}
// clCloseApplication.setOnClickListener(clickAction);
/**
* 根据手机品牌判断显示相应权限
*/
private void brandAdapter() {
if (SystemUtils.isOPPO()) {
clCloseQuickFreeze.setVisibility(View.VISIBLE);
clSettingDefaultLauncher.setVisibility(View.GONE);
}
if (SystemUtils.isVIVO()) {
clSettingDefaultLauncher.setVisibility(View.GONE);
clHeightPowerConsumption.setVisibility(View.VISIBLE);
}
}
/**
* 检查所有权限
*/
private void check() {
//判断是否有设备管理权限
boolean activateDeviceManager;
if (PermissionUtil.checkDeviceAdminPermission(this)) {
openFailTick(ivActivateDeviceManager);
clActivateDeviceManager.setEnabled(false);
activateDeviceManager = true;
} else {
clActivateDeviceManager.setEnabled(true);
openFailure(ivActivateDeviceManager);
activateDeviceManager = false;
}
//判断是否电池优化
boolean closePower;
//判断是否耗电保护
if (PermissionUtil.checkBatteryOptimize(this)) {
openFailTick(ivClosePower);
clClosePower.setEnabled(false);
closePower = true;
} else {
openFailure(ivClosePower);
clClosePower.setEnabled(true);
closePower = false;
}
boolean selfStarting;
//高耗电优化
boolean heightPowerConsumption;
if (PermissionUtil.checkHeightPowerConsumption(this)) {
openFailTick(ivHeightPowerConsumption);
heightPowerConsumption = true;
} else {
openFailure(ivHeightPowerConsumption);
heightPowerConsumption = false;
}
//自启动
boolean selfStarting;
if (PermissionUtil.checkAutoStartUp(this)) {
openFailTick(ivSelfStartingPermissions);
clSelfStartingPermissions.setEnabled(false);
selfStarting = true;
} else {
openFailure(ivSelfStartingPermissions);
clSelfStartingPermissions.setEnabled(true);
selfStarting = false;
}
boolean openApplicationPermission;
//判断是否开启查看应用使用权限
boolean openApplicationPermission;
if (PermissionUtil.checkAppUsagePermission(this)) {
openFailTick(ivOpenApplicationPermission);
clOpenApplicationPermission.setEnabled(false);
openApplicationPermission = true;
} else {
openFailure(ivOpenApplicationPermission);
clOpenApplicationPermission.setEnabled(true);
openApplicationPermission = false;
}
boolean closeUsbTest;
//判断是否开启usb权限
// 测试的时候
// clCloseUsbTest.setEnabled(false);
// closeUsbTest = true;
//打包的时候
boolean closeUsbTest;
if (!PermissionUtil.enAbleADB(this)) {
openFailTick(ivCloseUsbTest);
clCloseUsbTest.setEnabled(false);
closeUsbTest = true;
} else {
openFailure(ivCloseUsbTest);
clCloseUsbTest.setEnabled(true);
closeUsbTest = false;
}
boolean openNotificationListener;
//判断是否开启通知栏
boolean openNotificationListener;
if (PermissionUtil.isNotificationListenersEnabled(this)) {
openFailTick(ivOpenNotificationListener);
clOpenNotificationListener.setEnabled(false);
openNotificationListener = true;
} else {
openFailure(ivOpenNotificationListener);
clOpenNotificationListener.setEnabled(true);
openNotificationListener = false;
}
boolean settingDefaultLauncher;
//判断是否设置为默认桌面
boolean settingDefaultLauncher;
if (PermissionUtil.isDefaultHome(this)) {
openFailTick(ivSettingDefaultLauncher);
clSettingDefaultLauncher.setEnabled(false);
settingDefaultLauncher = true;
} else {
openFailure(ivSettingDefaultLauncher);
clSettingDefaultLauncher.setEnabled(true);
settingDefaultLauncher = false;
}
//判断应用速冻(oppo)
boolean isQuickFreeze;
if (PermissionUtil.checkQuickFreeze(this)) {
openFailTick(ivSettingQuickFreeze);
isQuickFreeze = true;
} else {
openFailure(ivSettingQuickFreeze);
isQuickFreeze = false;
}
if (SystemUtils.isVIVO()) {
buttonConfirm.setEnabled(activateDeviceManager && closePower && openApplicationPermission &&
closeUsbTest && openNotificationListener && heightPowerConsumption && selfStarting);
return;
}
buttonConfirm.setEnabled(activateDeviceManager && closePower && openApplicationPermission &&
closeUsbTest && openNotificationListener && settingDefaultLauncher);
// //判断是否应用分身
// if (!PermissionUtil.isDualApk(this)) {
// openFailTick(ivCloseApplication);
// clCloseApplication.setEnabled(false);
// } else {
// openFailure(ivCloseApplication);
// clCloseApplication.setEnabled(true);
// }
}
// private void startOpen(ImageView imageView) {
// openLoad(imageView);
// }
private void openFailure(ImageView imageView) {
imageView.setImageResource(R.mipmap.ic_failure);
......@@ -237,51 +371,81 @@ public class PermissionSettingActivity extends AppCompatActivity {
}
// private void openLoad(ImageView imageView) {
// imageView.setImageResource(R.mipmap.ic_loading);
// ObjectAnimator icon_anim = ObjectAnimator.ofFloat(imageView, "rotation", 0.0F, 3600F);
// icon_anim.addListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// super.onAnimationEnd(animation);
// Logger.e("addListener。onAnimationEnd");
// buttonConfirm.setEnabled(true);
// openFailTick(imageView);
// }
// });
// icon_anim.setDuration(3000);
// RxAnimationTool.start(icon_anim);
// }
class ClickAction implements View.OnClickListener {
@Override
public void onClick(View v) {
int id = v.getId();
if (R.id.cl_self_starting_permissions == id) {//自启动权限
PermissionUtil.jumpStartInterface(PermissionSettingActivity.this);
} else if (R.id.cl_activate_device_manager == id) {
//设备管理
PermissionUtil.gotoDeviceAdminPermissionSetting(PermissionSettingActivity.this);
} else if (R.id.cl_close_power == id) {
//关闭耗电保护
PermissionUtil.gotoBatteryOptimize(PermissionSettingActivity.this);
} else if (R.id.cl_open_application_permission == id) {
//开启使用权限
PermissionUtil.gotoAppUsagePermission(PermissionSettingActivity.this);
} else if (R.id.cl_close_usb_test == id) {
//关闭usb
PermissionUtil.gotoDeveloperChoice(PermissionSettingActivity.this);
} else if (R.id.cl_open_notification_listener == id) {
//通知
PermissionUtil.goToNotificationAccessSetting(PermissionSettingActivity.this);
} else if (R.id.cl_setting_launcher == id) {
//设置默认桌面
PermissionUtil.setDefaultL(PermissionSettingActivity.this);
// Utils.openResolverLauncher(PermissionSettingActivity.this);
//设置默认桌面
mResultPermissionType = 0;
String tipText = "";//需要提示的文本
switch (v.getId()) {
case R.id.cl_self_starting_permissions://自启动权限
mResultPermissionType = 1;
PermissionUtil.jumpStartInterface(PermissionSettingActivity.this);
/* if (Build.DISPLAY.equals("PAFM00_11_F.12")) {//搜索自启动权限
String tipText = "1、直接搜索自启动,并打开“倍知守-孩子端”开关\n2、找到“应用管理”+“自启动管理”并打开“倍知守-孩子端”开关";
showFloatPermissionWindow(tipText);
}*/
if (SystemUtils.isVIVO()) {
tipText = "1、点击<big><font color='#FFC537'>权限</font></big><br/>" +
"2、点击<big><font color='#FFC537' >单项权限设置</font></big><br/>" +
"3、开启<big><font color='#FFC537'>自启动</font></big>";
showFloatPermissionWindow(tipText);
}
break;
case R.id.cl_activate_device_manager://设备管理
PermissionUtil.gotoDeviceAdminPermissionSetting(PermissionSettingActivity.this);
break;
case R.id.cl_close_power: //关闭耗电保护
PermissionUtil.gotoBatteryOptimize(PermissionSettingActivity.this);
break;
case R.id.cl_open_application_permission: //开启使用权限
PermissionUtil.gotoAppUsagePermission(PermissionSettingActivity.this);
break;
case R.id.cl_close_usb_test://关闭usb
PermissionUtil.gotoDeveloperChoice(PermissionSettingActivity.this);
break;
case R.id.cl_open_notification_listener:////通知
PermissionUtil.goToNotificationAccessSetting(PermissionSettingActivity.this);
break;
case R.id.cl_setting_launcher://设置默认桌面
PermissionUtil.setDefaultL(PermissionSettingActivity.this);
//Utils.openResolverLauncher(PermissionSettingActivity.this);
//设置默认桌面
break;
case R.id.cl_power_consumption_protection://耗电保护中允许后台运行
tipText = "在“耗电保护中”找到“倍知守护孩子端”选择允许后台运行";
showFloatPermissionWindow(tipText);
PermissionUtil.jumpStartInterface(PermissionSettingActivity.this);
break;
case R.id.cl_apply_quick_freeze://应用速冻
mResultPermissionType = 3;
tipText = "1、滑动页面找到<big><font color='#FFC537'>电池</font></big><br/>" +
"2、点击<big><font color='#FFC537' >应用速冻</font></big>并找到<big><font color='#FFC537' >倍知守护孩子端</font></big><br/>" +
"3、关闭<big><font color='#FFC537'>自动速冻开关</font></big>";
showFloatPermissionWindow(tipText);
PermissionUtil.jumpSystemSettings(PermissionSettingActivity.this);
break;
case R.id.cl_multitasking://锁定多任务
break;
case R.id.cl_height_power_consumption://电池高耗电(vivo)
mResultPermissionType = 2;
tipText = "1、滑动页面找到<big><font color='#FFC537'>电池</font></big><br/>" +
"2、点击<big><font color='#FFC537' >后台高耗电</font></big>并找到<big><font color='#FFC537' >倍知守护孩子端</font></big><br/>" +
"3、开启<big><font color='#FFC537'>倍知守护孩子端</font></big>";
showFloatPermissionWindow(tipText);
PermissionUtil.jumpHeightPowerConsumption(PermissionSettingActivity.this);
break;
}
}
}
private synchronized void showFloatPermissionWindow(String tipText) {
if (mFloatPermissionDetectView != null) {
mFloatPermissionDetectView.remove();
mFloatPermissionDetectView = null;
}
mFloatPermissionDetectView = new FloatPermissionDetectView(getApplicationContext(), tipText);
mFloatPermissionDetectView.show();
}
}
package com.dankal.dankal_launcher;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
......@@ -10,5 +12,6 @@ public class SetActivity extends Activity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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;
import android.view.accessibility.AccessibilityManager;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.UIExecutor;
import java.util.ArrayList;
import java.util.List;
......@@ -45,18 +46,23 @@ public class WindowPermissionCheck {
int resultCode,
Intent data,
OnWindowPermissionListener onWindowPermissionListener) {
if (requestCode == 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(activity)) {
UIExecutor.postRunableDelay(new Runnable() {//延迟1秒处理判断,否则部分手机canDrawOverlays一直为false
@Override
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();
if (onWindowPermissionListener != null)
onWindowPermissionListener.onFailure();
} else {
if (onWindowPermissionListener != null)
onWindowPermissionListener.onFailure();
} else {
// Toast.makeText(activity.getApplicationContext(), "授权成功", Toast.LENGTH_SHORT).show();
if (onWindowPermissionListener != null)
onWindowPermissionListener.onSuccess();
if (onWindowPermissionListener != null)
onWindowPermissionListener.onSuccess();
}
}
}
}
},1000);
}
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 @@
android:id="@+id/jump_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="跳转设置"
android:text="退出管制"
android:textSize="22sp"></TextView>
<TextView
......@@ -82,6 +82,19 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
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>
\ No newline at end of file
......@@ -18,6 +18,7 @@
android:layout_marginTop="11.5dp"
android:background="@mipmap/ic_set" />
<!--设备管理器OPPO不需要-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_activate_device_manager"
android:layout_width="match_parent"
......@@ -44,10 +45,11 @@
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--耗电保护-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_close_power"
android:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/cl_close_power"
android:layout_marginTop="1dp"
android:background="@color/colorFF">
......@@ -60,20 +62,49 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_close_power"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
android:id="@+id/iv_close_power"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--耗电保护中允许后台运行-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_power_consumption_protection"
android:layout_width="match_parent"
android:layout_height="55dp"
android:visibility="gone"
android:layout_marginTop="1dp"
android:background="@color/colorFF">
<TextView
style="@style/text_col97_size16"
android:layout_marginStart="17.5dp"
android:text="耗电保护中允许后台运行"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_power_consumption_protection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--自启动-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_self_starting_permissions"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:background="@color/colorFF">
......@@ -86,21 +117,22 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_self_starting_permissions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
android:id="@+id/iv_self_starting_permissions"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--查看应用使用权限-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_open_application_permission"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_open_application_permission"
android:background="@color/colorFF">
<TextView
......@@ -112,21 +144,22 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_open_application_permission"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
android:id="@+id/iv_open_application_permission"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--关闭USB测试-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_close_usb_test"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_close_usb_test"
android:background="@color/colorFF">
<TextView
......@@ -138,21 +171,22 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_close_usb_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
android:id="@+id/iv_close_usb_test"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--开启通知栏监听-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_open_notification_listener"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_open_notification_listener"
android:background="@color/colorFF">
<TextView
......@@ -164,9 +198,9 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_open_notification_listener"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iv_open_notification_listener"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -174,37 +208,12 @@
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="63dp"-->
<!-- android:layout_marginTop="1dp"-->
<!-- android:id="@+id/cl_open_auto_start_manager"-->
<!-- android:background="@color/colorFF">-->
<!-- <TextView-->
<!-- style="@style/text_col97_size16"-->
<!-- android:layout_marginStart="17.5dp"-->
<!-- android:text="@string/open_auto_start_management"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!-- <ImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="15.5dp"-->
<!-- android:src="@mipmap/ic_tick"-->
<!-- android:id="@+id/iv_open_auto_start_manager"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<!--设置默认桌面-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_setting_launcher"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_setting_launcher"
android:background="@color/colorFF">
<TextView
......@@ -216,64 +225,99 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_setting_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--锁定多任务-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_multitasking"
android:layout_width="match_parent"
android:layout_height="55dp"
android:visibility="gone"
android:layout_marginTop="1dp"
android:background="@color/colorFF">
<TextView
style="@style/text_col97_size16"
android:layout_marginStart="17.5dp"
android:text="锁定多任务"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_multitasking"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:id="@+id/iv_setting_launcher"
android:src="@mipmap/ic_tick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="63dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_close_application"
android:background="@color/colorFF">
<TextView
style="@style/text_col97_size16"
android:layout_marginStart="17.5dp"
android:text="@string/close_application_avatar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
android:id="@+id/iv_close_application"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
-->
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_searchAppCanUseActivity"
style="@style/text_col97_size16"
android:paddingStart="17.5dp"
<!--应用速冻oppo-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_apply_quick_freeze"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:gravity="center_vertical"
android:text="SearchAppCanUseActivity"
android:background="@color/colorFF"/>
android:visibility="gone"
android:background="@color/colorFF">
<TextView
style="@style/text_col97_size16"
android:layout_marginStart="17.5dp"
android:text="应用速冻"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_apply_quick_freeze"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_debugInfoActivity"
style="@style/text_col97_size16"
android:paddingStart="17.5dp"
<!--vivo电池高耗电优化-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_height_power_consumption"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:gravity="center_vertical"
android:text="DebugInfoActivity"
android:background="@color/colorFF"/>
android:visibility="gone"
android:background="@color/colorFF">
<TextView
style="@style/text_col97_size16"
android:layout_marginStart="17.5dp"
android:text="电池高耗电优化"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_height_power_consumption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_tick"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/button_confirm"
......@@ -283,8 +327,8 @@
android:layout_marginStart="14dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="14dp"
android:paddingBottom="5dp"
android:layout_marginBottom="22.5dp"
android:paddingBottom="5dp"
android:text="开启守护" />
</LinearLayout>
......
<?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 @@
<item name="android:layout_height">wrap_content</item>
</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>
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