Skip to content

Commit

Permalink
更新图片,文档
Browse files Browse the repository at this point in the history
  • Loading branch information
tignioj committed Jun 2, 2020
1 parent 9d8512f commit b8a9695
Show file tree
Hide file tree
Showing 24 changed files with 171 additions and 26 deletions.
120 changes: 108 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
# 定时冻结

无需root,定时冻结应用或者锁定手机
无需root,定时冻结应用或者锁定手机,侧重点在于在哪个时间段内冻结App和锁定手机,而不是App限制使用时长。

它并不是一个App管理器,当然你也可以这样用。

配合另一个App【[TimeLine App](https://github.com/tignioj/TimeLineApp)】,一起食用更佳,适合管不住自己玩手机的,或者本来查题目,查到着突然打开某某新闻,一个小时又过去了,忘记自己本来想干嘛。

# 截图
![Home](resources/imgs/device-2020-05-27-174429.png)

![Category](resources/imgs/device-2020-05-27-174539.png)
- 未激活

-[NO ACTIVATE](resources/imgs/device-2020-05-27-174714.png)

- 第一次冻结,选中app后,需要添加分类

![FIRST LAUNCH](resources/imgs/device-2020-06-02-090801_first_launch.png);

- 添加分类

![NEW Category](resources/imgs/device-2020-06-02-090857_new_category.png)

- 分类

![Category](resources/imgs/device-2020-06-02-091505_categorys.png)

- 分类下的App

![Apps Category](resources/imgs/device-2020-06-02-091125_apps_by_category.png)

- 首个任务

![Apps By Category](resources/imgs/device-2020-05-27-174616.png)
![NEW TASKS](resources/imgs/device-2020-06-02-091318_first_tasks.png)

![Timer Task](resources/imgs/device-2020-05-27-174633.png)
- 添加锁屏任务示例

![Edit Task](resources/imgs/device-2020-05-27-174714.png)
![LOCK SCREEN](resources/imgs/device-2020-06-02-091610_lock_screen_demo.png)

- 任务列表

![TASK LIST](resources/imgs/device-2020-06-02-091629_tasks.png)

- 取消激活后,就可以卸载

![DEACTIVATE](resources/imgs/device-2020-06-02-091705_deactivate.png)


# 特性
Expand All @@ -35,21 +66,49 @@
因为它不需要Root权限,因此需要一些特殊的手段来激活这个应用

## 步骤一:下载Apk,*不能*直接安装到手机,你需要使用[adb工具](https://developer.android.com/studio/releases/platform-tools)

这是因为清单中设置了`testOnly="true"`

只有这样,才能更加方便卸载,否则如果app突然打不开,你将无法卸载

如果你发现你的可以直接安装,是酷安下载的,那是因为该的版本删去了`testOnly="true"`的代码。其实也是可以用的

不过我建议你把它卸载了, 不然到时候那天你打不开这个APP,就只能恢复出厂设置了, 之前我用一个App就是如此。刚授予权限就打不开,结果卸载也失败, 该开发者也停更了, 导致我最后只能恢复出厂设置。

去release下最新版,按照这里的教程走一遍。

因为单纯安装到手机意义不大,还需要激活。

## 步骤二:退出所有手机账户
在设置->账户 出退出你的所有账号,例如退出小米账号, 注意,是所有

## 步骤三:打开开发者模式,打开USB调试模式
- 在设置->账户 出退出你的所有账号,例如退出小米账号, 注意,是所有

![退出账号](resources/imgs/device-2020-06-02-085457_log_out.png)

- 账户与同步, 一个都不要留

![账户与同步](resources/imgs/device-2020-06-02-085559_remove_all_account.png)

- 建议先卸载支付宝,激活后再重新安装

## 步骤三:手机打开开发者模式,打开USB调试模式

- 这个不用多说了吧 设置->开发者选项->开启USB调试模式

## 步骤四:下载adb工具到电脑[adb工具](https://developer.android.com/studio/releases/platform-tools) ,并解压

![ADB-TOOLS](resources/imgs/2020-06-02%2009_32_25-platform-tools.png)

- 去release下载[APK文件](https://github.com/tignioj/AutoFreezeApp/releases)

放到和adb解压后的同一个目录下,如图所示(我把它改名为app-release.apk)

![ADB APK WITH SAME DIRECTORY](resources/imgs/2020-06-02%2009_38_39-platform-tools_apk.png)

## 步骤四:下载adb工具到电脑

## 步骤五:用adb工具连接手机

### 1) 显示设备

```
PS C:\Users\lili> adb devices
List of devices attached
Expand Down Expand Up @@ -77,7 +136,12 @@ Users:
generic_x86_64:/ $ pm remove-user 999
```

只留下一个 (中文的是`UserInfo{0:机主:13}`,英文是`UserInfo{0:Owner:13}`)
![LEFT ONE](resources/imgs/2020-06-02%2008_56_47-left_one.png)


## 步骤七:利用adb安装App, 并设置该App为管理员

### 1) 安装App
先退出shell, 再安装
```
Expand All @@ -86,6 +150,10 @@ PS C:\Users\lili> adb -s [你设备的id] install -t app-release.apk
Performing Streamed Install
Success
```
上面的命令手机可能弹出提示, 点击允许

![INSTALL APK](resources/imgs/device-2020-06-02-090133_allow_install_using_adb.png)

## 2) 设置为管理员(关键)
```
PS C:\Users\lili> adb -s [你设备的id] shell dpm set-device-owner com.tignioj.freezeapp/.MyDeviceAdminReceiver
Expand Down Expand Up @@ -116,17 +184,45 @@ Caused by: android.os.RemoteException: Remote stack trace:

解决办法: 尝试卸载支付宝后,回到步骤六的2). 如果仍然没有出现Success, 请参考我下面给出的链接再去寻找解决办法, 或者贴出你的操作步骤到github的ISSUE

![SET DEVICE OWNER](resources/imgs/2020-06-02%2009_03_49-Windows%20PowerShell_success_and_falure.png)

# 如何卸载?

## 方法一:
进入App,设置->取消激活,确认之后会提示: `管理员:未激活`, 这时候就可以直接卸载了


## 方法二:

(不适用于直接安装的用户)

1. 做上述同样的步骤直到第五步(包括第五步)以连接到手机
2. 执行命令

2. 执行命令
```
generic_x86_64:/ $ dpm remove-active-admin com.tignioj.freezeapp/.MyDeviceAdminReceiver
Success: Admin removed ComponentInfo{com.tignioj.freezeapp/com.tignioj.freezeapp.MyDeviceAdminReceiver}
```
然后你就可以卸载它了
未设置`testOnly=true`的会报错 `Attempt to remove non-test admin ComponentInfo`
```shell
PS C:\Users\lili> adb -s emulator-5554 shell dpm remove-active-admin com.tignioj.freezeapp/.MyDeviceAdminReceiver
java.lang.SecurityException: Attempt to remove non-test admin ComponentInfo{com.tignioj.freezeapp/com.tignioj.freezeapp.MyDeviceAdminReceiver} 0
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.forceRemoveActiveAdmin(IDevicePolicyManager.java:8177)
at com.android.commands.dpm.Dpm.runRemoveActiveAdmin(Dpm.java:222)
at com.android.commands.dpm.Dpm.onRun(Dpm.java:121)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)
at com.android.commands.dpm.Dpm.main(Dpm.java:41)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:338)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.devicepolicy.DevicePolicyManagerService.forceRemoveActiveAdmin(DevicePolicyManagerService.java:4017)
at android.app.admin.IDevicePolicyManager$Stub.onTransact(IDevicePolicyManager.java:3154)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
```


## 参考教程
Expand Down
75 changes: 62 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ android {
release {
//load resources from local.properties
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream() ;
properties.load( inputStream )
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream();
properties.load(inputStream)

//
def sdkDir = properties.getProperty('key.file')
storeFile file(sdkDir)

//read key
def key_keyAlias = properties.getProperty( 'keyAlias' )
def key_keyPassword = properties.getProperty( 'keyPassword' ) ;
def key_storePassword = properties.getProperty( 'storePassword' ) ;
def key_keyAlias = properties.getProperty('keyAlias')
def key_keyPassword = properties.getProperty('keyPassword');
def key_storePassword = properties.getProperty('storePassword');

storePassword key_storePassword
keyAlias key_keyAlias
Expand All @@ -24,33 +24,38 @@ android {
debug {
//load resources from local.properties
Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream() ;
properties.load( inputStream )
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream();
properties.load(inputStream)

//
def sdkDir = properties.getProperty('key.file')
storeFile file( sdkDir )
storeFile file(sdkDir)

//read key
def key_keyAlias = properties.getProperty( 'keyAlias' )
def key_keyPassword = properties.getProperty( 'keyPassword' ) ;
def key_storePassword = properties.getProperty( 'storePassword' ) ;
def key_keyAlias = properties.getProperty('keyAlias')
def key_keyPassword = properties.getProperty('keyPassword');
def key_storePassword = properties.getProperty('storePassword');

storePassword key_storePassword
keyAlias key_keyAlias
keyPassword key_keyPassword
}

}


compileSdkVersion 29
buildToolsVersion "29.0.3"

def vCode = getVersionCode()
def vName = getVersionName()

defaultConfig {
applicationId 'com.tignioj.freezeapp'
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionCode vCode
versionName vName

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
Expand All @@ -66,6 +71,50 @@ android {

}

/**
* 根据版本名称获取版本号
* @return
*/
//获取版本code,通过100 000 000 关联versionName
def getVersionCode() {
def versionSplite = getVersionName().split("\\.")
println(versionSplite.toString())
StringBuffer sb = new StringBuffer();
for (item in versionSplite) {
switch (item.length()) {
case 1:
sb.append('00');
sb.append(item);
break
case 2:
sb.append('0');
sb.append(item);
break
case 3:
sb.append(item);
break
default:
throw new GradleException("version name is error !")
break
}
}
return sb.toInteger()
}

/**
* 获取名称
* @return
*/
def getVersionName() {

Properties properties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream();
properties.load(inputStream)
def versionCode = properties.getProperty('version.name')
return versionCode.toString()

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:testOnly="true"
android:theme="@style/AppTheme">
<activity
android:name="com.tignioj.freezeapp.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
Binary file added resources/imgs/2020-06-02 08_56_47-left_one.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/imgs/device-2020-05-27-174429.png
Binary file not shown.
Binary file removed resources/imgs/device-2020-05-27-174539.png
Binary file not shown.
Binary file removed resources/imgs/device-2020-05-27-174616.png
Binary file not shown.
Binary file removed resources/imgs/device-2020-05-27-174633.png
Binary file not shown.
Binary file modified resources/imgs/device-2020-05-27-174714.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/imgs/device-2020-06-02-091629_tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b8a9695

Please sign in to comment.