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.wallpaper; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.content.pm.PackageManager; 22 import android.os.Bundle; 23 import android.support.annotation.VisibleForTesting; 24 25 import com.android.internal.logging.nano.MetricsProto; 26 import com.android.settings.R; 27 import com.android.settings.Utils; 28 29 public class WallpaperSuggestionActivity extends Activity { 30 31 @Override 32 protected void onCreate(Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 final PackageManager pm = getPackageManager(); 35 final Intent intent = new Intent() 36 .setClassName(getString(R.string.config_wallpaper_picker_package), 37 getString(R.string.config_wallpaper_picker_class)) 38 .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); 39 if (pm.resolveActivity(intent, 0) != null) { 40 startActivity(intent); 41 } else { 42 startFallbackSuggestion(); 43 } 44 45 finish(); 46 } 47 48 @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) 49 void startFallbackSuggestion() { 50 // fall back to default wallpaper picker 51 Utils.startWithFragment(this, WallpaperTypeSettings.class.getName(), null, null, 0, 52 R.string.wallpaper_suggestion_title, null, 53 MetricsProto.MetricsEvent.DASHBOARD_SUMMARY); 54 } 55 56 } 57