Merge "Remove AgingHelper code" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fbc908ab86
@@ -30,11 +30,9 @@ import android.app.Notification;
|
|||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.IPackageManager;
|
import android.content.pm.IPackageManager;
|
||||||
import android.ext.services.notification.AgingHelper.Callback;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.service.notification.Adjustment;
|
import android.service.notification.Adjustment;
|
||||||
@@ -76,8 +74,6 @@ import java.util.concurrent.Executors;
|
|||||||
public class Assistant extends NotificationAssistantService {
|
public class Assistant extends NotificationAssistantService {
|
||||||
private static final String TAG = "ExtAssistant";
|
private static final String TAG = "ExtAssistant";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
public static final boolean AGE_NOTIFICATIONS = SystemProperties.getBoolean(
|
|
||||||
"debug.age_notifs", false);
|
|
||||||
|
|
||||||
private static final String TAG_ASSISTANT = "assistant";
|
private static final String TAG_ASSISTANT = "assistant";
|
||||||
private static final String TAG_IMPRESSION = "impression-set";
|
private static final String TAG_IMPRESSION = "impression-set";
|
||||||
@@ -94,7 +90,6 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
|
|
||||||
private SmartActionsHelper mSmartActionsHelper;
|
private SmartActionsHelper mSmartActionsHelper;
|
||||||
private NotificationCategorizer mNotificationCategorizer;
|
private NotificationCategorizer mNotificationCategorizer;
|
||||||
private AgingHelper mAgingHelper;
|
|
||||||
|
|
||||||
// key : impressions tracker
|
// key : impressions tracker
|
||||||
// TODO: prune deleted channels and apps
|
// TODO: prune deleted channels and apps
|
||||||
@@ -125,9 +120,6 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
getApplicationContext().getContentResolver(), getUserId(), this::updateThresholds);
|
getApplicationContext().getContentResolver(), getUserId(), this::updateThresholds);
|
||||||
mSmartActionsHelper = new SmartActionsHelper(getContext(), mSettings);
|
mSmartActionsHelper = new SmartActionsHelper(getContext(), mSettings);
|
||||||
mNotificationCategorizer = new NotificationCategorizer();
|
mNotificationCategorizer = new NotificationCategorizer();
|
||||||
mAgingHelper = new AgingHelper(getContext(),
|
|
||||||
mNotificationCategorizer,
|
|
||||||
new AgingCallback());
|
|
||||||
mSmsHelper = new SmsHelper(this);
|
mSmsHelper = new SmsHelper(this);
|
||||||
mSmsHelper.initialize();
|
mSmsHelper.initialize();
|
||||||
}
|
}
|
||||||
@@ -313,7 +305,6 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
sbn.getPackageName(), sbn.getKey(), sbn.getUserId()));
|
sbn.getPackageName(), sbn.getKey(), sbn.getUserId()));
|
||||||
}
|
}
|
||||||
mLiveNotifications.put(sbn.getKey(), entry);
|
mLiveNotifications.put(sbn.getKey(), entry);
|
||||||
mAgingHelper.onNotificationPosted(entry);
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, "Error occurred processing post", e);
|
Log.e(TAG, "Error occurred processing post", e);
|
||||||
@@ -328,8 +319,6 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAgingHelper.onNotificationRemoved(sbn.getKey());
|
|
||||||
|
|
||||||
boolean updatedImpressions = false;
|
boolean updatedImpressions = false;
|
||||||
String channelId = mLiveNotifications.remove(sbn.getKey()).getChannel().getId();
|
String channelId = mLiveNotifications.remove(sbn.getKey()).getChannel().getId();
|
||||||
String key = getKey(sbn.getPackageName(), sbn.getUserId(), channelId);
|
String key = getKey(sbn.getPackageName(), sbn.getUserId(), channelId);
|
||||||
@@ -374,22 +363,6 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationsSeen(List<String> keys) {
|
public void onNotificationsSeen(List<String> keys) {
|
||||||
try {
|
|
||||||
if (keys == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String key : keys) {
|
|
||||||
NotificationEntry entry = mLiveNotifications.get(key);
|
|
||||||
|
|
||||||
if (entry != null) {
|
|
||||||
entry.setSeen();
|
|
||||||
mAgingHelper.onNotificationSeen(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Slog.e(TAG, "Error occurred processing seen", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -456,9 +429,6 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListenerDisconnected() {
|
public void onListenerDisconnected() {
|
||||||
if (mAgingHelper != null) {
|
|
||||||
mAgingHelper.onDestroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isForCurrentUser(StatusBarNotification sbn) {
|
private boolean isForCurrentUser(StatusBarNotification sbn) {
|
||||||
@@ -541,21 +511,4 @@ public class Assistant extends NotificationAssistantService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final class AgingCallback implements Callback {
|
|
||||||
@Override
|
|
||||||
public void sendAdjustment(String key, int newImportance) {
|
|
||||||
if (AGE_NOTIFICATIONS) {
|
|
||||||
NotificationEntry entry = mLiveNotifications.get(key);
|
|
||||||
if (entry != null) {
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(KEY_IMPORTANCE, newImportance);
|
|
||||||
Adjustment adjustment = new Adjustment(entry.getSbn().getPackageName(), key,
|
|
||||||
bundle, "aging", entry.getSbn().getUserId());
|
|
||||||
adjustNotification(adjustment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user