version:1.0.2
fix: update:优化主页
This commit is contained in:
1 parent
8799e85443
commit
4daf5ab92f
54 files changed
+401
-1585
No files matched your search
@@ -105,7 +105,6 @@ import com.uiuipad.os.model.AppLaunchTracker;
|
||||
import com.uiuipad.os.model.ModelWriter;
|
||||
import com.uiuipad.os.network.bean.AppPasswdBean;
|
||||
import com.uiuipad.os.network.bean.BaseResponse;
|
||||
import com.uiuipad.os.network.HTTPInterface;
|
||||
import com.uiuipad.os.network.NetInterfaceManager;
|
||||
import com.uiuipad.os.network.bean.NewestAppUpdateResult;
|
||||
import com.uiuipad.os.notification.NotificationListener;
|
||||
@@ -156,9 +155,6 @@ import com.uiuipad.os.widget.custom.CustomWidgetParser;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
@@ -480,25 +476,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
});
|
||||
JGYUtils.getInstance().wakeUpAppstore();
|
||||
JGYUtils.getInstance().wakeUpDeviceInfo();
|
||||
XGPushConfig.enableDebug(this, true);
|
||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
//token在设备卸载重装的时候有可能会变
|
||||
Log.e("TPush", "注册成功,设备token为:" + data);
|
||||
NetInterfaceManager.getInstance().setPushTag(true, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Object data, int errCode, String msg) {
|
||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
PushServiceFactory.init(this);
|
||||
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||
pushService.setLogLevel(CloudPushService.LOG_DEBUG);
|
||||
@@ -1173,43 +1150,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
Log.e("onStart", "app = null" + packageName);
|
||||
return;
|
||||
}
|
||||
sendAppUsageRecord(packageName);
|
||||
}
|
||||
|
||||
private void sendAppUsageRecord(String packageName) {
|
||||
Log.e("sendAppUsageRecord", "packageName: " + packageName);
|
||||
String app_name = APKUtils.getAppNameByPackage(Launcher.this, packageName);
|
||||
long openTime = TimeUtils.getInstance().getStartTime() / 1000;
|
||||
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppUsageRecordControl()
|
||||
.sendAppUsageRecord(Utils.getSerial(Launcher.this), packageName, app_name, openTime, closeTime)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAppUsageRecord", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAppUsageRecord", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAppUsageRecord", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAppUsageRecord", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void handleDeferredResume() {
|
||||
if (hasBeenResumed() && !mStateManager.getState().disableInteraction) {
|
||||
getUserEventDispatcher().logActionCommand(Action.Command.RESUME,
|
||||
@@ -1286,7 +1228,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mUpdate.checkUpdate(System.currentTimeMillis());
|
||||
mPasswd.getPassword(System.currentTimeMillis());
|
||||
TimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
HTTPInterface.sendRunningApp(Launcher.this);
|
||||
JGYUtils.getInstance().wakeUpAppstore();
|
||||
JGYUtils.getInstance().wakeUpDeviceInfo();
|
||||
checkIsRest();
|
||||
@@ -1344,7 +1285,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("passwdObserver", "onNext: " + aLong);
|
||||
HTTPInterface.getAppPasswd();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1380,7 +1321,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("updateObserver", "onNext: " + aLong);
|
||||
checkUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1394,77 +1334,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
};
|
||||
|
||||
private void checkUpdate() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getCheckUpdateObservable()
|
||||
.getCheckUpdate(BuildConfig.APPLICATION_ID,
|
||||
BuildConfig.VERSION_CODE,
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<NewestAppUpdateResult>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("checkUpdate", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<NewestAppUpdateResult> response) {
|
||||
Log.e("checkUpdate", "onNext: " + response);
|
||||
int code = response.code;
|
||||
if (code == 200) {
|
||||
NewestAppUpdateResult result = response.data;
|
||||
checkAppUpdate(result);
|
||||
} else {
|
||||
Log.e(TAG, "onNext: " + "not find update");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("checkUpdate", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("checkUpdate", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkAppUpdate(NewestAppUpdateResult result) {
|
||||
int version_code = result.getVersion_code();
|
||||
String app_package = result.getApp_package();
|
||||
String url = result.getUrl();
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = getPackageManager().getPackageInfo(app_package, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = info.versionCode;
|
||||
}
|
||||
if (info != null && appVersionCode < version_code) {
|
||||
Aria.download(this)
|
||||
.load(url)
|
||||
.setExtendField(result.toString())
|
||||
.setFilePath(ContextCompat.getExternalFilesDirs(Launcher.this, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath() + File.separator + getFileNamefromURL(url))
|
||||
.ignoreFilePathOccupy()
|
||||
.create();
|
||||
} else {
|
||||
Log.e(TAG, "checkAppUpdate: " + app_package + " :无需更新");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFileNamefromURL(String url) {
|
||||
int position = url.lastIndexOf("/");
|
||||
return url.substring(position + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
// Ensure that items added to Launcher are queued until Launcher returns
|
||||
@@ -3067,7 +2936,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
// Setting the touch point to (-1, -1) will show the options popup in the center of
|
||||
// the screen.
|
||||
// OptionsPopupView.showDefaultOptions(this, -1, -1);
|
||||
OptionsPopupView.showDefaultOptions(this, -1, -1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user