1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.dashboard.suggestions; 18 19 import android.app.ActivityManager; 20 import android.content.ComponentName; 21 import android.content.Context; 22 import android.content.SharedPreferences; 23 24 import androidx.annotation.NonNull; 25 import androidx.fragment.app.Fragment; 26 27 import com.android.settings.Settings.NightDisplaySuggestionActivity; 28 import com.android.settings.biometrics.fingerprint.FingerprintEnrollSuggestionActivity; 29 import com.android.settings.biometrics.fingerprint.FingerprintSuggestionActivity; 30 import com.android.settings.display.NightDisplayPreferenceController; 31 import com.android.settings.notification.zen.ZenOnboardingActivity; 32 import com.android.settings.notification.zen.ZenSuggestionActivity; 33 import com.android.settings.password.ScreenLockSuggestionActivity; 34 import com.android.settings.wallpaper.StyleSuggestionActivity; 35 import com.android.settings.wallpaper.WallpaperSuggestionActivity; 36 import com.android.settings.wifi.calling.WifiCallingSuggestionActivity; 37 38 public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider { 39 40 private static final String SHARED_PREF_FILENAME = "suggestions"; 41 42 @Override isSuggestionEnabled(Context context)43 public boolean isSuggestionEnabled(Context context) { 44 final ActivityManager am = 45 (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); 46 return !am.isLowRamDevice(); 47 } 48 49 @Override getSuggestionServiceComponent()50 public ComponentName getSuggestionServiceComponent() { 51 return new ComponentName( 52 "com.android.settings.intelligence", 53 "com.android.settings.intelligence.suggestions.SuggestionService"); 54 } 55 56 @Override isSuggestionComplete(Context context, @NonNull ComponentName component)57 public boolean isSuggestionComplete(Context context, @NonNull ComponentName component) { 58 final String className = component.getClassName(); 59 if (className.equals(WallpaperSuggestionActivity.class.getName())) { 60 return WallpaperSuggestionActivity.isSuggestionComplete(context); 61 } else if (className.equals(StyleSuggestionActivity.class.getName())) { 62 return StyleSuggestionActivity.isSuggestionComplete(context); 63 } else if (className.equals(FingerprintSuggestionActivity.class.getName())) { 64 return FingerprintSuggestionActivity.isSuggestionComplete(context); 65 } else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) { 66 return FingerprintEnrollSuggestionActivity.isSuggestionComplete(context); 67 } else if (className.equals(ScreenLockSuggestionActivity.class.getName())) { 68 return ScreenLockSuggestionActivity.isSuggestionComplete(context); 69 } else if (className.equals(WifiCallingSuggestionActivity.class.getName())) { 70 return WifiCallingSuggestionActivity.isSuggestionComplete(context); 71 } else if (className.equals(NightDisplaySuggestionActivity.class.getName())) { 72 return NightDisplayPreferenceController.isSuggestionComplete(context); 73 } else if (className.equals(ZenSuggestionActivity.class.getName())) { 74 return ZenOnboardingActivity.isSuggestionComplete(context); 75 } 76 return false; 77 } 78 79 @Override getSharedPrefs(Context context)80 public SharedPreferences getSharedPrefs(Context context) { 81 return context.getSharedPreferences(SHARED_PREF_FILENAME, Context.MODE_PRIVATE); 82 } 83 84 @Override getContextualSuggestionFragment()85 public Class<? extends Fragment> getContextualSuggestionFragment() { 86 return null; 87 } 88 } 89