Commit 1b5ee325 by lihuaikun

fix:修复禁用模式不能打电话/KToast帮助按钮点击闪退的问题

parent e5192f94
......@@ -9,7 +9,7 @@ Launcher3
* 现在Google官方的代码已经不需要做太大改动就能用了,有需要定制桌面的可以只从官方仓库拉取最新代码了
---
我写了几篇博客来讲解Launcher3桌面什么的,有兴趣的可以看看这里
参考资料
* [概述](https://fookwood.com/launcher-source-analysis)
* [Android的触摸控制流程](https://fookwood.com/android-touch-events)
......
......@@ -104,7 +104,7 @@ ext {
GITHUB_REPO_PATH = "../../androidlibrary"
PUBLISH_GROUP_ID = 'cn.dankal.android'
PUBLISH_ARTIFACT_ID = 'launcher'
PUBLISH_VERSION = '1.3.6'
PUBLISH_VERSION = '1.3.7'
}
uploadArchives {
......
......@@ -57,6 +57,7 @@
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signatureOrSystem" />
<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" />
......
......@@ -62,6 +62,7 @@
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="dollar_openBracket_applicationId_closeBracket.permission.READ_SETTINGS" />
<uses-permission android:name="dollar_openBracket_applicationId_closeBracket.permission.WRITE_SETTINGS" />
<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" />
......@@ -171,6 +172,9 @@ a
android:screenOrientation="portrait"
android:taskAffinity="dollar_openBracket_applicationId_closeBracket.lockscreen"
android:theme="@style/LockScreenStyle" />
<activity
android:name="com.android.launcher3.HelpActivity"
android:screenOrientation="portrait" />
<!--
Should point to the content provider which can be used to dump Launcher3 compatible
......
......@@ -57,6 +57,7 @@
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="signatureOrSystem" />
<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" />
......
......@@ -62,6 +62,7 @@
<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 android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
......@@ -171,6 +172,9 @@ a
android:screenOrientation="portrait"
android:taskAffinity="${applicationId}.lockscreen"
android:theme="@style/LockScreenStyle" />
<activity
android:name="com.android.launcher3.HelpActivity"
android:screenOrientation="portrait" />
<!--
Should point to the content provider which can be used to dump Launcher3 compatible
......
......@@ -248,6 +248,7 @@ drawable ic_all_apps_bg_icon_4
drawable ic_allapps
drawable ic_allapps_pressed
drawable ic_allapps_search
drawable ic_back_black
drawable ic_call_phone
drawable ic_camera
drawable ic_close
......@@ -338,6 +339,7 @@ id iv_message
id iv_normal
id iv_normal_game
id iv_normal_mode
id iv_onback
id iv_rest
id launcher
id layout
......@@ -367,10 +369,12 @@ id tabs
id text
id text_and_background
id title
id tv_close
id tv_current_date
id tv_current_time
id tv_force_mode
id tv_game_time
id tv_help
id tv_know
id tv_msg
id tv_normal
......@@ -386,6 +390,7 @@ id tv_tips
id view_highlighted
id view_scrim
id view_unhighlight_background
id webview
id widget_cell
id widget_dims
id widget_name
......@@ -422,6 +427,7 @@ interpolator disco_bounce
interpolator folder_interpolator
interpolator large_folder_preview_item_close_interpolator
interpolator large_folder_preview_item_open_interpolator
layout activity_help
layout activity_lock_screen
layout add_item_confirmation_activity
layout all_apps
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/white"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_onback"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:padding="15dp"
android:src="@drawable/ic_back_black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="权限引导"
android:layout_gravity="center"
android:textSize="16sp"
android:textColor="#000"></TextView>
</FrameLayout>
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/shape_toast_back"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_msg"
android:id="@+id/tv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingLeft="10dp"
android:paddingTop="4dp"
android:paddingRight="10dp"
android:paddingBottom="4dp"
android:text="关闭"
android:textColor="@android:color/white"
android:textSize="16sp"></TextView>
<TextView
android:id="@+id/tv_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="4dp"
android:paddingRight="10dp"
android:paddingBottom="4dp"
android:text="没有自动获取权限?(帮助)"
android:textColor="@android:color/white"
android:textSize="18sp"></TextView>
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>
</LinearLayout>
\ No newline at end of file
......@@ -7,4 +7,4 @@
android:description="@string/app_manager_accessibility_service_description"
android:canRequestFilterKeyEvents="true"
android:canPerformGestures="true"
android:notificationTimeout="1000" />
\ No newline at end of file
android:notificationTimeout="100" />
\ No newline at end of file
......@@ -931,6 +931,7 @@ drawable ic_all_apps_bg_icon_4
drawable ic_allapps
drawable ic_allapps_pressed
drawable ic_allapps_search
drawable ic_back_black
drawable ic_call_phone
drawable ic_camera
drawable ic_close
......@@ -1120,6 +1121,7 @@ id iv_message
id iv_normal
id iv_normal_game
id iv_normal_mode
id iv_onback
id iv_rest
id launcher
id layout
......@@ -1218,10 +1220,12 @@ id titleDividerNoCustom
id title_template
id top
id topPanel
id tv_close
id tv_current_date
id tv_current_time
id tv_force_mode
id tv_game_time
id tv_help
id tv_know
id tv_msg
id tv_normal
......@@ -1240,6 +1244,7 @@ id up
id view_highlighted
id view_scrim
id view_unhighlight_background
id webview
id widget_cell
id widget_dims
id widget_name
......@@ -1318,6 +1323,7 @@ layout abc_search_dropdown_item_icons_2line
layout abc_search_view
layout abc_select_dialog_material
layout abc_tooltip
layout activity_help
layout activity_lock_screen
layout add_item_confirmation_activity
layout all_apps
......
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="dankal_launcher" module="Launcher3" revision="unspecified" status="integration" publication="20200413150614"/>
<info organisation="dankal_launcher" module="Launcher3" revision="unspecified" status="integration" publication="20200423101513"/>
<configurations>
<conf name="_internal_aapt2_binary" visibility="private" transitive="false"/>
<conf name="androidApis" visibility="public"/>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.dankal.android</groupId>
<artifactId>launcher</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
......
......@@ -49,6 +49,7 @@
android:label="@string/permlab_write_settings"
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.RECEIVE_USER_PRESENT" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
......
......@@ -8,12 +8,16 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.StrictMode;
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.DisplayMetrics;
......@@ -40,10 +44,13 @@ import com.android.launcher3.util.PermissionUtil;
import com.android.launcher3.util.TimeUtils;
import com.android.launcher3.views.SwipeUpFinishLayout;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.reflect.Method;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
/**
* 锁屏
......@@ -68,6 +75,7 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
private SwipeUpFinishLayout swipeUpFinishLayout;
private File imagePath;
public static final int TIME_CYCLE = 1000;
private Handler handler = new Handler() {
......@@ -86,6 +94,9 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();
View root = LayoutInflater.from(this).inflate(R.layout.activity_lock_screen, null);
......@@ -254,8 +265,25 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
Intent intent = new Intent(Intent.ACTION_DIAL);
startActivity(intent);
} else if (v == ivCamera) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivity(intent);
// Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
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();
String name = "bzsh_" + System.currentTimeMillis() + ".png";
imagePath = new File(rootPath + "/bzsh/", name);
if (!imagePath.exists()) {
imagePath.getParentFile().mkdir();
}
Logger.e(TAG, imagePath.getAbsolutePath());
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 if (v == ivMessage) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("vnd.android-dir/mms-sms");
......@@ -287,16 +315,20 @@ public class LockScreenActivity extends BaseActivity implements View.OnClickList
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Logger.e(TAG, requestCode + "" + resultCode);
if (imagePath!=null){
try {
MediaStore.Images.Media.insertImage(getContentResolver(), imagePath.getAbsolutePath(), imagePath.getName(), null);//图片插入到系统图库
} catch (FileNotFoundException e) {
e.printStackTrace();
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + imagePath.getAbsolutePath())));//通知图库刷新
imagePath=null;
}
@Override
protected void onStop() {
super.onStop();
LauncherManager.getInstance().updateLockScreenDelay();
}
@Override
protected void onDestroy() {
handler.removeCallbacksAndMessages(null);
......
......@@ -294,6 +294,8 @@ public class ListenerAppService extends Service {
}
topActivity = stats.get(j).getPackageName();
Logger.e(TAG, topActivity + "\t" + currentMills);
if (LauncherManager.getInstance().isSafePackageName(topActivity) || LauncherManager.getInstance().isSystemPackageName(topActivity)) {
return -1;
}
......@@ -305,7 +307,7 @@ public class ListenerAppService extends Service {
lastUseAppControlTimeStamp = currentMills;
Logger.e(TAG, topActivity + "\t" + currentMills);
if (topActivity.equals(context.getPackageName()))
......
......@@ -3353,8 +3353,8 @@ public class PermissionOpenAccessiblityService extends AccessibilityService {
handler.post(new Runnable() {
@Override
public void run() {
Logger.e(TAG, "dismissToast");
toast.dismiss();
// Logger.e(TAG, "dismissToast");
// toast.dismiss();
}
});
}
......
......@@ -27,7 +27,7 @@ public class Constants {
// 某个分类下的分类总时长已使用完毕
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"};
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[] SYSTEM_APP = {"com.android.systemui", "com.samsung.android.packageinstaller|com.android.packageinstaller", "com.samsung.android.incallui|com.android.incallui"};
......
......@@ -422,8 +422,6 @@ public class LauncherManager {
notifyListeners();
DBManager.doSql(mContext, ops);
}
}
......
......@@ -80,6 +80,7 @@ public class KToast {
// SystemUtils.getDeviceBrand()+Build.MODEL+Build.VERSION.SDK_INT;
String url = "https://php-parent-child.dankal.cn/v1/kid/index?name=" + SystemUtils.getDeviceBrand();
intent.putExtra("url", url);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
......
......@@ -197,7 +197,7 @@ public class PackageManageActivity extends Activity {
new Thread(new Runnable() {
@Override
public void run() {
LauncherManager.getInstance().forceLockScreen(PackageManageActivity.this, 10*60);
LauncherManager.getInstance().forceLockScreen(PackageManageActivity.this, 1*60);
// PermissionUtil.gotoDeviceAdminPermissionSetting(getApplicationContext());
// handler.sendEmptyMessage(3);
}
......
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