diff options
author | Nick Chalko <nchalko@google.com> | 2016-10-26 14:03:09 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2016-10-31 10:36:49 -0700 |
commit | d41f0075a7d2ea826204e81fcec57d0aa57171a9 (patch) | |
tree | cb30cfbafd80e01d314868cdc36e783d39981119 /common/src/com/android | |
parent | 5e0ec06a797e3497da94390c63c7072de442695b (diff) | |
download | TV-d41f0075a7d2ea826204e81fcec57d0aa57171a9.tar.gz |
Sync to ub-tv-killing at 6f6e46557accb62c9548e4177d6005aa944dbf33
Change-Id: I873644d6d9d0110c981ef6075cb4019c16bbb94b
Diffstat (limited to 'common/src/com/android')
4 files changed, 42 insertions, 11 deletions
diff --git a/common/src/com/android/tv/common/CollectionUtils.java b/common/src/com/android/tv/common/CollectionUtils.java index 294159c7..300ad8f2 100644 --- a/common/src/com/android/tv/common/CollectionUtils.java +++ b/common/src/com/android/tv/common/CollectionUtils.java @@ -60,7 +60,7 @@ public class CollectionUtils { Collections.sort(result, comparator); List<T> resultToAdd = new ArrayList<>(); for (T toAdd : toAdds) { - if (Collections.binarySearch(result, toAdd, comparator) != 0) { + if (Collections.binarySearch(result, toAdd, comparator) < 0) { resultToAdd.add(toAdd); } } @@ -77,7 +77,7 @@ public class CollectionUtils { Collections.sort(result, comparator); for (T toSubtract : toSubtracts) { int index = Collections.binarySearch(result, toSubtract, comparator); - if (index != -1) { + if (index >= 0) { result.remove(index); } } @@ -92,7 +92,7 @@ public class CollectionUtils { List<T> contains = new ArrayList<>(c1); Collections.sort(contains, comparator); for (T iterate : c2) { - if (Collections.binarySearch(contains, iterate, comparator) != -1) { + if (Collections.binarySearch(contains, iterate, comparator) >= 0) { return true; } } diff --git a/common/src/com/android/tv/common/feature/CommonFeatures.java b/common/src/com/android/tv/common/feature/CommonFeatures.java index dfaa527c..d47aa603 100644 --- a/common/src/com/android/tv/common/feature/CommonFeatures.java +++ b/common/src/com/android/tv/common/feature/CommonFeatures.java @@ -16,6 +16,7 @@ package com.android.tv.common.feature; +import static com.android.tv.common.feature.FeatureUtils.AND; import static com.android.tv.common.feature.FeatureUtils.OR; import static com.android.tv.common.feature.TestableFeature.createTestableFeature; @@ -30,12 +31,10 @@ public class CommonFeatures { * * <p>See <a href="https://goto.google.com/atv-dvr-onepager">go/atv-dvr-onepager</a> * - * DVR API is introduced in N. - * - * STOPSHIP: Double-check of DVR is a part of the release before launching. + * DVR API is introduced in N, it only works when app runs as a system app. */ - public static final TestableFeature DVR = - createTestableFeature(OR(Sdk.N_PRE_2_OR_HIGHER, Sdk.AT_LEAST_N)); + public static final TestableFeature DVR = createTestableFeature( + AND(OR(Sdk.N_PRE_2_OR_HIGHER, Sdk.AT_LEAST_N), SystemAppFeature.SYSTEM_APP_FEATURE)); /** * ENABLE_RECORDING_REGARDLESS_OF_STORAGE_STATUS diff --git a/common/src/com/android/tv/common/feature/SystemAppFeature.java b/common/src/com/android/tv/common/feature/SystemAppFeature.java new file mode 100644 index 00000000..79fd32f3 --- /dev/null +++ b/common/src/com/android/tv/common/feature/SystemAppFeature.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.tv.common.feature; + +import android.content.Context; +import android.content.pm.ApplicationInfo; + +/** + * A feature that is for system App. + */ +public final class SystemAppFeature implements Feature { + public static final Feature SYSTEM_APP_FEATURE = new SystemAppFeature(); + + private SystemAppFeature() { } + + @Override + public boolean isEnabled(Context context) { + return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0; + } +} diff --git a/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java b/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java index 3eb9ebf2..bcaefec9 100644 --- a/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java +++ b/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java @@ -57,9 +57,7 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { R.dimen.setup_done_button_container_width); // Guided actions list View list = view.findViewById(R.id.guidedactions_list); - View list2 = view.findViewById(R.id.guidedactions_list2); - MarginLayoutParams marginLayoutParams = (MarginLayoutParams) view.findViewById( - R.id.guidedactions_list).getLayoutParams(); + MarginLayoutParams marginLayoutParams = (MarginLayoutParams) list.getLayoutParams(); // Use content view to check layout direction while view is being created. if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) { |