Add an interface that returns time spent text for app.
Bug: 129266977 Test: robotest Change-Id: Iaa5b4c5504eccbe0290b1014bd8e25aa3d4c3dd8
This commit is contained in:
@@ -28,7 +28,9 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,13 +40,15 @@ public class TimeSpentInAppPreferenceController extends BasePreferenceController
|
||||
static final Intent SEE_TIME_IN_APP_TEMPLATE = new Intent(Settings.ACTION_APP_USAGE_SETTINGS);
|
||||
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
private final ApplicationFeatureProvider mAppFeatureProvider;
|
||||
private Intent mIntent;
|
||||
private String mPackageName;
|
||||
|
||||
public TimeSpentInAppPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mPackageManager = context.getPackageManager();
|
||||
mAppFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getApplicationFeatureProvider(context);
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
@@ -80,6 +84,11 @@ public class TimeSpentInAppPreferenceController extends BasePreferenceController
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mAppFeatureProvider.getTimeSpentInApp(mPackageName);
|
||||
}
|
||||
|
||||
private boolean isSystemApp(ResolveInfo info) {
|
||||
return info != null
|
||||
&& info.activityInfo != null
|
||||
|
Reference in New Issue
Block a user