update:2020.5.14

fix:兼容Android10.0 http联网问题,静默安装问题
add:
This commit is contained in:
2020-05-14 18:34:36 +08:00
parent eb1f74288c
commit fdbecb973e
13 changed files with 236 additions and 195 deletions

View File

@@ -15,11 +15,10 @@ android {
minSdkVersion 20 minSdkVersion 20
targetSdkVersion 29 targetSdkVersion 29
// versionCode 128 versionCode 129
// versionName "2.8.5"//测试jiaoguanyi.cn versionName "2.8.6"//测试jiaoguanyi.cn
// versionCode 127
versionCode 127 // versionName "2.0.0.7"// 正式jiaoguanyi.com 双数正式 单数测试
versionName "2.0.0.7"// 正式jiaoguanyi.com 双数正式 单数测试
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -11,14 +11,11 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.ACTION_SCREEN_ON" /> <uses-permission android:name="android.permission.ACTION_SCREEN_ON" />
<uses-permission android:name="android.permission.ACTION_SCREEN_OFF" /> <uses-permission android:name="android.permission.ACTION_SCREEN_OFF" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- ##############################极光推送############################## -->
<!-- ##############################极光推送############################## -->
<!-- Required --> <!-- Required -->
<permission <permission
android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE" android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" /> android:protectionLevel="signature" /> <!-- Required -->
<!-- Required -->
<uses-permission android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE" /> <uses-permission android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
@@ -29,7 +26,6 @@
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission <uses-permission
android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
android:maxSdkVersion="22" /> android:maxSdkVersion="22" />
@@ -39,11 +35,16 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:networkSecurityConfig="@xml/network"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<receiver
android:name=".utils.InstallResultReceiver"
android:enabled="true"
android:exported="true"></receiver>
<activity <activity
android:name="com.mjsheng.myappstore.activity.MainActivity" android:name=".activity.MainActivity"
android:excludeFromRecents="true"> android:excludeFromRecents="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -52,16 +53,15 @@
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name=".server.MyDownloadService" />
<service android:name="com.mjsheng.myappstore.server.MyDownloadService" /> <service android:name=".server.GuardService" />
<service android:name="com.mjsheng.myappstore.server.GuardService" />
<service <service
android:name="com.mjsheng.myappstore.server.StepService" android:name=".server.StepService"
android:exported="true" /> android:exported="true" />
<service android:name="com.mjsheng.myappstore.server.InitJpushServer" /> <service android:name=".server.InitJpushServer" />
<receiver <receiver
android:name="com.mjsheng.myappstore.receiver.NewAppReceiver" android:name=".receiver.NewAppReceiver"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true">
<intent-filter android:priority="1000"> <intent-filter android:priority="1000">
@@ -73,7 +73,7 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name="com.mjsheng.myappstore.receiver.BootReceiver" android:name=".receiver.BootReceiver"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true">
<intent-filter android:priority="1000"> <intent-filter android:priority="1000">
@@ -87,11 +87,10 @@
<action android:name="android.intent.action.USER_PRESENT" /> <action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.SCREEN_ON" /> <action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" /> <action android:name="android.intent.action.SCREEN_OFF" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name="com.mjsheng.myappstore.receiver.MyJPushReceiver" android:name=".receiver.MyJPushReceiver"
android:enabled="true"> android:enabled="true">
<intent-filter> <intent-filter>
@@ -108,8 +107,7 @@
<category android:name="${JPUSH_PKGNAME}" /> <category android:name="${JPUSH_PKGNAME}" />
</intent-filter> </intent-filter>
</receiver> </receiver> <!-- Required. For publish channel feature -->
<!-- Required. For publish channel feature -->
<!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。 --> <!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。 -->
<!-- 例如: --> <!-- 例如: -->
<!-- 发到 Google Play 的APK可以设置为 google-play; --> <!-- 发到 Google Play 的APK可以设置为 google-play; -->
@@ -131,16 +129,13 @@
<meta-data <meta-data
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider> <!-- ##############################极光推送############################## -->
<!-- ##############################极光推送############################## --> <!-- Rich push 核心功能 since 2.0.6 -->
<!-- Rich push 核心功能 since 2.0.6-->
<activity <activity
android:name="cn.jpush.android.ui.PopWinActivity" android:name="cn.jpush.android.ui.PopWinActivity"
android:exported="false" android:exported="false"
android:theme="@style/MyDialogStyle" android:theme="@style/MyDialogStyle"
tools:replace="android:exported"></activity> tools:replace="android:exported" /> <!-- Required SDK核心功能 -->
<!-- Required SDK核心功能-->
<activity <activity
android:name="cn.jpush.android.ui.PushActivity" android:name="cn.jpush.android.ui.PushActivity"
android:configChanges="orientation|keyboardHidden" android:configChanges="orientation|keyboardHidden"
@@ -153,9 +148,7 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="com.jiaoguanyi.appstore" /> <category android:name="com.jiaoguanyi.appstore" />
</intent-filter> </intent-filter>
</activity> </activity> <!-- Required SDK 核心功能 -->
<!-- Required SDK 核心功能-->
<!-- 可配置android:process参数将PushService放在其他进程中 --> <!-- 可配置android:process参数将PushService放在其他进程中 -->
<service <service
android:name="cn.jpush.android.service.PushService" android:name="cn.jpush.android.service.PushService"
@@ -167,16 +160,13 @@
<action android:name="cn.jpush.android.intent.PushService" /> <action android:name="cn.jpush.android.intent.PushService" />
<action android:name="cn.jpush.android.intent.PUSH_TIME" /> <action android:name="cn.jpush.android.intent.PUSH_TIME" />
</intent-filter> </intent-filter>
</service> </service> <!-- since 3.0.9 Required SDK 核心功能 -->
<!-- since 3.0.9 Required SDK 核心功能-->
<provider <provider
android:name="cn.jpush.android.service.DataProvider" android:name="cn.jpush.android.service.DataProvider"
android:authorities="com.jiaoguanyi.appstore.DataProvider" android:authorities="com.jiaoguanyi.appstore.DataProvider"
android:exported="false" android:exported="false"
android:process=":pushcore" android:process=":pushcore"
tools:replace="android:authorities" /> tools:replace="android:authorities" /> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 --> <!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
<service <service
android:name="cn.jpush.android.service.DaemonService" android:name="cn.jpush.android.service.DaemonService"
@@ -184,23 +174,21 @@
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.DaemonService" /> <action android:name="cn.jpush.android.intent.DaemonService" />
<category android:name="com.jiaoguanyi.appstore" /> <category android:name="com.jiaoguanyi.appstore" />
</intent-filter> </intent-filter>
</service> <!-- since 3.1.0 Required SDK 核心功能 -->
</service>
<!-- since 3.1.0 Required SDK 核心功能-->
<provider <provider
android:name="cn.jpush.android.service.DownloadProvider" android:name="cn.jpush.android.service.DownloadProvider"
android:authorities="com.jiaoguanyi.appstore.DownloadProvider" android:authorities="com.jiaoguanyi.appstore.DownloadProvider"
android:exported="true" android:exported="true"
tools:replace="android:authorities" /> tools:replace="android:authorities" /> <!-- Required SDK核心功能 -->
<!-- Required SDK核心功能-->
<receiver <receiver
android:name="cn.jpush.android.service.PushReceiver" android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true" android:enabled="true"
android:exported="false"> android:exported="false">
<intent-filter android:priority="1000"> <intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!--Required 显示通知栏 --> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!-- Required 显示通知栏 -->
<category android:name="com.jiaoguanyi.appstore" /> <category android:name="com.jiaoguanyi.appstore" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
@@ -214,14 +202,10 @@
<data android:scheme="package" /> <data android:scheme="package" />
</intent-filter> </intent-filter>
</receiver> </receiver> <!-- Required SDK核心功能 -->
<!-- Required SDK核心功能-->
<receiver <receiver
android:name="cn.jpush.android.service.AlarmReceiver" android:name="cn.jpush.android.service.AlarmReceiver"
android:exported="false" /> android:exported="false" /> <!-- since 3.3.0 Required SDK核心功能 -->
<!--since 3.3.0 Required SDK核心功能-->
<activity <activity
android:name="cn.jpush.android.service.JNotifyActivity" android:name="cn.jpush.android.service.JNotifyActivity"
android:exported="true" android:exported="true"
@@ -229,41 +213,36 @@
android:theme="@android:style/Theme.Translucent.NoTitleBar"> android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.JNotifyActivity" /> <action android:name="cn.jpush.android.intent.JNotifyActivity" />
<category android:name="com.jiaoguanyi.appstore" /> <category android:name="com.jiaoguanyi.appstore" />
</intent-filter> </intent-filter>
</activity> </activity> <!-- Since JCore2.0.0 Required SDK核心功能 -->
<!-- Since JCore2.0.0 Required SDK核心功能-->
<!-- 这个Service要继承JCommonService --> <!-- 这个Service要继承JCommonService -->
<service <service
android:name="com.mjsheng.myappstore.jpush.PushService" android:name=".jpush.PushService"
android:process=":pushcore"> android:process=":pushcore">
<intent-filter> <intent-filter>
<action android:name="cn.jiguang.user.service.action" /> <action android:name="cn.jiguang.user.service.action" />
</intent-filter> </intent-filter>
</service> </service> <!-- User defined. For test only 用户自定义的广播接收器 -->
<!-- User defined. For test only 用户自定义的广播接收器-->
<receiver <receiver
android:name="com.mjsheng.myappstore.jpush.MyReceiver" android:name=".jpush.MyReceiver"
android:enabled="true" android:enabled="true"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户注册SDK的intent--> <action android:name="cn.jpush.android.intent.REGISTRATION" /> <!-- Required 用户注册SDK的intent -->
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK消息的intent--> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!-- Required 用户接收SDK消息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent--> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!-- Required 用户接收SDK通知栏信息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required 用户打开自定义通知栏的intent--> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!-- Required 用户打开自定义通知栏的intent -->
<action android:name="cn.jpush.android.intent.CONNECTION" /><!-- 接收网络变化 连接/断开 since 1.6.3 --> <action android:name="cn.jpush.android.intent.CONNECTION" /> <!-- 接收网络变化 连接/断开 since 1.6.3 -->
<category android:name="com.jiaoguanyi.appstore" /> <category android:name="com.jiaoguanyi.appstore" />
</intent-filter> </intent-filter>
</receiver> </receiver> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
<receiver android:name=".jpush.MyJPushMessageReceiver">
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
<receiver android:name="com.mjsheng.myappstore.jpush.MyJPushMessageReceiver">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" /> <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="com.jiaoguanyi.appstore"></category>
<category android:name="com.jiaoguanyi.appstore" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@@ -272,10 +251,7 @@
android:value="developer-default" /> <!-- Required. AppKey copied from Portal --> android:value="developer-default" /> <!-- Required. AppKey copied from Portal -->
<meta-data <meta-data
android:name="JPUSH_APPKEY" android:name="JPUSH_APPKEY"
android:value="20f70bbeb78bad23eddd08d0" /><!-- </>值来自开发者平台取得的AppKey--> android:value="20f70bbeb78bad23eddd08d0" />
<!-- ##############################极光推送end############################## -->
</application> </application>
</manifest> </manifest>

View File

@@ -65,7 +65,7 @@ import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
*/ */
//public class MyApplication extends MultiDexApplication implements Thread.UncaughtExceptionHandler { //public class MyApplication extends MultiDexApplication implements Thread.UncaughtExceptionHandler {
public class MyApplication extends MultiDexApplication { public class MyApplication extends MultiDexApplication {
public static String userName = null; public static String userName = null;
private static final String TAG = "--MyApplication--"; private static final String TAG = "--MyApplication--";
@@ -442,7 +442,8 @@ import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
} }
private void catchException() { private void catchException() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { Thread.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler() {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
Log.d("捕获异常子线程:", Thread.currentThread().getName() + Log.d("捕获异常子线程:", Thread.currentThread().getName() +

View File

@@ -543,7 +543,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
int batteryLevel = getBatteryLevel(); int batteryLevel = getBatteryLevel();
LogUtils.e(batteryLevel + "------------------" + isReset); LogUtils.e(batteryLevel + "------------------" + isReset);
if (isReset && batteryLevel >= CommonDatas.MIN_POWER) { if (isReset && batteryLevel >= CommonDatas.MIN_POWER) {
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR").setPackage("com.android.settings"));
} }
} }
@@ -1242,32 +1242,6 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
} }
} }
private class BroadcastThread extends Thread {
String packagename[];
String action;
public BroadcastThread(String a, String s[]) {
super();
this.packagename = s;
this.action = a;
}
@Override
public void run() {
super.run();
for (String name : packagename) {
Intent disIntent = new Intent(action);
disIntent.putExtra("package_name", name);
Log.e("mymjsheng", "package_name::" + name);
sendBroadcast(disIntent);
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
private void writeDeselectBrowserIDtoSystem(String ids) { private void writeDeselectBrowserIDtoSystem(String ids) {
if (!TextUtils.isEmpty(ids)) { if (!TextUtils.isEmpty(ids)) {
@@ -1376,7 +1350,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
break; break;
} }
Intent usbIntent = new Intent(usbStatus); Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
sendBroadcast(usbIntent); sendBroadcast(usbIntent);
} }
@@ -1417,7 +1391,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
break; break;
} }
Intent navIntent = new Intent(navigationStatus); Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
sendBroadcast(navIntent); sendBroadcast(navIntent);
@@ -1436,7 +1410,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
statusbarStatus = "qch_hide_statusBar"; statusbarStatus = "qch_hide_statusBar";
break; break;
} }
Intent statusIntent = new Intent(statusbarStatus); Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
mContext.sendBroadcast(statusIntent); mContext.sendBroadcast(statusIntent);
} }
@@ -1452,7 +1426,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
cameraStatus = "qch_camera_forbid"; cameraStatus = "qch_camera_forbid";
break; break;
} }
Intent cameraIntent = new Intent(cameraStatus); Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
sendBroadcast(cameraIntent); sendBroadcast(cameraIntent);
//added:2019.12.6 //added:2019.12.6

