version:2.0.1.6_release

update:2020.07.14
fix:修复id管控冲突
add:安装完成后10.0添加桌面图标
This commit is contained in:
2020-07-14 18:54:49 +08:00
parent c6c025c225
commit f4cb8b96a4
8 changed files with 377 additions and 215 deletions

View File

@@ -7,13 +7,13 @@
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.MASTER_CLEAR" />
<uses-permission android:name="android.permission.REBOOT"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<!--静默安装权限-->
<uses-permission
android:name="android.permission.INSTALL_PACKAGES"
@@ -71,13 +71,15 @@
<service
android:name=".server.StepService"
android:exported="true" />
<service android:name=".server.InitJpushServer"
<service
android:name=".server.InitJpushServer"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
<data android:scheme="package" />
</intent-filter>
</service>
@@ -85,7 +87,9 @@
<receiver
android:name=".receiver.NewAppReceiver"
android:enabled="true"
android:exported="true">
android:exported="true"
android:permission="com.example.broadcast.permission">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
@@ -110,17 +114,17 @@
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
<!--测试-->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_DETACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />-->
<!-- <action android:name="android.intent.action.MEDIA_MOUNTED" />-->
<!-- <action android:name="android.intent.action.MEDIA_CHECKING" />-->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTED" />-->
<!-- <action android:name="android.intent.action.MEDIA_EJECT" />-->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTABLE" />-->
<!-- <action android:name="android.intent.action.MEDIA_REMOVED" />-->
<!-- <action android:name="android.intent.action.MEDIA_BAD_REMOVAL" />-->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_DETACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />-->
<!-- <action android:name="android.intent.action.MEDIA_MOUNTED" />-->
<!-- <action android:name="android.intent.action.MEDIA_CHECKING" />-->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTED" />-->
<!-- <action android:name="android.intent.action.MEDIA_EJECT" />-->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTABLE" />-->
<!-- <action android:name="android.intent.action.MEDIA_REMOVED" />-->
<!-- <action android:name="android.intent.action.MEDIA_BAD_REMOVAL" />-->
<!-- 自定义广播-->
<action android:name="com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED" />
</intent-filter>

View File

@@ -202,6 +202,7 @@ public class MyApplication extends MultiDexApplication {
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
registerReceiver(mNewAppReceiver, filter);
}

View File

