Move static UsageStatsManager from DatabaseUtils to DataProcessor to
avoid reference from DataProcessor. This is to fix the Accessibility tests hang issue. Tested on main branch (https://android-build.googleplex.com/builds/abtd/run/L40400000962473343). Test: make RunSettingsRoboTests Bug: 293366011 Bug: 295026588 Bug: 295123907 Change-Id: I345e0c060165e4d06f98ada6b2e1ca3cbb4f911a
This commit is contained in:
@@ -31,7 +31,6 @@ import android.os.BatteryUsageStats;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserManager;
|
||||
import android.util.Log;
|
||||
@@ -117,11 +116,6 @@ public final class DatabaseUtils {
|
||||
@VisibleForTesting
|
||||
static Supplier<Cursor> sFakeSupplier;
|
||||
|
||||
@VisibleForTesting
|
||||
static IUsageStatsManager sUsageStatsManager =
|
||||
IUsageStatsManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.USAGE_STATS_SERVICE));
|
||||
|
||||
private DatabaseUtils() {
|
||||
}
|
||||
|
||||
@@ -488,7 +482,7 @@ public final class DatabaseUtils {
|
||||
*
|
||||
* @see UsageStatsManager#getUsageSource()
|
||||
*/
|
||||
static int getUsageSource(Context context) {
|
||||
static int getUsageSource(Context context, IUsageStatsManager usageStatsManager) {
|
||||
final SharedPreferences sharedPreferences = getSharedPreferences(context);
|
||||
if (sharedPreferences != null && sharedPreferences.contains(KEY_LAST_USAGE_SOURCE)) {
|
||||
return sharedPreferences
|
||||
@@ -497,7 +491,7 @@ public final class DatabaseUtils {
|
||||
int usageSource = ConvertUtils.DEFAULT_USAGE_SOURCE;
|
||||
|
||||
try {
|
||||
usageSource = sUsageStatsManager.getUsageSource();
|
||||
usageSource = usageStatsManager.getUsageSource();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to getUsageSource", e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user