mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Temporarily ignoring session broadcasts for 3 hours
Bug: 34957633 Change-Id: Ia82a4a33f3ab07c12e98bd9060a839d660827acd
This commit is contained in:
@@ -19,14 +19,17 @@ package com.android.launcher3;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||
import com.android.launcher3.compat.UserManagerCompat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,9 +38,13 @@ import java.util.List;
|
||||
*/
|
||||
public class SessionCommitReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final long SESSION_IGNORE_DURATION = 3 * 60 * 60 * 1000; // 3 hours
|
||||
|
||||
// Preference key for automatically adding icon to homescreen.
|
||||
public static final String ADD_ICON_PREFERENCE_KEY = "pref_add_icon_to_home";
|
||||
|
||||
private static final String KEY_FIRST_TIME = "first_session_broadcast_time";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!isEnabled(context)) {
|
||||
@@ -57,6 +64,17 @@ public class SessionCommitReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
// STOPSHIP: Remove this workaround when we start getting proper install reason
|
||||
SharedPreferences prefs = context
|
||||
.getSharedPreferences(LauncherFiles.DEVICE_PREFERENCES_KEY, 0);
|
||||
long now = System.currentTimeMillis();
|
||||
long firstTime = prefs.getLong(KEY_FIRST_TIME, now);
|
||||
prefs.edit().putLong(KEY_FIRST_TIME, firstTime).apply();
|
||||
if ((now - firstTime) < SESSION_IGNORE_DURATION) {
|
||||
Log.d("SessionCommitReceiver", "Temporarily ignoring session broadcast");
|
||||
return;
|
||||
}
|
||||
|
||||
List<LauncherActivityInfo> activities = LauncherAppsCompat.getInstance(context)
|
||||
.getActivityList(info.getAppPackageName(), user);
|
||||
if (activities == null || activities.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user