add zhanxun keystore
add mpv file add 跨进程广播安装文件
This commit is contained in:
@@ -91,7 +91,7 @@ android {
|
||||
//签名
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file("src/jks/tt.jks")
|
||||
storeFile file("src/keystore/tt.jks")
|
||||
storePassword "fht19961207"
|
||||
keyAlias "key0"
|
||||
keyPassword "981964879aa"
|
||||
@@ -100,7 +100,7 @@ android {
|
||||
}
|
||||
|
||||
release {
|
||||
storeFile file("src/jks/tt.jks")
|
||||
storeFile file("src/keystore/tt.jks")
|
||||
storePassword "fht19961207"
|
||||
keyAlias "key0"
|
||||
keyPassword "981964879aa"
|
||||
|
||||
BIN
app/src/keystore/zhanxun.keystore
Normal file
BIN
app/src/keystore/zhanxun.keystore
Normal file
Binary file not shown.
@@ -35,6 +35,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="com.jiaoguanyi.appstore.permissions.INSTALL_APK" />
|
||||
|
||||
<application
|
||||
android:name="com.tt.base.MyApplication"
|
||||
@@ -46,19 +47,19 @@
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name="com.tt.activity.PackageActivity"></activity>
|
||||
<activity android:name="com.tt.activity.JMainActivity" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.tt.activity.MainActivity">
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
</activity>
|
||||
<activity android:name="com.tt.activity.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<receiver
|
||||
android:name="com.tt.receiver.PackageReceiver"
|
||||
android:enabled="true"
|
||||
|
||||
@@ -33,6 +33,15 @@ public class JMainActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void initView() {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
View decorView = getWindow().getDecorView();
|
||||
// Hide both the navigation bar and the status bar.
|
||||
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
|
||||
// a general rule, you should design your app to hide the status bar whenever you
|
||||
// hide the navigation bar.
|
||||
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //导航栏
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN;//全屏
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,22 +1,36 @@
|
||||
package com.tt.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.os.Environment
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tt.ttutils.R
|
||||
import com.tt.ttutils.java.CmdUtil
|
||||
import com.tt.ttutils.java.DevicesUtils
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.jessyan.autosize.internal.CancelAdapt
|
||||
import java.io.File
|
||||
|
||||
class MainActivity : AppCompatActivity(), CancelAdapt {
|
||||
lateinit var button: Button
|
||||
private val INSTALLAPK_ACTION = "JGY_INSTALLAPK_ACTION"
|
||||
private val INSTALLAPK_PREMISSIONS = "com.jiaoguanyi.appstore.permissions.INSTALL_APK"
|
||||
lateinit var filePath:String
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
//截图
|
||||
// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png")
|
||||
textView.setText(DevicesUtils.getSerial())
|
||||
|
||||
filePath =
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator + "Android_8.8.0.5420_537068981.apk"
|
||||
button = findViewById(R.id.button)
|
||||
button.setOnClickListener {
|
||||
val intent = Intent(INSTALLAPK_ACTION)
|
||||
intent.putExtra("packageName", "com.tencent.mobileqq")
|
||||
intent.putExtra("filePath", filePath)
|
||||
sendBroadcast(intent, INSTALLAPK_PREMISSIONS)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
app/src/main/java/com/tt/mvp/BasePresenter.java
Normal file
10
app/src/main/java/com/tt/mvp/BasePresenter.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.tt.mvp;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public interface BasePresenter<V extends BaseView> {
|
||||
|
||||
void attachView(@NonNull V view);
|
||||
|
||||
void detachView();
|
||||
}
|
||||
4
app/src/main/java/com/tt/mvp/BaseView.java
Normal file
4
app/src/main/java/com/tt/mvp/BaseView.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package com.tt.mvp;
|
||||
|
||||
public interface BaseView {
|
||||
}
|
||||
143
app/src/main/java/com/tt/mvp/MainContact.java
Normal file
143
app/src/main/java/com/tt/mvp/MainContact.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.tt.mvp;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class MainContact {
|
||||
public interface MainView extends BaseView {
|
||||
//设置批次信息
|
||||
void setBatchText(String text, int visibility);
|
||||
//设置班级信息
|
||||
void setClassText(String text, int visibility);
|
||||
//设置学号信息
|
||||
void setNumberText(String text, int visibility);
|
||||
//设置姓名信息
|
||||
void setNameText(String text, int visibility);
|
||||
//获取设备锁定状态
|
||||
void setLockedState(boolean loocked);
|
||||
//是否第一次联网
|
||||
void setFirstConnect(boolean state);
|
||||
//发送mac地址
|
||||
void sendMACFinished();
|
||||
//更新设备信息
|
||||
void updateDeviceInfoFinished();
|
||||
//获取时间管控
|
||||
void getSnTimeControlFinished();
|
||||
//设置击关推送别名
|
||||
void setAliasFinished();
|
||||
//设置极光推送标签
|
||||
void setTagsFinished();
|
||||
//设置极光推送平台标签
|
||||
void setJpushPlatformTagsFinished();
|
||||
//获取应用市场更新
|
||||
void checkStoreUpdateFinished();
|
||||
//获取测试应用更新
|
||||
void checkTestUpdateFinished();
|
||||
//手动获取设备信息更新
|
||||
void buttonCheckUpdateFinished(boolean update, JsonObject jsonObject);
|
||||
//开始
|
||||
//设置设备后台设置
|
||||
void getSystemSettingbegin();
|
||||
//获取可被写入的安装包名结束
|
||||
void getAppLimitFinished(String packageList);
|
||||
//获取设备批次结束
|
||||
void getDeviceBatchFinished();
|
||||
//获取强制下载apk结束
|
||||
void getForceDownloadFinished();
|
||||
//获取浏览器上网管控设置结束
|
||||
void getBrowserListFinished(String whitelist);
|
||||
//获取浏览器书签设置管控结束
|
||||
void getBrowserBookmarksFinished();
|
||||
//获取应用图标桌面可见性管控结束
|
||||
void getDesktopIconFinished();
|
||||
//获取应用自启升级和网络权限管理结束
|
||||
void getAppAutoStartUpdateAndNetFinished();
|
||||
//获取第三方应用子页面ID连网限制结束
|
||||
void getAppIDControlFinished();
|
||||
//获取第三方应用内部网页跳转屏蔽结束
|
||||
void setAppinsideWebFinished();
|
||||
//获取系统其他管控设置结束
|
||||
void setSystemSettingFinished();
|
||||
//获取开发者选项结束
|
||||
void getDeveloperFinished();
|
||||
//设置开机动画
|
||||
void setLogoImgFinished();
|
||||
//获取应用霸屏结束
|
||||
void setTopAppFinished();
|
||||
/*
|
||||
* MainService
|
||||
* */
|
||||
//设置屏幕锁状态结束
|
||||
void setScreenLockStateFinished(boolean locked, String tips);
|
||||
//获取桌面结束
|
||||
void getDefaultDesktopFinished();
|
||||
}
|
||||
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
//获取学生信息
|
||||
void getStudesInfo();
|
||||
//获取设备锁定状态
|
||||
void getLockedState();
|
||||
//是否第一次联网
|
||||
void getFirstConnect();
|
||||
//关闭所有功能
|
||||
void setDisableSetting();
|
||||
//发送mac地址
|
||||
void sendMACAddress();
|
||||
//更新设备信息
|
||||
void updateDeviceInfo();
|
||||
//获取时间管控
|
||||
void getSnTimeControl();
|
||||
//设置击关推送别名
|
||||
void setJpushAlias();
|
||||
//设置极光推送标签
|
||||
void setJpushTags();
|
||||
//设置极光推送平台标签
|
||||
void setJpushPlatformTags(int platform);
|
||||
//获取应用更新
|
||||
void checkStoreUpdate();
|
||||
//手动获取设备信息更新
|
||||
void buttonCheckUpdate(View view);
|
||||
//获取测试应用更新
|
||||
void checkTestUpdate();
|
||||
//开始
|
||||
//获取设备后台设置
|
||||
void getSystemSettingbegin();
|
||||
//获取可被写入的安装包名
|
||||
void getAppLimit();
|
||||
//获取设备批次
|
||||
void getDeviceBatch(String packageList);
|
||||
//获取强制下载apk
|
||||
void getForceDownload();
|
||||
//获取浏览器上网管控设置
|
||||
void getBrowserList();
|
||||
//获取浏览器书签设置管控
|
||||
void getBrowserBookmarks(String whitelist);
|
||||
//设置白名单的url
|
||||
void getBrowserWhiteList();
|
||||
//获取应用图标桌面可见性管控
|
||||
void getDesktopIcon();
|
||||
//获取应用自启升级和网络权限管理
|
||||
void getAppAutoStartUpdateAndNet();
|
||||
//获取第三方应用子页面ID连网限制
|
||||
void getAppIDControl();
|
||||
//获取第三方应用内部网页跳转屏蔽
|
||||
void setAppinsideWeb();
|
||||
//获取系统其他管控设置
|
||||
void setSystemSetting();
|
||||
//获取开发者选项
|
||||
void getDeveloper();
|
||||
//设置开机动画
|
||||
void setLogoImg();
|
||||
//应用霸屏
|
||||
void setTopApp();
|
||||
/*
|
||||
* MainService
|
||||
* */
|
||||
//获取屏幕锁状态
|
||||
void getScreenLockState();
|
||||
//获取桌面
|
||||
void getDefaultDesktop();
|
||||
}
|
||||
}
|
||||
217
app/src/main/java/com/tt/mvp/MainPresenter.java
Normal file
217
app/src/main/java/com/tt/mvp/MainPresenter.java
Normal file
@@ -0,0 +1,217 @@
|
||||
package com.tt.mvp;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
|
||||
/**
|
||||
* MainActivity和MainService 的 Presenter
|
||||
*
|
||||
* @author jgy02
|
||||
*/
|
||||
public class MainPresenter implements MainContact.Presenter {
|
||||
private static final String TAG = MainPresenter.class.getSimpleName();
|
||||
private MainContact.MainView mView;
|
||||
private Context mContext;
|
||||
|
||||
private final String DEFAULT_INFO = "暂无信息";
|
||||
private final int OK = 200;
|
||||
|
||||
public MainPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "MainPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@androidx.annotation.NonNull MainContact.MainView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStudesInfo() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLockedState() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFirstConnect() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisableSetting() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendMACAddress() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceInfo() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSnTimeControl() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJpushAlias() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJpushTags() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJpushPlatformTags(int platform) {
|
||||
mView.setJpushPlatformTagsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkStoreUpdate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonCheckUpdate(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkTestUpdate() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getSystemSettingbegin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppLimit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeviceBatch(String packageList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getForceDownload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserList() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserBookmarks(String whitelist) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserWhiteList() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDesktopIcon() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppAutoStartUpdateAndNet() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppIDControl() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppinsideWeb() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemSetting() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeveloper() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoImg() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopApp() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getScreenLockState() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDefaultDesktop() {
|
||||
|
||||
}
|
||||
}
|
||||
580
app/src/main/java/com/tt/server/MainService.java
Normal file
580
app/src/main/java/com/tt/server/MainService.java
Normal file
@@ -0,0 +1,580 @@
|
||||
package com.tt.server;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tt.mvp.MainContact;
|
||||
import com.tt.mvp.MainPresenter;
|
||||
import com.tt.ttutils.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class MainService extends Service implements MainContact.MainView {
|
||||
private MainPresenter mPresenter;
|
||||
private static final String TAG = MainService.class.getSimpleName();
|
||||
public static boolean netWorkIsRunning = false;
|
||||
|
||||
private interface Start {
|
||||
void onstar(long time);
|
||||
}
|
||||
|
||||
private Start start;
|
||||
|
||||
private ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Long> emitter) throws Exception {
|
||||
start = new Start() {
|
||||
@Override
|
||||
public void onstar(long time) {
|
||||
emitter.onNext(time);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> timeObserver = new Observer<Long>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("TimeObserver", "onNext: " + aLong);
|
||||
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
mPresenter.getFirstConnect();
|
||||
mPresenter.getLockedState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public MainService() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
mPresenter = new MainPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
registerReceivers();
|
||||
Observable.create(subscribe)
|
||||
.throttleLast(60, TimeUnit.SECONDS)
|
||||
.subscribe(timeObserver);
|
||||
// cleanLauncherCache();
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unRegisterReceivers();
|
||||
mPresenter.detachView();
|
||||
}
|
||||
|
||||
//执行所有请求的时间
|
||||
long runningTime;
|
||||
|
||||
//MainService上次执行时间
|
||||
long startCommandTime = 0;
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
JPushInterface.init(this);
|
||||
// if (MainActivity.isForeground) {
|
||||
// Log.e(TAG, "onStartCommand: MainActivity: isForeground: " + MainActivity.isForeground);
|
||||
// } else {
|
||||
// if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) && startCommandTime != 0) {
|
||||
// Log.e(TAG, "onStartCommand: " + "启动时间过短");
|
||||
// //一分钟内防止多次调用
|
||||
// } else {
|
||||
// mPresenter.getFirstConnect();
|
||||
// mPresenter.getLockedState();
|
||||
// startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
// Log.e(TAG, "onStartCommand: isForeground: " + MainActivity.isForeground);
|
||||
// Log.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime));
|
||||
// }
|
||||
start.onstar(SystemClock.elapsedRealtime());
|
||||
Log.e("timeObserver", "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime) + "ms");
|
||||
// }
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void registerReceivers() {
|
||||
registerLockScreenReceiver();
|
||||
registerTimeReceiver();
|
||||
registerInstallReceiver();
|
||||
}
|
||||
|
||||
private void unRegisterReceivers() {
|
||||
if (null != lockScreenReceiver) {
|
||||
unregisterReceiver(lockScreenReceiver);
|
||||
}
|
||||
if (null != mTimeChangedReceiver) {
|
||||
unregisterReceiver(mTimeChangedReceiver);
|
||||
}
|
||||
if (null != mInstallReceiver) {
|
||||
unregisterReceiver(mInstallReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private static WindowManager windowManager;
|
||||
private View topView;
|
||||
boolean screenlocked = false;
|
||||
boolean timelocked = false;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void showFloatingWindow(String name) {
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
// 获取WindowManager服务
|
||||
if (null == windowManager) {
|
||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
}
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
windowManager.getDefaultDisplay().getRealMetrics(dm);
|
||||
int width = dm.widthPixels; // 屏幕宽度(像素)
|
||||
int height = dm.heightPixels; // 屏幕高度(像素)
|
||||
// 新建悬浮窗控件
|
||||
final Button button = new Button(getApplicationContext());
|
||||
button.setText("霸屏测试");
|
||||
button.setAlpha(0.9f);
|
||||
button.setBackgroundColor(Color.WHITE);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// windowManager.removeView(button);
|
||||
}
|
||||
});
|
||||
if (null == topView) {
|
||||
// topView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.activity_top, null);
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
} else {
|
||||
if (topView.getTag().equals("added")) {
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// topView.setAlpha(0.8f);
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
// 设置LayoutParam
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
|
||||
} else {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
layoutParams.flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND
|
||||
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
|
||||
layoutParams.format = PixelFormat.RGBA_8888;
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
//systemUiVisibility 关闭通知栏和导航栏
|
||||
layoutParams.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||
layoutParams.x = 0;
|
||||
layoutParams.y = 0;
|
||||
// 将悬浮窗控件添加到WindowManager
|
||||
windowManager.addView(topView, layoutParams);
|
||||
topView.setTag("added");
|
||||
}
|
||||
}
|
||||
|
||||
private void hideFloatingWindow() {
|
||||
if (null == windowManager) {
|
||||
return;
|
||||
}
|
||||
if (null != topView) {
|
||||
windowManager.removeView(topView);
|
||||
topView = null;
|
||||
}
|
||||
}
|
||||
|
||||
private LockScreenReceiver lockScreenReceiver;
|
||||
|
||||
private void registerLockScreenReceiver() {
|
||||
if (null == lockScreenReceiver) {
|
||||
lockScreenReceiver = new LockScreenReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(LockScreenReceiver.action_lock);
|
||||
filter.addAction(LockScreenReceiver.action_unlock);
|
||||
registerReceiver(lockScreenReceiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
//锁屏管控广播
|
||||
public class LockScreenReceiver extends BroadcastReceiver {
|
||||
public static final String action_lock = "LockScreenReceiver_lockscreen";
|
||||
public static final String action_unlock = "LockScreenReceiver_unlockscreen";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("LockScreenReceiver", "onReceive: " + action);
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
if (action_lock.equals(action)) {
|
||||
String name = intent.getStringExtra("name");
|
||||
if (!timelocked) {
|
||||
showFloatingWindow(name);
|
||||
}
|
||||
screenlocked = true;
|
||||
} else if (action_unlock.equals(action)) {
|
||||
if (!timelocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
screenlocked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TimeChangedReceiver mTimeChangedReceiver;
|
||||
|
||||
/**
|
||||
* 监听时间变化
|
||||
*/
|
||||
public void registerTimeReceiver() {
|
||||
mTimeChangedReceiver = new TimeChangedReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||
filter.addAction(TimeChangedReceiver.ACTION_UPDATE);
|
||||
registerReceiver(mTimeChangedReceiver, filter);
|
||||
}
|
||||
|
||||
public class TimeChangedReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION_UPDATE = "TimeChangedReceiver_update";
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "data changed");
|
||||
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "time changed");
|
||||
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "timezone changed");
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "time tick");
|
||||
} else if (ACTION_UPDATE.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "date update");
|
||||
}
|
||||
// ForegroundAppUtil.openTopApp(context);
|
||||
// long nowTime = System.currentTimeMillis();
|
||||
// TimeUtils.ContralTime contralTime = TimeUtils.getDefaltContralTime(MainService.this);
|
||||
// if (null != contralTime) {
|
||||
// if (contralTime.inControlTime(nowTime)) {
|
||||
// if (!screenlocked) {
|
||||
// showFloatingWindow("管控时间:" + contralTime.toString());
|
||||
// } else {
|
||||
// TextView textView = topView.findViewById(R.id.textView);
|
||||
// textView.setText("管控时间:" + contralTime.toString());
|
||||
// }
|
||||
// timelocked = true;
|
||||
// } else {
|
||||
// mPresenter.getScreenLockState();
|
||||
// if (!screenlocked) {
|
||||
// hideFloatingWindow();
|
||||
// }
|
||||
// timelocked = false;
|
||||
// }
|
||||
// } else {
|
||||
// if (!screenlocked) {
|
||||
// hideFloatingWindow();
|
||||
// }
|
||||
// mPresenter.getScreenLockState();
|
||||
// timelocked = false;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInstallReceiver() {
|
||||
if (mInstallReceiver == null) {
|
||||
mInstallReceiver = new InstallReceiver();
|
||||
}
|
||||
IntentFilter intentFilter = new IntentFilter(INSTALLAPK_ACTION);
|
||||
registerReceiver(mInstallReceiver, intentFilter, INSTALLAPK_PREMISSIONS, null);
|
||||
}
|
||||
|
||||
private String INSTALLAPK_ACTION = "JGY_INSTALLAPK_ACTION";
|
||||
private String INSTALLAPK_PREMISSIONS = "com.jiaoguanyi.appstore.permissions.INSTALL_APK";
|
||||
|
||||
private InstallReceiver mInstallReceiver;
|
||||
|
||||
/**
|
||||
* https://blog.csdn.net/jdsjlzx/article/details/82630113
|
||||
*/
|
||||
class InstallReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
Log.e(TAG, "onReceive: " + "Action is NULL!");
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "onReceive: " + "Sender is " + intent.getPackage());
|
||||
String packageName = intent.getStringExtra("packageName");
|
||||
String filePath = intent.getStringExtra("filePath");
|
||||
if (!TextUtils.isEmpty(packageName) && !TextUtils.isEmpty(filePath)) {
|
||||
Log.e(TAG, "onReceive: " + "packageName: " + packageName + "filePath: " + filePath);
|
||||
installApkByPackage(filePath, packageName);
|
||||
} else if (!TextUtils.isEmpty(filePath)) {
|
||||
// String pkg = ApkUtils.getPackageName(MainService.this, filePath);
|
||||
// Log.e(TAG, "onReceive: " + "pkg: " + pkg + "\tfilePath: " + filePath);
|
||||
// installApkByPackage(filePath, pkg);
|
||||
} else {
|
||||
Log.e(TAG, "onReceive: " + "no filePath and packageName");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePath 路径
|
||||
* @param pkg 包名
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
synchronized private void installApkByPackage(String filePath, String pkg) {
|
||||
String oldListString = Settings.System.getString(getContentResolver(), "qch_app_forbid");
|
||||
HashSet<String> packageList = new HashSet<>(Arrays.asList(oldListString.split(",")));
|
||||
packageList.add(pkg);
|
||||
String join = String.join(",", packageList);
|
||||
Log.e(TAG, "installApkByPackage: " + join);
|
||||
Settings.System.putString(getContentResolver(), "qch_app_forbid", join);
|
||||
// ApkUtils.installApp(MainService.this, filePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBatchText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNumberText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNameText(String text, int visibility) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockedState(boolean loocked) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次使用默认关闭所有功能
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
@Override
|
||||
public void setFirstConnect(boolean state) {
|
||||
Log.e(TAG, "isFirstConnect: " + "end request");
|
||||
if (state) {
|
||||
mPresenter.setDisableSetting();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMACFinished() {
|
||||
mPresenter.updateDeviceInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceInfoFinished() {
|
||||
mPresenter.getSnTimeControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSnTimeControlFinished() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAliasFinished() {
|
||||
mPresenter.setJpushTags();
|
||||
//设置极光推送tag
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTagsFinished() {
|
||||
mPresenter.checkStoreUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJpushPlatformTagsFinished() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkStoreUpdateFinished() {
|
||||
mPresenter.checkTestUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkTestUpdateFinished() {
|
||||
mPresenter.getDefaultDesktop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonCheckUpdateFinished(boolean update, JsonObject jsonObject) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSystemSettingbegin() {
|
||||
mPresenter.getAppLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppLimitFinished(String packageList) {
|
||||
mPresenter.getDeviceBatch(packageList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeviceBatchFinished() {
|
||||
mPresenter.getForceDownload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getForceDownloadFinished() {
|
||||
mPresenter.getBrowserList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserListFinished(String whitelist) {
|
||||
mPresenter.getBrowserBookmarks(whitelist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserBookmarksFinished() {
|
||||
mPresenter.getBrowserWhiteList();
|
||||
mPresenter.getDesktopIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDesktopIconFinished() {
|
||||
mPresenter.getAppAutoStartUpdateAndNet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppAutoStartUpdateAndNetFinished() {
|
||||
mPresenter.getAppIDControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppIDControlFinished() {
|
||||
mPresenter.setAppinsideWeb();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppinsideWebFinished() {
|
||||
mPresenter.setSystemSetting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemSettingFinished() {
|
||||
mPresenter.getDeveloper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeveloperFinished() {
|
||||
mPresenter.setLogoImg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoImgFinished() {
|
||||
mPresenter.setTopApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopAppFinished() {
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScreenLockStateFinished(boolean locked, String tips) {
|
||||
if (locked) {
|
||||
if (!timelocked) {
|
||||
showFloatingWindow(tips);
|
||||
}
|
||||
screenlocked = true;
|
||||
} else {
|
||||
if (!timelocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
screenlocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDefaultDesktopFinished() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,4 +16,39 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<com.ttstd.viewlibrary.ToggleButton2
|
||||
android:id="@+id/disable_switch"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="60dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.ttstd.viewlibrary.ToggleButton
|
||||
android:id="@+id/toggleButton"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="40dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/disable_switch" />
|
||||
|
||||
<com.suke.widget.SwitchButton
|
||||
android:id="@+id/switch_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toggleButton" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -16,6 +16,15 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<com.ttstd.viewlibrary.ToggleButton2
|
||||
android:id="@+id/disable_switch"
|
||||
android:layout_width="80dp"
|
||||
|
||||
BIN
app/src/sign/security.rar
Normal file
BIN
app/src/sign/security.rar
Normal file
Binary file not shown.
BIN
app/src/sign/security.zip
Normal file
BIN
app/src/sign/security.zip
Normal file
Binary file not shown.
BIN
app/src/sign/signapk.jar
Normal file
BIN
app/src/sign/signapk.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user