List of usage examples for android.support.v4.os BuildCompat isAtLeastN
public static boolean isAtLeastN()
From source file:com.android.tv.util.TestUtils.java
public static TvInputInfo createTvInputInfo(ResolveInfo service, String id, String parentId, int type, boolean isHardwareInput) throws Exception { // Create a mock TvInputInfo by using private constructor // TODO: Find better way to mock TvInputInfo. // Note that mockito doesn't support mock/spy on final object. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return createTvInputInfoForLmp(service, id, parentId, type); } else if (BuildCompat.isAtLeastN()) { new RuntimeException("TOOD(dvr): implement"); // http://b/26903987 }// w w w. j a v a 2 s .co m return createTvInputInfoForMnc(service, id, parentId, type, isHardwareInput); }
From source file:android.support.v17.leanback.supportleanbackshowcase.app.media.VideoExampleActivity.java
public static boolean supportsPictureInPicture(Context context) { return BuildCompat.isAtLeastN() && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); }
From source file:com.example.android.directboot.alarms.AlarmStorage.java
public AlarmStorage(Context context) { Context storageContext;/* w ww . jav a2 s. com*/ if (BuildCompat.isAtLeastN()) { // All N devices have split storage areas, but we may need to // move the existing preferences to the new device protected // storage area, which is where the data lives from now on. final Context deviceContext = context.createDeviceProtectedStorageContext(); if (!deviceContext.moveSharedPreferencesFrom(context, ALARM_PREFERENCES_NAME)) { Log.w(TAG, "Failed to migrate shared preferences."); } storageContext = deviceContext; } else { storageContext = context; } mSharedPreferences = storageContext.getSharedPreferences(ALARM_PREFERENCES_NAME, Context.MODE_PRIVATE); }
From source file:com.example.android.leanback.VideoActivityWithDetailedCard.java
/** * Helper function to determine if picture in picture mode is supported or not * @param context current context//from ww w .j a va 2 s . c o m * @return if Picture in Picture mode is supported or not */ public static boolean supportsPictureInPicture(Context context) { return BuildCompat.isAtLeastN() && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); }
From source file:com.android.talkback.BootReceiver.java
@Override public void onReceive(Context context, Intent intent) { TalkBackService service = TalkBackService.getInstance(); if (service == null) { return;/* w w w. j a v a2 s .c o m*/ } // We need to ensure that onLockedBootCompleted() and onUnlockedBootCompleted() are called // *in that order* to properly set up TalkBack. switch (intent.getAction()) { case Intent.ACTION_LOCKED_BOOT_COMPLETED: // Only N+ devices will get this intent (even if they don't have FBE enabled). service.onLockedBootCompleted(); break; case Intent.ACTION_BOOT_COMPLETED: if (!BuildCompat.isAtLeastN()) { // Pre-N devices will never get LOCKED_BOOT, so we need to do the locked-boot // initialization here right before we do the unlocked-boot initialization. service.onLockedBootCompleted(); } service.onUnlockedBootCompleted(); break; } }
From source file:com.example.android.directboot.BootBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { boolean bootCompleted; String action = intent.getAction(); Log.i(TAG, "Received action: " + action + ", user unlocked: " + UserManagerCompat.isUserUnlocked(context)); if (BuildCompat.isAtLeastN()) { bootCompleted = Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(action); } else {//from ww w .j a v a 2 s. c o m bootCompleted = Intent.ACTION_BOOT_COMPLETED.equals(action); } if (!bootCompleted) { return; } AlarmUtil util = new AlarmUtil(context); AlarmStorage alarmStorage = new AlarmStorage(context); for (Alarm alarm : alarmStorage.getAlarms()) { util.scheduleAlarm(alarm); } }
From source file:com.android.talkback.menurules.RuleSeekBarTest.java
@MediumTest public void testMenuAcceptedOrRejected() { setContentView(R.layout.seek_bar_test); AccessibilityNodeInfoCompat seekBar = getNodeForId(R.id.seek_bar_40); RuleSeekBar ruleSeekBar = new RuleSeekBar(); boolean accepted = ruleSeekBar.accept(mTalkBack, seekBar); // Accept if and only if at least N. assertEquals(BuildCompat.isAtLeastN(), accepted); }
From source file:com.android.talkback.menurules.RuleSeekBarTest.java
@MediumTest public void testMenuPopulated_atLeastN() { if (!BuildCompat.isAtLeastN()) { return;//www .j a va2 s . c o m } setContentView(R.layout.seek_bar_test); AccessibilityNodeInfoCompat seekBar = getNodeForId(R.id.seek_bar_40); RuleSeekBar ruleSeekBar = new RuleSeekBar(); ListMenu listMenu = new ListMenu(mTalkBack); List<ContextMenuItem> items = ruleSeekBar.getMenuItemsForNode(mTalkBack, listMenu.getMenuItemBuilder(), seekBar); // There should be one item (set seek control level). assertEquals(1, items.size()); }
From source file:com.android.talkback.menurules.RuleSuggestions.java
@Override public boolean accept(TalkBackService service, AccessibilityNodeInfoCompat node) { if (!BuildCompat.isAtLeastN()) { return false; }/*from w w w.ja v a 2s .c o m*/ // Only accept for "Jump to suggestions" if we're in an edit field. if (Role.getRole(node) == Role.ROLE_EDIT_TEXT) { WindowManager windowManager = new WindowManager(service.isScreenLayoutRTL()); windowManager.setWindows(service.getWindows()); AccessibilityWindowInfo anchoredWindow = windowManager.getAnchoredWindow(node); if (anchoredWindow != null) { return true; } } // Only accept for "Return to edit field" if the anchor is an edit field. AccessibilityNodeInfoCompat anchor = AccessibilityNodeInfoUtils.getAnchor(node); if (anchor != null) { try { if (Role.getRole(anchor) == Role.ROLE_EDIT_TEXT) { return true; } } finally { anchor.recycle(); } } return false; }
From source file:com.android.tv.data.Program.java
private static String[] createProjection() { return CollectionUtils.concatAll(PROJECTION_BASE, BuildCompat.isAtLeastN() ? PROJECTION_ADDED_IN_NYC : PROJECTION_DEPRECATED_IN_NYC); }