update:2020.5.14
fix:兼容Android10.0 http联网问题,静默安装问题 add:
This commit is contained in:
@@ -11,14 +11,11 @@
|
||||
<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_OFF" />
|
||||
|
||||
<!-- ##############################极光推送############################## -->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- ##############################极光推送############################## -->
|
||||
<!-- Required -->
|
||||
<permission
|
||||
android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE"
|
||||
android:protectionLevel="signature" />
|
||||
<!-- Required -->
|
||||
|
||||
android:protectionLevel="signature" /> <!-- Required -->
|
||||
<uses-permission android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||
<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.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<uses-permission
|
||||
android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
|
||||
android:maxSdkVersion="22" />
|
||||
@@ -39,11 +35,16 @@
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<receiver
|
||||
android:name=".utils.InstallResultReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true"></receiver>
|
||||
|
||||
<activity
|
||||
android:name="com.mjsheng.myappstore.activity.MainActivity"
|
||||
android:name=".activity.MainActivity"
|
||||
android:excludeFromRecents="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -52,16 +53,15 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
<service android:name="com.mjsheng.myappstore.server.MyDownloadService" />
|
||||
<service android:name="com.mjsheng.myappstore.server.GuardService" />
|
||||
<service android:name=".server.MyDownloadService" />
|
||||
<service android:name=".server.GuardService" />
|
||||
<service
|
||||
android:name="com.mjsheng.myappstore.server.StepService"
|
||||
android:name=".server.StepService"
|
||||
android:exported="true" />
|
||||
<service android:name="com.mjsheng.myappstore.server.InitJpushServer" />
|
||||
<service android:name=".server.InitJpushServer" />
|
||||
|
||||
<receiver
|
||||
android:name="com.mjsheng.myappstore.receiver.NewAppReceiver"
|
||||
android:name=".receiver.NewAppReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1000">
|
||||
@@ -73,7 +73,7 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="com.mjsheng.myappstore.receiver.BootReceiver"
|
||||
android:name=".receiver.BootReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1000">
|
||||
@@ -87,11 +87,10 @@
|
||||
<action android:name="android.intent.action.USER_PRESENT" />
|
||||
<action android:name="android.intent.action.SCREEN_ON" />
|
||||
<action android:name="android.intent.action.SCREEN_OFF" />
|
||||
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="com.mjsheng.myappstore.receiver.MyJPushReceiver"
|
||||
android:name=".receiver.MyJPushReceiver"
|
||||
android:enabled="true">
|
||||
<intent-filter>
|
||||
|
||||
@@ -108,8 +107,7 @@
|
||||
|
||||
<category android:name="${JPUSH_PKGNAME}" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- Required. For publish channel feature -->
|
||||
</receiver> <!-- Required. For publish channel feature -->
|
||||
<!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。 -->
|
||||
<!-- 例如: -->
|
||||
<!-- 发到 Google Play 的APK可以设置为 google-play; -->
|
||||
@@ -131,16 +129,13 @@
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
<!-- ##############################极光推送############################## -->
|
||||
<!-- Rich push 核心功能 since 2.0.6-->
|
||||
</provider> <!-- ##############################极光推送############################## -->
|
||||
<!-- Rich push 核心功能 since 2.0.6 -->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PopWinActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/MyDialogStyle"
|
||||
tools:replace="android:exported"></activity>
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
tools:replace="android:exported" /> <!-- Required SDK核心功能 -->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PushActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
@@ -153,9 +148,7 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="com.jiaoguanyi.appstore" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Required SDK 核心功能-->
|
||||
</activity> <!-- Required SDK 核心功能 -->
|
||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||
<service
|
||||
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.PUSH_TIME" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<!-- since 3.0.9 Required SDK 核心功能-->
|
||||
</service> <!-- since 3.0.9 Required SDK 核心功能 -->
|
||||
<provider
|
||||
android:name="cn.jpush.android.service.DataProvider"
|
||||
android:authorities="com.jiaoguanyi.appstore.DataProvider"
|
||||
android:exported="false"
|
||||
android:process=":pushcore"
|
||||
tools:replace="android:authorities" />
|
||||
|
||||
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
||||
tools:replace="android:authorities" /> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
||||
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
|
||||
<service
|
||||
android:name="cn.jpush.android.service.DaemonService"
|
||||
@@ -184,23 +174,21 @@
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.DaemonService" />
|
||||
|
||||
<category android:name="com.jiaoguanyi.appstore" />
|
||||
</intent-filter>
|
||||
|
||||
</service>
|
||||
<!-- since 3.1.0 Required SDK 核心功能-->
|
||||
</service> <!-- since 3.1.0 Required SDK 核心功能 -->
|
||||
<provider
|
||||
android:name="cn.jpush.android.service.DownloadProvider"
|
||||
android:authorities="com.jiaoguanyi.appstore.DownloadProvider"
|
||||
android:exported="true"
|
||||
tools:replace="android:authorities" />
|
||||
<!-- Required SDK核心功能-->
|
||||
tools:replace="android:authorities" /> <!-- Required SDK核心功能 -->
|
||||
<receiver
|
||||
android:name="cn.jpush.android.service.PushReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<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" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
@@ -214,14 +202,10 @@
|
||||
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
</receiver> <!-- Required SDK核心功能 -->
|
||||
<receiver
|
||||
android:name="cn.jpush.android.service.AlarmReceiver"
|
||||
android:exported="false" />
|
||||
|
||||
<!--since 3.3.0 Required SDK核心功能-->
|
||||
android:exported="false" /> <!-- since 3.3.0 Required SDK核心功能 -->
|
||||
<activity
|
||||
android:name="cn.jpush.android.service.JNotifyActivity"
|
||||
android:exported="true"
|
||||
@@ -229,41 +213,36 @@
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.JNotifyActivity" />
|
||||
|
||||
<category android:name="com.jiaoguanyi.appstore" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Since JCore2.0.0 Required SDK核心功能-->
|
||||
</activity> <!-- Since JCore2.0.0 Required SDK核心功能 -->
|
||||
<!-- 这个Service要继承JCommonService -->
|
||||
<service
|
||||
android:name="com.mjsheng.myappstore.jpush.PushService"
|
||||
android:name=".jpush.PushService"
|
||||
android:process=":pushcore">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jiguang.user.service.action" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
|
||||
<!-- User defined. For test only 用户自定义的广播接收器-->
|
||||
</service> <!-- User defined. For test only 用户自定义的广播接收器 -->
|
||||
<receiver
|
||||
android:name="com.mjsheng.myappstore.jpush.MyReceiver"
|
||||
android:name=".jpush.MyReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<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.NOTIFICATION_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的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.REGISTRATION" /> <!-- 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_OPENED" /> <!-- Required 用户打开自定义通知栏的intent -->
|
||||
<action android:name="cn.jpush.android.intent.CONNECTION" /> <!-- 接收网络变化 连接/断开 since 1.6.3 -->
|
||||
<category android:name="com.jiaoguanyi.appstore" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
|
||||
<receiver android:name="com.mjsheng.myappstore.jpush.MyJPushMessageReceiver">
|
||||
</receiver> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
|
||||
<receiver android:name=".jpush.MyJPushMessageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
||||
<category android:name="com.jiaoguanyi.appstore"></category>
|
||||
|
||||
<category android:name="com.jiaoguanyi.appstore" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
@@ -272,10 +251,7 @@
|
||||
android:value="developer-default" /> <!-- Required. AppKey copied from Portal -->
|
||||
<meta-data
|
||||
android:name="JPUSH_APPKEY"
|
||||
android:value="20f70bbeb78bad23eddd08d0" /><!-- </>值来自开发者平台取得的AppKey-->
|
||||
<!-- ##############################极光推送end############################## -->
|
||||
|
||||
|
||||
android:value="20f70bbeb78bad23eddd08d0" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -65,7 +65,7 @@ import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
|
||||
*/
|
||||
|
||||
//public class MyApplication extends MultiDexApplication implements Thread.UncaughtExceptionHandler {
|
||||
public class MyApplication extends MultiDexApplication {
|
||||
public class MyApplication extends MultiDexApplication {
|
||||
|
||||
public static String userName = null;
|
||||
private static final String TAG = "--MyApplication--";
|
||||
@@ -442,13 +442,14 @@ import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
|
||||
}
|
||||
|
||||
private void catchException() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
Log.d("捕获异常子线程:", Thread.currentThread().getName() +
|
||||
"在:" + e.getStackTrace()[0].getClassName());
|
||||
}
|
||||
}
|
||||
Thread.setDefaultUncaughtExceptionHandler(
|
||||
new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
Log.d("捕获异常子线程:", Thread.currentThread().getName() +
|
||||
"在:" + e.getStackTrace()[0].getClassName());
|
||||
}
|
||||
}
|
||||
);
|
||||
//下面是新增方法!
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
|
||||
@@ -543,7 +543,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
int batteryLevel = getBatteryLevel();
|
||||
LogUtils.e(batteryLevel + "------------------" + isReset);
|
||||
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) {
|
||||
if (!TextUtils.isEmpty(ids)) {
|
||||
@@ -1376,7 +1350,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
break;
|
||||
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
@@ -1417,7 +1391,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
break;
|
||||
|
||||
}
|
||||
Intent navIntent = new Intent(navigationStatus);
|
||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||
sendBroadcast(navIntent);
|
||||
|
||||
|
||||
@@ -1436,7 +1410,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
statusbarStatus = "qch_hide_statusBar";
|
||||
break;
|
||||
}
|
||||
Intent statusIntent = new Intent(statusbarStatus);
|
||||
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||
mContext.sendBroadcast(statusIntent);
|
||||
}
|
||||
|
||||
@@ -1452,7 +1426,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
cameraStatus = "qch_camera_forbid";
|
||||
break;
|
||||
}
|
||||
Intent cameraIntent = new Intent(cameraStatus);
|
||||
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
||||
sendBroadcast(cameraIntent);
|
||||
|
||||
//added:2019.12.6
|
||||
|
||||
@@ -357,7 +357,7 @@ public class HTTPInterface {
|
||||
JSONObject jsondata = JSON.parseObject(data);
|
||||
//主页
|
||||
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("")) {
|
||||
homepag.putExtra("homepage", homepagURL);
|
||||
} else {
|
||||
@@ -367,7 +367,7 @@ public class HTTPInterface {
|
||||
|
||||
//书签
|
||||
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("")) {
|
||||
websiteBookMark.putExtra("websiteBookMark", labelpage);
|
||||
} else {
|
||||
@@ -376,10 +376,10 @@ public class HTTPInterface {
|
||||
context.sendBroadcast(websiteBookMark);
|
||||
|
||||
} else {
|
||||
Intent intent1 = new Intent("qch_app_brower_homepage");
|
||||
Intent intent1 = new Intent("qch_app_brower_homepage").setPackage("com.android.settings");
|
||||
intent1.putExtra("homepage", " ");
|
||||
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", " ");
|
||||
context.sendBroadcast(intent2);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ public class HTTPInterface {
|
||||
packageList = packageList.substring(0, packageList.length() - 1);
|
||||
//去掉多余的,
|
||||
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);
|
||||
context.sendBroadcast(qch_app_website);
|
||||
} else {
|
||||
@@ -437,7 +437,7 @@ public class HTTPInterface {
|
||||
strings = strings.substring(0, strings.length() - 1);
|
||||
//去掉多余的;
|
||||
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);
|
||||
context.sendBroadcast(intent);
|
||||
} else {
|
||||
@@ -466,13 +466,13 @@ public class HTTPInterface {
|
||||
}
|
||||
|
||||
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");
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
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");
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@@ -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 = "https://www.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 ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式
|
||||
// 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 WebsocketURL = "ws://47.107.133.19:2345";
|
||||
public static final String ROOT_URL = "http://www.jiaoguanyi.cn/api/";//测试
|
||||
public static final String WebsocketURL = "ws://47.107.133.19:2345";
|
||||
|
||||
private static UploadAppInfoApi uploadAppInfoApi;
|
||||
private static DeselectIDApi deselectIDApi;
|
||||
|
||||
@@ -133,7 +133,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
|
||||
}
|
||||
Intent navIntent = new Intent(navigationStatus);
|
||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||
mContext.sendBroadcast(navIntent);
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
statusbarStatus = "qch_hide_statusBar";
|
||||
break;
|
||||
}
|
||||
Intent statusIntent = new Intent(statusbarStatus);
|
||||
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||
mContext.sendBroadcast(statusIntent);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
cameraStatus = "qch_camera_forbid";
|
||||
break;
|
||||
}
|
||||
Intent cameraIntent = new Intent(cameraStatus);
|
||||
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(cameraIntent);
|
||||
|
||||
//影音管控开关
|
||||
@@ -518,7 +518,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
case MSG_RESET:
|
||||
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 {
|
||||
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"}
|
||||
private void settingCamera(String 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");
|
||||
this.mContext.sendBroadcast(intent);
|
||||
Log.e("mjsheng", "settingNetControl extras is null");
|
||||
@@ -587,11 +587,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
Log.e("mymjsheng", "ban::" + s1);
|
||||
// Log.e("mymjsheng", "not::" + str);
|
||||
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);
|
||||
this.mContext.sendBroadcast(intent2);
|
||||
} 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);
|
||||
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管控
|
||||
@@ -854,7 +828,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
Log.e("SystemSetting", "qch_unlock_ipad---------" + i);
|
||||
|
||||
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 {
|
||||
MySQLData.SetBooleanData(mContext, CommonDatas.IS_RESET, true);
|
||||
}
|
||||
|
||||
@@ -522,39 +522,13 @@ public class InitJpushServer extends Service {
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
// if (!TextUtils.isEmpty(ids)) {
|
||||
@@ -719,7 +693,7 @@ public class InitJpushServer extends Service {
|
||||
private void resetDevice() {
|
||||
boolean isReset = MySQLData.GetBooleanData(this, CommonDatas.IS_RESET);
|
||||
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;
|
||||
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
@@ -807,7 +781,7 @@ public class InitJpushServer extends Service {
|
||||
break;
|
||||
|
||||
}
|
||||
Intent navIntent = new Intent(navigationStatus);
|
||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||
sendBroadcast(navIntent);
|
||||
|
||||
|
||||
@@ -826,7 +800,7 @@ public class InitJpushServer extends Service {
|
||||
statusbarStatus = "qch_hide_statusBar";
|
||||
break;
|
||||
}
|
||||
Intent statusIntent = new Intent(statusbarStatus);
|
||||
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||
sendBroadcast(statusIntent);
|
||||
}
|
||||
|
||||
@@ -843,7 +817,7 @@ public class InitJpushServer extends Service {
|
||||
cameraStatus = "qch_camera_forbid";
|
||||
break;
|
||||
}
|
||||
Intent cameraIntent = new Intent(cameraStatus);
|
||||
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
||||
sendBroadcast(cameraIntent);
|
||||
|
||||
|
||||
@@ -861,7 +835,7 @@ public class InitJpushServer extends Service {
|
||||
tfmediaStatus = "qch_tfmedia_forbid";
|
||||
break;
|
||||
}
|
||||
Intent tfmediaIntent = new Intent(tfmediaStatus);
|
||||
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
|
||||
sendBroadcast(tfmediaIntent);
|
||||
if (setting_tfmedia == 1) {
|
||||
JSONArray jSONArray = null;
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.mjsheng.myappstore.utils;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -18,12 +21,18 @@ import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.utils.update.ToastTool;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
@@ -303,7 +312,15 @@ public class ApkUtils {
|
||||
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("正在安装应用...");
|
||||
Process process = null;
|
||||
BufferedReader successResult = null;
|
||||
@@ -347,6 +364,85 @@ public class ApkUtils {
|
||||
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) {
|
||||
ToastUtil.show("正在安装应用...");
|
||||
|
||||
@@ -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 + "安装成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -740,7 +740,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String getSn() {
|
||||
return Build.SERIAL;
|
||||
return getSerial();
|
||||
}
|
||||
|
||||
public static Bitmap createQRImage(String content, int widthPix, int heightPix) {
|
||||
|
||||
4
app/src/main/res/xml/network.xml
Normal file
4
app/src/main/res/xml/network.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true" />
|
||||
</network-security-config>
|
||||
Reference in New Issue
Block a user