View File

@@ -357,7 +357,7 @@ public class HTTPInterface {
JSONObject jsondata = JSON.parseObject(data); JSONObject jsondata = JSON.parseObject(data);
//主页 //主页
String homepagURL = jsondata.getString("homepage"); String homepagURL = jsondata.getString("homepage");
Intent homepag = new Intent("qch_app_brower_homepage"); Intent homepag = new Intent("qch_app_brower_homepage").setPackage("com.android.settings");
if (homepagURL != null && !homepagURL.equals("")) { if (homepagURL != null && !homepagURL.equals("")) {
homepag.putExtra("homepage", homepagURL); homepag.putExtra("homepage", homepagURL);
} else { } else {
@@ -367,7 +367,7 @@ public class HTTPInterface {
//书签 //书签
String labelpage = jsondata.getString("labelpage"); String labelpage = jsondata.getString("labelpage");
Intent websiteBookMark = new Intent("qch_app_brower_website"); Intent websiteBookMark = new Intent("qch_app_brower_website").setPackage("com.android.settings");
if (labelpage != null && !labelpage.equals("")) { if (labelpage != null && !labelpage.equals("")) {
websiteBookMark.putExtra("websiteBookMark", labelpage); websiteBookMark.putExtra("websiteBookMark", labelpage);
} else { } else {
@@ -376,10 +376,10 @@ public class HTTPInterface {
context.sendBroadcast(websiteBookMark); context.sendBroadcast(websiteBookMark);
} else { } else {
Intent intent1 = new Intent("qch_app_brower_homepage"); Intent intent1 = new Intent("qch_app_brower_homepage").setPackage("com.android.settings");
intent1.putExtra("homepage", " "); intent1.putExtra("homepage", " ");
context.sendBroadcast(intent1); context.sendBroadcast(intent1);
Intent intent2 = new Intent("qch_app_brower_website"); Intent intent2 = new Intent("qch_app_brower_website").setPackage("com.android.settings");
intent2.putExtra("websiteBookMark", " "); intent2.putExtra("websiteBookMark", " ");
context.sendBroadcast(intent2); context.sendBroadcast(intent2);
} }
@@ -426,7 +426,7 @@ public class HTTPInterface {
packageList = packageList.substring(0, packageList.length() - 1); packageList = packageList.substring(0, packageList.length() - 1);
//去掉多余的, //去掉多余的,
Log.e("setAppinsideWeb ", "packageList:" + packageList); Log.e("setAppinsideWeb ", "packageList:" + packageList);
Intent qch_app_website = new Intent("qch_app_website"); Intent qch_app_website = new Intent("qch_app_website").setPackage("com.android.settings");
qch_app_website.putExtra("package_name", packageList); qch_app_website.putExtra("package_name", packageList);
context.sendBroadcast(qch_app_website); context.sendBroadcast(qch_app_website);
} else { } else {
@@ -437,7 +437,7 @@ public class HTTPInterface {
strings = strings.substring(0, strings.length() - 1); strings = strings.substring(0, strings.length() - 1);
//去掉多余的; //去掉多余的;
Log.e("setAppinsideWeb ", "strings:" + strings); Log.e("setAppinsideWeb ", "strings:" + strings);
Intent intent = new Intent("qch_app_inside_website"); Intent intent = new Intent("qch_app_inside_website").setPackage("com.android.settings");
intent.putExtra("websitelist", strings); intent.putExtra("websitelist", strings);
context.sendBroadcast(intent); context.sendBroadcast(intent);
} else { } else {
@@ -466,13 +466,13 @@ public class HTTPInterface {
} }
private static void sendAllweb(Context context) { private static void sendAllweb(Context context) {
Intent intent = new Intent("qch_app_website"); Intent intent = new Intent("qch_app_website").setPackage("com.android.settings");
intent.putExtra("package_name", "Invalid"); intent.putExtra("package_name", "Invalid");
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
private static void sendwebUrl(Context context) { private static void sendwebUrl(Context context) {
Intent intent = new Intent("qch_app_inside_website"); Intent intent = new Intent("qch_app_inside_website").setPackage("com.android.settings");
intent.putExtra("websitelist", "Invalid"); intent.putExtra("websitelist", "Invalid");
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }

View File

@@ -39,11 +39,11 @@ public class Network {
// public static final String ROOT_URL = "http://www.as.xueshibao.com.cn/api/"; 弃用 // public static final String ROOT_URL = "http://www.as.xueshibao.com.cn/api/"; 弃用
// public static final String ROOT_URL = "https://www.jiaoguanyi.com/api/";//正式 弃用 // public static final String ROOT_URL = "https://www.jiaoguanyi.com/api/";//正式 弃用
public static final String ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式 // public static final String ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式
public static final String WebsocketURL = "ws://47.107.133.19:1234"; // public static final String WebsocketURL = "ws://47.107.133.19:1234";
// public static final String ROOT_URL = "http://www.jiaoguanyi.cn/api/";//测试 public static final String ROOT_URL = "http://www.jiaoguanyi.cn/api/";//测试
// public static final String WebsocketURL = "ws://47.107.133.19:2345"; public static final String WebsocketURL = "ws://47.107.133.19:2345";
private static UploadAppInfoApi uploadAppInfoApi; private static UploadAppInfoApi uploadAppInfoApi;
private static DeselectIDApi deselectIDApi; private static DeselectIDApi deselectIDApi;

View File

@@ -133,7 +133,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
break; break;
} }
Intent usbIntent = new Intent(usbStatus); Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
mContext.sendBroadcast(usbIntent); mContext.sendBroadcast(usbIntent);
} }
@@ -175,7 +175,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
break; break;
} }
Intent navIntent = new Intent(navigationStatus); Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
mContext.sendBroadcast(navIntent); mContext.sendBroadcast(navIntent);
@@ -194,7 +194,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
statusbarStatus = "qch_hide_statusBar"; statusbarStatus = "qch_hide_statusBar";
break; break;
} }
Intent statusIntent = new Intent(statusbarStatus); Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
mContext.sendBroadcast(statusIntent); mContext.sendBroadcast(statusIntent);
} }
@@ -210,7 +210,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
cameraStatus = "qch_camera_forbid"; cameraStatus = "qch_camera_forbid";
break; break;
} }
Intent cameraIntent = new Intent(cameraStatus); Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
mContext.sendBroadcast(cameraIntent); mContext.sendBroadcast(cameraIntent);
//影音管控开关 //影音管控开关
@@ -518,7 +518,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
break; break;
case MSG_RESET: case MSG_RESET:
if (getBatteryLevel() >= CommonDatas.MIN_POWER) { if (getBatteryLevel() >= CommonDatas.MIN_POWER) {
mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR").setPackage("com.android.settings"));
} else { } else {
MySQLData.SetBooleanData(mContext, CommonDatas.IS_RESET, true); MySQLData.SetBooleanData(mContext, CommonDatas.IS_RESET, true);
} }
@@ -574,7 +574,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
// "com.handsgo.jiakao.android,com.chinessjunqi.nb,com.cktiku.gushiwenbibei,com.yangcong345.android.phone"} // "com.handsgo.jiakao.android,com.chinessjunqi.nb,com.cktiku.gushiwenbibei,com.yangcong345.android.phone"}
private void settingCamera(String s) { private void settingCamera(String s) {
if (TextUtils.isEmpty(s)) { if (TextUtils.isEmpty(s)) {
Intent intent = new Intent("qch_camera_forbid"); Intent intent = new Intent("qch_camera_forbid").setPackage("com.android.settings");
intent.putExtra("camera_package_name", "close"); intent.putExtra("camera_package_name", "close");
this.mContext.sendBroadcast(intent); this.mContext.sendBroadcast(intent);
Log.e("mjsheng", "settingNetControl extras is null"); Log.e("mjsheng", "settingNetControl extras is null");
@@ -587,11 +587,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
Log.e("mymjsheng", "ban::" + s1); Log.e("mymjsheng", "ban::" + s1);
// Log.e("mymjsheng", "not::" + str); // Log.e("mymjsheng", "not::" + str);
if (s1.equals("0")) { if (s1.equals("0")) {
Intent intent2 = new Intent("qch_camera_forbid"); Intent intent2 = new Intent("qch_camera_forbid").setPackage("com.android.settings");
// intent2.putExtra("camera_package_name", s1); // intent2.putExtra("camera_package_name", s1);
this.mContext.sendBroadcast(intent2); this.mContext.sendBroadcast(intent2);
} else { } else {
Intent intent1 = new Intent("qch_camera_open"); Intent intent1 = new Intent("qch_camera_open").setPackage("com.android.settings");
// intent1.putExtra("camera_package_name", str); // intent1.putExtra("camera_package_name", str);
this.mContext.sendBroadcast(intent1); this.mContext.sendBroadcast(intent1);
} }
@@ -751,32 +751,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
// } // }
} }
private class BroadcastThread extends Thread {
String[] packagename;
String action;
public BroadcastThread(String a, String[] s) {
super();
this.packagename = s;
this.action = a;
}
@Override
public void run() {
super.run();
for (String name : packagename) {
Intent disIntent = new Intent(action);
disIntent.putExtra("package_name", name);
Log.e("mymjsheng", "package_name::" + name);
mContext.sendBroadcast(disIntent);
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
//应用id管控 //应用id管控
@@ -854,7 +828,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
Log.e("SystemSetting", "qch_unlock_ipad---------" + i); Log.e("SystemSetting", "qch_unlock_ipad---------" + i);
if (getBatteryLevel() >= CommonDatas.MIN_POWER) { if (getBatteryLevel() >= CommonDatas.MIN_POWER) {
mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR").setPackage("com.android.settings"));
} else { } else {
MySQLData.SetBooleanData(mContext, CommonDatas.IS_RESET, true); MySQLData.SetBooleanData(mContext, CommonDatas.IS_RESET, true);
} }

View File

@@ -522,39 +522,13 @@ public class InitJpushServer extends Service {
Intent intent2 = new Intent("qch_camera_forbid"); Intent intent2 = new Intent("qch_camera_forbid");
intent2.putExtra("camera_package_name", camera_not); intent2.putExtra("camera_package_name", camera_not).setPackage("com.android.settings");
sendBroadcast(intent2); sendBroadcast(intent2);
Intent intent1 = new Intent("qch_camera_open"); Intent intent1 = new Intent("qch_camera_open");
intent1.putExtra("camera_package_name", camera_ok); intent1.putExtra("camera_package_name", camera_ok).setPackage("com.android.settings");
sendBroadcast(intent1); sendBroadcast(intent1);
} }
private class BroadcastThread extends Thread {
String packagename[];
String action;
public BroadcastThread(String a, String s[]) {
super();
this.packagename = s;
this.action = a;
}
@Override
public void run() {
super.run();
for (String name : packagename) {
Intent disIntent = new Intent(action);
disIntent.putExtra("package_name", name);
Log.e("mymjsheng", "package_name::" + name);
sendBroadcast(disIntent);
// try {
// sleep(5000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}
}
}
private void writeDeselectBrowserIDtoSystem(String ids) { private void writeDeselectBrowserIDtoSystem(String ids) {
// if (!TextUtils.isEmpty(ids)) { // if (!TextUtils.isEmpty(ids)) {
@@ -719,7 +693,7 @@ public class InitJpushServer extends Service {
private void resetDevice() { private void resetDevice() {
boolean isReset = MySQLData.GetBooleanData(this, CommonDatas.IS_RESET); boolean isReset = MySQLData.GetBooleanData(this, CommonDatas.IS_RESET);
if (isReset) { if (isReset) {
sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR")); sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR").setPackage("com.android.settings"));
} }
} }
@@ -768,7 +742,7 @@ public class InitJpushServer extends Service {
break; break;
} }
Intent usbIntent = new Intent(usbStatus); Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
sendBroadcast(usbIntent); sendBroadcast(usbIntent);
} }
@@ -807,7 +781,7 @@ public class InitJpushServer extends Service {
break; break;
} }
Intent navIntent = new Intent(navigationStatus); Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
sendBroadcast(navIntent); sendBroadcast(navIntent);
@@ -826,7 +800,7 @@ public class InitJpushServer extends Service {
statusbarStatus = "qch_hide_statusBar"; statusbarStatus = "qch_hide_statusBar";
break; break;
} }
Intent statusIntent = new Intent(statusbarStatus); Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
sendBroadcast(statusIntent); sendBroadcast(statusIntent);
} }
@@ -843,7 +817,7 @@ public class InitJpushServer extends Service {
cameraStatus = "qch_camera_forbid"; cameraStatus = "qch_camera_forbid";
break; break;
} }
Intent cameraIntent = new Intent(cameraStatus); Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
sendBroadcast(cameraIntent); sendBroadcast(cameraIntent);
@@ -861,7 +835,7 @@ public class InitJpushServer extends Service {
tfmediaStatus = "qch_tfmedia_forbid"; tfmediaStatus = "qch_tfmedia_forbid";
break; break;
} }
Intent tfmediaIntent = new Intent(tfmediaStatus); Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
sendBroadcast(tfmediaIntent); sendBroadcast(tfmediaIntent);
if (setting_tfmedia == 1) { if (setting_tfmedia == 1) {
JSONArray jSONArray = null; JSONArray jSONArray = null;

View File

@@ -1,13 +1,16 @@
package com.mjsheng.myappstore.utils; package com.mjsheng.myappstore.utils;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Binder; import android.os.Binder;
import android.os.Build; import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.content.FileProvider; import android.support.v4.content.FileProvider;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@@ -18,12 +21,18 @@ import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.utils.update.ToastTool; import com.mjsheng.myappstore.utils.update.ToastTool;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.annotation.ElementType;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
@@ -303,7 +312,15 @@ public class ApkUtils {
void installInfoCallback(String path, String packageName); void installInfoCallback(String path, String packageName);
} }
public static boolean installApp(Context context, String apkPath) { public static void installApp(Context context, String filePath) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
installAppatPie(context, filePath);
} else {
installApps(filePath);
}
}
public static boolean installApps(String apkPath) {
ToastUtil.show("正在安装应用..."); ToastUtil.show("正在安装应用...");
Process process = null; Process process = null;
BufferedReader successResult = null; BufferedReader successResult = null;
@@ -347,6 +364,85 @@ public class ApkUtils {
return successMsg.toString().equalsIgnoreCase("success"); return successMsg.toString().equalsIgnoreCase("success");
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void installAppatPie(Context context, String apkFilePath) {
File file = new File(apkFilePath);
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(PackageInstaller
.SessionParams.MODE_FULL_INSTALL);
sessionParams.setSize(file.length());
int sessionId = createSession(packageInstaller, sessionParams);
if (sessionId != -1) {
boolean copySuccess = copyApkFile(packageInstaller, sessionId, apkFilePath);
if (copySuccess) {
ToastUtil.show("正在安装应用");
install(packageInstaller, sessionId, context);
}
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static void install(PackageInstaller packageInstaller, int sessionId, Context context) {
try {
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
Intent intent = new Intent(context, InstallResultReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context,
1, intent,
PendingIntent.FLAG_UPDATE_CURRENT
);
session.commit(pendingIntent.getIntentSender());
} catch (IOException e) {
e.printStackTrace();
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static int createSession(PackageInstaller packageInstaller, PackageInstaller.SessionParams sessionParams) {
int sessionId = -1;
try {
sessionId = packageInstaller.createSession(sessionParams);
} catch (IOException e) {
e.printStackTrace();
}
return sessionId;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static boolean copyApkFile(PackageInstaller pi, int sessionId, String apkFilePath) {
boolean success = false;
File apkFile = new File(apkFilePath);
PackageInstaller.Session session = null;
try {
session = pi.openSession(sessionId);
OutputStream out = session.openWrite("app.apk", 0, apkFile.length());
FileInputStream input = new FileInputStream(apkFile);
int read = 0;
byte[] buffer = new byte[65536];
// while (read != -1) {
// read = input.read(buffer);
// out.write(buffer, 0, read);
// }
while (true) {
read = input.read(buffer);
if (read == -1) {
session.fsync(out);
success = true;
out.close();
input.close();
break;
}
out.write(buffer, 0, read);
}
} catch (IOException e) {
e.printStackTrace();
Log.e("fht", e.getMessage());
}
return success;
}
public static void installApkInSilence(String installPath, String packageName) { public static void installApkInSilence(String installPath, String packageName) {
ToastUtil.show("正在安装应用..."); ToastUtil.show("正在安装应用...");

View File

@@ -0,0 +1,43 @@
package com.mjsheng.myappstore.utils;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import java.util.Iterator;
import java.util.Set;
import static android.content.pm.PackageInstaller.STATUS_PENDING_USER_ACTION;
public class InstallResultReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
//throw new UnsupportedOperationException("Not yet implemented");
// String s = intent.getAction();
// Log.e("fht", s);
// Bundle extras = intent.getExtras();
// Set<String> ks = extras.keySet();
// Iterator<String> iterator = ks.iterator();
// while (iterator.hasNext()) {
// Log.d("KEY", iterator.next());
// }
String STATUS = intent.getStringExtra("android.content.pm.extra.STATUS");
String PACKAGE_NAME = intent.getStringExtra("android.content.pm.extra.PACKAGE_NAME");
String SESSION_ID = intent.getStringExtra("android.content.pm.extra.SESSION_ID");
String LEGACY_STATUS = intent.getStringExtra("android.content.pm.extra.LEGACY_STATUS");
String STATUS_MESSAGE = intent.getStringExtra("android.content.pm.extra.STATUS_MESSAGE");
// Log.e("fht", STATUS);
// Log.e("fht", PACKAGE_NAME);
// Log.e("fht", SESSION_ID);
// Log.e("fht", LEGACY_STATUS);
// Log.e("fht", STATUS_MESSAGE);
if (STATUS_MESSAGE.equals("INSTALL_SUCCEEDED")) {
ToastUtil.show(PACKAGE_NAME + "安装成功");
}
}
}

View File

@@ -740,7 +740,7 @@ public class Utils {
} }
public static String getSn() { public static String getSn() {
return Build.SERIAL; return getSerial();
} }
public static Bitmap createQRImage(String content, int widthPix, int heightPix) { public static Bitmap createQRImage(String content, int widthPix, int heightPix) {

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

View File

@@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> <excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content> </content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" /> <orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>