1 /* 2 * Copyright (C) 2014 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.tv.settings.device.apps; 18 19 import android.app.Fragment; 20 import android.net.Uri; 21 import android.os.Bundle; 22 import android.util.Log; 23 24 import com.android.tv.settings.BaseSettingsFragment; 25 import com.android.tv.settings.TvSettingsActivity; 26 27 /** 28 * Activity that manages an app. 29 */ 30 public class AppManagementActivity extends TvSettingsActivity { 31 32 private static final String TAG = "AppManagementActivity"; 33 34 @Override 35 protected Fragment createSettingsFragment() { 36 final Uri uri = getIntent().getData(); 37 if (uri == null) { 38 Log.wtf(TAG, "No app to inspect (missing data uri in intent)"); 39 finish(); 40 return null; 41 } 42 final String packageName = uri.getSchemeSpecificPart(); 43 return SettingsFragment.newInstance(packageName); 44 } 45 46 public static class SettingsFragment extends BaseSettingsFragment { 47 private static final String ARG_PACKAGE_NAME = "packageName"; 48 49 public static SettingsFragment newInstance(String packageName) { 50 final Bundle b = new Bundle(1); 51 b.putString(ARG_PACKAGE_NAME, packageName); 52 final SettingsFragment f = new SettingsFragment(); 53 f.setArguments(b); 54 return f; 55 } 56 57 @Override 58 public void onPreferenceStartInitialScreen() { 59 final Bundle b = new Bundle(); 60 AppManagementFragment.prepareArgs(b, getArguments().getString(ARG_PACKAGE_NAME)); 61 final Fragment f = new AppManagementFragment(); 62 f.setArguments(b); 63 startPreferenceFragment(f); 64 } 65 } 66 } 67