version:1.2.9
update: fix:屏蔽清除桌面缓存,增加首页显示自定义版本号 add:
This commit is contained in:
@@ -50,8 +50,8 @@ android {
|
||||
productFlavors {
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 1036
|
||||
versionName "2.0.3.6"
|
||||
versionCode 1037
|
||||
versionName "2.0.3.7"
|
||||
/*********************************极光推送************************************/
|
||||
manifestPlaceholders = [
|
||||
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
|
||||
@@ -182,7 +182,6 @@ android {
|
||||
if (outputFile != null) {
|
||||
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${productFlavors[0].name}-${buildType.name}.apk"
|
||||
output.outputFileName = fileName
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,7 +233,7 @@ dependencies {
|
||||
|
||||
preBuild {
|
||||
doLast {
|
||||
def imlFile = file( project.name + ".iml")
|
||||
def imlFile = file(project.name + ".iml")
|
||||
println 'Change ' + project.name + '.iml order'
|
||||
try {
|
||||
def parsedXml = (new XmlParser()).parse(imlFile)
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.SHUTDOWN" />
|
||||
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
|
||||
<uses-permission android:name="android.permission.DELETE_CACHE_FILES"/>
|
||||
|
||||
<!-- 静默安装权限 -->
|
||||
<uses-permission
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.lzy.okgo.model.HttpHeaders;
|
||||
import com.mjsheng.myappstore.utils.CacheUtils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -51,7 +52,13 @@ public class HomeActivity extends AppCompatActivity {
|
||||
// hideStatusBar();
|
||||
Log.e(TAG, "DebugTest: " + HttpHeaders.getUserAgent());
|
||||
boolean qch_force_app = Settings.System.putString(getContentResolver(), "qch_launcher_icon_app", "");
|
||||
Log.e(TAG, "DebugTest: "+ Settings.System.getString(getContentResolver(), "qch_launcher_icon_app"));
|
||||
Log.e(TAG, "DebugTest: " + Settings.System.getString(getContentResolver(), "qch_launcher_icon_app"));
|
||||
// try {
|
||||
// new CacheUtils().cleanApplicationUserData(HomeActivity.this, "com.android.launcher3");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// Log.e(TAG, "DebugTest: " + e.getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@@ -66,7 +73,6 @@ public class HomeActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void bootanimotion() {
|
||||
// File file = new File(Environment.getExternalStorageDirectory() + File.separator + "bootanimation.zip");
|
||||
// String path0 = "/data/local/qchmedia/bootanimation.zip";
|
||||
|
||||
@@ -72,6 +72,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
RelativeLayout layout_number;
|
||||
@BindView(R.id.layout_name)
|
||||
RelativeLayout layout_name;
|
||||
@BindView(R.id.tv_customversion)
|
||||
TextView tv_customversion;
|
||||
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
private MainPresenter mPresenter;
|
||||
@@ -116,6 +118,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
tv_devmac.setText(macaddr);
|
||||
}
|
||||
tv_version.setText(BuildConfig.VERSION_NAME);
|
||||
String customVersion = Utils.getProperty("ro.custom.build.version", "获取失败");//获取自定义版本
|
||||
tv_customversion.setText(customVersion);
|
||||
}
|
||||
|
||||
private void showSNErrorDialog() {
|
||||
|
||||
@@ -80,10 +80,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
private boolean isOfficialVersion() {
|
||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
||||
return "official".equals(channelValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过sn获取用户信息
|
||||
@@ -273,7 +270,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void updateDeviceInfo() {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
mView.updateDeviceInfoFinished();
|
||||
return;
|
||||
}
|
||||
@@ -332,7 +329,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getSnTimeControl() {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
mView.getSnTimeControlFinished();
|
||||
return;
|
||||
}
|
||||
@@ -554,7 +551,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void checkTestUpdate() {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
mView.checkTestUpdateFinished();
|
||||
return;
|
||||
}
|
||||
@@ -651,7 +648,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getDeviceBatch(String packageList) {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
mView.getDeviceBatchFinished();
|
||||
return;
|
||||
}
|
||||
@@ -1034,7 +1031,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setAppinsideWeb() {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
getAppinsideWeb();
|
||||
} else {
|
||||
getNewAppinsideWeb();
|
||||
@@ -1149,7 +1146,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setLogoImg() {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
mView.setLogoImgFinished();
|
||||
return;
|
||||
}
|
||||
@@ -1197,7 +1194,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
@Override
|
||||
public void getScreenLockState() {
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
|
||||
if (isOfficialVersion() || locked == 1) {
|
||||
if (JGYUtils.isOfficialVersion() || locked == 1) {
|
||||
mView.setScreenLockStateFinished(false, "");
|
||||
return;
|
||||
}
|
||||
@@ -1239,7 +1236,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getDefaultDesktop() {
|
||||
if (isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
mView.getDefaultDesktopFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public class BaseApplication extends MultiDexApplication {
|
||||
|| action.equals("android.intent.action.MASTER_CLEAR_NOTIFICATION")
|
||||
|| action.equals("android.intent.action.FORCE_FACTORY_RESET")
|
||||
) {
|
||||
Log.e("receiver", "MASTER_CLEAR");
|
||||
Log.e("ScreenReceiver", "MASTER_CLEAR");
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
}
|
||||
@@ -374,6 +374,9 @@ public class BaseApplication extends MultiDexApplication {
|
||||
}
|
||||
|
||||
private void getLockState(String status, String time) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
return;
|
||||
}
|
||||
GetLockStateApi getLockState = NetInterfaceManager.getLockState();
|
||||
getLockState.getLockState(Utils.getSerial(), status, time)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.mjsheng.myappstore.server.MainService;
|
||||
import com.mjsheng.myappstore.server.StepService;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
private String TAG = BootReceiver.class.getSimpleName();
|
||||
private String TAG = BootReceiver.class.getSimpleName() + "myapp";
|
||||
public static final String BOOT_COMPLETED = "com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED";
|
||||
|
||||
@Override
|
||||
@@ -21,7 +21,7 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
Log.e(TAG, "action:" + intent.getAction());
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
String packageList = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
|
||||
if (TextUtils.isEmpty(packageList)){
|
||||
if (TextUtils.isEmpty(packageList)) {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", "");
|
||||
}
|
||||
HTTPInterface.updateDeviceInfo(context);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class NewAppReceiver extends BroadcastReceiver {
|
||||
ApkUtils.RemoveTask(context, packageName);
|
||||
}
|
||||
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||
bootIntent.setComponent(new ComponentName("com.jiaoguanyi.store", "com.jiaoguanyi.store.receiver.BootReceiver"));
|
||||
bootIntent.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
|
||||
context.sendBroadcast(bootIntent);
|
||||
//启动教官壹
|
||||
}
|
||||
|
||||
@@ -23,11 +23,14 @@ import android.widget.TextView;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.activity.HomeActivity;
|
||||
import com.mjsheng.myappstore.activity.MainActivity;
|
||||
import com.mjsheng.myappstore.activity.MainContact;
|
||||
import com.mjsheng.myappstore.activity.MainPresenter;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.CacheUtils;
|
||||
import com.mjsheng.myappstore.utils.ForegroundAppUtil;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
import com.mjsheng.myappstore.utils.TimeUtils;
|
||||
@@ -55,6 +58,7 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
mPresenter.attachView(this);
|
||||
registerReceivers();
|
||||
addShortcut();
|
||||
// cleanLauncherCache();
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
@@ -91,7 +95,20 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void addShortcut(){
|
||||
private void cleanLauncherCache() {
|
||||
int cleaned = (int) SPUtils.get(MainService.this, "cleanLauncherCache", 0);
|
||||
if (cleaned == 0) {
|
||||
try {
|
||||
new CacheUtils().cleanApplicationUserData(MainService.this, "com.android.launcher3");
|
||||
SPUtils.put(MainService.this, "cleanLauncherCache", 1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "DebugTest: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addShortcut() {
|
||||
ApkUtils.addShortcut(MainService.this);
|
||||
}
|
||||
|
||||
|
||||
136
app/src/main/java/com/mjsheng/myappstore/utils/CacheUtils.java
Normal file
136
app/src/main/java/com/mjsheng/myappstore/utils/CacheUtils.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package com.mjsheng.myappstore.utils;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.IPackageDataObserver;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.IPackageStatsObserver;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageStats;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class CacheUtils {
|
||||
|
||||
private static final String TAG = CacheUtils.class.getSimpleName();
|
||||
private final long MAX_WAIT_TIME = 60 * 1000;
|
||||
private final long WAIT_TIME_INCR = 10 * 1000;
|
||||
|
||||
/**
|
||||
* 获取应用数据大小 cache + data
|
||||
*
|
||||
* @param context
|
||||
* @param packageName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public long getApplicationCache(Context context, String packageName) throws Exception {
|
||||
try {
|
||||
PackageStatsObserver observer = new PackageStatsObserver();
|
||||
// wait on observer
|
||||
synchronized (observer) {
|
||||
Method method = PackageManager.class.getMethod("getPackageSizeInfo", new Class[] { String.class, IPackageStatsObserver.class });
|
||||
method.invoke(context.getPackageManager(), packageName, observer);
|
||||
// getPm().getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
|
||||
long waitTime = 0;
|
||||
while ((!observer.isDone()) || (waitTime > MAX_WAIT_TIME)) {
|
||||
observer.wait(WAIT_TIME_INCR);
|
||||
waitTime += WAIT_TIME_INCR;
|
||||
}
|
||||
if (!observer.isDone()) {
|
||||
throw new Exception("Timed out waiting for PackageStatsObserver.onGetStatsCompleted");
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "toString " + observer.stats.toString());
|
||||
return observer.stats.dataSize + observer.stats.cacheSize;
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed to get handle for PackageManger Exception: " + e);
|
||||
return -1;
|
||||
} catch (InterruptedException e) {
|
||||
Log.w(TAG, "InterruptedException :" + e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除应用数据
|
||||
*
|
||||
* @param context
|
||||
* @param packageName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean cleanApplicationUserData(Context context, String packageName) throws Exception {
|
||||
try {
|
||||
PackageDataObserver observer = new PackageDataObserver();
|
||||
// wait on observer
|
||||
synchronized (observer) {
|
||||
Method method = PackageManager.class.getMethod("clearApplicationUserData", new Class[] { String.class, IPackageDataObserver.class });
|
||||
method.invoke(context.getPackageManager(), packageName, observer);
|
||||
// getPm().deleteApplicationCacheFiles(appid, observer);
|
||||
long waitTime = 0;
|
||||
while (!observer.isDone() || (waitTime > MAX_WAIT_TIME)) {
|
||||
observer.wait(WAIT_TIME_INCR);
|
||||
waitTime += WAIT_TIME_INCR;
|
||||
}
|
||||
if (!observer.isDone()) {
|
||||
throw new Exception("timed out waiting for PackageDataObserver.onRemoveCompleted");
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "cleanApplicationCache " + observer.retValue);
|
||||
return observer.retValue;
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed to get handle for PackageManger Exception: " + e);
|
||||
return false;
|
||||
} catch (InterruptedException e) {
|
||||
Log.w(TAG, "InterruptedException :" + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private IPackageManager getPm() {
|
||||
return IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
||||
}
|
||||
|
||||
class PackageDataObserver extends IPackageDataObserver.Stub {
|
||||
public boolean retValue = false;
|
||||
private boolean doneFlag = false;
|
||||
|
||||
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
|
||||
synchronized (this) {
|
||||
retValue = succeeded;
|
||||
doneFlag = true;
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return doneFlag;
|
||||
}
|
||||
}
|
||||
|
||||
class PackageStatsObserver extends IPackageStatsObserver.Stub {
|
||||
public boolean retValue = false;
|
||||
public PackageStats stats;
|
||||
private boolean doneFlag = false;
|
||||
|
||||
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
|
||||
synchronized (this) {
|
||||
retValue = succeeded;
|
||||
stats = pStats;
|
||||
doneFlag = true;
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return doneFlag;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ public class JGYUtils {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static boolean isOfficialVersion() {
|
||||
String channelValue = JGYUtils.getInstance().getStringMetaData();
|
||||
return "official".equals(channelValue);
|
||||
}
|
||||
|
||||
|
||||
public void resetDevice() {
|
||||
boolean isReset = MySQLData.GetBooleanData(mContext, CommonDatas.IS_RESET);
|
||||
|
||||
@@ -78,9 +78,8 @@
|
||||
android:fadingEdge="none"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_customversion"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView">
|
||||
|
||||
@@ -91,6 +90,7 @@
|
||||
android:layout_marginLeft="@dimen/dp_150"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginRight="@dimen/dp_150"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -309,8 +309,8 @@
|
||||
android:layout_width="@dimen/dp_240"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:background="@drawable/bt_checkupdate_selector"
|
||||
android:stateListAnimator="@null"
|
||||
android:text="检查更新"
|
||||
@@ -325,5 +325,14 @@
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_customversion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="@color/background_top"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -325,4 +325,14 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linearLayout" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_customversion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/background_top"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,19 +1,16 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
## For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
#
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# Default value: -Xmx1024m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
#
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
#Thu Apr 15 10:50:40 CST 2021
|
||||
android.enableJetifier=true
|
||||
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
|
||||
android.useAndroidX=true
|
||||
|
||||
Reference in New Issue
Block a user