version:2.2
fix:修复应用从第一屏开始排列 add:
This commit is contained in:
@@ -51,7 +51,6 @@ import android.os.Process;
|
||||
import android.os.StrictMode;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.method.TextKeyListener;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
@@ -71,16 +70,14 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.aoleyun.os.DropTarget.DragObject;
|
||||
import com.aoleyun.os.Statistics.AppInformation;
|
||||
import com.aoleyun.os.TTUtils.APKUtils;
|
||||
import com.aoleyun.os.TTUtils.Utils;
|
||||
import com.aoleyun.os.uiuiutils.APKUtils;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
import com.aoleyun.os.accessibility.LauncherAccessibilityDelegate;
|
||||
import com.aoleyun.os.allapps.AllAppsContainerView;
|
||||
import com.aoleyun.os.allapps.AllAppsStore;
|
||||
import com.aoleyun.os.allapps.AllAppsTransitionController;
|
||||
import com.aoleyun.os.allapps.DiscoveryBounce;
|
||||
import com.aoleyun.os.anim.PropertyListBuilder;
|
||||
import com.aoleyun.os.base.MyApplication;
|
||||
import com.aoleyun.os.compat.AppWidgetManagerCompat;
|
||||
import com.aoleyun.os.compat.LauncherAppsCompatVO;
|
||||
import com.aoleyun.os.config.FeatureFlags;
|
||||
@@ -103,12 +100,11 @@ import com.aoleyun.os.logging.UserEventDispatcher;
|
||||
import com.aoleyun.os.logging.UserEventDispatcher.UserEventDelegate;
|
||||
import com.aoleyun.os.model.AppLaunchTracker;
|
||||
import com.aoleyun.os.model.ModelWriter;
|
||||
import com.aoleyun.os.network.AppPasswdBean;
|
||||
import com.aoleyun.os.network.BaseResponse;
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.network.NetworkManager;
|
||||
import com.aoleyun.os.network.NewestAppUpdateResult;
|
||||
import com.aoleyun.os.network.api.AddAppLog;
|
||||
import com.aoleyun.os.network.bean.NewestAppUpdateResult;
|
||||
import com.aoleyun.os.notification.NotificationListener;
|
||||
import com.aoleyun.os.pageindicators.PageIndicatorDots;
|
||||
import com.aoleyun.os.popup.PopupContainerWithArrow;
|
||||
@@ -197,7 +193,6 @@ import static com.aoleyun.os.logging.LoggerUtils.newTarget;
|
||||
import static com.aoleyun.os.states.RotationHelper.REQUEST_NONE;
|
||||
import static com.aoleyun.os.util.RaceConditionTracker.ENTER;
|
||||
import static com.aoleyun.os.util.RaceConditionTracker.EXIT;
|
||||
import static com.aoleyun.os.touch.ItemClickHandler.getInfoFromPackageName;
|
||||
|
||||
/**
|
||||
* Default launcher application.
|
||||
@@ -341,8 +336,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
RaceConditionTracker.onEvent(ON_CREATE_EVT, ENTER);
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(1, TimeUnit.MINUTES)
|
||||
Observable.create(passwdSubscribe)
|
||||
.throttleFirst(1, TimeUnit.HOURS)
|
||||
.subscribe(passwdObserver);
|
||||
Observable.create(updateSubscribe)
|
||||
.throttleFirst(6, TimeUnit.HOURS)
|
||||
.subscribe(updateObserver);
|
||||
startService(new Intent(Launcher.this, MainService.class));
|
||||
if (DEBUG_STRICT_MODE) {
|
||||
@@ -1090,126 +1088,56 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Log.e(TAG, "onStart: " + TimeUtils.getInstance().isNormalTime());
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.NO_OVERVIEW_EVENT_TAG, "Launcher.onStart");
|
||||
}
|
||||
RaceConditionTracker.onEvent(ON_START_EVT, ENTER);
|
||||
super.onStart();
|
||||
removeRecentTask();
|
||||
String packagename = TimeUtils.getInstance().getAppPackageName();
|
||||
Log.e("SendcloseApp", "packagename=" + packagename);
|
||||
TimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
if (packagename != null && packagename.length() > 0) {
|
||||
SendcloseApp(packagename);
|
||||
// if (!APKUtils.isSystemApp(this, packagename) && !Arrays.asList(ItemClickHandler.packages).contains(packagename)) {
|
||||
// try {
|
||||
AppInformation app = getInfoFromPackageName(packagename);
|
||||
if (app != null) {
|
||||
long time = app.getUsedTimebyDay() / 1000;
|
||||
Log.e("fht", "返回运行时间: " + DateUtils.formatElapsedTime(time));
|
||||
Log.e("fht", "返回运行时间: " + time);
|
||||
NetworkManager.getInstance().getAppUsageRecordControl()
|
||||
.sendAppUsageRecord(Utils.getSerial(),
|
||||
app.getLabel(), app.getPackageName(),
|
||||
TimeUtils.getInstance().getStartTime()/1000,
|
||||
TimeUtils.getInstance().getEndTime()/1000)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("onStart", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("onStart", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("onStart", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("onStart", "onComplete: ");
|
||||
}
|
||||
});
|
||||
// if (userInfo != null) {
|
||||
// HTTPInterface.sendTimeLog(handler, userInfo, app.getLabel(), 2, time - MyApplication.getInstance().getRunTime());
|
||||
// } else {
|
||||
// Log.e("fht", "userInfo = null");
|
||||
// }
|
||||
//设为空值
|
||||
TimeUtils.getInstance().setAppPackageName("");
|
||||
} else {
|
||||
Log.e("fht", "app = null" + packagename);
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// Log.e("fht", e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Log.e("packagename", "packagename is null");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mLauncherCallbacks != null) {
|
||||
mLauncherCallbacks.onStart();
|
||||
}
|
||||
mAppWidgetHost.setListenIfResumed(true);
|
||||
RaceConditionTracker.onEvent(ON_START_EVT, EXIT);
|
||||
|
||||
/*移除最近任务列表*/
|
||||
TimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
removeRecentTask();
|
||||
String packageName = TimeUtils.getInstance().getAppPackageName();
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
Log.e("onStart", "app = null" + packageName);
|
||||
return;
|
||||
}
|
||||
sendAppUsageRecord(packageName);
|
||||
}
|
||||
|
||||
private void SendcloseApp(String packageName) {
|
||||
PackageManager pm = MyApplication.getInstance().getPackageManager();
|
||||
PackageInfo appInfo = null;
|
||||
try {
|
||||
appInfo = pm.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != appInfo) {
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = appInfo.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = appInfo.versionCode;
|
||||
}
|
||||
AddAppLog appLog = NetworkManager.getInstance().getapplogControl();
|
||||
String sn = Utils.getSerial();
|
||||
appLog.addLog(sn, packageName, appVersionCode, System.currentTimeMillis() / 1000, 2)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
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;
|
||||
NetworkManager.getInstance().getAppUsageRecordControl()
|
||||
.sendAppUsageRecord(Utils.getSerial(), packageName, app_name, openTime, closeTime)
|
||||
.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 onNext(BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
Log.e("SendcloseApp", "onNext: " + code + baseResponse.data);
|
||||
} else {
|
||||
Log.e("SendcloseApp", "onNext: " + code + baseResponse.msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("SendcloseApp", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAppUsageRecord", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAppUsageRecord", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1255,12 +1183,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
Log.e(TAG, "onResume: ");
|
||||
RaceConditionTracker.onEvent(ON_RESUME_EVT, ENTER);
|
||||
TraceHelper.beginSection("ON_RESUME");
|
||||
super.onResume();
|
||||
removeRecentTask();
|
||||
start.onstar(System.currentTimeMillis());
|
||||
TraceHelper.partitionSection("ON_RESUME", "superCall");
|
||||
|
||||
mHandler.removeCallbacks(mHandleDeferredResume);
|
||||
@@ -1281,19 +1206,20 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
TraceHelper.endSection("ON_RESUME");
|
||||
RaceConditionTracker.onEvent(ON_RESUME_EVT, EXIT);
|
||||
|
||||
Log.e(TAG, "onResume: ");
|
||||
isForeground = true;
|
||||
// TimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
// TimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
HTTPInterface.getAppPasswd();
|
||||
start.onstar(System.currentTimeMillis());
|
||||
/*打开霸屏应用*/
|
||||
String always_top_packagename = Settings.System.getString(getContentResolver(), "always_top_packagename");
|
||||
if (!TextUtils.isEmpty(always_top_packagename)) {
|
||||
APKUtils.openPackage(Launcher.this, always_top_packagename);
|
||||
}
|
||||
|
||||
mUpdate.checkUpdate(System.currentTimeMillis());
|
||||
mPasswd.getPassword(System.currentTimeMillis());
|
||||
TimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
HTTPInterface.sendRunningApp(Launcher.this);
|
||||
}
|
||||
|
||||
|
||||
private void removeRecentTask() {
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
@@ -1313,22 +1239,56 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private Passwd mPasswd;
|
||||
|
||||
private Start start;
|
||||
|
||||
private interface Start {
|
||||
void onstar(long time);
|
||||
private interface Passwd {
|
||||
void getPassword(long time);
|
||||
}
|
||||
|
||||
private ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
|
||||
private ObservableOnSubscribe<Long> passwdSubscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter emitter) throws Exception {
|
||||
start = emitter::onNext;
|
||||
mPasswd = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> passwdObserver = new Observer<Long>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("passwdObserver", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("passwdObserver", "onNext: " + aLong);
|
||||
HTTPInterface.getAppPasswd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("passwdObserver", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("passwdObserver", "onComplete: ");
|
||||
}
|
||||
};
|
||||
|
||||
private Update mUpdate;
|
||||
|
||||
private interface Update {
|
||||
void checkUpdate(long time);
|
||||
}
|
||||
|
||||
private ObservableOnSubscribe<Long> updateSubscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter emitter) throws Exception {
|
||||
mUpdate = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> updateObserver = new Observer<Long>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("updateObserver", "onSubscribe: ");
|
||||
@@ -1352,7 +1312,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
};
|
||||
|
||||
private void checkUpdate() {
|
||||
NetworkManager.getInstance().getCheckUpdateObservable()
|
||||
NetworkManager.getInstance()
|
||||
.getCheckUpdateObservable()
|
||||
.getCheckUpdate(BuildConfig.APPLICATION_ID,
|
||||
BuildConfig.VERSION_CODE,
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
@@ -1428,7 +1389,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
mLauncherCallbacks.onPause();
|
||||
}
|
||||
isForeground = false;
|
||||
// removeRecentTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user