Commit 7ac1bdac by 郑鹏

修复bug,适配机型

parent 3eecf6d3
......@@ -4,8 +4,10 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
......@@ -16,6 +18,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="testRunner" value="PLATFORM" />
</GradleProjectSettings>
</option>
</component>
......
......@@ -51,10 +51,8 @@ android {
}
dependencies {
implementation fileTree(dir:'libs',include:['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
......@@ -104,7 +102,7 @@ ext {
GITHUB_REPO_PATH = "../../androidlibrary"
PUBLISH_GROUP_ID = 'cn.dankal.android'
PUBLISH_ARTIFACT_ID = 'launcher'
PUBLISH_VERSION = '1.3.9.1'
PUBLISH_VERSION = '1.4.1.1'
}
uploadArchives {
......@@ -130,4 +128,4 @@ task androidSourcesJar(type: Jar) {
artifacts {
archives androidSourcesJar
}
\ No newline at end of file
}
<?xml version="1.0" encoding="utf-8"?><!--
/*
**
** Copyright 2016, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.launcher3">
<!--
The manifest defines the common entries that should be present in any derivative of Launcher3.
The components should generally not require any changes.
......@@ -40,7 +22,7 @@
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signatureOrSystem" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"></uses-permission>
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission
......@@ -50,37 +32,29 @@
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signatureOrSystem" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="${applicationId}.permission.READ_SETTINGS" />
<uses-permission android:name="${applicationId}.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.BIND_APPWIDGET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"></uses-permission>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"></uses-permission>
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!-- 显示系统窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 在 屏幕最顶部显示addview-->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <!-- 显示系统窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 在 屏幕最顶部显示addview -->
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<application
android:backupAgent="com.android.launcher3.LauncherBackupAgent"
android:backupAgent=".LauncherBackupAgent"
android:fullBackupContent="@xml/backupscheme"
android:fullBackupOnly="true"
android:hardwareAccelerated="true"
......@@ -88,7 +62,7 @@
android:restoreAnyVersion="true">
<activity
android:name="com.android.launcher3.Launcher"
android:name=".Launcher"
android:clearTaskOnLaunch="true"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:enabled="true"
......@@ -101,49 +75,41 @@
android:taskAffinity=""
android:windowSoftInputMode="adjustPan">
<intent-filter>
<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>
</activity>
<!-- Intent received used to install shortcuts from other applications -->
</activity> <!-- Intent received used to install shortcuts from other applications -->
<receiver
android:name="com.android.launcher3.InstallShortcutReceiver"
android:name=".InstallShortcutReceiver"
android:enabled="@bool/enable_install_shortcut_api"
android:permission="${applicationId}.permission.INSTALL_SHORTCUT">
<intent-filter>
<action android:name="${applicationId}.action.INSTALL_SHORTCUT" />
</intent-filter>
</receiver>
<!-- Intent received when a session is committed -->
<receiver android:name="com.android.launcher3.SessionCommitReceiver">
</receiver> <!-- Intent received when a session is committed -->
<receiver android:name=".SessionCommitReceiver">
<intent-filter>
<action android:name="android.content.pm.action.SESSION_COMMITTED" />
</intent-filter>
</receiver>
<!-- Intent received used to initialize a restored widget -->
<receiver android:name="com.android.launcher3.AppWidgetsRestoredReceiver">
</receiver> <!-- Intent received used to initialize a restored widget -->
<receiver android:name=".AppWidgetsRestoredReceiver">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_HOST_RESTORED" />a
<action android:name="android.appwidget.action.APPWIDGET_HOST_RESTORED" />
a
</intent-filter>
</receiver>
<service
android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
android:name=".uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"
android:process=":wallpaper_chooser" />
<service
android:name="com.android.launcher3.notification.NotificationListener"
android:name=".notification.NotificationListener"
android:enabled="@bool/notification_badging_enabled"
android:label="@string/icon_badging_service_title"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
......@@ -157,7 +123,7 @@
android:value="true" />
<activity
android:name="com.android.launcher3.dragndrop.AddItemActivity"
android:name=".dragndrop.AddItemActivity"
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
android:label="@string/action_add_to_workspace"
......@@ -167,26 +133,23 @@
<action android:name="android.content.pm.action.CONFIRM_PIN_APPWIDGET" />
</intent-filter>
</activity>
<activity
android:name=".LockScreenActivity"
android:excludeFromRecents="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:taskAffinity="${applicationId}.lockscreen"
android:theme="@style/LockScreenStyle"></activity>
android:theme="@style/LockScreenStyle" />
<activity
android:name=".HelpActivity"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".debug.DebugInfoActivity"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity android:name=".debug.SearchAppCanUseActivity"
android:screenOrientation="portrait"></activity>
<activity
android:name=".debug.SearchAppCanUseActivity"
android:screenOrientation="portrait" />
<!--
Should point to the content provider which can be used to dump Launcher3 compatible
worspace configuration to the dump's file descriptor by using launcher_dump.proto
......@@ -195,46 +158,32 @@
android:name="com.android.launcher3.launcher_dump_provider"
android:value="com.android.launcher3.LauncherProvider" />
<service android:name=".accessibility.ListenerAppService"></service>
<service android:name=".accessibility.ListenerAppService" />
<provider
android:name="com.android.launcher3.LauncherProvider"
android:name=".LauncherProvider"
android:authorities="${applicationId}.settings"
android:exported="true"
android:readPermission="com.android.launcher3.permission.READ_SETTINGS"
android:writePermission="com.android.launcher3.permission.WRITE_SETTINGS" />
<provider
android:name="com.android.launcher3.provider.ManagerAppProvider"
android:name=".provider.ManagerAppProvider"
android:authorities="${applicationId}.management"
android:exported="false"></provider>
<!-- <service-->
<!-- android:name=".accessibility.AppManagerAccessiblityService"-->
<!-- android:description="@string/app_manager_accessibility_service_description"-->
<!-- android:label="@string/app_manager_accessibility_service_label"-->
<!-- android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.accessibilityservice.AccessibilityService" />-->
<!-- </intent-filter>-->
<!-- <meta-data-->
<!-- android:name="android.accessibilityservice"-->
<!-- android:resource="@xml/accessibility_service_config" />-->
<!-- </service>-->
android:exported="false" /> <!-- <service -->
<!-- android:name=".accessibility.AppManagerAccessiblityService" -->
<!-- android:description="@string/app_manager_accessibility_service_description" -->
<!-- android:label="@string/app_manager_accessibility_service_label" -->
<!-- android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> -->
<!-- <intent-filter> -->
<!-- <action android:name="android.accessibilityservice.AccessibilityService" /> -->
<!-- </intent-filter> -->
<!-- <meta-data -->
<!-- android:name="android.accessibilityservice" -->
<!-- android:resource="@xml/accessibility_service_config" /> -->
<!-- </service> -->
<service
android:name=".accessibility.FloatWindowService"
android:process=":lock">
</service>
<!--设备管理-->
android:process=":lock"></service> <!-- 设备管理 -->
<receiver
android:name=".accessibility.DeviceReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN">
......@@ -249,14 +198,20 @@
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<receiver android:name=".accessibility.AutoRunReceiver">
<intent-filter android:priority="2147483647">
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".accessibility.StopRunReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
</manifest>
\ No newline at end of file
......@@ -150,7 +150,7 @@ public class CellLayout extends ViewGroup {
private boolean mDragging = false;
private final TimeInterpolator mEaseOutInterpolator;
private final ShortcutAndWidgetContainer mShortcutsAndWidgets;
public final ShortcutAndWidgetContainer mShortcutsAndWidgets;
@Retention(RetentionPolicy.SOURCE)
@IntDef({WORKSPACE, HOTSEAT, FOLDER})
......@@ -2444,25 +2444,31 @@ public class CellLayout extends ViewGroup {
int numRows = mLauncher.getDeviceProfile().inv.numRows;
if (mShortcutsAndWidgets != null) {
ItemInfo itemInfo = mShortcutsAndWidgets.getLastItemInfo();
Log.i("launcher_shortcut_index", "上一个应用:名字" + itemInfo.title + "坐标(" + itemInfo.cellX + "," + itemInfo.cellY + ")");
if (itemInfo != null) {
if (itemInfo.cellY + itemInfo.spanY - 1 + spanY >= numRows && itemInfo.cellX + itemInfo.spanX - 1 + spanX >= numColumns) {
// 需要添加的cell长度已经不足以放下
Logger.e(TAG, "itemInfo.cellY(" + itemInfo.cellY + ") + itemInfo.spanY(" + itemInfo.spanY + ") - 1 + " + spanY + " >= " + numRows);
Log.i("launcher_shortcut_index", "不足放下itemInfo.cellY(" + itemInfo.cellY + ") + itemInfo.spanY(" + itemInfo.spanY + ") - 1 + " + spanY + " >= " + numRows);
return false;
}
if (itemInfo.cellX + itemInfo.spanX - 1 + spanX < numColumns) {
cellXY[0] = itemInfo.cellX + itemInfo.spanX;
if (spanY == 1) {
cellXY[1] = itemInfo.cellY;
Log.i("launcher_shortcut_index", "当前图标坐标:x" + cellXY[0] + "\ty" + cellXY[1]);
return true;
}else if (itemInfo.cellY + itemInfo.spanY - 1 + spanY >= numRows){
} else if (itemInfo.cellY + itemInfo.spanY - 1 + spanY >= numRows) {
Log.i("launcher_shortcut_index", "不足放下itemInfo.cellY(" + itemInfo.cellY + ") + itemInfo.spanY(" + itemInfo.spanY + ") - 1 + " + spanY + " >= " + numRows);
Logger.e(TAG, "itemInfo.cellY(" + itemInfo.cellY + ") + itemInfo.spanY(" + itemInfo.spanY + ") - 1 + " + spanY + " >= " + numRows);
return false;
}
} else if (itemInfo.cellY + itemInfo.spanY - 1 + spanY < numRows){
} else if (itemInfo.cellY + itemInfo.spanY - 1 + spanY < numRows) {
cellXY[0] = 0;
cellXY[1] = itemInfo.cellY + 1;
Log.i("launcher_shortcut_index", "当前图标坐标:x" + cellXY[0] + "\ty" + cellXY[1]);
return true;
// 在最后一个cell的末尾添加不了 那就在下一行计算
}
......
......@@ -169,7 +169,7 @@ public class FastBitmapDrawable extends Drawable {
canvas.drawBitmap(mBitmap, null, bounds, mPaint);
if (info != null) {
if (info != null && info.getIntent()!=null) {
ManagementInfo managementInfo = LauncherManager.getInstance().getManageAppInfo(info.getIntent().getComponent().getPackageName());
if (managementInfo != null) {
......
......@@ -32,6 +32,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActivityOptions;
import android.appwidget.AppWidgetHostView;
......@@ -59,6 +60,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
import android.os.Process;
import android.os.StrictMode;
......@@ -68,9 +70,13 @@ import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.ObservableSource;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
......@@ -87,6 +93,7 @@ import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
......@@ -115,6 +122,7 @@ import com.android.launcher3.logging.FileLog;
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.model.ModelWriter;
import com.android.launcher3.model.PackageUpdatedTask;
import com.android.launcher3.notification.NotificationListener;
......@@ -140,11 +148,14 @@ import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
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.SystemUiController;
import com.android.launcher3.util.SystemUtils;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TimeUtils;
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.OptionsPopupView;
......@@ -305,6 +316,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override
protected void onCreate(Bundle savedInstanceState) {
if (DEBUG_STRICT_MODE) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
......@@ -322,6 +334,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
TraceHelper.beginSection("Launcher-onCreate");
super.onCreate(savedInstanceState);
if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("launch_debug_show", "Launcher_onNewIntent关闭了对话框");
}
TraceHelper.partitionSection("Launcher-onCreate", "super call");
LauncherAppState app = LauncherAppState.getInstance(this);
......@@ -408,6 +427,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Constants.ACTION_UPDATE_ICON);
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter);
if (PermissionUtil.isDefaultHome(this)) {
}
}
@Override
......@@ -849,6 +872,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
@Override
protected void onStop() {
super.onStop();
FirstFrameAnimatorHelper.setIsVisible(false);
if (mLauncherCallbacks != null) {
......@@ -866,6 +890,13 @@ 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 (PermissionUtil.isSystemUI) {
Log.i(TAG, "隐藏快捷方式");
PermissionUtil.initLauncherIconIsShow(this, false);
}
}
}
@Override
......@@ -886,6 +917,31 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
getUserEventDispatcher().logActionCommand(Action.Command.RESUME,
mStateManager.getState().containerType, -1);
getUserEventDispatcher().startSession();
Log.i("launch_debug_show", "logOnDelayedResume");
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);
LauncherManager.getInstance().changeExitState(false);//开启管制
if (SystemUtils.isOPPO()) {
//刷新页面显示图标
//PermissionUtil.initLauncherIconIsShow(this, true);
UIExecutor.postRunableDelay(new Runnable() {
@Override
public void run() {
needRefresh = true;
LauncherManager.getInstance().changeExitState(false);//开启管制
LauncherManager.getInstance().refreshLauncherIconWidget(Launcher.this.getPackageName());
}
}, 2000);
}
}
}
......@@ -1338,6 +1394,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
TraceHelper.beginSection("NEW_INTENT");
super.onNewIntent(intent);
boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags() &
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
......@@ -1397,6 +1454,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
TraceHelper.endSection("NEW_INTENT");
judgeDialogShow(intent);
}
private void judgeDialogShow(Intent intent) {
......@@ -1409,7 +1467,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
return;
}
if (intent.hasExtra(Constants.DIALOG_STRING_KEY_VALUE) && !TextUtils.isEmpty(intent.getStringExtra(Constants.DIALOG_STRING_KEY_VALUE))) {
showTipDialog(intent.getStringExtra(Constants.DIALOG_STRING_KEY_VALUE));
}
......@@ -2289,8 +2346,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
anim.start();
} else if (executor != null) {
executor.onLoadAnimationCompleted();
}
Log.i("launch_debug_show", "finishFirstPageBind");
}
/**
......@@ -2386,6 +2445,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
int numRows = getDeviceProfile().inv.numRows;
ItemInfo itemInfo = lastItenInfo;
Log.i("launcher_shortcut", "上一个坐标" + itemInfo.cellX + ":" + itemInfo.cellY);
if (itemInfo.cellX >= 0) {
if (itemInfo.cellY + itemInfo.spanY - 1 + spanY >= numRows && itemInfo.cellX + itemInfo.spanX - 1 + spanX >= numColumns) {
......@@ -2430,9 +2490,135 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
* @param added
* @param user
*/
@SuppressLint("CheckResult")
@Override
public void bindShortcutsAdd(ArrayList<ShortcutInfo> added, UserHandle user) {
Log.i("launcher_shortcut", "开始创建快捷方式");
if (!added.isEmpty()) {
/* Observable.fromIterable(added)
.concatMap(new Function<ShortcutInfo, ObservableSource<ShortcutInfo>>() {
@Override
public ObservableSource<ShortcutInfo> apply(ShortcutInfo shortcutInfo) throws Exception {
return Observable.create(new ObservableOnSubscribe<ShortcutInfo>() {
@Override
public void subscribe(ObservableEmitter<ShortcutInfo> emitter) throws Exception {
int screenColunms = mDeviceProfile.inv.numColumns;
int screenRows = mDeviceProfile.inv.numRows;
Log.i("launcher_shortcut", "screenColunms" + screenColunms + "\tscreenRows" + screenColunms);
ArrayList<Long> workspaceScreens = LauncherModel.loadWorkspaceScreensDb(getApplicationContext());
long currentLastScreenId = workspaceScreens.get(workspaceScreens.size() - 1).longValue();
long lastScreenId = currentLastScreenId;
// 在新的CellLayout创建快捷方式的位置
int index = 0;
// 是否是第一次添加桌面图标
boolean isFirst = true;
// 上一个添加Cell的位置信息
ItemInfo lastInfo = new ItemInfo();
CellLayout lastCellLayout = (CellLayout) mWorkspace.getChildAt(mWorkspace.getChildCount() - 1);
final ContentWriter writer = new ContentWriter(getApplicationContext());
final ContentResolver cr = getApplicationContext().getContentResolver();
final Uri favoritesUri = LauncherSettings.Favorites.CONTENT_URI;
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
int[] cell = new int[2];
boolean finded = false;
if (isFirst) {
finded = lastCellLayout.findEmptyCellForSpan(cell, 1, 1);
isFirst = false;
} else {
finded = findEmptyCellForSpan(lastInfo, cell, 1, 1);
}
Log.i("launcher_shortcut", "finded" + finded);
long itemId = LauncherSettings.Settings.call(cr, LauncherSettings.Settings.METHOD_NEW_ITEM_ID).getLong(LauncherSettings.Settings.EXTRA_VALUE);
if (finded) {
Log.i("launcher_shortcut", "最后一屏找到可以安放的空间");
// 最后一屏找到可以安放的空间
shortcutInfo.cellX = cell[0];
shortcutInfo.cellY = cell[1];
lastInfo = shortcutInfo;
Log.i("launcher_shortcut", "cellX" + cell[0] + "\tcellY" + cell[1]);
} else {
Log.i("launcher_shortcut", "将图标放在下一屏");
// 将图标放在下一屏
lastScreenId = LauncherSettings.Settings.call(cr,
LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
.getLong(LauncherSettings.Settings.EXTRA_VALUE);
workspaceScreens.add(lastScreenId);
shortcutInfo.cellX = index % screenColunms;
shortcutInfo.cellY = (index) % (screenRows * screenColunms) / screenRows;
index += 1;
lastInfo = shortcutInfo;
}
shortcutInfo.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
shortcutInfo.id = itemId;
shortcutInfo.rank = (int) itemId;
shortcutInfo.screenId = lastScreenId;
// 高清图标
shortcutInfo.usingLowResIcon = false;
shortcutInfo.onAddToDatabase(writer);
ContentValues values = writer.getValues(getApplicationContext());
writer.put(LauncherSettings.Favorites._ID, shortcutInfo.id);
writer.put(LauncherSettings.Favorites.CELLX, shortcutInfo.cellX);
writer.put(LauncherSettings.Favorites.CELLY, shortcutInfo.cellY);
writer.put(LauncherSettings.Favorites.INTENT, shortcutInfo.getIntent());
writer.put(LauncherSettings.Favorites.TITLE, shortcutInfo.title);
writer.put(LauncherSettings.Favorites.ITEM_TYPE, shortcutInfo.itemType);
writer.put(LauncherSettings.Favorites.SPANX, shortcutInfo.spanX);
writer.put(LauncherSettings.Favorites.SPANY, shortcutInfo.spanY);
writer.put(LauncherSettings.Favorites.CONTAINER, shortcutInfo.container);
ops.add(ContentProviderOperation.newInsert(favoritesUri).withValues(values).build());
// cr.insert(favoritesUri,values);
Logger.e(TAG, "bindShortcutsAdd\t" + shortcutInfo.toString());
cr.applyBatch(LauncherProvider.AUTHORITY, ops);
if (lastScreenId != currentLastScreenId) {
LauncherModel.updateWorkspaceScreenOrder(getApplicationContext(), workspaceScreens);
Logger.e(TAG, "bindShortcutsAdd insertNewWorkspaceScreen");
}
emitter.onNext(shortcutInfo);
emitter.onComplete();
}
}).subscribeOn(Schedulers.io());
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ShortcutInfo>() {
@Override
public void accept(ShortcutInfo shortcutInfo) throws Exception {
long currentLastScreenId = mWorkspace.getScreenOrder().get(mWorkspace.getScreenOrder().size() - 1).longValue();
CellLayout lastCellLayout = (CellLayout) mWorkspace.getChildAt(mWorkspace.getChildCount() - 1);
View mView;
if (shortcutInfo.screenId != currentLastScreenId) {
lastCellLayout = mWorkspace.insertNewWorkspaceScreen(shortcutInfo.screenId, mWorkspace.getChildCount());
}
mView = createShortcut(lastCellLayout, shortcutInfo);
mWorkspace.addInScreen(mView, shortcutInfo);
}
});*/
Observable.just(added).subscribeOn(Schedulers.io())
.map(new Function<ArrayList<ShortcutInfo>, ArrayList<ShortcutInfo>>() {
@Override
......@@ -2440,6 +2626,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
int screenColunms = mDeviceProfile.inv.numColumns;
int screenRows = mDeviceProfile.inv.numRows;
Log.i("launcher_shortcut", "screenColunms" + screenColunms + "\tscreenRows" + screenColunms);
ArrayList<Long> workspaceScreens = LauncherModel.loadWorkspaceScreensDb(getApplicationContext());
long currentLastScreenId = workspaceScreens.get(workspaceScreens.size() - 1).longValue();
......@@ -2457,6 +2645,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
for (int i = 0; i < shortcutInfos.size(); i++) {
ShortcutInfo shortcutInfo = shortcutInfos.get(i);
Log.i("launcher_title", "title" + shortcutInfo.title);
int[] cell = new int[2];
boolean finded = false;
......@@ -2466,16 +2655,21 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
} else {
finded = findEmptyCellForSpan(lastInfo, cell, 1, 1);
}
Log.i("launcher_shortcut", "finded" + finded);
long itemId = LauncherSettings.Settings.call(cr, LauncherSettings.Settings.METHOD_NEW_ITEM_ID).getLong(LauncherSettings.Settings.EXTRA_VALUE);
if (finded) {
Log.i("launcher_shortcut", "最后一屏找到可以安放的空间");
// 最后一屏找到可以安放的空间
shortcutInfo.cellX = cell[0];
shortcutInfo.cellY = cell[1];
lastInfo = shortcutInfo;
Log.i("launcher_shortcut", "cellX" + cell[0] + "\tcellY" + cell[1]);
} else {
Log.i("launcher_shortcut", "将图标放在下一屏");
// 将图标放在下一屏
lastScreenId = LauncherSettings.Settings.call(cr,
LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
......@@ -2491,6 +2685,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
lastInfo = shortcutInfo;
}
if (lastInfo.id != lastCellLayout.mShortcutsAndWidgets.getId()) {
lastCellLayout.mShortcutsAndWidgets.setLastItemInfo(lastInfo);
}
shortcutInfo.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
shortcutInfo.id = itemId;
......@@ -2545,7 +2742,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
ShortcutInfo shortcutInfo = added.get(i);
View mView;
if (shortcutInfo.screenId != currentLastScreenId) {
lastCellLayout = mWorkspace.insertNewWorkspaceScreen(shortcutInfo.screenId, mWorkspace.getChildCount());
try {
lastCellLayout = mWorkspace.insertNewWorkspaceScreen(shortcutInfo.screenId, mWorkspace.getChildCount());
} catch (Exception e) {
e.printStackTrace();
}
}
mView = createShortcut(lastCellLayout, shortcutInfo);
......@@ -2565,7 +2766,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
});
// mWorkspace.addInScreen();
}
......
......@@ -21,6 +21,7 @@ import android.os.StrictMode;
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
......@@ -94,6 +95,12 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("qqqqqqqqqqqq", "LockScreenActivity关闭了对话框");
}
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();
......@@ -129,6 +136,12 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
@Override
protected void onNewIntent(Intent intent) {
if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("qqqqqqqqqqqq", "LockScreenActivity关闭了进度条"+Thread.currentThread());
}
if (lockMode != LauncherManager.getInstance().getLockScreenMode()) {
lockMode = LauncherManager.getInstance().getLockScreenMode();
......@@ -267,7 +280,7 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
} else if (v == ivCamera) {
// Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED){
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String rootPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
......@@ -280,8 +293,8 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imagePath));// 设置图片输出路径
imageCaptureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //
startActivity(imageCaptureIntent);
}else {
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},100);
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
}
} else if (v == ivMessage) {
......@@ -315,7 +328,7 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (imagePath!=null){
if (imagePath != null) {
try {
MediaStore.Images.Media.insertImage(getContentResolver(), imagePath.getAbsolutePath(), imagePath.getName(), null);//图片插入到系统图库
} catch (FileNotFoundException e) {
......@@ -323,7 +336,7 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + imagePath.getAbsolutePath())));//通知图库刷新
imagePath=null;
imagePath = null;
}
}
......
......@@ -214,6 +214,10 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
return mLastItemInfo;
}
public void setLastItemInfo(ItemInfo mLastItemInfo) {
this.mLastItemInfo = mLastItemInfo;
}
@Override
public void cancelLongPress() {
super.cancelLongPress();
......
......@@ -4,20 +4,40 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
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.UIExecutor;
/**
* 开机自启动接收器
*/
public class AutoRunReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context mContext, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
//PermissionUtil.initLauncherIconIsShow(mContext,true);
Intent intent2 = new Intent(mContext, ListenerAppService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mContext.startForegroundService(intent2);
} else {
mContext.startService(intent2);
}
try {
if (LauncherManager.mCustomDialog == null) {
LauncherManager.mCustomDialog = new CustomDialog(mContext, R.layout.activity_clock_alarm);
LauncherManager.mCustomDialog.show();
Log.i("launch_debug_show", "开机显示了进度条");
}
} catch (Exception e) {
e.printStackTrace();
}
//重启之后启动桌面
LauncherManager.getInstance().backLauncherHome(mContext.getApplicationContext());
}
}
}
package com.android.launcher3.accessibility;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
......@@ -19,7 +20,11 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.WindowManager;
import com.android.launcher3.R;
import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.manager.ColumnDef;
import com.android.launcher3.manager.Constants;
import com.android.launcher3.manager.LauncherManager;
......@@ -27,8 +32,13 @@ import com.android.launcher3.manager.ManagementInfo;
import com.android.launcher3.model.ConfigManager;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.NotificationUtils;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import com.android.launcher3.util.UIExecutor;
import com.android.launcher3.util.WeakHandler;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
......@@ -71,6 +81,7 @@ public class ListenerAppService extends Service {
private ExecutorService executors;
@SuppressLint("HandlerLeak")
private WeakHandler handler = new WeakHandler(this) {
@Override
public void handleMessage(Message msg) {
......@@ -143,7 +154,7 @@ public class ListenerAppService extends Service {
//动态注册广播
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
// intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_USER_PRESENT);
// intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
//启动广播
......@@ -216,24 +227,36 @@ public class ListenerAppService extends Service {
Logger.e(TAG, action);
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
if (!LauncherManager.getInstance().getExitState()) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
Logger.e(TAG, action + "\t" + reason);
if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
//PermissionUtil.initLauncherIconIsShow(context,false);
// "Home键被监听"
if (!LauncherManager.getInstance().isForceLock()) {
Log.i("launch_debug_show", "Home键监听");
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
} else {
// LauncherManager.getInstance().relockScreen();
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
LauncherManager.getInstance().relockScreen();
}
} else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
} else if (reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {//多任务监听
if (!LauncherManager.getInstance().isForceLock()) {
Log.i("launch_debug_show", "多任务按钮监听");
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
} else {
// LauncherManager.getInstance().relockScreen();
showProgress(context);
LauncherManager.getInstance().backLauncherHome(getApplicationContext());
LauncherManager.getInstance().relockScreen();
}
} else if (reason.equals("globalactions")) {//电源键被长按
Log.i("launch_debug_show", "电源键被长按");
}
}
}
......@@ -251,6 +274,21 @@ public class ListenerAppService extends Service {
}
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.show();
Log.i("launch_debug_show", "显示了进度条");
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class CheckAppAsyncTask extends AsyncTask<Void, Void, Integer> {
private WeakHandler handler;
......@@ -312,8 +350,10 @@ public class ListenerAppService extends Service {
lastUseAppControlTimeStamp = currentMills;
if (topActivity.equals(context.getPackageName()))
Log.i("launch_debug_show", "当前顶部包名" + topActivity + "****" + "当前应用包名" + context.getPackageName());
if (topActivity.equals(context.getPackageName())) {
return -1;
}
if (LauncherManager.getInstance().isInterceptSystemSetting() && "com.android.settings".equals(topActivity)) {
......@@ -323,7 +363,6 @@ public class ListenerAppService extends Service {
ManagementInfo appinfo = LauncherManager.getInstance().getManageAppInfo(topActivity);
if (!LauncherManager.getInstance().isSafePackageName(topActivity) && !LauncherManager.getInstance().isSystemPackageName(topActivity)) {
if (appinfo != null) {
if (appinfo.getLock() == ColumnDef.LockApp.LOCKED) {
......@@ -344,7 +383,8 @@ public class ListenerAppService extends Service {
}
}
} else {
return APP_UNCLASS_TYPE;
//return APP_UNCLASS_TYPE;
return -1;
}
}
} else {
......@@ -364,6 +404,13 @@ public class ListenerAppService extends Service {
if (code != -1) {
handler.sendEmptyMessage(code);
}
/* if (code == 200) {
if (LauncherManager.mCustomDialog != null) {
LauncherManager.mCustomDialog.dismiss();
LauncherManager.mCustomDialog = null;
Log.i("launch_debug_show", "关闭了进度条=" + Thread.currentThread());
}
}*/
}
}
}
......
......@@ -20,6 +20,9 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;
import android.widget.Toast;
import com.android.launcher3.auto_get_permission.BaseAutoGetPermission;
import com.android.launcher3.auto_get_permission.GeneralAutoGetPermission;
......@@ -54,9 +57,13 @@ import io.reactivex.schedulers.Schedulers;
public class PermissionOpenAccessiblityService extends AccessibilityService {
private static final String TAG = "PermissionOpenAccessiblityService";
private static final String TAG_TOW = "permission_show_info";
private BaseAutoGetPermission permissionGetter;
// private boolean breadWhile = false;
private Handler handler = new Handler(Looper.getMainLooper());
@Override
protected void onServiceConnected() {
super.onServiceConnected();
......@@ -97,30 +104,73 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
//监听魅族默认桌面选择
Logger.e(TAG, "onAccessibilityEvent " + event.toString());
if (LauncherManager.getInstance().isInterceptSystemSetting())
AccessibilityNodeInfo rowNode = getRootInActiveWindow();//获取当前屏幕所有节点
if (rowNode != null) {
recycle(event, rowNode);
}
Log.i(TAG_TOW, "==============================================");
if (LauncherManager.getInstance().isInterceptSystemSetting()) {
return;
}
if (event == null || event.getClassName() == null) {
return;
}
if ((event.getPackageName().toString().equals(getApplicationContext().getPackageName()) && !TextUtils.isEmpty(event.getClassName()) && event.getClassName().toString().equals("android.widget.LinearLayout"))) {
Log.i("reqeustAutoStartUp", "GLOBAL_ACTION_BACK==返回");
performGlobalAction(GLOBAL_ACTION_BACK);
return;
}
Log.i("reqeustAutoStartUp", "event.getEventType()" + event.getEventType());
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
permissionGetter.operateAccessibilityEvent(event);
}
/* if (SystemUtils.isMEIZU()) {//处理魅族桌面
handlerMeizhuDefaultDesktop(event);
}*/
}
private boolean mIsSelectDefaultUse = false;
private void handlerMeizhuDefaultDesktop(AccessibilityEvent event) {
//点击事件
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) {
AccessibilityNodeInfo rowNode = event.getSource();
//先判断,默认使用改应用是否勾选
List<AccessibilityNodeInfo> selectViews = rowNode.findAccessibilityNodeInfosByText("默认使用该应用");
if (selectViews != null && selectViews.size() > 0) {
AccessibilityNodeInfo selectView = selectViews.get(0);
if (selectView.isChecked()) {
mIsSelectDefaultUse = true;
}
}
if (mIsSelectDefaultUse) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (nodeInfo.getText().equals("倍知守护孩子端")) {
Log.i("zzzzzzzzzzzzzzzzzzzz", "默认桌面设置成功");
PermissionUtil.mIsDefaultDesktop = true;
mIsSelectDefaultUse = false;
}
}
}
}
@Override
public void onInterrupt() {
......@@ -140,4 +190,36 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
super.onDestroy();
}
public void recycle(AccessibilityEvent event, AccessibilityNodeInfo info) {
if (info.getChildCount() == 0) {
Log.i(TAG_TOW, "child widget----------------------------" + info.getClassName());
Log.i(TAG_TOW, "showDialog:" + info.canOpenPopup());
Log.i(TAG_TOW, "Text:" + info.getText());
Log.i(TAG_TOW, "windowId:" + info.getWindowId());
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if (info.getChild(i) != null) {
recycle(event, info.getChild(i));
}
}
}
try {
Log.i("reqeustAutoStartUp", "当前界面包名:" + event.getPackageName() + "\n当前应用的包名:" + getApplicationContext().getPackageName());
Log.i("reqeustAutoStartUp", "当前界面类名:" + event.getClassName() + "\n当前应用类:" + "android.widget.LinearLayout");
//判断当前界面
if (event.getPackageName().equals("android")) {
Log.i("qqqqqqqqqqqqqqqqqqqq", "在系统界面");
PermissionUtil.isSystemUI = true;
} else {
PermissionUtil.isSystemUI = false;
}
} catch (Exception e) {
e.printStackTrace();
PermissionUtil.isSystemUI = false;
}
}
}
package com.android.launcher3.accessibility;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import com.android.launcher3.R;
import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.util.PermissionUtil;
/**
* 关机接收器
*/
public class StopRunReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context mContext, Intent intent) {
Log.i("launch_debug_show", "关机1");
if (intent.getAction().equals(Intent.ACTION_SHUTDOWN)){//关机
/**
* 隐藏图标
*/
//PermissionUtil.initLauncherIconIsShow(mContext,false);
Log.i("launch_debug_show", "关机2");
}
}
}
......@@ -10,6 +10,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.Settings;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
......@@ -20,23 +21,25 @@ import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import java.util.List;
import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BACK;
import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_HOME;
public abstract class BaseAutoGetPermission {
// 设备管理器
// 设备管理器
public static final int STEP_REQUEST_DEVICE_ADMIN = 1;
// 自启动
// 自启动
public static final int STEP_REQUEST_AUTO_STARTUP = 2;
// 忽略电量优化
// 忽略电量优化
public static final int STEP_REQUEST_BATTERY_OPTIMIZE = 3;
// 使用记录访问权限
public static final int STEP_REQUEST_APP_USAGE= 4;
// 关闭USB调试
// 使用记录访问权限
public static final int STEP_REQUEST_APP_USAGE = 4;
// 关闭USB调试
public static final int STEP_REQUEST_CLOSE_USB = 5;
// 通知访问使用权
public static final int STEP_REQUEST_NOTIFICATION_MANAGER= 6;
// 默认桌面
// 通知访问使用权
public static final int STEP_REQUEST_NOTIFICATION_MANAGER = 6;
// 默认桌面
public static final int STEP_REQUEST_DEFAULT_LAUNCHER = 7;
......@@ -44,9 +47,9 @@ public abstract class BaseAutoGetPermission {
public static final long MAX_SEARCH_TIME = 4000;
public static final int BREAK_WHILE = 2;
// public static String appName = "倍知守护孩子端";
public static String appName = "倍知守护孩子端";
public static String appName = "dankal_launcher";
//public static String appName = "dankal_launcher";
public boolean isRunning;
private KToast toast;
......@@ -74,8 +77,12 @@ public abstract class BaseAutoGetPermission {
handler.sendEmptyMessageDelayed(0, 1000);
// Logger.e(TAG, "onServiceConnected\t");
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
showToastLong("辅助权限设置已开启,请根据提示点击,如无提示请等待片刻");
if (toast != null) {
toast.dismiss();
toast = null;
}
toast = new KToast(service.getApplicationContext());
showToastLongTow("辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面");
}
private boolean isFinish = false;
......@@ -92,6 +99,8 @@ public abstract class BaseAutoGetPermission {
public void operateAccessibilityEvent(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "operateAccessibilityEvent");
if (step == STEP_REQUEST_DEVICE_ADMIN) {
if (event.getClassName() != null) {
......@@ -118,15 +127,16 @@ public abstract class BaseAutoGetPermission {
}
if (step == STEP_REQUEST_AUTO_STARTUP) {
if (event.getClassName() != null) {
if (event.getSource() == null)
return;
if (PermissionUtil.checkAutoStartUp(getApplicationContext())) {
Log.i("reqeustAutoStartUp", "已经有了自启动");
resetStep();
} else {
reqeustAutoStartUp(event);
}
......@@ -143,9 +153,10 @@ public abstract class BaseAutoGetPermission {
if (event.getSource() != null) {
if (PermissionUtil.checkBatteryOptimize(getApplicationContext())) {
Log.i("reqeustAutoStartUp", "已经忽略电量优化");
resetStep();
} else {
Log.i("reqeustAutoStartUp", "没有忽略电量优化");
requestBatteryOptimize(event);
}
}
......@@ -156,8 +167,10 @@ public abstract class BaseAutoGetPermission {
if (event.getClassName() != null) {
if (event.getSource() != null) {
if (PermissionUtil.checkAppUsagePermission(getApplicationContext())) {
Log.i("reqeustAutoStartUp", "已经有了用户使用权限");
resetStep();
} else {
Log.i("reqeustAutoStartUp", "没有了用户使用权限");
requestUsageAppPermission(event);
}
}
......@@ -211,7 +224,6 @@ public abstract class BaseAutoGetPermission {
}
if (!PermissionUtil.checkDeviceAdminPermission(getApplicationContext())) {
......@@ -397,12 +409,24 @@ public abstract class BaseAutoGetPermission {
}
public void showToastLong(String msg) {
handler.post(new Runnable() {
@Override
public void run() {
Logger.e(TAG, "showToastLong\t" + msg);
toast.setText("倍知守护提醒您 : \n" + msg);
toast.setText(msg);
toast.show();
}
});
}
public void showToastLongTow(String msg) {
handler.post(new Runnable() {
@Override
public void run() {
Logger.e(TAG, "showToastLong\t" + msg);
toast.setText(msg);
toast.show();
}
});
......
......@@ -67,9 +67,11 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
sleep();//等待应用扫描完成
sleepLongLong();
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity".equals(event.getClassName())) {
if ("com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity".equals(event.getClassName())
|| "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity".equals(event.getClassName())) {
List<AccessibilityNodeInfo> listViewNodeList = sourceNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/lv_listview");
if (listViewNodeList != null && listViewNodeList.size() > 0) {
......@@ -77,8 +79,9 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
AccessibilityNodeInfo listViewNode = listViewNodeList.get(0);
AccessibilityNodeInfo targetAppNode = getChildNodeByIdEqualText(listViewNode, "com.huawei.systemmanager:id/tv_title", appName);
long time = System.currentTimeMillis();
while (targetAppNode == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
//long time = System.currentTimeMillis();
//while (targetAppNode == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
while (targetAppNode == null) {
if (listViewNode.isScrollable()) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
......@@ -101,26 +104,9 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
sleep();
} else {
showToastLong("请找到【" + appName + "】并点击右侧的按钮");
// List<AccessibilityNodeInfo> manualBtnList = sourceNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/listitem_all_manual");
// long time2 = System.currentTimeMillis();
//
// while ((manualBtnList == null || manualBtnList.size() <= 0) && System.currentTimeMillis() - time2 < MAX_SEARCH_TIME) {
// if (listViewNode.isScrollable()) {
// listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
// sleepShort();
// listViewNode.refresh();
// } else {
// break;
// }
//
// manualBtnList = sourceNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/listitem_all_manual");
// }
//
// if (manualBtnList.size() > 0 && manualBtnList.get(0).getParent() != null) {
// manualBtnList.get(0).getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
// sleep();
// }
}
}else {
return;
}
} else {
showToastLong("请找到【" + appName + "】并点击右侧的按钮");
......@@ -144,6 +130,7 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
sleepShort();
}
}
sleepShort();
PermissionUtil.isAutoStartUp = true;
//
// performGlobalAction(GLOBAL_ACTION_BACK);
......@@ -207,137 +194,159 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
// PermissionUtil.isIgnoreBatteryOptimize = true;
// resetStep();
PermissionUtil.isAutoStartUp = true;
resetStep();
}
}
}
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
sleepLong();//等待应用扫描完成
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity".equals(event.getClassName())) {
long time2 = System.currentTimeMillis();
if ("com.android.settings.Settings$HighPowerApplicationsActivity".equals(event.getClassName())) {
boolean loadFinish = false;
do {
AccessibilityNodeInfo allAppNodeInfo = getChildNodeEqual(sourceNode, "所有应用");
AccessibilityNodeInfo nodeInfo = getChildNodeEqual(sourceNode, "允许");
if (allAppNodeInfo != null) {
loadFinish = true;
getChildNodeEqual(sourceNode, appName);
List<AccessibilityNodeInfo> listViewNodeList = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodeList != null && listViewNodeList.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodeList.get(0);
AccessibilityNodeInfo targetAppNode = getChildNodeEqual(listViewNode, appName);
long time = System.currentTimeMillis();
while (nodeInfo == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode.isScrollable()) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
targetAppNode = getChildNodeEqual(listViewNode, appName);
}
if (performAction(targetAppNode, AccessibilityNodeInfo.ACTION_CLICK)) {
Logger.e(TAG, "忽略电池\t" + targetAppNode.toString());
sleepShort();
} else {
showToastLong("请找到【" + appName + "】并点击");
return;
}
}
List<AccessibilityNodeInfo> listViewNodeList = sourceNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/lv_listview");
if (listViewNodeList != null && listViewNodeList.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodeList.get(0);
} else {
if (performAction(nodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
loadFinish = true;
nodeInfo.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
AccessibilityNodeInfo targetAppNode = getChildNodeByIdEqualText(listViewNode, "com.huawei.systemmanager:id/tv_title", appName);
//long time = System.currentTimeMillis();
//while (targetAppNode == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
while (targetAppNode == null) {
if (listViewNode.isScrollable()) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
showToastLong("请点击【允许】");
return;
break;
}
targetAppNode = getChildNodeByIdEqualText(listViewNode, "com.huawei.systemmanager:id/tv_title", appName);
}
} while (!loadFinish && System.currentTimeMillis() - time2 < MAX_SEARCH_TIME);
// 将自动管理的swicher关闭
if (targetAppNode != null && targetAppNode.getParent() != null) {
List<AccessibilityNodeInfo> switcherNodes = targetAppNode.getParent().findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/switcher");
}
if (switcherNodes != null && switcherNodes.size() > 0) {
if ("android.widget.FrameLayout".equals(event.getClassName())) {
AccessibilityNodeInfo nodeInfo = getChildNodeEqual(sourceNode, "所有应用");
if (performAction(nodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepLongLong();
sourceNode.refresh();
operateAccessibilityEvent(event);
if (switcherNodes.get(0).isChecked()) {
if (switcherNodes.get(0).isCheckable() && performAction(switcherNodes.get(0), AccessibilityNodeInfo.ACTION_CLICK)) {
sleep();
} else {
showToastLong("请找到【" + appName + "】并点击右侧的按钮");
}
}
} else {
showToastLong("请找到【" + appName + "】并点击右侧的按钮");
}
} else {
showToastLong("请找到【" + appName + "】并点击右侧的按钮");
}
} else {
showToastLong("请点击【所有应用】");
return;
showToastLong("请找到【" + appName + "】并点击右侧的按钮");
}
}
if ("android.app.AlertDialog".equals(event.getClassName())) {
if (event.getText() != null && event.getText().toString().contains(appName)) {
AccessibilityNodeInfo acceptTvNode = getChildNodeEqual(sourceNode, "允许");
AccessibilityNodeInfo allowNode = getChildNodeEqual(sourceNode, "允许");
if (allowNode == null) {
allowNode = getChildNodeEqual(sourceNode, "确定");
}
if (performAction(allowNode, AccessibilityNodeInfo.ACTION_CLICK)) {
sleep();
resetStep();
} else {
showToastLong("请点击【确定】");
return;
}
if (acceptTvNode != null && acceptTvNode.getParent() != null) {
acceptTvNode.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
sleepShort();
if ("com.huawei.systemmanager.appcontrol.activity.BatchManuControlActivity".equals(event.getClassName())) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodes.get(0);
AccessibilityNodeInfo deterBtnNode = getChildNodeEqual(sourceNode, "确定");
if (performAction(deterBtnNode, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
AccessibilityNodeInfo nodeInfo = getChildNodeByIdEqualText(listViewNode, "com.huawei.systemmanager:id/tv_title", appName);
long time = System.currentTimeMillis();
while (nodeInfo == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode.isScrollable()) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
showToastLong("请点击【确定/允许】");
return;
break;
}
nodeInfo = getChildNodeByIdEqualText(listViewNode, "com.huawei.systemmanager:id/tv_title", appName);
}
if (nodeInfo != null && nodeInfo.getParent() != null) {
AccessibilityNodeInfo linearNode = nodeInfo.getParent();
} else {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
}
}
List<AccessibilityNodeInfo> checkBoxNodeList = linearNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/auto_checkbox");
if ("android.app.Dialog".equals(event.getClassName()) && event.getText() != null && event.getText().contains(appName)) {
AccessibilityNodeInfo acceptTvNode = getChildNodeEqual(sourceNode, "允许");
if (checkBoxNodeList != null && checkBoxNodeList.size() > 0) {
if (!checkBoxNodeList.get(0).isChecked()) {
checkBoxNodeList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
}
if (acceptTvNode != null && acceptTvNode.getParent() != null) {
acceptTvNode.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
List<AccessibilityNodeInfo> checkBoxNode2List = linearNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/associate_checkbox");
sleepShort();
if (checkBoxNode2List != null && checkBoxNode2List.size() > 0) {
if (!checkBoxNode2List.get(0).isChecked()) {
checkBoxNode2List.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
}
List<AccessibilityNodeInfo> checkBoxNode3List = linearNode.findAccessibilityNodeInfosByViewId("com.huawei.systemmanager:id/background_checkbox");
if (checkBoxNode3List != null && checkBoxNode3List.size() > 0) {
if (!checkBoxNode3List.get(0).isChecked()) {
checkBoxNode3List.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
}
// PermissionUtil.isIgnoreBatteryOptimize = true;
// resetStep();
PermissionUtil.isAutoStartUp = true;
AccessibilityNodeInfo deterBtnNode = getChildNodeEqual(sourceNode, "确定");
if (performAction(deterBtnNode, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else {
showToastLong("请点击【确定/允许】");
return;
}
}
}
resetStep();
}
@Override
public void requestUsageAppPermission(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
AccessibilityNodeInfo sourceNode = event.getSource();//获取当前节点信息
if ("com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName())) {
getChildNodeEqual(sourceNode, appName);
/* AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeEqual(sourceNode, appName);
if (accessibilityNodeInfo!=null && accessibilityNodeInfo.isClickable()){
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
return;
}else if (accessibilityNodeInfo.getParent()!=null && accessibilityNodeInfo.getParent().isClickable()){
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
return;
}*/
sleep();
List<AccessibilityNodeInfo> appListNodeList = null;
......@@ -350,9 +359,8 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
appListNodeList = sourceNode.findAccessibilityNodeInfosByViewId("com.android.settings:id/apps_list");
}
if (appListNodeList != null && appListNodeList.size() > 0) {
AccessibilityNodeInfo appListNode = appListNodeList.get(0);
if (appListNodeList != null && appListNodeList.size() > 2) {
AccessibilityNodeInfo appListNode = appListNodeList.get(1);
AccessibilityNodeInfo targetAppItem = null;
......@@ -413,21 +421,48 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
*/
if ("com.android.settings.SubSettings".equals(event.getClassName()) && event.getText() != null && (event.getText().toString().contains("使用情况访问权限") || event.getText().toString().contains("使用记录访问权限") || event.getText().toString().contains("使用量数据访问"))) {
AccessibilityNodeInfo textViewNode = getChildNodeByIdEqualText(sourceNode, "android:id/title", "允许访问使用记录");
if (performAction(textViewNode, AccessibilityNodeInfo.ACTION_CLICK)) {
List<AccessibilityNodeInfo> accessibilityNodeInfos = sourceNode.findAccessibilityNodeInfosByText("允许访问使用记录");
AccessibilityNodeInfo textViewNode = null;
if (accessibilityNodeInfos != null && accessibilityNodeInfos.size() > 0) {
AccessibilityNodeInfo accessibilityNodeInfo = accessibilityNodeInfos.get(0);
if (accessibilityNodeInfo != null && accessibilityNodeInfo.getParent() != null) {
List<AccessibilityNodeInfo> listNode = accessibilityNodeInfo.getParent().findAccessibilityNodeInfosByViewId("android:id/switch_widget");
if (listNode != null && listNode.size() > 0) {
AccessibilityNodeInfo nodeInfo = listNode.get(0);
if (!nodeInfo.isChecked())
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
} else {
if (performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else if (textViewNode != null) {
showToastLong("请点击【允许访问使用记录右侧按钮】并返回上一页");
return;
resetStep();
} else if (accessibilityNodeInfo != null) {
showToastLong("请点击【允许访问使用记录右侧按钮】并返回上一页");
return;
} else {
textViewNode = getChildNodeByIdEqualText(sourceNode, "android:id/title", "允许查看使用情况");
if (performAction(textViewNode, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else {
showToastLong("请点击【允许查看使用情况右侧按钮】并返回上一页");
return;
}
}
}
} else {
textViewNode = getChildNodeByIdEqualText(sourceNode, "android:id/title", "允许查看使用情况");
if (performAction(textViewNode, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else {
showToastLong("请点击【允许查看使用情况右侧按钮】并返回上一页");
if (textViewNode != null) {
showToastLong("请点击【允许访问使用记录右侧按钮】并返回上一页");
return;
} else {
textViewNode = getChildNodeByIdEqualText(sourceNode, "android:id/title", "允许查看使用情况");
if (performAction(textViewNode, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else {
showToastLong("请点击【允许查看使用情况右侧按钮】并返回上一页");
return;
}
}
}
......@@ -470,7 +505,19 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
resetStep();
} else {
showToastLong("请点击【USB 调试】按钮 并返回上一页");
AccessibilityNodeInfo parentNode = usbNode.getParent();
if (parentNode != null) {
List<AccessibilityNodeInfo> listNodeSwitch = parentNode.findAccessibilityNodeInfosByViewId("android:id/switch_widget");
if (listNodeSwitch != null && listNodeSwitch.size() > 0) {
AccessibilityNodeInfo switchNodeInfo = listNodeSwitch.get(0);
switchNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}else {
showToastLong("请点击【USB 调试】按钮 并返回上一页");
}
}else {
showToastLong("请点击【USB 调试】按钮 并返回上一页");
}
}
}
......@@ -506,8 +553,32 @@ public class HuaweiAutoPermissionGetter extends BaseAutoGetPermission {
}
if (!performAction(targetAppItem, AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请点击【" + appName + "】");
AccessibilityNodeInfo parentNode = targetAppItem.getParent();
if (parentNode != null) {
List<AccessibilityNodeInfo> listNodeSwitch = parentNode.findAccessibilityNodeInfosByViewId("android:id/switch_widget");
if (listNodeSwitch != null && listNodeSwitch.size() > 0) {
AccessibilityNodeInfo switchNodeInfo = listNodeSwitch.get(0);
switchNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}else {
showToastLong("请点击【" + appName + "】");
}
}else {
showToastLong("请点击【" + appName + "】");
}
return;
}else {
AccessibilityNodeInfo parentNode = targetAppItem.getParent();
if (parentNode != null) {
List<AccessibilityNodeInfo> listNodeSwitch = parentNode.findAccessibilityNodeInfosByViewId("android:id/switch_widget");
if (listNodeSwitch != null && listNodeSwitch.size() > 0) {
AccessibilityNodeInfo switchNodeInfo = listNodeSwitch.get(0);
switchNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}else {
showToastLong("请点击【" + appName + "】");
}
}else {
showToastLong("请点击【" + appName + "】");
}
}
} else {
showToastLong("请点击【" + appName + "】");
......
......@@ -9,6 +9,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import com.android.launcher3.accessibility.PermissionOpenAccessiblityService;
import com.android.launcher3.auto_get_permission.BaseAutoGetPermission;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import java.util.List;
......@@ -26,12 +27,129 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestkDeviceAdmin(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.Settings$DeviceAdminSettingsActivity".equals(event.getClassName())) {
AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeEqual(sourceNode, appName);
if (!performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
if (accessibilityNodeInfo != null) {
if (!performAction(accessibilityNodeInfo.getParent(), AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【" + appName + "】并点击");
}
}
sleepShort();
}
}
//进入激活此设备管理员
if ("com.android.settings.DeviceAdminAdd".equals(event.getClassName())) {
AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeEqual(sourceNode, "激活此设备管理员");
if (!performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
if (accessibilityNodeInfo != null) {
if (!performAction(accessibilityNodeInfo.getParent(), AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【激活此设备管理员】并点击");
}
}
sleepShort();
}
}
}
/**
* 跳转魅族自启动
*
* @param event
*/
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
// 魅族 权限管理 ->后台管理-> 打开应用开关
if ("com.meizu.safe.SecurityMainActivity".equals(event.getClassName().toString())) {
// 手机管家页面
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, "权限管理");
if (accessibilityNodeInfo1 != null && accessibilityNodeInfo1.getParent() != null) {
Logger.e(TAG, accessibilityNodeInfo1.getParent().toString());
boolean success = performAction(accessibilityNodeInfo1, AccessibilityNodeInfo.ACTION_CLICK);
if (!success) {
sleep();
} else {
showToastLong("请点击【权限管理】");
return;
}
}
return;
}
if ("com.meizu.safe.permission.PermissionMainActivity".equals(event.getClassName().toString())) {
// 权限管理页面
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, "后台管理");
if (accessibilityNodeInfo1 != null && performAction(accessibilityNodeInfo1, AccessibilityNodeInfo.ACTION_CLICK)) {
sleep();
} else {
showToastLong("请点击【后台管理】");
return;
}
return;
}
sleep();
if ("com.meizu.safe.permission.SmartBGActivity".equals(event.getClassName().toString())) {
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeByIdEqualText(sourceNode, "com.meizu.safe:id/name", appName);
List<AccessibilityNodeInfo> nodeInfoList = sourceNode.findAccessibilityNodeInfosByViewId("com.meizu.safe:id/list");
if (nodeInfoList != null && nodeInfoList.size() > 0) {
AccessibilityNodeInfo listViewNode = nodeInfoList.get(0);
long time = System.currentTimeMillis();
while (accessibilityNodeInfo1 == null && System.currentTimeMillis() - time < MAX_SEARCH_TIME) {
if (listViewNode == null) {
break;
}
if (listViewNode.isScrollable()) {
listViewNode.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
sleepShort();
listViewNode.refresh();
} else {
break;
}
accessibilityNodeInfo1 = getChildNodeByIdEqualText(sourceNode, "com.meizu.safe:id/name", appName);
}
}
if (accessibilityNodeInfo1 != null && performAction(accessibilityNodeInfo1, AccessibilityNodeInfo.ACTION_CLICK)) {
} else {
showToastLong("请找到【" + appName + "】应用并点击");
return;
}
}
sleep();
if ("android.app.AlertDialog".equals(event.getClassName().toString())) {
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, "允许后台运行");
if (accessibilityNodeInfo1 != null && performAction(accessibilityNodeInfo1, AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else {
showToastLong("请点击【允许后台运行】");
return;
}
//成功获取到后台运行权限
PermissionUtil.isAutoStartUp = true;
}
}
@Override
......@@ -170,6 +288,7 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
}
if (!performAction(targetAppItem, AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【" + appName + "】并点击");
return;
} else {
......@@ -260,6 +379,13 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
resetStep();
} else {
if (usbNode != null) {
if (performAction(usbNode.getParent(), AccessibilityNodeInfo.ACTION_CLICK)) {
resetStep();
} else {
showToastLong("请点击【USB 调试】");
}
}
showToastLong("请点击【USB 调试】");
return;
}
......@@ -269,7 +395,7 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestNotificationPermission(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode=event.getSource();
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.Settings$NotificationAccessSettingsActivity".equals(event.getClassName())) {
AccessibilityNodeInfo targetApp = getChildNodeEqual(sourceNode, appName);
......@@ -325,10 +451,23 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestDefaultLauncher(AccessibilityEvent event) {
AccessibilityNodeInfo nodeInfo=event.getSource();
AccessibilityNodeInfo nodeInfo = event.getSource();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if ("com.android.internal.app.MzResolverActivity".equals(event.getClassName())) {
if ("com.android.settings.Settings$AllApplicationsActivity".equals(event.getClassName())) {//应用管理页面
AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeEqual(nodeInfo, "默认应用");
if (!performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
if (accessibilityNodeInfo != null) {
if (!performAction(accessibilityNodeInfo.getParent(), AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【" + appName + "】并点击");
{
}
showToastLong("请找到【" + appName + "】并点击");
}
}
sleepShort();
}
} else if ("com.android.internal.app.MzResolverActivity".equals(event.getClassName())) {
AccessibilityNodeInfo checkBoxNode = getChildNodeEqual(nodeInfo, "默认使用该应用打开");
if (performAction(checkBoxNode, AccessibilityNodeInfo.ACTION_CLICK)) {
......@@ -347,7 +486,33 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
showToastLong("请点击【" + appName + "】");
return;
}
} else if ("com.android.settings.SubSettings".equals(event.getClassName().toString())) {
// 设置页面
AccessibilityNodeInfo accessibilityNodeInfo2 = getChildNodeEqual(nodeInfo, appName);
if (accessibilityNodeInfo2 == null) {
AccessibilityNodeInfo accessibilityNodeInfo = getChildNodeEqual(nodeInfo, "桌面");
if (!performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
if (accessibilityNodeInfo != null) {
if (!performAction(accessibilityNodeInfo.getParent(), AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【" + "桌面" + "】并点击");
}
}
sleep();
}
} else {
if (!performAction(accessibilityNodeInfo2, AccessibilityNodeInfo.ACTION_CLICK)) {
if (accessibilityNodeInfo2 != null) {
if (!performAction(accessibilityNodeInfo2.getParent(), AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【" + appName + "】并点击");
}
}
sleep();
}
}
}
} else {
if ("com.android.settings.Settings".equals(event.getClassName().toString())) {
// 设置页面
......@@ -413,9 +578,7 @@ public class MeizuAutoPermissionGetter extends BaseAutoGetPermission {
if (performAction(targetNode, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
return;
} else {
showToastLong("请点击【" + appName + "】");
......
package com.android.launcher3.auto_get_permission.oppo;
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.BaseAutoGetPermission;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import java.util.List;
......@@ -15,6 +17,7 @@ import static com.android.launcher3.auto_get_permission.AccessibilityNodeOperate
public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
public static final String TAG = "OppoAutoPermissionGetter";
private boolean mIsActivation = false;
public OppoAutoPermissionGetter(PermissionOpenAccessiblityService service) {
super(service);
......@@ -22,8 +25,10 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestkDeviceAdmin(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始设备管理器权限");
AccessibilityNodeInfo sourceNode = event.getSource();
Logger.e(TAG, "isOPPO" + event.getClassName());
sleepLongLong();
if ("com.android.settings.SubSettings".equals(event.getClassName()) && event.getText() != null && event.getText().toString().equals("[设备管理器]")) {
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, appName);
......@@ -44,7 +49,6 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
} else if ("com.android.settings.Settings$DeviceAdminSettingsActivity".equals(event.getClassName().toString())) {
// 已跳转到设备管理器页面
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, appName);
if (accessibilityNodeInfo1 != null && accessibilityNodeInfo1.getParent() != null) {
......@@ -66,14 +70,22 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
sleep();
AccessibilityNodeInfo accessibilityNodeInfo2 = getChildNodeEqual(sourceNode, "激活");
if (accessibilityNodeInfo2 != null && accessibilityNodeInfo2.getParent() != null) {
if (accessibilityNodeInfo2.isClickable()) {
accessibilityNodeInfo2.performAction(AccessibilityNodeInfo.ACTION_CLICK);
} else {
accessibilityNodeInfo2.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
mIsActivation = true;
}
}
}
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings") && mIsActivation) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
......@@ -91,11 +103,93 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始自启动权限");
AccessibilityNodeInfo sourceNode = event.getSource();
Log.i("reqeustAutoStartUp", "自启动,当前界面:" + event.getClassName());
if ("com.android.settings.applications.InstalledAppDetailsTop".equals(event.getClassName())) {
boolean isTargetApp = getChildNodeEqual(sourceNode, appName) != null;
Log.i("reqeustAutoStartUp", "自启动权限sourceNode" + sourceNode + "\nappName" + appName);
if (isTargetApp) {
Log.i("reqeustAutoStartUp", "进来设置自启动权限");
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
Log.i("reqeustAutoStartUp", "进来列表");
AccessibilityNodeInfo listView = listViewNodes.get(0);
AccessibilityNodeInfo allowAutoStart = getChildNodeEqual(listView, "允许自动启动");
if (allowAutoStart != null && allowAutoStart.getParent() != null) {
Log.i("reqeustAutoStartUp", "允许自动启动");
List<AccessibilityNodeInfo> listNode = allowAutoStart.getParent().findAccessibilityNodeInfosByViewId("android:id/switch_widget");
if (listNode != null && listNode.size() > 0) {
AccessibilityNodeInfo accessibilityNodeInfo = listNode.get(0);
if (!accessibilityNodeInfo.isChecked())
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
}
AccessibilityNodeInfo allowOtherAppAutoStart = getChildNodeEqual(listView, "允许其他应用自动启动");
if (allowOtherAppAutoStart != null && allowOtherAppAutoStart.getParent() != null) {
List<AccessibilityNodeInfo> listNode = allowOtherAppAutoStart.getParent().findAccessibilityNodeInfosByViewId("android:id/switch_widget");
Log.i("reqeustAutoStartUp", "允许其他应用自动启动");
if (listNode != null && listNode.size() > 0) {
AccessibilityNodeInfo accessibilityNodeInfo = listNode.get(0);
if (!accessibilityNodeInfo.isChecked())
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
}
AccessibilityNodeInfo allowFloatingWindowStart = getChildNodeEqual(listView, "允许显示悬浮窗");
if (allowFloatingWindowStart != null && allowFloatingWindowStart.getParent() != null) {
List<AccessibilityNodeInfo> listNode = allowFloatingWindowStart.getParent().findAccessibilityNodeInfosByViewId("android:id/switch_widget");
Log.i("reqeustAutoStartUp", "允许显示悬浮窗");
if (listNode != null && listNode.size() > 0) {
AccessibilityNodeInfo accessibilityNodeInfo = listNode.get(0);
if (!accessibilityNodeInfo.isChecked())
accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}
}
}
// getChildNodeEqual(sourceNode, "允许其他应用自动启动");
AccessibilityNodeInfo batterySaveNode = getChildNodeEqual(sourceNode, "耗电保护");
Log.i("reqeustAutoStartUp", "耗电保护");
if (batterySaveNode != null && batterySaveNode.getParent() != null) {
batterySaveNode.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleep();
}
}
} else if ("com.coloros.powermanager.fuelgaue.PowerAppsBgSetting".equals(event.getClassName())) {
boolean isTargetApp = getChildNodeEqual(sourceNode, appName) != null;
if (isTargetApp) {
AccessibilityNodeInfo node = getChildNodeEqual(sourceNode, "允许后台运行");
if (node != null && node.getParent() != null) {
Log.i("reqeustAutoStartUp", "允许后台运行");
node.getParent().performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
resetStep();
PermissionUtil.isAutoStartUp = true;
Log.i("reqeustAutoStartUp", "自启动设置完成");
}
}
}
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始电量优化权限");
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.applications.InstalledAppDetailsTop".equals(event.getClassName())) {
boolean isTargetApp = getChildNodeEqual(sourceNode, appName) != null;
......@@ -148,6 +242,7 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestUsageAppPermission(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始用户使用权限");
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.Settings$UsageAccessSettingsActivity".equals(event.getClassName())) {
......@@ -277,6 +372,7 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestCloseUSB(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始USB使用权限");
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.android.settings.Settings$DevelopmentSettingsActivity".equals(event.getClassName())) {
......@@ -329,6 +425,7 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void requestNotificationPermission(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始通知使用权限");
AccessibilityNodeInfo sourceNode = event.getSource();
if ("com.coloros.securitypermission.permission.PermissionNotificationActivity".equals(event.getClassName())) {
......@@ -363,6 +460,7 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
showToastLong("请点击【" + appName + "】");
return;
}
}
......@@ -376,11 +474,22 @@ public class OppoAutoPermissionGetter extends BaseAutoGetPermission {
showToastLong("请点击【允许】");
return;
}
} else if ("com.coloros.securitypermission.common.m.a".equals(event.getClassName())) {
AccessibilityNodeInfo allowNode = getChildNodeEqual(sourceNode, "允许");
sleepShort();
if (performAction(allowNode, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
resetStep();
} else {
showToastLong("请点击【允许】");
return;
}
}
}
@Override
public void requestDefaultLauncher(AccessibilityEvent event) {
Log.i("reqeustAutoStartUp", "开始默认桌面权限");
AccessibilityNodeInfo nodeInfo = event.getSource();
if ("android.app.Dialog".equals(event.getClassName()) || "com.android.internal.app.ResolverActivity".equals(event.getClassName())) {
......
......@@ -8,6 +8,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import com.android.launcher3.accessibility.PermissionOpenAccessiblityService;
import com.android.launcher3.auto_get_permission.BaseAutoGetPermission;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.SystemUtils;
import java.util.List;
......@@ -31,11 +32,17 @@ public class SamsungAutoPermissionGetter extends BaseAutoGetPermission {
if ("com.android.settings.Settings$DeviceAdminSettingsActivity".equals(event.getClassName().toString())) {
// 已跳转到设备管理器页面
sleepShort();
AccessibilityNodeInfo accessibilityNodeInfo1 = getChildNodeEqual(sourceNode, appName);
if (!performAction(accessibilityNodeInfo1, AccessibilityNodeInfo.ACTION_CLICK)) {
showToastLong("请找到【" + appName + "】应用并点击");
if (accessibilityNodeInfo1 != null) {
if (!performAction(accessibilityNodeInfo1.getParent(), AccessibilityNodeInfo.ACTION_CLICK))
showToastLong("请找到【" + appName + "】应用并点击");
} else {
showToastLong("请找到【" + appName + "】应用并点击");
}
return;
} else {
sleepShort();
......@@ -57,6 +64,7 @@ public class SamsungAutoPermissionGetter extends BaseAutoGetPermission {
return;
}
showToastLong("请点击【启用/激活此设备管理员】");
PermissionUtil.isAdminDevice = true;
return;
}
}
......
......@@ -2,6 +2,7 @@ package com.android.launcher3.auto_get_permission.xiaomi;
import android.accessibilityservice.AccessibilityService;
import android.text.TextUtils;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
......@@ -375,7 +376,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
if (systemSafeBtn != null && performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
sleep();
} else {
showToastLong("请点击【系统安全】");
return;
......@@ -432,23 +433,18 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
@Override
public void reqeustAutoStartUp(AccessibilityEvent event) {
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
if (sourceNode == null) {
return;
}
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
sleep();
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", "应用管理");
......@@ -480,7 +476,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
} else if ("com.android.settings.SubSettings".equals(event.getClassName())) {
sleep();
String title = event.getText().toString();
if (TextUtils.equals(title, "[应用设置]")) {
......@@ -515,7 +511,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
if ("com.miui.appmanager.AppManagerMainActivity".equals(event.getClassName().toString())) {
sleepShort();
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("com.miui.securitycenter:id/app_manager_list_view");
if (listViewNodes != null && listViewNodes.size() > 0) {
......@@ -571,15 +567,29 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
if (switcherBtnNode != null && performAction(switcherBtnNode.get(0), AccessibilityNodeInfo.ACTION_CLICK)) {
if (switcherBtnNode.get(0) != null) {
if (!switcherBtnNode.get(0).isChecked()) {
if (switcherBtnNode != null && performAction(switcherBtnNode.get(0), AccessibilityNodeInfo.ACTION_CLICK)) {
/* for (int i = 0; i < switcherBtnNode.size(); i++) {
AccessibilityNodeInfo accessibilityNodeInfo = switcherBtnNode.get(i);
if (accessibilityNodeInfo != null) {
Log.i("mmmmmmmmmmmmmmm", accessibilityNodeInfo.isChecked() + "");
}
}
if (!switcherBtnNode.get(0).isChecked()) {
switcherBtnNode.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
sleepShort();
}*/
sleepShort();
} else {
showToastLong("请点击【自启动】");
return;
}
} else {//已经选择过了
PermissionUtil.isAutoStartUp = true;
}
} else {
showToastLong("请点击【自启动】");
return;
}
}
......@@ -590,16 +600,140 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
AccessibilityNodeInfo acceptBtnNode = getChildNodeEqual(sourceNode, "确定");
if (acceptBtnNode != null && performAction(acceptBtnNode, AccessibilityNodeInfo.ACTION_CLICK)) {
sleep();
//getService().performGlobalAction(GLOBAL_ACTION_BACK);
} else {
showToastLong("请点击【确定】");
return;
}
PermissionUtil.isAutoStartUp = true;
}
}
@Override
public void requestBatteryOptimize(AccessibilityEvent event) {
AccessibilityNodeInfo sourceNode = event.getSource();
if (sourceNode == null) {
return;
}
if ("android.app.Dialog".equals(event.getClassName()) && event.getText() != null) {
AccessibilityNodeInfo acceptBtnNode = getChildNodeEqual(sourceNode, "允许");
if (performAction(acceptBtnNode, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
resetStep();
getService().performGlobalAction(GLOBAL_ACTION_BACK);
} else {
showToastLong("请点击【确定】");
showToastLong("请点击【允许】");
return;
}
}
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
sleep();
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if ("com.miui.appmanager.ApplicationsDetailsActivity".equals(event.getClassName().toString()) && event.getText() != null && event.getText().toString().contains(appName)) {
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;
} else if ("com.android.settings.SubSettings".equals(event.getClassName())) {
sleep();
String title = event.getText().toString();
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;
}
}
return;
}
}
if ("com.miui.appmanager.AppManagerMainActivity".equals(event.getClassName().toString())) {
sleepShort();
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("com.miui.securitycenter:id/app_manager_list_view");
if (listViewNodes != null && listViewNodes.size() > 0) {
AccessibilityNodeInfo listViewNode = listViewNodes.get(0);
AccessibilityNodeInfo systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "com.miui.securitycenter:id/am_label", appName);
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, "com.miui.securitycenter:id/am_label", appName);
}
if (systemSafeBtn != null && performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
} else {
showToastLong("请找到【" + appName + "】并点击");
return;
}
}
return;
}
Logger.e(TAG, "gotoDeviceAdminPermissionSetting\t" + event.getClassName().toString());
if ("com.miui.appmanager.ApplicationsDetailsActivity".equals(event.getClassName().toString()) && event.getText() != null && event.getText().toString().contains(appName)) {
List<AccessibilityNodeInfo> scrollViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("com.miui.securitycenter:id/am_scrollview");
......@@ -638,7 +772,6 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
if (accessibilityNodeInfo != null && performAction(accessibilityNodeInfo, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
resetStep();
} else {
showToastLong("请点击【无限制】");
return;
......@@ -646,17 +779,18 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
sleep();
/* if (event.getPackageName() != null && event.getPackageName().equals("com.android.settings")) {
getService().performGlobalAction(GLOBAL_ACTION_BACK);
sleepShort();
// gotoDeviceAdminPermissionSetting();
return;
}
resetStep();*/
//gotoBatteryOptimize();
sleep();
}
@Override
......@@ -832,8 +966,6 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
}
}
return;
}
......@@ -849,7 +981,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
gotoAppUsagePermission();
} else {
if ("com.android.settings.MiuiSettings".equals(event.getClassName().toString())) {
sleep();
List<AccessibilityNodeInfo> listViewNodeS = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodeS != null && listViewNodeS.size() > 0) {
......@@ -886,6 +1018,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
String title = event.getText().toString();
if (TextUtils.equals(title, "[密码、隐私与安全]")) {
sleep();
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
......@@ -913,9 +1046,8 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
return;
} else if (TextUtils.equals(title, "[系统安全]")) {
sleep();
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", "特殊应用权限");
......@@ -942,6 +1074,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
return;
} else if (TextUtils.equals(title, "[特殊应用权限]")) {
sleep();
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
......@@ -969,7 +1102,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
return;
} else if (TextUtils.equals(title, "[使用情况访问权限]")) {
sleep();
AccessibilityNodeInfo allowPermissionNode = getChildNodeEqual(sourceNode, "允许查看使用情况");
if (allowPermissionNode != null && allowPermissionNode.getParent() != null) {
......@@ -1077,7 +1210,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
} else if ("com.android.settings.SubSettings".equals(event.getClassName())) {
String title = event.getText().toString();
sleep();
if (TextUtils.equals(title, "[更多设置]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -1107,7 +1240,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
return;
}
sleep();
if (TextUtils.equals(title, "[开发者选项]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -1382,7 +1515,6 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
} else if ("com.android.settings.SubSettings".equals(event.getClassName())) {
String title = event.getText().toString();
if (TextUtils.equals(title, "[密码、隐私与安全]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -1412,7 +1544,7 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
return;
}
sleep();
if (TextUtils.equals(title, "[系统安全]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -1428,7 +1560,6 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
} else {
break;
}
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", "特殊应用权限");
}
......@@ -1442,7 +1573,6 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
}
return;
}
if (TextUtils.equals(title, "[特殊应用权限]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
......@@ -1472,8 +1602,8 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
return;
}
sleep();
if (TextUtils.equals(title, "[通知使用权]")) {
List<AccessibilityNodeInfo> listViewNodes = sourceNode.findAccessibilityNodeInfosByViewId("android:id/list");
if (listViewNodes != null && listViewNodes.size() > 0) {
......@@ -1490,16 +1620,16 @@ public class XiaoMiAutoPermissionGetter extends BaseAutoGetPermission {
systemSafeBtn = getChildNodeByIdEqualText(sourceNode, "android:id/title", appName);
}
if (systemSafeBtn != null && systemSafeBtn.getParent() != null) {
}
if (performAction(systemSafeBtn, AccessibilityNodeInfo.ACTION_CLICK)) {
sleepShort();
sleep();
} else {
showToastLong("请点击【" + appName + "】");
return;
}
}
return;
}
......
package com.android.launcher3.debug;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import com.android.launcher3.R;
/**
* Author: roczheng
* Date: 2019/11/28
* Time: 14:10
* Description:
*/
public class CustomDialog extends AlertDialog {
private Context mContext;
private int mResource;
private View mDialogView;
public CustomDialog(Context context, int resource) {
super(context, R.style.Theme_AppCompat_Dialog);//加载dialog的样式
this.mContext = context;
this.mResource = resource;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {//6.0
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
}else {
getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
}
} else {
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
if (mDialogView != null) {
setContentView(mDialogView);
} else if (mResource != 0) {
mDialogView = LayoutInflater.from(mContext).inflate(mResource, null);
setContentView(mDialogView, layoutParams);
}
setCanceledOnTouchOutside(false);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
}
}
......@@ -78,6 +78,9 @@ public class DebugInfoActivity extends BaseActivity implements View.OnClickListe
rv_app_manage_info.setLayoutManager(new LinearLayoutManager(this));
rv_app_manage_info.setAdapter(timeAdapter);
//TimeModeManager.getInstance(getApplicationContext()).setCurrentWorkModel(ColumnDef.TimeManager.WEEK_RESET);
//LauncherManager.getInstance().lockScreenNormal(getApplicationContext());
loadWorkMode();
loadAppInfo();
update();
......
package com.android.launcher3.debug;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import com.android.launcher3.R;
import com.android.launcher3.manager.LauncherManager;
public class ProgressActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("service_zzzzzzzzzzzz", "ProgressActivity监听");
setContentView(R.layout.activity_clock_alarm);
}
}
......@@ -22,14 +22,18 @@ public class Constants {
// 应用使用时长上限
public static final int DIALOG_TYPE_APP_USE_DEADLINE = 3;
// 金币不足
// 金币不足
public static final int DIALOG_TYPE_MONEY_NOT_ENOUGH = 4;
// 某个分类下的分类总时长已使用完毕
// 某个分类下的分类总时长已使用完毕
public static final int DIALOG_TYPE_SOME_CLASS_TIME_OUT = 5;
public static final String[] SAFE_APP = {"com.samsung.android.dialer|com.android.dialer|com.samsung.android.contacts|com.android.contacts", "com.samsung.android.messaging|com.android.mms", "com.sec.android.app.camera|com.android.camera2|com.meizu.media.camera|com.huawei.camera"};
//忽略规则的应用
public static final String[] SAFE_APP = {"com.samsung.android.dialer|com.android.dialer|com.samsung.android.contacts|com.android.contacts",
"com.samsung.android.messaging|com.android.mms",
"com.sec.android.app.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"};
......
package com.android.launcher3.manager;
import android.app.Activity;
import android.app.Application;
import android.content.ComponentName;
import android.content.ContentProviderOperation;
......@@ -13,7 +14,9 @@ import android.database.Cursor;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.ArrayMap;
......@@ -27,6 +30,7 @@ import com.android.launcher3.LockScreenActivity;
import com.android.launcher3.LockScreenInterface;
import com.android.launcher3.accessibility.FloatWindowService;
import com.android.launcher3.accessibility.ListenerAppService;
import com.android.launcher3.debug.CustomDialog;
import com.android.launcher3.debug.DebugInfoActivity;
import com.android.launcher3.debug.SearchAppCanUseActivity;
import com.android.launcher3.model.ConfigManager;
......@@ -80,6 +84,9 @@ public class LauncherManager {
private static Context mContext;
public static CustomDialog mCustomDialog;
public static int mStartSendCount = 0;
private final LauncherProvider.ChangeListenerWrapper mListenerWrapper = new LauncherProvider.ChangeListenerWrapper();
private Handler mListenerHandler;
......@@ -111,6 +118,7 @@ public class LauncherManager {
/**
* 设置Debug模式 正式版需关闭
*
* @param debugModel
*/
public static void setDebugModel(boolean debugModel) {
......@@ -153,6 +161,15 @@ public class LauncherManager {
private LauncherManager() {
appInfo = new ArrayMap<>();
/* ManagementInfo managementInfo = new ManagementInfo();
managementInfo.setUseEndTimeStamp(43320);
managementInfo.setPackageName("com.tencent.mobileqq");
managementInfo.setLock(ColumnDef.LockApp.LOCKED);
managementInfo.setUseType(ColumnDef.AppUseType.GAME_LOCK_TYPE);
LauncherManager.getInstance().addPackageInfo(managementInfo);
*/
timeModeManager = TimeModeManager.getInstance(getContext());
mListenerHandler = new Handler(mListenerWrapper);
......@@ -288,9 +305,10 @@ public class LauncherManager {
/**
* 状态更新发广播给桌面(Launcher)处理
*
* @param packageName
*/
private void refreshLauncherIconWidget(String packageName) {
public void refreshLauncherIconWidget(String packageName) {
Intent intent = new Intent(Constants.ACTION_UPDATE_ICON);
intent.putExtra(Constants.EXTRA_PACKAGE, packageName);
......@@ -519,6 +537,7 @@ public class LauncherManager {
return appInfo;
}
public void backLauncherHome(Context context) {
UIExecutor.postRunable(new Runnable() {
@Override
......@@ -529,7 +548,6 @@ public class LauncherManager {
context.startActivity(home);
}
});
}
......@@ -667,6 +685,11 @@ public class LauncherManager {
}
/**
* 是否强制锁屏
*
* @return
*/
public boolean isForceLock() {
return lockScreenMode == ColumnDef.LockScreen.MODE_FORCE_LOCK || lockScreenMode == ColumnDef.LockScreen.MODE_REST;
}
......@@ -873,20 +896,22 @@ public class LauncherManager {
/**
* 跳转debug信息页面
*
* @param context
*/
public void jumpDebugInfo(Context context){
Intent intent=new Intent(context, DebugInfoActivity.class);
public void jumpDebugInfo(Context context) {
Intent intent = new Intent(context, DebugInfoActivity.class);
context.startActivity(intent);
}
/**
* 跳转查询app是否可用页面
*
* @param context
*/
public void jumpSearchAppCanUse(Context context){
Intent intent=new Intent(context, SearchAppCanUseActivity.class);
public void jumpSearchAppCanUse(Context context) {
Intent intent = new Intent(context, SearchAppCanUseActivity.class);
context.startActivity(intent);
}
}
......@@ -280,6 +280,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
if (componentName.getPackageName().equals(mLauncher.getPackageName())) {
boolean enable = LauncherManager.getInstance().getUninstallEnable();
Logger.e("uninstallDisableApp", enable + "");
//是否拦截系统设置
LauncherManager.getInstance().setInterceptSystemSetting(!enable);
return enable;
}
......
......@@ -20,6 +20,7 @@ import android.content.ComponentName;
import android.os.Handler;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
......@@ -47,7 +48,8 @@ import java.util.List;
public class PopupPopulator {
public static final int MAX_SHORTCUTS = 4;
@VisibleForTesting static final int NUM_DYNAMIC = 2;
@VisibleForTesting
static final int NUM_DYNAMIC = 2;
public static final int MAX_SHORTCUTS_IF_NOTIFICATIONS = 2;
/**
......@@ -122,9 +124,9 @@ public class PopupPopulator {
}
public static Runnable createUpdateRunnable(final Launcher launcher, final ItemInfo originalInfo,
final Handler uiHandler, final PopupContainerWithArrow container,
final List<String> shortcutIds, final List<DeepShortcutView> shortcutViews,
final List<NotificationKeyData> notificationKeys) {
final Handler uiHandler, final PopupContainerWithArrow container,
final List<String> shortcutIds, final List<DeepShortcutView> shortcutViews,
final List<NotificationKeyData> notificationKeys) {
final ComponentName activity = originalInfo.getTargetComponent();
final UserHandle user = originalInfo.user;
return () -> {
......@@ -138,9 +140,14 @@ public class PopupPopulator {
}
uiHandler.post(() -> container.applyNotificationInfos(infos));
}
List<ShortcutInfoCompat> shortcuts = new ArrayList<>();
try {
shortcuts = DeepShortcutManager.getInstance(launcher)
.queryForShortcutsContainer(activity, shortcutIds, user);
} catch (Exception e) {
e.printStackTrace();
}
List<ShortcutInfoCompat> shortcuts = DeepShortcutManager.getInstance(launcher)
.queryForShortcutsContainer(activity, shortcutIds, user);
String shortcutIdToDeDupe = notificationKeys.isEmpty() ? null
: notificationKeys.get(0).shortcutId;
shortcuts = PopupPopulator.sortAndFilterShortcuts(shortcuts, shortcutIdToDeDupe);
......
......@@ -81,12 +81,12 @@ public class DeepShortcutManager {
/**
* Queries for the shortcuts with the package name and provided ids.
*
* <p>
* This method is intended to get the full details for shortcuts when they are added or updated,
* because we only get "key" fields in onShortcutsChanged().
*/
public List<ShortcutInfoCompat> queryForFullDetails(String packageName,
List<String> shortcutIds, UserHandle user) {
List<String> shortcutIds, UserHandle user) {
return query(FLAG_GET_ALL, packageName, null, shortcutIds, user);
}
......@@ -95,7 +95,7 @@ public class DeepShortcutManager {
* to be displayed in the shortcuts container on long press.
*/
public List<ShortcutInfoCompat> queryForShortcutsContainer(ComponentName activity,
List<String> ids, UserHandle user) {
List<String> ids, UserHandle user) {
return query(ShortcutQuery.FLAG_MATCH_MANIFEST | ShortcutQuery.FLAG_MATCH_DYNAMIC,
activity.getPackageName(), activity, ids, user);
}
......@@ -115,7 +115,7 @@ public class DeepShortcutManager {
try {
mLauncherApps.pinShortcuts(packageName, pinnedIds, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
} catch (SecurityException | IllegalStateException e) {
Log.w(TAG, "Failed to unpin shortcut", e);
mWasLastCallSuccess = false;
}
......@@ -137,7 +137,7 @@ public class DeepShortcutManager {
try {
mLauncherApps.pinShortcuts(packageName, pinnedIds, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
} catch (SecurityException | IllegalStateException e) {
Log.w(TAG, "Failed to pin shortcut", e);
mWasLastCallSuccess = false;
}
......@@ -146,13 +146,13 @@ public class DeepShortcutManager {
@TargetApi(25)
public void startShortcut(String packageName, String id, Rect sourceBounds,
Bundle startActivityOptions, UserHandle user) {
Bundle startActivityOptions, UserHandle user) {
if (Utilities.ATLEAST_NOUGAT_MR1) {
try {
mLauncherApps.startShortcut(packageName, id, sourceBounds,
startActivityOptions, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
} catch (SecurityException | IllegalStateException e) {
Log.e(TAG, "Failed to start shortcut", e);
mWasLastCallSuccess = false;
}
......@@ -167,7 +167,7 @@ public class DeepShortcutManager {
shortcutInfo.getShortcutInfo(), density);
mWasLastCallSuccess = true;
return icon;
} catch (SecurityException|IllegalStateException e) {
} catch (SecurityException | IllegalStateException e) {
Log.e(TAG, "Failed to get shortcut icon", e);
mWasLastCallSuccess = false;
}
......@@ -177,7 +177,7 @@ public class DeepShortcutManager {
/**
* Returns the id's of pinned shortcuts associated with the given package and user.
*
* <p>
* If packageName is null, returns all pinned shortcuts regardless of package.
*/
public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName, UserHandle user) {
......@@ -185,7 +185,7 @@ public class DeepShortcutManager {
}
public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName,
List<String> shortcutIds, UserHandle user) {
List<String> shortcutIds, UserHandle user) {
return query(ShortcutQuery.FLAG_MATCH_PINNED, packageName, null, shortcutIds, user);
}
......@@ -204,39 +204,45 @@ public class DeepShortcutManager {
/**
* Query the system server for all the shortcuts matching the given parameters.
* If packageName == null, we query for all shortcuts with the passed flags, regardless of app.
*
* <p>
* TODO: Use the cache to optimize this so we don't make an RPC every time.
*/
@TargetApi(25)
private List<ShortcutInfoCompat> query(int flags, String packageName,
ComponentName activity, List<String> shortcutIds, UserHandle user) {
if (Utilities.ATLEAST_NOUGAT_MR1) {
ShortcutQuery q = new ShortcutQuery();
q.setQueryFlags(flags);
if (packageName != null) {
q.setPackage(packageName);
q.setActivity(activity);
q.setShortcutIds(shortcutIds);
}
List<ShortcutInfo> shortcutInfos = null;
try {
shortcutInfos = mLauncherApps.getShortcuts(q, user);
mWasLastCallSuccess = true;
} catch (SecurityException|IllegalStateException e) {
Log.e(TAG, "Failed to query for shortcuts", e);
mWasLastCallSuccess = false;
}
if (shortcutInfos == null) {
ComponentName activity, List<String> shortcutIds, UserHandle user) {
try {
if (Utilities.ATLEAST_NOUGAT_MR1) {
ShortcutQuery q = new ShortcutQuery();
q.setQueryFlags(flags);
if (packageName != null) {
q.setPackage(packageName);
q.setActivity(activity);
q.setShortcutIds(shortcutIds);
}
List<ShortcutInfo> shortcutInfos = null;
try {
shortcutInfos = mLauncherApps.getShortcuts(q, user);
mWasLastCallSuccess = true;
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "Failed to query for shortcuts", e);
mWasLastCallSuccess = false;
}
if (shortcutInfos == null) {
return Collections.EMPTY_LIST;
}
List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcutInfos.size());
for (ShortcutInfo shortcutInfo : shortcutInfos) {
shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo));
}
return shortcutInfoCompats;
} else {
return Collections.EMPTY_LIST;
}
List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcutInfos.size());
for (ShortcutInfo shortcutInfo : shortcutInfos) {
shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo));
}
return shortcutInfoCompats;
} else {
return Collections.EMPTY_LIST;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@TargetApi(25)
......@@ -244,7 +250,7 @@ public class DeepShortcutManager {
if (Utilities.ATLEAST_NOUGAT_MR1) {
try {
return mLauncherApps.hasShortcutHostPermission();
} catch (SecurityException|IllegalStateException e) {
} catch (SecurityException | IllegalStateException e) {
Log.e(TAG, "Failed to make shortcut manager call", e);
}
}
......
......@@ -91,7 +91,6 @@ public class ItemClickHandler {
ShortcutInfo shortcutInfo = (ShortcutInfo) tag;
String packageName = shortcutInfo.getIntent().getComponent().getPackageName();
if (packageName.equals(v.getContext().getPackageName())) {
onClickAppShortcut(v, (ShortcutInfo) tag, launcher);
return;
......@@ -108,7 +107,6 @@ public class ItemClickHandler {
LauncherManager.getInstance().backLauncherHome(v.getContext(), Constants.DIALOG_TYPE_APP_UNCLASS);
return;
} else {
int type = LauncherManager.getInstance().canUse(packageName);
if (type < 0) {
switch (type) {
......@@ -125,6 +123,11 @@ public class ItemClickHandler {
}
}
} else {
/*if (packageName.equals(v.getContext().getPackageName())){
LauncherManager.getInstance().backLauncherHome(v.getContext(), Constants.DIALOG_TYPE_APP_USE_DEADLINE);
}else {
LauncherManager.getInstance().backLauncherHome(v.getContext(), Constants.DIALOG_TYPE_APP_UNCLASS);
}*/
LauncherManager.getInstance().backLauncherHome(v.getContext(), Constants.DIALOG_TYPE_APP_UNCLASS);
return;
}
......
......@@ -70,7 +70,10 @@ public class KToast {
mView.findViewById(R.id.tv_close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
if (mView.getParent() != null) {
windowManager.removeView(mView);
isShowing = false;
}
}
});
mView.findViewById(R.id.tv_help).setOnClickListener(new View.OnClickListener() {
......@@ -84,7 +87,6 @@ public class KToast {
context.startActivity(intent);
}
});
}
public void setText(String msg) {
......
......@@ -18,17 +18,16 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.PowerManager;
import android.os.Process;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import com.android.launcher3.accessibility.AppManagerAccessiblityService;
import com.android.launcher3.accessibility.DeviceReceiver;
import com.android.launcher3.compat.LauncherAppsCompat;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
......@@ -40,10 +39,16 @@ public class PermissionUtil {
private static final String TAG = "PermissionUtil";
public static boolean isAdminDevice = false;
//临时变量 判断电量优化
//临时变量 判断电量优化
public static boolean isBatterySaveClose = false;
// 临时变量 判断自启动
public static boolean isAutoStartUp=false;
// 临时变量 判断自启动
public static boolean isAutoStartUp = false;
// 临时变量,魅族默认桌面判断
public static boolean mIsDefaultDesktop = false;
public static boolean isSystemUI = false;
public static boolean isRefreshIcon = false;
public static boolean isAccessibilitySettingsOn(Context mContext) {
int accessibilityEnabled = 0;
......@@ -173,6 +178,7 @@ public class PermissionUtil {
/**
* 判断是否有自启动权限
*
* @param context
* @return
*/
......@@ -182,9 +188,12 @@ public class PermissionUtil {
}
/**
* 跳转自启动
*
* @param context
*/
public static void gotoAutoStartUpSettings(Context context) {
Intent intent = new Intent();
ComponentName componentName = null;
if (SystemUtils.isHW() || SystemUtils.isHONOR()) {
......@@ -208,26 +217,19 @@ public class PermissionUtil {
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return;
}
} else if (SystemUtils.isOPPO()) {
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.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {//抛出异常就直接打开设置页面
intent = new Intent(Settings.ACTION_SETTINGS);
......@@ -239,9 +241,6 @@ public class PermissionUtil {
}
public static void gotoBatteryOptimize(Context context) {
requestIgnoreBatteryOptimizations(context);
}
......@@ -294,6 +293,7 @@ public class PermissionUtil {
Logger.e(TAG, "enAbleADB\t" + enableAdb);
return enableAdb;
//return false;
}
......@@ -415,8 +415,27 @@ public class PermissionUtil {
}
}
} else {
} else if (SystemUtils.isMEIZU()) {//针对魅族做处理
/* Intent intent2 = new Intent();
intent2.setComponent(new ComponentName("com.android.settings", "com.android.settings.SubSettings"));
context.startActivity(intent);*/
/* intent.setAction(Intent.ACTION_MAIN);
intent.addCategory("android.intent.category.HOME");
intent.setComponent(new ComponentName("android", "com.android.settings.Settings$ManageApplicationsActivity"));*/
//context.startActivity(intent);
intent = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
/* Intent intent2 = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent2.setData(Uri.parse("package:" + "com.android.settings.Settings$ManageApplicationsActivity"));
intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent2);*/
return;
} else {
if (SystemUtils.isSAMSUNG() && Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
// componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
......@@ -426,8 +445,6 @@ public class PermissionUtil {
context.startActivity(intent);
return;
}
if (SystemUtils.isVIVO()) {
intent.setAction(Settings.ACTION_SETTINGS);
context.startActivity(intent);
......@@ -449,13 +466,23 @@ public class PermissionUtil {
* 设置为华为手机
*/
private static void startHuaweiSettingActOfDefLauncher(Context activity) {
//判断华为EMUI版本
IntentFilter localIntentFilter = new IntentFilter();
localIntentFilter.addAction(Intent.ACTION_MAIN);//"android.intent.action.MAIN"
localIntentFilter.addCategory(Intent.CATEGORY_HOME);//"android.intent.category.HOME"
Intent localIntent3 = new Intent(localIntentFilter.getAction(0));
localIntent3.addCategory(localIntentFilter.getCategory(0));
Intent localIntent4 = new Intent();
localIntent4.setClassName("com.android.settings", "com.android.settings.Settings$PreferredSettingsActivity");
switch (SystemUtils.getEMUI()) {
case "EmotionUI_8.0.0":
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$PreferredListSettingsActivity"));
activity.startActivity(intent);
return;
default:
localIntent4.setClassName("com.android.settings", "com.android.settings.Settings$PreferredSettingsActivity");
break;
}
localIntent4.putExtra("preferred_app_package_name", activity.getPackageName());
localIntent4.putExtra("preferred_app_class_name", activity.getClass().getName());
localIntent4.putExtra("is_user_confirmed", true);
......@@ -474,11 +501,18 @@ public class PermissionUtil {
intent.addCategory("android.intent.category.HOME");
intent.addCategory("android.intent.category.DEFAULT");
PackageManager pm = context.getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
boolean isDefault = context.getPackageName().equals(info.activityInfo.packageName);
Logger.e(TAG, "isDefaultHome\t" + isDefault);
return isDefault || SystemUtils.isMIUI();
//如果是荣耀,判断版本
if (SystemUtils.isHONOR()) {
if (!SystemUtils.getEMUI().equals("EmotionUI_8.0.0")) {
return true;
}
}
return isDefault || SystemUtils.isMIUI() || SystemUtils.isOPPO() || SystemUtils.isHW();
}
/**
......@@ -626,4 +660,217 @@ public class PermissionUtil {
return result;
}
public static boolean mIsFirstCheck = true;//是否第一次检测权限
/**
* 检测是否有悬浮窗权限
* 第一次系统默认返回的是有权限
*
* @param context
* @return
*/
public static boolean checkFloatPermission(Context context) {
if (mIsFirstCheck) {
return mIsFirstCheck = false;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
return true;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
try {
Class cls = Class.forName("android.content.Context");
Field declaredField = cls.getDeclaredField("APP_OPS_SERVICE");
declaredField.setAccessible(true);
Object obj = declaredField.get(cls);
if (!(obj instanceof String)) {
return false;
}
String str2 = (String) obj;
obj = cls.getMethod("getSystemService", String.class).invoke(context, str2);
cls = Class.forName("android.app.AppOpsManager");
Field declaredField2 = cls.getDeclaredField("MODE_ALLOWED");
declaredField2.setAccessible(true);
Method checkOp = cls.getMethod("checkOp", Integer.TYPE, Integer.TYPE, String.class);
int result = (Integer) checkOp.invoke(obj, 24, Binder.getCallingUid(), context.getPackageName());
return result == declaredField2.getInt(cls);
} catch (Exception e) {
return false;
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AppOpsManager appOpsMgr = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
if (appOpsMgr == null)
return false;
int mode = appOpsMgr.checkOpNoThrow("android:system_alert_window", android.os.Process.myUid(), context
.getPackageName());
return mode == AppOpsManager.MODE_ALLOWED || mode == AppOpsManager.MODE_IGNORED;
} else {
return Settings.canDrawOverlays(context);
}
}
}
/**
* 处理图标的显示和隐藏
*/
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);
}
}
/**
* 启用组件 *
*
* @param componentName 重要方法
*/
private static void enableComponent(Context context, ComponentName componentName) {
PackageManager pm = context.getPackageManager();
int state = pm.getComponentEnabledSetting(componentName);
if (PackageManager.COMPONENT_ENABLED_STATE_ENABLED == state) {
//已经启用
return;
}
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
0);
}
/**
* 禁用组件 *
*
* @param componentName 重要方法
*/
private static void disableComponent(Context context, ComponentName componentName) {
PackageManager pm = context.getPackageManager();
int state = pm.getComponentEnabledSetting(componentName);
if (PackageManager.COMPONENT_ENABLED_STATE_DISABLED == state) {
//已经禁用
return;
}
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
0);
}
/**
* Get Mobile Type
*
* @return
*/
private static String getMobileType() {
return Build.MANUFACTURER;
}
/**
* GoTo Open Self Setting Layout
* Compatible Mainstream Models 兼容市面主流机型
* 跳转自启动
*
* @param context
*/
public static void jumpStartInterface(Context context) {
/* Intent intent = new Intent();
try {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.e("HLQ_Struggle", "******************当前手机型号为:" + getMobileType());
ComponentName componentName = null;
if (getMobileType().equals("Xiaomi")) { // 红米Note4测试通过
componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity");
} else if (getMobileType().equals("Letv")) { // 乐视2测试通过
intent.setAction("com.letv.android.permissionautoboot");
} else if (getMobileType().equals("samsung")) { // 三星Note5测试通过
componentName = new ComponentName("com.samsung.android.sm_cn", "com.samsung.android.sm.ui.ram.AutoRunActivity");
} else if (getMobileType().equals("HUAWEI")) { // 华为测试通过
componentName = ComponentName.unflattenFromString("com.huawei.systemmanager/.startupmgr.ui.StartupNormalAppListActivity");//跳自启动管理
//SettingOverlayView.show(context);
} else if (getMobileType().equals("vivo")) { // VIVO测试通过
componentName = ComponentName.unflattenFromString("com.iqoo.secure/.safeguard.PurviewTabActivity");
} else if (getMobileType().equals("Meizu")) { //万恶的魅族
// 通过测试,发现魅族是真恶心,也是够了,之前版本还能查看到关于设置自启动这一界面,系统更新之后,完全找不到了,心里默默Fuck!
// 针对魅族,我们只能通过魅族内置手机管家去设置自启动,所以我在这里直接跳转到魅族内置手机管家界面,具体结果请看图
componentName = ComponentName.unflattenFromString("com.meizu.safe/.permission.PermissionMainActivity");
} else if (getMobileType().equals("OPPO")) { // OPPO R8205测试通过
componentName = ComponentName.unflattenFromString("com.oppo.safe/.permission.startup.StartupAppListActivity");
} else if (getMobileType().equals("ulong")) { // 360手机 未测试
componentName = new ComponentName("com.yulong.android.coolsafe", ".ui.activity.autorun.AutoRunListActivity");
} else {
// 以上只是市面上主流机型,由于公司你懂的,所以很不容易才凑齐以上设备
// 针对于其他设备,我们只能调整当前系统app查看详情界面
// 在此根据用户手机当前版本跳转系统设置界面
if (Build.VERSION.SDK_INT >= 9) {
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", context.getPackageName(), null));
} else if (Build.VERSION.SDK_INT <= 8) {
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
intent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
}
}
intent.setComponent(componentName);
context.startActivity(intent);
} catch (Exception e) {//抛出异常就直接打开设置页面
//intent = new Intent(Settings.ACTION_SETTINGS);
intent = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}*/
;
/* try {
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
PermissionUtil.isAutoStartUp = true;*/
Intent intent = new Intent();
ComponentName componentName = null;
if (SystemUtils.isHW() || SystemUtils.isHONOR()) {
componentName = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity");
intent.setComponent(componentName);
} else if (SystemUtils.isSAMSUNG()) {
intent = getLauncherAppIntent(context, "com.samsung.android.sm_cn");
} else if (SystemUtils.isMEIZU()) {
intent = getLauncherAppIntent(context, "com.meizu.safe");
// componentName = new ComponentName("com.meizu.safe", "com.meizu.safe.SecurityMainActivity");
// intent.setComponent(componentName);
} else if (SystemUtils.isNOKIA()) {
componentName = new ComponentName("com.evenwell.powersaving.g3", "com.evenwell.powersaving.g3.exception.PowerSaverExceptionActivity");
intent.setComponent(componentName);
} else if (SystemUtils.isMIUI()) {
if (context instanceof Activity) {
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);
return;
}
} else if (SystemUtils.isOPPO()) {
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);
}
try {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {//抛出异常就直接打开设置页面
intent = new Intent(Settings.ACTION_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
Logger.e(TAG, "gotoBatteryOptimize\t" + e.getMessage());
}
PermissionUtil.isAutoStartUp = true;
}
}
......@@ -6,6 +6,7 @@ import android.text.TextUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
public class SystemUtils {
......@@ -21,7 +22,7 @@ public class SystemUtils {
* @return
*/
public static boolean isMIUI() {
return getDeviceBrand().toUpperCase().equals("XIAOMI")||getDeviceBrand().toUpperCase().equals("MEITU");
return getDeviceBrand().toUpperCase().equals("XIAOMI") || getDeviceBrand().toUpperCase().equals("MEITU");
}
......@@ -75,10 +76,15 @@ public class SystemUtils {
return getDeviceBrand().toUpperCase().equals("SAMSUNG");
}
public static boolean isNOKIA(){
public static boolean isNOKIA() {
return getDeviceBrand().toUpperCase().equals("NOKIA");
}
/**
* 获取MIUI版本
*
* @return
*/
public static String getMIUIVersion() {
String versionCode = "";
String manufacturer = Build.MANUFACTURER;
......@@ -89,6 +95,24 @@ public class SystemUtils {
return versionCode;
}
/**
* 获取EMUI版本
*
* @return
*/
public static String getEMUI() {
Class<?> classType = null;
String buildVersion = null;
try {
classType = Class.forName("android.os.SystemProperties");
Method getMethod = classType.getDeclaredMethod("get", new Class<?>[]{String.class});
buildVersion = (String) getMethod.invoke(classType, new Object[]{"ro.build.version.emui"});
} catch (Exception e) {
e.printStackTrace();
}
return buildVersion;
}
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
......
package com.android.launcher3.util;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.android.launcher3.Launcher;
import com.android.launcher3.manager.LauncherManager;
public class UIExecutor {
private static Handler uiHandler = new Handler(Looper.getMainLooper());
public static Handler uiHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
if (msg.what == 200) {
Intent home = new Intent(LauncherManager.getContext(), Launcher.class);
home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
LauncherManager.getContext().startActivity(home);
}
}
};
public static void postRunable(Runnable runnable) {
......@@ -13,8 +28,8 @@ public class UIExecutor {
// Looper.prepare();
}
public static void postRunableDelay(Runnable runnable,long millsTime) {
uiHandler.postDelayed(runnable,millsTime);
public static void postRunableDelay(Runnable runnable, long millsTime) {
uiHandler.postDelayed(runnable, millsTime);
// Looper.prepare();
}
}
......@@ -266,7 +266,7 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver {
private void setOffsetSafely(IBinder token) {
try {
mWM.setWallpaperOffsets(token, mCurrentOffset, 0.5f);
} catch (IllegalArgumentException e) {
} catch (Exception e) {
Log.e(TAG, "Error updating wallpaper offset: " + e);
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dp"
android:color="@color/color_white"/>
</shape>
\ 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">
<ProgressBar
android:id="@+id/pb_loading"
android:layout_width="60dp"
android:layout_height="60dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -6,51 +6,80 @@
android:background="@drawable/shape_toast_back"
android:orientation="vertical">
<RelativeLayout
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="6dp"
android:layout_marginBottom="10dp"
android:text="倍知守护提醒您:"
android:textColor="@android:color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:textColor="@android:color/white"
android:textSize="16sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/button_bg_drawable_shape"
android:paddingLeft="10dp"
android:paddingTop="4dp"
android:paddingRight="10dp"
android:paddingBottom="4dp"
android:text="关闭"
android:text="关闭提示"
android:textColor="@android:color/white"
android:textSize="16sp"></TextView>
android:textSize="16sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_bg_drawable_shape"
android:paddingLeft="10dp"
android:paddingTop="4dp"
android:paddingRight="10dp"
android:paddingBottom="4dp"
android:text="没有自动获取权限?(帮助)"
android:text="点此获取帮助"
android:textColor="@android:color/white"
android:textSize="16sp"></TextView>
</RelativeLayout>
<TextView
android:id="@+id/tv_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:gravity="center"
android:layout_centerHorizontal="true"
android:textColor="@android:color/white"
android:textSize="16sp"></TextView>
android:textSize="16sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -88,7 +88,7 @@
<string name="title_missing_notification_access" msgid="7503287056163941064">"需要获取通知使用权"</string>
<string name="msg_missing_notification_access" msgid="281113995110910548">"要显示通知圆点,请开启<xliff:g id="NAME">%1$s</xliff:g>的应用通知功能"</string>
<string name="title_change_settings" msgid="1376365968844349552">"更改设置"</string>
<string name="icon_badging_service_title" msgid="2309733118428242174">dankal_launcher</string>
<string name="icon_badging_service_title" msgid="2309733118428242174">倍知守护孩子端</string>
<string name="auto_add_shortcuts_label" msgid="8222286205987725611">"将图标添加到主屏幕"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"适用于新应用"</string>
<string name="icon_shape_override_label" msgid="2977264953998281004">"更改图标形状"</string>
......
......@@ -88,7 +88,7 @@
<string name="title_missing_notification_access" msgid="7503287056163941064">"需要獲取通知存取權"</string>
<string name="msg_missing_notification_access" msgid="281113995110910548">"如要顯示「通知圓點」,請開啟「<xliff:g id="NAME">%1$s</xliff:g>」的應用程式通知功能"</string>
<string name="title_change_settings" msgid="1376365968844349552">"變更設定"</string>
<string name="icon_badging_service_title" msgid="2309733118428242174">dankal_launcher</string>
<string name="icon_badging_service_title" msgid="2309733118428242174">倍知守护孩子端</string>
<string name="auto_add_shortcuts_label" msgid="8222286205987725611">"將圖示加到主畫面"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"適用於新安裝的應用程式"</string>
<string name="icon_shape_override_label" msgid="2977264953998281004">"變更圖示形狀"</string>
......
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
/*
* Copyright (C) 2008 The Android Open Source Project
*
......@@ -63,7 +62,7 @@
<!-- Loading apps text. [CHAR_LIMIT=50] -->
<string name="all_apps_loading_message">Loading apps&#8230;</string>
<!-- No-search-results text. [CHAR_LIMIT=50] -->
<string name="all_apps_no_search_results">No apps found matching \"<xliff:g id="query" example="Android">%1$s</xliff:g>\"</string>
<string name="all_apps_no_search_results">No apps found matching \"<xliff:g example="Android" id="query">%1$s</xliff:g>\"</string>
<!-- Label for the button which allows the user to get app search results. [CHAR_LIMIT=50] -->
<string name="all_apps_search_market_message">Search for more apps</string>
......@@ -120,10 +119,10 @@
shortcuts in Home.</string>
<!-- Toast shown on clicking a direct call shortcut. [CHAR_LIMIT=80] -->
<string name="msg_no_phone_permission"><xliff:g id="app_name" example="Launcher3">%1$s</xliff:g> is not allowed to make phone calls</string>
<string name="msg_no_phone_permission"><xliff:g example="Launcher3" id="app_name">%1$s</xliff:g> is not allowed to make phone calls</string>
<!-- Widgets: -->
<skip />
<skip />
<!-- Text to show user in place of a gadget when we can't display it properly -->
<string name="gadget_error_text">Problem loading widget</string>
......@@ -139,11 +138,11 @@
<!-- Accessibility -->
<!-- The format string for when an app is temporarily disabled. -->
<string name="disabled_app_label">Disabled <xliff:g id="app_name" example="Messenger">%1$s</xliff:g></string>
<string name="disabled_app_label">Disabled <xliff:g example="Messenger" id="app_name">%1$s</xliff:g></string>
<!-- The format string for when an app has a notification dot (meaning it has associated notifications). -->
<plurals name="badged_app_label">
<item quantity="one"><xliff:g id="app_name" example="Messenger">%1$s</xliff:g>, has <xliff:g id="notification_count" example="1">%2$d</xliff:g> notification</item>
<item quantity="other"><xliff:g id="app_name" example="Messenger">%1$s</xliff:g>, has <xliff:g id="notification_count" example="3">%2$d</xliff:g> notifications</item>
<item quantity="one"><xliff:g example="Messenger" id="app_name">%1$s</xliff:g>, has <xliff:g example="1" id="notification_count">%2$d</xliff:g> notification</item>
<item quantity="other"><xliff:g example="Messenger" id="app_name">%1$s</xliff:g>, has <xliff:g example="3" id="notification_count">%2$d</xliff:g> notifications</item>
</plurals>
<skip />
......@@ -156,7 +155,7 @@
<!-- Folder accessibility -->
<!-- The format string for when a folder is opened, speaks the dimensions -->
<string name="folder_opened">Folder opened, <xliff:g id="width" example="5">%1$d</xliff:g> by <xliff:g id="height" example="3">%2$d</xliff:g></string>
<string name="folder_opened">Folder opened, <xliff:g example="5" id="width">%1$d</xliff:g> by <xliff:g example="3" id="height">%2$d</xliff:g></string>
<!-- Instruction that clicking outside will close folder -->
<string name="folder_tap_to_close">Tap to close folder</string>
<!-- Instruction that clicking outside will commit folder rename -->
......@@ -164,9 +163,9 @@
<!-- Indication that folder closed -->
<string name="folder_closed">Folder closed</string>
<!-- Folder renamed format -->
<string name="folder_renamed">Folder renamed to <xliff:g id="name" example="Games">%1$s</xliff:g></string>
<string name="folder_renamed">Folder renamed to <xliff:g example="Games" id="name">%1$s</xliff:g></string>
<!-- Folder name format -->
<string name="folder_name_format">Folder: <xliff:g id="name" example="Games">%1$s</xliff:g></string>
<string name="folder_name_format">Folder: <xliff:g example="Games" id="name">%1$s</xliff:g></string>
<!-- Strings for the customization mode -->
<!-- Text for widget add button -->
......@@ -192,11 +191,11 @@
<!-- Title for the dialog shown when the app does not has notification access, explaining the requirement for notification access [CHAR LIMIT=50] -->
<string name="title_missing_notification_access">Notification access needed</string>
<!-- Message explaining to the user that the notification access is required by the app for showing 'Notification dots' [CHAR LIMIT=NONE] -->
<string name="msg_missing_notification_access">To show Notification Dots, turn on app notifications for <xliff:g id="name" example="My App">%1$s</xliff:g></string>
<string name="msg_missing_notification_access">To show Notification Dots, turn on app notifications for <xliff:g example="My App" id="name">%1$s</xliff:g></string>
<!-- Button text in the confirmation dialog which would take the user to the system settings [CHAR LIMIT=50] -->
<string name="title_change_settings">Change settings</string>
<!-- Summary for Notification dots setting. Tapping this will link enable/disable notification dots feature on the home screen. [CHAR LIMIT=50] -->
<string name="icon_badging_service_title">dankal_launcher</string>
<string name="icon_badging_service_title">倍知守护</string>
<!-- Label for the setting that allows the automatic placement of launcher shortcuts for applications and games installed on the device [CHAR LIMIT=40] -->
<string name="auto_add_shortcuts_label">Add icon to Home screen</string>
......@@ -236,20 +235,20 @@
You can remove it, or search for the app and install it manually.
</string>
<!-- Title for an app which is being downloaded. -->
<string name="app_downloading_title"><xliff:g id="name" example="Messenger">%1$s</xliff:g> downloading, <xliff:g id="progress" example="30%">%2$s</xliff:g> complete</string>
<string name="app_downloading_title"><xliff:g example="Messenger" id="name">%1$s</xliff:g> downloading, <xliff:g example="30%" id="progress">%2$s</xliff:g> complete</string>
<!-- Title for an app whose download has been started. -->
<string name="app_waiting_download_title"><xliff:g id="name" example="Messenger">%1$s</xliff:g> waiting to install</string>
<string name="app_waiting_download_title"><xliff:g example="Messenger" id="name">%1$s</xliff:g> waiting to install</string>
<!-- Strings for widgets & more in the popup container/bottom sheet -->
<!-- Title for a bottom sheet that shows widgets for a particular app -->
<string name="widgets_bottom_sheet_title"><xliff:g id="name" example="Messenger">%1$s</xliff:g> widgets</string>
<string name="widgets_bottom_sheet_title"><xliff:g example="Messenger" id="name">%1$s</xliff:g> widgets</string>
<!-- Accessibility title for the popup containing a list of widgets. [CHAR_LIMIT=50] -->
<string name="widgets_list">Widgets list</string>
<!-- Text announced by accessibility when the popup containing the list of widgets is closed. [CHAR_LIMIT=100] -->
<string name="widgets_list_closed">Widgets list closed</string>
<!-- Strings for accessibility actions -->
<!-- Strings for accessibility actions -->
<!-- Accessibility action to add an app to workspace. [CHAR_LIMIT=30] -->
<string name="action_add_to_workspace">Add to Home screen</string>
......@@ -266,28 +265,28 @@
<string name="action_move">Move item</string>
<!-- Accessibility description to move item to empty cell. -->
<string name="move_to_empty_cell">Move to row <xliff:g id="number" example="1">%1$s</xliff:g> column <xliff:g id="number" example="1">%2$s</xliff:g></string>
<string name="move_to_empty_cell">Move to row <xliff:g example="1" id="number">%1$s</xliff:g> column <xliff:g example="1" id="number">%2$s</xliff:g></string>
<!-- Accessibility description to move item inside a folder. -->
<string name="move_to_position">Move to position <xliff:g id="number" example="1">%1$s</xliff:g></string>
<string name="move_to_position">Move to position <xliff:g example="1" id="number">%1$s</xliff:g></string>
<!-- Accessibility description to move item to the hotseat. -->
<string name="move_to_hotseat_position">Move to favorites position <xliff:g id="number" example="1">%1$s</xliff:g></string>
<string name="move_to_hotseat_position">Move to favorites position <xliff:g example="1" id="number">%1$s</xliff:g></string>
<!-- Accessibility confirmation for item move. -->
<string name="item_moved">Item moved</string>
<!-- Accessibility description to move item into an existing folder. -->
<string name="add_to_folder">Add to folder: <xliff:g id="name" example="Games">%1$s</xliff:g></string>
<string name="add_to_folder">Add to folder: <xliff:g example="Games" id="name">%1$s</xliff:g></string>
<!-- Accessibility description to move item into an existing folder containing an app. -->
<string name="add_to_folder_with_app">Add to folder with <xliff:g id="name" example="Messenger">%1$s</xliff:g></string>
<string name="add_to_folder_with_app">Add to folder with <xliff:g example="Messenger" id="name">%1$s</xliff:g></string>
<!-- Accessibility confirmation for item added to folder. -->
<string name="added_to_folder">Item added to folder</string>
<!-- Accessibility description to create folder with another item. -->
<string name="create_folder_with">Create folder with: <xliff:g id="name" example="Game">%1$s</xliff:g></string>
<string name="create_folder_with">Create folder with: <xliff:g example="Game" id="name">%1$s</xliff:g></string>
<!-- Accessibility confirmation for folder created. -->
<string name="folder_created">Folder created</string>
......@@ -311,7 +310,7 @@
<string name="action_decrease_height">Decrease height</string>
<!-- Accessibility confirmation for widget resize. -->
<string name="widget_resized">Widget resized to width <xliff:g id="number" example="2">%1$s</xliff:g> height <xliff:g id="number" example="1">%2$s</xliff:g></string>
<string name="widget_resized">Widget resized to width <xliff:g example="2" id="number">%1$s</xliff:g> height <xliff:g example="1" id="number">%2$s</xliff:g></string>
<!-- Accessibility action to show quick actions menu for an icon. [CHAR_LIMIT=30] -->
<string name="action_deep_shortcut">Shortcuts</string>
......
......@@ -25,7 +25,7 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug{
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
......
......@@ -3,9 +3,12 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.dankal.dankal_launcher">
<uses-permission
android:name="android.permission.SET_ACTIVITY_WATCHER"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".MyApplication"
android:backupAgent="com.android.launcher3.LauncherBackupAgent"
android:debuggable="true"
......@@ -18,33 +21,43 @@
android:restoreAnyVersion="true"
android:supportsRtl="true"
android:theme="@style/LauncherTheme"
tools:replace="android:icon">
tools:replace="android:icon"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".PermissionSettingActivity"></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
-->
<!-- The settings activity. When extending keep the intent filter present -->
<activity
android:name=".PackageManageActivity"
android:autoRemoveFromRecents="true"
android:theme="@android:style/Theme.DeviceDefault.Settings">
<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">
<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"></activity>
<service
android:name="com.android.launcher3.accessibility.PermissionOpenAccessiblityService"
......@@ -58,17 +71,7 @@
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
<!--
The settings provider contains Home's data, like the workspace favorites. The permissions
should be changed to what is defined above. The authorities should also be changed to
represent the package name.
-->
</application>
</manifest>
\ No newline at end of file
package com.dankal.dankal_launcher;
import android.app.Activity;
import android.app.Application;
import com.android.launcher3.manager.LauncherManager;
......
package com.dankal.dankal_launcher;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
......@@ -15,20 +17,20 @@ import android.provider.Settings;
import android.text.Html;
import android.util.Log;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.Launcher;
import com.android.launcher3.accessibility.StopRunReceiver;
import com.android.launcher3.manager.ColumnDef;
import com.android.launcher3.manager.LauncherManager;
import com.android.launcher3.manager.ManagementInfo;
import com.android.launcher3.manager.TimeModeManager;
import com.android.launcher3.model.TimeConfig;
import com.android.launcher3.model.TimeRegion;
import com.android.launcher3.util.KToast;
import com.android.launcher3.util.Logger;
import com.android.launcher3.util.PermissionUtil;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -45,13 +47,15 @@ public class PackageManageActivity extends Activity {
private TextView tvLock, tvUnlock;
private KToast toast;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
List<Long> regions = new ArrayList<>();
/* List<Long> regions = new ArrayList<>();
regions.add(Long.valueOf(9 * 3600));
regions.add(Long.valueOf(10 * 3600));
......@@ -75,7 +79,7 @@ public class PackageManageActivity extends Activity {
.addUseRegion(regions)
.addAppTypeConfig(ColumnDef.AppUseType.GAME_LOCK_TYPE, 46800)
.build();
LauncherManager.getInstance().addWorkMode(config);
LauncherManager.getInstance().addWorkMode(config);*/
break;
case 1:
//
......@@ -107,6 +111,8 @@ public class PackageManageActivity extends Activity {
}
};
private Context mContent;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -123,6 +129,8 @@ public class PackageManageActivity extends Activity {
tvUnlock = findViewById(R.id.tv_unlock);
toast = new KToast(this.getApplicationContext());
tvAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -162,13 +170,13 @@ public class PackageManageActivity extends Activity {
managementInfo.setUseEndTimeStamp(3600);
managementInfo.setPackageName("com.tencent.mm");
managementInfo.setLock(ColumnDef.LockApp.DEADLINE);
managementInfo.setUseType(ColumnDef.AppUseType.GAME_LOCK_TYPE);
managementInfo.setPackageName("com.tencent.android.qqdownloader");
managementInfo.setLock(ColumnDef.LockApp.UNLOCKED);
managementInfo.setUseType(ColumnDef.AppUseType.SAFE_TYPE);
LauncherManager.getInstance().addPackageInfo(managementInfo);
handler.sendEmptyMessageDelayed(1, 500);
Logger.e(TAG, "before\t" + LauncherManager.getInstance().getManageAppInfo("com.tencent.mm").toString());
// Logger.e(TAG, "before\t" + LauncherManager.getInstance().getManageAppInfo("com.tencent.mm").toString());
}
......@@ -178,10 +186,12 @@ public class PackageManageActivity extends Activity {
tvLock.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// LauncherManager.getInstance().forceLockScreenForever(PackageManageActivity.this);
// handler.sendEmptyMessageDelayed(1,1000*15);
// PermissionUtil.setDefaultL(getApplicationContext());
LauncherManager.getInstance().jumpSearchAppCanUse(PackageManageActivity.this);
//LauncherManager.getInstance().forceLockScreenForever(PackageManageActivity.this);
PermissionUtil.setDefaultL(getApplicationContext());
/* handler.sendEmptyMessageDelayed(1,1000*15);
PermissionUtil.setDefaultL(getApplicationContext());*/
//LauncherManager.getInstance().jumpSearchAppCanUse(PackageManageActivity.this);
}
});
......@@ -192,7 +202,6 @@ public class PackageManageActivity extends Activity {
}
});
findViewById(R.id.jump_setting).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -210,6 +219,55 @@ public class PackageManageActivity extends Activity {
});
findViewById(R.id.tv_is_uninstall).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* if (LauncherManager.getInstance().getUninstallEnable()){
Toast.makeText(PackageManageActivity.this, "可以卸载", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(PackageManageActivity.this, "不能卸载", Toast.LENGTH_SHORT).show();
}*/
/*Intent progressIntent = new Intent();
progressIntent.setAction("activity.home.progress");
progressIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(progressIntent);*/
//LauncherManager.getInstance().getUninstallEnable()
LauncherManager.getInstance().changeUninstallEnable(true);
String msg = "辅助权限设置已开启,请根据提示点击,\n如无提示请等稍等 或 手动返回权限设置页面";
toast.setText(msg);
toast.show();
toast.show();
}
});
//findViewById(R.id.tv_is_uninstall).setOnLongClickListener();
findViewById(R.id.tv_permission).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(PackageManageActivity.this, PermissionSettingActivity.class));
}
});
findViewById(R.id.tv_1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WindowPermissionCheck.openPermission(PackageManageActivity.this);
}
});
findViewById(R.id.tv_2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
// Date date = new Date();
//
// date.setTime(System.currentTimeMillis());
......@@ -220,14 +278,14 @@ public class PackageManageActivity extends Activity {
// Logger.e(TAG, week + "\t" + (calendar.getFirstDayOfWeek() == Calendar.SUNDAY));
List<Long> regions = new ArrayList<>();
regions.add(Long.valueOf(11 * 3600));
regions.add(Long.valueOf(12 * 3600));
regions.add(Long.valueOf(0 * 3600));
regions.add(Long.valueOf(13 * 3600));
regions.add(Long.valueOf(14 * 3600));
regions.add(Long.valueOf(15 * 3600));
regions.add(Long.valueOf(15 * 3600));
regions.add(Long.valueOf(17 * 3600));
regions.add(Long.valueOf(24 * 3600));
TimeConfig config = new TimeConfig.Builder(ColumnDef.TimeManager.WORK_DAY)
.lockScreenMode(ColumnDef.LockScreen.MODE_REST)
......@@ -238,9 +296,30 @@ public class PackageManageActivity extends Activity {
LauncherManager.getInstance().addWorkMode(config);
LauncherManager.getInstance().setCurrentWorkMode(ColumnDef.TimeManager.WORK_DAY);
// handler.sendEmptyMessageDelayed(0, 15000);
}
//判断是否有悬浮窗权限
findViewById(R.id.tv_floating_window).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (WindowPermissionCheck.checkPermission(PackageManageActivity.this)) {
Toast.makeText(PackageManageActivity.this, "有悬浮窗权限", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(PackageManageActivity.this, "没有开启悬浮窗权限", Toast.LENGTH_SHORT).show();
}
}
});
findViewById(R.id.tv_change_icon).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//隐藏图标
//PermissionUtil.initLauncherIconIsShow(PackageManageActivity.this, false);
PermissionUtil.jumpStartInterface(PackageManageActivity.this);
}
});
}
private void toggleNotificationListenerService() {
PackageManager pm = getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(this, NotificationListener2.class),
......@@ -267,6 +346,8 @@ public class PackageManageActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
Log.i("zzzzzzzzzzz", "PackageManageActivity_onResume");
Logger.e(TAG, PermissionUtil.hasOverLayerPermission(this) + "");
}
......@@ -277,6 +358,33 @@ public class PackageManageActivity extends Activity {
onResume();
}
public void showToastLongTow(String msg) {
handler.post(new Runnable() {
@Override
public void run() {
Logger.e(TAG, "showToastLong\t" + msg);
toast.setText(msg);
toast.show();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i("zzzzzzzzzzz", "PackageManageActivity_onDestroy");
}
@Override
protected void onStop() {
super.onStop();
Log.i("zzzzzzzzzzz", "PackageManageActivity_onStop");
}
@Override
protected void onPause() {
super.onPause();
Log.i("zzzzzzzzzzz", "PackageManageActivity_onPause");
}
}
package com.dankal.dankal_launcher;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.content.Intent;
import android.os.Bundle;
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.manager.LauncherManager;
import com.android.launcher3.util.PermissionUtil;
public class PermissionSettingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_permission_setting);
initData();
}
@Override
protected void onResume() {
super.onResume();
check();
}
//激活设备管理
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 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;
private Button buttonConfirm;
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);
buttonConfirm = findViewById(R.id.button_confirm);
buttonConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//mPresenter.addTimeSwitch();
LauncherManager.getInstance().setInterceptSystemSetting(true);
LauncherManager.getInstance().changeExitState(false);
}
});
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);
// clCloseApplication.setOnClickListener(clickAction);
}
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;
//自启动
if (PermissionUtil.checkAutoStartUp(this)) {
openFailTick(ivSelfStartingPermissions);
clSelfStartingPermissions.setEnabled(false);
selfStarting = true;
} else {
openFailure(ivSelfStartingPermissions);
clSelfStartingPermissions.setEnabled(true);
selfStarting = false;
}
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;
//打包的时候
if (!PermissionUtil.enAbleADB(this)) {
openFailTick(ivCloseUsbTest);
clCloseUsbTest.setEnabled(false);
closeUsbTest = true;
} else {
openFailure(ivCloseUsbTest);
clCloseUsbTest.setEnabled(true);
closeUsbTest = false;
}
boolean openNotificationListener;
//判断是否开启通知栏
if (PermissionUtil.isNotificationListenersEnabled(this)) {
openFailTick(ivOpenNotificationListener);
clOpenNotificationListener.setEnabled(false);
openNotificationListener = true;
} else {
openFailure(ivOpenNotificationListener);
clOpenNotificationListener.setEnabled(true);
openNotificationListener = false;
}
boolean settingDefaultLauncher;
//判断是否设置为默认桌面
if (PermissionUtil.isDefaultHome(this)) {
openFailTick(ivSettingDefaultLauncher);
clSettingDefaultLauncher.setEnabled(false);
settingDefaultLauncher = true;
} else {
openFailure(ivSettingDefaultLauncher);
clSettingDefaultLauncher.setEnabled(true);
settingDefaultLauncher = false;
}
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);
}
private void openFailTick(ImageView imageView) {
imageView.setImageResource(R.mipmap.ic_tick);
}
// 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);
//设置默认桌面
}
}
}
}
package com.dankal.dankal_launcher;
import android.app.Activity;
import android.app.admin.DeviceAdminService;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import androidx.core.view.accessibility.AccessibilityViewCommand;
public class PermissionUtils {
}
package com.dankal.dankal_launcher;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.accessibility.AccessibilityManager;
import com.android.launcher3.util.PermissionUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Author: roczheng
* Date: 2020/5/31
* Time: 15:26
* Description:
*/
public class WindowPermissionCheck {
public static boolean checkPermission(Activity activity) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
// && !Settings.canDrawOverlays(activity)) {
// return false;
// }
return PermissionUtil.checkFloatPermission(activity);
}
public static void openPermission(Activity activity) {
activity.startActivityForResult(
new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + activity.getPackageName())), 0);
}
public static void onActivityResult(Activity activity,
int requestCode,
int resultCode,
Intent data,
OnWindowPermissionListener onWindowPermissionListener) {
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 {
// Toast.makeText(activity.getApplicationContext(), "授权成功", Toast.LENGTH_SHORT).show();
if (onWindowPermissionListener != null)
onWindowPermissionListener.onSuccess();
}
}
}
public static boolean isServiceON(Context context, String className) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo>
runningServices = activityManager.getRunningServices(100);
if (runningServices.size() < 0) {
return false;
}
for (int i = 0; i < runningServices.size(); i++) {
ComponentName service = runningServices.get(i).service;
if (service.getClassName().contains(className)) {
return true;
}
}
return false;
}
/** 查看服务是否开启*/
public static Boolean isServiceRunning(Context context, String serviceName) {
//获取服务方法 参数 必须用大写的Context!!!
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> infos = am.getRunningServices(100);
for (ActivityManager.RunningServiceInfo info : infos) {
String className = info.service.getClassName();
if(serviceName.equals(className))
return true;
}
return false;
}
public static boolean isAccessibilityEnabled(Context context) throws RuntimeException {
if (context == null) {
return false;
}
// 检查AccessibilityService是否开启
AccessibilityManager am = (AccessibilityManager) context.getSystemService(android.content.Context.ACCESSIBILITY_SERVICE);
boolean isAccessibilityEnabled_flag = am.isEnabled();
boolean isExploreByTouchEnabled_flag = false;
// 检查无障碍服务是否以语音播报的方式开启
isExploreByTouchEnabled_flag = isScreenReaderActive(context);
return (isAccessibilityEnabled_flag && isExploreByTouchEnabled_flag);
}
private final static String SCREEN_READER_INTENT_ACTION = "android.accessibilityservice.AccessibilityService";
private final static String SCREEN_READER_INTENT_CATEGORY = "android.accessibilityservice.category.FEEDBACK_SPOKEN";
private static boolean isScreenReaderActive(Context context) {
// 通过Intent方式判断是否存在以语音播报方式提供服务的Service,还需要判断开启状态
Intent screenReaderIntent = new Intent(SCREEN_READER_INTENT_ACTION);
screenReaderIntent.addCategory(SCREEN_READER_INTENT_CATEGORY);
List<ResolveInfo> screenReaders = context.getPackageManager().queryIntentServices(screenReaderIntent, 0);
// 如果没有,返回false
if (screenReaders == null || screenReaders.size() <= 0) {
return false;
}
boolean hasActiveScreenReader = false;
if (Build.VERSION.SDK_INT <= 15) {
ContentResolver cr = context.getContentResolver();
Cursor cursor = null;
int status = 0;
for (ResolveInfo screenReader : screenReaders) {
cursor = cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName
+ ".providers.StatusProvider"), null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
status = cursor.getInt(0);
cursor.close();
// 状态1为开启状态,直接返回true即可
if (status == 1) {
return true;
}
}
}
} else if (Build.VERSION.SDK_INT >= 26) {
// 高版本可以直接判断服务是否处于开启状态
for (ResolveInfo screenReader : screenReaders) {
hasActiveScreenReader |= isAccessibilitySettingsOn(context, screenReader.serviceInfo.packageName + "/" + screenReader.serviceInfo.name);
}
} else {
// 判断正在运行的Service里有没有上述存在的Service
List<String> runningServices = new ArrayList<String>();
android.app.ActivityManager manager = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (android.app.ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
runningServices.add(service.service.getPackageName());
}
for (ResolveInfo screenReader : screenReaders) {
if (runningServices.contains(screenReader.serviceInfo.packageName)) {
hasActiveScreenReader |= true;
}
}
}
return hasActiveScreenReader;
}
// To check if service is enabled
private static boolean isAccessibilitySettingsOn(Context context, String service) {
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
String settingValue = Settings.Secure.getString(
context.getApplicationContext().getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
mStringColonSplitter.setString(settingValue);
while (mStringColonSplitter.hasNext()) {
String accessibilityService = mStringColonSplitter.next();
if (accessibilityService.equalsIgnoreCase(service)) {
return true;
}
}
}
return false;
}
public interface OnWindowPermissionListener {
void onSuccess();
void onFailure();
}
}
......@@ -40,4 +40,48 @@
android:layout_height="wrap_content"
android:text="跳转设置"
android:textSize="22sp"></TextView>
<TextView
android:id="@+id/tv_is_uninstall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="设置可卸载"/>
<TextView
android:id="@+id/tv_floating_window"
android:layout_width="match_parent"
android:text="判断是否有悬浮窗权限"
android:textSize="22sp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="步骤1,显示在其他应用上层"/>
<TextView
android:id="@+id/tv_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="步骤2,打开无障碍"/>
<TextView
android:id="@+id/tv_permission"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="步骤3,,跳转权限页面"/>
<TextView
android:id="@+id/tv_change_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:text="切换图标"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="11.5dp"
android:background="@mipmap/ic_set" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_activate_device_manager"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="15.5dp"
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_activate_device_manager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15.5dp"
android:src="@mipmap/ic_failure"
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="55dp"
android:id="@+id/cl_close_power"
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: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:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/cl_self_starting_permissions"
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: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:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_open_application_permission"
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: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>
<androidx.constraintlayout.widget.ConstraintLayout
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
style="@style/text_col97_size16"
android:layout_marginStart="17.5dp"
android:text="关闭USB测试"
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_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:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_open_notification_listener"
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: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"
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_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:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:id="@+id/cl_setting_launcher"
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: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"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:gravity="center_vertical"
android:text="SearchAppCanUseActivity"
android:background="@color/colorFF"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_debugInfoActivity"
style="@style/text_col97_size16"
android:paddingStart="17.5dp"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="1dp"
android:gravity="center_vertical"
android:text="DebugInfoActivity"
android:background="@color/colorFF"/>
<Button
android:id="@+id/button_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="14dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="14dp"
android:paddingBottom="5dp"
android:layout_marginBottom="22.5dp"
android:text="开启守护" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -3,4 +3,9 @@
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorFF">#FFFFFF</color>
<color name="col_97">#FF979797</color>
</resources>
<resources>
<string name="app_name">dankal_launcher</string>
<string name="app_name">倍知守护孩子端</string>
</resources>
<resources>
<style name="text_col97_size16" parent="text_col97">
<item name="android:textSize">16sp</item>
</style>
<style name="text_col97" parent="ww_hw">
<item name="android:textColor">@color/col_97</item>
</style>
<style name="ww_hw">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
</resources>
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