@@ -86,6 +86,7 @@ import com.mjsheng.myappstore.utils.update.NotificationDownloadCreator;
import com.mjsheng.myappstore.utils.update.OkhttpCheckWorker;
import com.mjsheng.myappstore.utils.update.ToastCallback;
import org.json.JSONException;
import org.json.JSONObject;
import org.lzh.framework.updatepluginlib.UpdateBuilder;
@@ -171,7 +172,7 @@ public class MainActivity extends AppCompatActivity {
sequence++;
tagAliasBean.alias = Utils.getSerial();
tagAliasBean.isAliasAction = true;
TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), sequence, tagAliasBean);
TagAliasOperatorHelper.getInstance().handleAction(MainActivity.this, sequence, tagAliasBean);
}
@Override
@@ -244,7 +245,7 @@ public class MainActivity extends AppCompatActivity {
synchronized public void sendMACaddress() {
String devices_version = Utils.getProperty("ro.custom.build.version", "获取失败");
String rid = JPushInterface.getRegistrationID(getApplicationContext());
String rid = JPushInterface.getRegistrationID(MainActivity.this);
OkGo.post(Configure.SEND_DEVICES)
.params("sn", Utils.getSerial())
.params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress())
@@ -489,17 +490,17 @@ public class MainActivity extends AppCompatActivity {
Log.e("ttlocked", String.valueOf(lock));
if (lock == 0) {
locked = false;
boolean se = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_unlock_ipad", 1);
Log.e("ttlocked1", "getLockedState---------" + Settings.System.getString(getApplicationContext().getContentResolver(), "qch_unlock_ipad"));
boolean se = Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_unlock_ipad", 1);
Log.e("ttlocked1", "getLockedState---------" + Settings.System.getString(MainActivity.this.getContentResolver(), "qch_unlock_ipad"));
Log.e("ttlocked1", "qch_unlock_ipad---------" + locked + se);
} else {
locked = true;
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_unlock_ipad", 0);
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_unlock_ipad", 0);
Log.e("ttlocked2", "qch_unlock_ipad---------" + locked);
String a = Settings.System.getString(getApplicationContext().getContentResolver(), "DeselectBrowserArray");
String a = Settings.System.getString(MainActivity.this.getContentResolver(), "DeselectBrowserArray");
Log.e("ttlocked2", "DeselectBrowserArray---------" + a);
String b = Settings.System.getString(getApplicationContext().getContentResolver(), "qch_webblack_url");
String b = Settings.System.getString(MainActivity.this.getContentResolver(), "qch_webblack_url");
Log.e("ttlocked2", "qch_webblack_url---------" + b);
HTTPInterface.setJpushTags(MainActivity.this);
sendMACaddress();
@@ -586,17 +587,17 @@ public class MainActivity extends AppCompatActivity {
tv_batch.setVisibility(View.VISIBLE);
tv_batch.setText(info.getBatch());
}
// try {
if (info.getClasses().equals("")) {
layout_class.setVisibility(View.GONE);
tv_class.setText("暂无信息");
} else {
layout_class.setVisibility(View.VISIBLE);
tv_class.setText(info.getClasses());
try {
if (info.getClasses().equals("")) {
layout_class.setVisibility(View.GONE);
tv_class.setText("暂无信息");
} else {
layout_class.setVisibility(View.VISIBLE);
tv_class.setText(info.getClasses());
}
} catch (Exception e) {
Log.e("fht", e.getMessage());
}
// } catch (Exception e) {
// Log.e("fht", e.getMessage());
// }
if (info.getSno().equals("")) {
layout_number.setVisibility(View.GONE);
tv_number.setText("暂无信息");
@@ -691,7 +692,7 @@ public class MainActivity extends AppCompatActivity {
}
private Runnable toast = new Runnable() {
private Runnable toast = new Runnable() {
@Override
public void run() {
@@ -704,7 +705,7 @@ public class MainActivity extends AppCompatActivity {
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
} else {
Intent intent = new ContextWrapper(getApplicationContext()).
Intent intent = new ContextWrapper(MainActivity.this).
registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
return (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) /
intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
@@ -785,7 +786,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onError(Throwable e) {
// Utils.showToast(getApplicationContext(), "网络出错!");
// Utils.showToast(MainActivity.this, "网络出错!");
Log.e("mjsheng", "brankPicApi---error----" + e.getMessage());
}
@@ -922,7 +923,7 @@ public class MainActivity extends AppCompatActivity {
private void initJpush() {
JPushInterface.init(this);
setAlias();
String rid = JPushInterface.getRegistrationID(getApplicationContext());
String rid = JPushInterface.getRegistrationID(MainActivity.this);
if (!rid.isEmpty()) {
// ToastUtil.debugShow("RegId:" + rid);
Log.e("jiguang", "RegId:" + rid);
@@ -1087,7 +1088,8 @@ public class MainActivity extends AppCompatActivity {
case 200:
JSONObject data = jsonObject.getJSONObject("data");
String ids = data.optString("ids");
writeDeselectIDtoSystem(ids);
String packages = data.optString("package");
writeDeselectIDtoSystem(ids,packages);
break;
default:
Log.e("mjhseng", "getDeselectID---code is -200");
@@ -1453,7 +1455,7 @@ public class MainActivity extends AppCompatActivity {
Utils.writeDisableUpdateList(this, upgrade_not.split(","), upgrade_ok.split(","));
LogUtils.e("launch:" + launch + "-----------net_ok:" + net_ok + "-----------net_not:" + net_not);
boolean qch_app_power_on = Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_power_on", launch);
boolean qch_app_power_on = Settings.System.putString(MainActivity.this.getContentResolver(), "qch_app_power_on", launch);
// Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
// netControlIntent.putExtra("package_name", net_not);
@@ -1497,14 +1499,27 @@ public class MainActivity extends AppCompatActivity {
}
}
private void writeDeselectIDtoSystem(String ids) {
if (!TextUtils.isEmpty(ids)) {
boolean deselectViewArray = Settings.System.putString(getContentResolver(), "DeselectViewArray", ids);
Log.e("SystemSetting", "deselectViewArray---------" + deselectViewArray);
//应用id管控
private void writeDeselectIDtoSystem(String s1, String result) {
if (!TextUtils.isEmpty(s1) && !TextUtils.isEmpty(result)) {
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
LogUtils.e(result);
if (!result.contains(appstore)) {
result = result + "," + appstore;
}
if (!result.contains(store)) {
result = result + "," + store;
}
String olddeselectViewArray = Settings.System.getString(this.getContentResolver(), "qch_app_forbid_id");
Log.e("SystemSetting", "olddeselectViewArray---------" + olddeselectViewArray);
Settings.System.putString(this.getContentResolver(), "qch_app_forbid_id", result);
Settings.System.putString(this.getContentResolver(), "DeselectViewArray", s1);
Log.e("qch_app_forbid_id", "qch_app_forbid_id---------" + result);
Log.e("SystemSetting", "deselectViewArray---------" + s1);
} else {
boolean deselectViewArray = Settings.System.putString(getContentResolver(), "DeselectViewArray", "Invalid");
Log.e("mjsheng", "writeDeselectIDtoSystem is null:");
Settings.System.putString(this.getContentResolver(), "DeselectViewArray", "Invalid");
}
}
@@ -1535,9 +1550,12 @@ public class MainActivity extends AppCompatActivity {
Log.e("mjhseng", "getSystemSetting---code is -200");
break;
}
} catch (Exception e) {
Log.e("mjhseng", "getSystemSetting---wroing----" + e.getMessage());
} catch (IOException e) {
e.printStackTrace();
Log.e("initmjsheng", "1getSystemSetting---IOException----" + e.getMessage());
} catch (JSONException e) {
e.printStackTrace();
Log.e("initmjsheng", "1getSystemSetting---JSONException----" + e.getMessage());
}
}
@@ -1554,52 +1572,52 @@ public class MainActivity extends AppCompatActivity {
}
private void SettingSysData(JSONObject data) {
try {
int setting_call = changeNum(data.optInt("setting_call"));
boolean qch_call_forbid = Settings.System.putInt(getContentResolver(), "qch_call_forbid", setting_call);
Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
// try {
int setting_call = changeNum(data.optInt("setting_call"));
boolean qch_call_forbid = Settings.System.putInt(getContentResolver(), "qch_call_forbid", setting_call);
Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
int setting_phone = changeNum(data.optInt("setting_phone"));
boolean qch_white_list_on = Settings.System.putInt(getContentResolver(), "qch_white_list_on", setting_phone);
Log.e("SystemSetting", "qch_white_list_on---------" + qch_white_list_on);
int setting_phone = changeNum(data.optInt("setting_phone"));
boolean qch_white_list_on = Settings.System.putInt(getContentResolver(), "qch_white_list_on", setting_phone);
Log.e("SystemSetting", "qch_white_list_on---------" + qch_white_list_on);
String setting_phones = data.optString("setting_phones");
boolean qch_white_list_Array = Settings.System.putString(getContentResolver(), "qch_white_list_Array", setting_phones);
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array---------" + qch_white_list_Array + "---" + setting_phones);
String setting_phones = data.optString("setting_phones");
boolean qch_white_list_Array = Settings.System.putString(getContentResolver(), "qch_white_list_Array", setting_phones);
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array---------" + qch_white_list_Array + "---" + setting_phones);
int setting_memory = changeNum(data.optInt("setting_memory"));
boolean qch_sdcard_forbid_on = Settings.System.putInt(getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
Log.e("SystemSetting", "qch_sdcard_forbid_on---------" + qch_sdcard_forbid_on);
int setting_memory = changeNum(data.optInt("setting_memory"));
boolean qch_sdcard_forbid_on = Settings.System.putInt(getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
Log.e("SystemSetting", "qch_sdcard_forbid_on---------" + qch_sdcard_forbid_on);
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
//Midi模式usb_midi
String setting_usb = data.optString("setting_usb");
if (!BuildConfig.DEBUG) {
boolean qch_usb_choose = Settings.System.putString(getContentResolver(), "qch_usb_choose", setting_usb);
Log.e("SystemSetting", "qch_usb_choose---------" + qch_usb_choose);
String usbStatus = "";
switch (setting_usb) {
case "usb_charge":
usbStatus = "qch_action_usb_usb_charge";
break;
case "usb_mtp":
usbStatus = "qch_action_usb_usb_mtp";
break;
case "usb_midi":
usbStatus = "qch_action_usb_usb_midi";
break;
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
//Midi模式usb_midi
String setting_usb = data.optString("setting_usb");
if (!BuildConfig.DEBUG) {
boolean qch_usb_choose = Settings.System.putString(getContentResolver(), "qch_usb_choose", setting_usb);
Log.e("SystemSetting", "qch_usb_choose---------" + qch_usb_choose);
String usbStatus = "";
switch (setting_usb) {
case "usb_charge":
usbStatus = "qch_action_usb_usb_charge";
break;
case "usb_mtp":
usbStatus = "qch_action_usb_usb_mtp";
break;
case "usb_midi":
usbStatus = "qch_action_usb_usb_midi";
break;
}
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
sendBroadcast(usbIntent);
}
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
sendBroadcast(usbIntent);
}
//otg开关
//otg开关
// int setting_otg = changeNum(data.optInt("setting_otg"));
// Log.e("SystemSetting", "setting_otg---------" + setting_otg);
// String otgStatus = "";
@@ -1614,96 +1632,96 @@ public class MainActivity extends AppCompatActivity {
// Intent otgIntent = new Intent(otgStatus);
// sendBroadcast(otgIntent);
//蓝牙开关
int setting_bluetooth = changeNum(data.optInt("setting_bluetooth"));
boolean qch_bt_forbid_on = Settings.System.putInt(getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
Log.e("SystemSetting", "qch_bt_forbid_on---------" + qch_bt_forbid_on);
Log.e("SystemSetting", "qch_bt_forbid_on---------" + Settings.System.getInt(getContentResolver(), "qch_bt_forbid_on", 0));
//蓝牙开关
int setting_bluetooth = changeNum(data.optInt("setting_bluetooth"));
boolean qch_bt_forbid_on = Settings.System.putInt(getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
Log.e("SystemSetting", "qch_bt_forbid_on---------" + qch_bt_forbid_on);
Log.e("SystemSetting", "qch_bt_forbid_on---------" + Settings.System.getInt(getContentResolver(), "qch_bt_forbid_on", 0));
//系统导航条显示开关
int setting_navigation = changeNum(data.optInt("setting_navigation"));
boolean qch_hide_navigationBar = Settings.System.putInt(getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
//系统导航条显示开关
int setting_navigation = changeNum(data.optInt("setting_navigation"));
boolean qch_hide_navigationBar = Settings.System.putInt(getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
String navigationStatus = "";
switch (setting_navigation) {
case 0:
navigationStatus = "qch_show_NavigationBar";
break;
case 1:
navigationStatus = "qch_hide_NavigationBar";
break;
String navigationStatus = "";
switch (setting_navigation) {
case 0:
navigationStatus = "qch_show_NavigationBar";
break;
case 1:
navigationStatus = "qch_hide_NavigationBar";
break;
}
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
sendBroadcast(navIntent);
//状态栏显示开关
int setting_statusbar = changeNum(data.optInt("setting_statusbar"));
int oldNum = Settings.System.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
if (oldNum != setting_statusbar) {
boolean qch_hide_statusBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
String statusbarStatus = "";
switch (setting_statusbar) {
case 0:
statusbarStatus = "qch_show_statusBar";
break;
case 1:
statusbarStatus = "qch_hide_statusBar";
break;
}
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
mContext.sendBroadcast(statusIntent);
}
//摄像头开关
int setting_camera = changeNum(data.optInt("setting_camera"));
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
String cameraStatus = "";
switch (setting_camera) {
case 0:
cameraStatus = "qch_camera_open";
break;
case 1:
cameraStatus = "qch_camera_forbid";
break;
}
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
sendBroadcast(cameraIntent);
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = changeNum(data.optInt("setting_clock"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_deskclock", deskclock);
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(data.optInt("setting_recording"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_soundrecorder", soundrecorder);
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(data.optInt("setting_music"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_music", music);
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(data.optInt("setting_picture"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_gallery", gallery);
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_wallpaper", wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
//文件管理器
int filemanager = changeNum(data.optInt("setting_file"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_filemanager", filemanager);
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
} catch (Exception e) {
e.printStackTrace();
Log.e("mjhseng", "SettingSysData---error::" + e.getMessage());
}
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
sendBroadcast(navIntent);
//状态栏显示开关
int setting_statusbar = changeNum(data.optInt("setting_statusbar"));
int oldNum = Settings.System.getInt(MainActivity.this.getContentResolver(), "qch_hide_statusBar", 0);
if (oldNum != setting_statusbar) {
boolean qch_hide_statusBar = Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
String statusbarStatus = "";
switch (setting_statusbar) {
case 0:
statusbarStatus = "qch_show_statusBar";
break;
case 1:
statusbarStatus = "qch_hide_statusBar";
break;
}
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
MainActivity.this.sendBroadcast(statusIntent);
}
//摄像头开关
int setting_camera = changeNum(data.optInt("setting_camera"));
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
String cameraStatus = "";
switch (setting_camera) {
case 0:
cameraStatus = "qch_camera_open";
break;
case 1:
cameraStatus = "qch_camera_forbid";
break;
}
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
sendBroadcast(cameraIntent);
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = changeNum(data.optInt("setting_clock"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_deskclock", deskclock);
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(data.optInt("setting_recording"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(data.optInt("setting_music"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_music", music);
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(data.optInt("setting_picture"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_gallery", gallery);
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_wallpaper", wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
//文件管理器
int filemanager = changeNum(data.optInt("setting_file"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_filemanager", filemanager);
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
// } catch (Exception e) {
// e.printStackTrace();
// Log.e("mjhseng", "SettingSysData---2error::" + e.getMessage());
// }
}
private int changeNum(int status) {

View File

@@ -52,7 +52,9 @@ public class BootReceiver extends BroadcastReceiver {
}
private void startService(Context context) {
context.startService(new Intent(context, InitJpushServer.class));
Intent intent=new Intent(context, InitJpushServer.class);
// intent.putExtra("boot","BOOT_COMPLETED");
context.startService(intent);
context.startService(new Intent(context, StepService.class));
context.startService(new Intent(context, GuardService.class));
context.startService(new Intent(context, MyDownloadService.class));

View File

@@ -440,7 +440,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
} catch (Exception e) {
e.printStackTrace();
Log.e("mjhseng", "SettingSysData---error::" + e.getMessage());
Log.e("mjhseng", "SettingSysData---3error::" + e.getMessage());
}
}
@@ -901,9 +901,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
if (!result.contains(store)) {
result = result + "," + store;
}
Settings.System.putString(this.mContext.getContentResolver(), "qch_app_forbid", result);
String olddeselectViewArray = Settings.System.getString(this.mContext.getContentResolver(), "qch_app_forbid_id");
Log.e("SystemSetting", "olddeselectViewArray---------" + olddeselectViewArray);
Settings.System.putString(this.mContext.getContentResolver(), "qch_app_forbid_id", result);
Settings.System.putString(this.mContext.getContentResolver(), "DeselectViewArray", s1);
Log.e("qch_app_forbid", "qch_app_forbid---------" + result);
Log.e("qch_app_forbid_id", "qch_app_forbid_id---------" + result);
Log.e("SystemSetting", "deselectViewArray---------" + s1);
return;
} else {

View File

@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import com.google.gson.Gson;
@@ -43,17 +44,26 @@ public class NewAppReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
action = intent.getAction();
Log.e("onReceive", action);
//接收安装广播
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
context.sendBroadcast(intent1);
}
Intent allIntent = new Intent();
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
context.sendBroadcast(allIntent);
String packageName = intent.getDataString().replace("package:", "");
String result = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (!packageName.equals("com.jiaoguanyi.store") || !packageName.equals("com.jiaoguanyi.appstore")) {
// ApkUtils.getStartActivityName(context, packageName);
ApkUtils.addShortcut(context, result);
}
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
context.sendBroadcast(intent1);
}
// MyApplication.getInstance().removeDate(packageName);
Log.e(TAG, "安装了:" + packageName + "包名的程序");
Log.e("fht", "安装了:" + packageName + "包名的程序");
@@ -96,6 +106,17 @@ public class NewAppReceiver extends BroadcastReceiver {
if (!packageName.equals(Utils.YOUNGSYSTEM_APP_TONGBU) && !packageName.equals(context.getPackageName())) {
deletedateUserApp(context, packageName);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String result = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
if (!packageName.equals("com.jiaoguanyi.store") || !packageName.equals("com.jiaoguanyi.appstore")) {
// ApkUtils.getStartActivityName(context, packageName);
ApkUtils.addShortcut(context, result);
}
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
context.sendBroadcast(intent1);
}
Intent intent1 = new Intent();
intent1.setAction(Utils.ACTION_PACKAGE_REMOVED);
intent1.putExtra("packageName", packageName);

View File

@@ -1,6 +1,7 @@
package com.mjsheng.myappstore.server;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -46,6 +47,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -85,12 +87,18 @@ public class InitJpushServer extends Service {
public void onCreate() {
Log.e("InitJpushServer", "onCreate");
super.onCreate();
// android.os.Debug.waitForDebugger();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// String boot = intent.getStringExtra("boot");
// if (null != boot&&boot.equals("BOOT_COMPLETED")) {
// String result = Settings.System.getString(getContentResolver(), "qch_app_forbid");
// addShortcut(this, result);//开机之后添加图标到桌面
// }
getAppLimitApi();//获取可以写入的app包名
HTTPInterface.getNetAndLaunchSetting(this);
timerImitate();
@@ -106,7 +114,7 @@ public class InitJpushServer extends Service {
sequence++;
tagAliasBean.alias = Utils.getSerial();
tagAliasBean.isAliasAction = true;
TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), sequence, tagAliasBean);
TagAliasOperatorHelper.getInstance().handleAction(InitJpushServer.this, sequence, tagAliasBean);
// JPushInterface.setAlias(this, Utils.getSerial(), new TagAliasCallback() {
// @Override
// public void gotResult(int i, String s, Set<String> set) {
@@ -172,7 +180,8 @@ public class InitJpushServer extends Service {
case 200:
JSONObject data = jsonObject.getJSONObject("data");
String ids = data.optString("ids");
writeDeselectIDtoSystem(ids);
String packages = data.optString("package");
writeDeselectIDtoSystem(ids, packages);
break;
default:
Log.e("initmjsheng", "getDeselectID---code is -200");
@@ -290,6 +299,7 @@ public class InitJpushServer extends Service {
}
private void writeAppPackageList(String result) {
ApkUtils. addShortcut(this, result);//开机之后添加图标到桌面
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
if (!TextUtils.isEmpty(result)) {
@@ -309,6 +319,8 @@ public class InitJpushServer extends Service {
}
private void deleteOtherApp(String packageList) {
Log.e("deleteOtherApp", "packageList:" + packageList);
String[] result = packageList.split(",");
@@ -593,7 +605,7 @@ public class InitJpushServer extends Service {
LogUtils.e("UpdateList:upgrade_not:" + upgrade_not + "-----------upgrade_ok:" + upgrade_ok);
LogUtils.e("launch:" + launch + "-----------net_ok:" + net_ok + "-----------net_not:" + net_not);
boolean qch_app_power_on = Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_power_on", launch);
boolean qch_app_power_on = Settings.System.putString(InitJpushServer.this.getContentResolver(), "qch_app_power_on", launch);
// Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
// netControlIntent.putExtra("package_name", net_not);
@@ -627,20 +639,34 @@ public class InitJpushServer extends Service {
private void writeDeselectBrowserIDtoSystem(String ids) {
// if (!TextUtils.isEmpty(ids)) {
boolean deselectBrowserArray = Settings.System.putString(getApplicationContext().getContentResolver(), "DeselectBrowserArray", ids);
boolean deselectBrowserArray = Settings.System.putString(InitJpushServer.this.getContentResolver(), "DeselectBrowserArray", ids);
Log.e("SystemSetting", "DeselectBrowserArray---------" + deselectBrowserArray);
// } else {
// Log.e("mjsheng", "writeDeselectBrowserIDtoSystem is null:");
// }
}
private void writeDeselectIDtoSystem(String ids) {
if (!TextUtils.isEmpty(ids)) {
boolean deselectViewArray = Settings.System.putString(getApplicationContext().getContentResolver(), "DeselectViewArray", ids);
Log.e("SystemSetting", "deselectViewArray---------" + deselectViewArray);
//应用id管控
private void writeDeselectIDtoSystem(String s1, String result) {
if (!TextUtils.isEmpty(s1) && !TextUtils.isEmpty(result)) {
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
LogUtils.e(result);
if (!result.contains(appstore)) {
result = result + "," + appstore;
}
if (!result.contains(store)) {
result = result + "," + store;
}
String olddeselectViewArray = Settings.System.getString(this.getContentResolver(), "qch_app_forbid_id");
Log.e("SystemSetting", "olddeselectViewArray---------" + olddeselectViewArray);
Settings.System.putString(this.getContentResolver(), "qch_app_forbid_id", result);
Settings.System.putString(this.getContentResolver(), "DeselectViewArray", s1);
Log.e("qch_app_forbid_id", "qch_app_forbid_id---------" + result);
Log.e("SystemSetting", "deselectViewArray---------" + s1);
} else {
boolean deselectViewArray = Settings.System.putString(getApplicationContext().getContentResolver(), "DeselectViewArray", "Invalid");
Log.e("mjsheng", "writeDeselectIDtoSystem is null:");
Settings.System.putString(this.getContentResolver(), "DeselectViewArray", "Invalid");
}
}
@@ -671,9 +697,12 @@ public class InitJpushServer extends Service {
Log.e("initmjsheng", "getSystemSetting---code is -200");
break;
}
} catch (Exception e) {
Log.e("initmjsheng", "1getSystemSetting---wroing----" + e.getMessage());
} catch (IOException e) {
e.printStackTrace();
Log.e("initmjsheng", "1getSystemSetting---IOException----" + e.getMessage());
} catch (JSONException e) {
e.printStackTrace();
Log.e("initmjsheng", "1getSystemSetting---JSONException----" + e.getMessage());
}
}
@@ -704,7 +733,7 @@ public class InitJpushServer extends Service {
}
synchronized public void sendMACaddress() {
String rid = JPushInterface.getRegistrationID(getApplicationContext());
String rid = JPushInterface.getRegistrationID(InitJpushServer.this);
OkGo.post(Configure.SEND_DEVICES)
.params("sn", Utils.getSerial())
@@ -751,15 +780,15 @@ public class InitJpushServer extends Service {
Log.e("jpttlocked", String.valueOf(lock));
if (lock == 0) {
locked = false;
boolean se = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_unlock_ipad", 1);
Log.e("fht", "getLockedState---------" + Settings.System.getString(getApplicationContext().getContentResolver(), "qch_unlock_ipad"));
boolean se = Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_unlock_ipad", 1);
Log.e("fht", "getLockedState---------" + Settings.System.getString(InitJpushServer.this.getContentResolver(), "qch_unlock_ipad"));
Log.e("jpttlocked1", "qch_unlock_ipad---------" + locked + se);
} else {
locked = true;
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_unlock_ipad", 0);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_unlock_ipad", 0);
Log.e("jpttlocked2", "qch_unlock_ipad---------" + locked);
// Settings.System.putString(getApplicationContext().getContentResolver(), "DeselectBrowserArray", "http://www.baidu.com");
String ss = Settings.System.getString(getApplicationContext().getContentResolver(), "DeselectBrowserArray");
// Settings.System.putString(InitJpushServer.this.getContentResolver(), "DeselectBrowserArray", "http://www.baidu.com");
String ss = Settings.System.getString(InitJpushServer.this.getContentResolver(), "DeselectBrowserArray");
Log.e("jpttlocked2", "DeselectBrowserArray---------" + ss);
// 初始化 JPush
JPushInterface.init(InitJpushServer.this);
@@ -811,20 +840,20 @@ public class InitJpushServer extends Service {
private void SettingSysData(JSONObject data) {
try {
int setting_call = changeNum(data.optInt("setting_call"));
boolean qch_call_forbid = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_call_forbid", setting_call);
boolean qch_call_forbid = Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_call_forbid", setting_call);
Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
int setting_phone = changeNum(data.optInt("setting_phone"));
boolean qch_white_list_on = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_white_list_on", setting_phone);
boolean qch_white_list_on = Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_white_list_on", setting_phone);
Log.e("SystemSetting", "qch_white_list_on---------" + qch_white_list_on);
String setting_phones = data.optString("setting_phones");
boolean qch_white_list_Array = Settings.System.putString(getApplicationContext().getContentResolver(), "qch_white_list_Array", setting_phones);
boolean qch_white_list_Array = Settings.System.putString(InitJpushServer.this.getContentResolver(), "qch_white_list_Array", setting_phones);
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array---------" + qch_white_list_Array + "---" + setting_phones);
int setting_memory = changeNum(data.optInt("setting_memory"));
boolean qch_sdcard_forbid_on = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
boolean qch_sdcard_forbid_on = Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
Log.e("SystemSetting", "qch_sdcard_forbid_on---------" + qch_sdcard_forbid_on);
@@ -834,7 +863,7 @@ public class InitJpushServer extends Service {
//Midi模式usb_midi
String setting_usb = data.optString("setting_usb");
if (!BuildConfig.DEBUG) {
boolean qch_usb_choose = Settings.System.putString(getApplicationContext().getContentResolver(), "qch_usb_choose", setting_usb);
boolean qch_usb_choose = Settings.System.putString(InitJpushServer.this.getContentResolver(), "qch_usb_choose", setting_usb);
Log.e("SystemSetting", "qch_usb_choose---------" + qch_usb_choose);
String usbStatus = "";
switch (setting_usb) {
@@ -870,12 +899,12 @@ public class InitJpushServer extends Service {
//蓝牙开关
int setting_bluetooth = changeNum(data.optInt("setting_bluetooth"));
boolean qch_bt_forbid_on = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
boolean qch_bt_forbid_on = Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
Log.e("SystemSetting", "qch_bt_forbid_on---------" + qch_bt_forbid_on);
//系统导航条显示开关
int setting_navigation = changeNum(data.optInt("setting_navigation"));
boolean qch_hide_navigationBar = Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
boolean qch_hide_navigationBar = Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
String navigationStatus = "";
@@ -930,7 +959,7 @@ public class InitJpushServer extends Service {
//tfmedia开关
int setting_tfmedia = changeNum(data.optInt("setting_tfmedia"));
boolean qch_tfmedia_forbid = Settings.System.putInt(getApplicationContext().getContentResolver(),
boolean qch_tfmedia_forbid = Settings.System.putInt(InitJpushServer.this.getContentResolver(),
"qch_tfmedia_forbid", setting_tfmedia);
Log.e("SystemSetting", "setting_tfmedia---------" + qch_tfmedia_forbid);
String tfmediaStatus = "";
@@ -957,7 +986,7 @@ public class InitJpushServer extends Service {
i++;
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
Settings.System.putString(getApplicationContext().getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
Settings.System.putString(InitJpushServer.this.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + stringBuffer.toString());
} catch (JSONException e) {
@@ -965,37 +994,37 @@ public class InitJpushServer extends Service {
}
} else {
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_tfmedia_forbid", 0);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_tfmedia_forbid", 0);
}
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = changeNum(data.optInt("setting_clock"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_deskclock", deskclock);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_deskclock", deskclock);
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(data.optInt("setting_recording"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_soundrecorder", soundrecorder);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(data.optInt("setting_music"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_music", music);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_music", music);
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(data.optInt("setting_picture"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_gallery", gallery);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_gallery", gallery);
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_wallpaper", wallpaper);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_wallpaper", wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
//文件管理器
int filemanager = changeNum(data.optInt("setting_file"));
Settings.System.putInt(getApplicationContext().getContentResolver(), "qch_app_filemanager", filemanager);
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_filemanager", filemanager);
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
} catch (Exception e) {
e.printStackTrace();
Log.e("mjsheng", "SettingSysData---error::" + e.getMessage());
Log.e("mjsheng", "SettingSysData---1error::" + e.getMessage());
}
}

View File

@@ -7,9 +7,15 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.support.v4.content.FileProvider;
import android.util.Log;
@@ -18,6 +24,7 @@ import android.widget.Toast;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.server.InitJpushServer;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@@ -29,6 +36,7 @@ import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
@@ -663,4 +671,81 @@ public class ApkUtils {
return true;
}
}
public static void getStartActivityName(Context mContext, String packagename) {
// 通过包名获取此APP详细信息包括Activities、services、versioncode、name等等
PackageInfo packageinfo = null;
PackageManager pm = mContext.getPackageManager();
try {
packageinfo = pm.getPackageInfo(packagename, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (packageinfo == null) {
return;
}
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
resolveIntent.setPackage(packageinfo.packageName);
// 通过getPackageManager()的queryIntentActivities方法遍历
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
for (ResolveInfo resolveInfo : resolveinfoList) {
Log.d("", "resolveInfo:" + resolveInfo);
}
ResolveInfo resolveinfo = resolveinfoList.iterator().next();
if (resolveinfo != null) {
// packagename = 参数packname
String packageName = resolveinfo.activityInfo.packageName;
// 这个就是我们要找的该APP的LAUNCHER的Activity[组织形式packagename.mainActivityname]
String className = resolveinfo.activityInfo.name;
Drawable icon = resolveinfo.loadIcon(pm);
Bitmap APKicon;
if (icon instanceof BitmapDrawable) {
APKicon = ((BitmapDrawable) icon).getBitmap();
} else {
Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
icon.draw(canvas);
APKicon = bitmap;
}
Intent apkIntent = new Intent();
apkIntent.setClassName(packageName, className);
Intent shortcutIntent = new Intent("android.content.hr.action.shortcutsh");
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, APKicon);
shortcutIntent.putExtra("duplicate", false);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, resolveinfo.loadLabel(pm));
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, apkIntent);
shortcutIntent.setPackage("com.android.launcher3");
mContext.sendBroadcast(shortcutIntent);
}
}
public static void addShortcut(Context context, String packageList) {
String[] stringList = packageList.split(",");
List<String> packages = new ArrayList<>(Arrays.asList(stringList));
String installedList = "";
for (String s : packages) {
if (s.equals("com.jiaoguanyi.store") || s.equals("com.jiaoguanyi.appstore")) {
continue;
}
if (!ApkUtils.isAvailable(context, s)) {
continue;
}
// ApkUtils.getStartActivityName(context, s);
installedList += s + ",";
Log.e("addShortcut", s);
}
installedList = installedList.substring(0, installedList.length() - 1);
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList);
// String old = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
// Log.e("addShortcut", old);
Log.e("addShortcut", "putstring:" + qch_force_app);
}
}