1 /* 2 * Copyright (C) 2023 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.federatedcompute.services.training.jni; 18 19 /** 20 * This class provides callbacks for the C++ federated learning logic, "FL runner". 21 * 22 * <p>This interface is used by "fl_runner_jni.cc". 23 */ 24 public interface SimpleTaskEnvironment { 25 /** 26 * Returns the path of the directory that the C++ implementation should use to store persistent 27 * files. If files created by the C++ runtime in this directory are deleted, it may not function 28 * properly. 29 */ getBaseDir()30 String getBaseDir(); 31 32 /** 33 * Returns the path of the directory that the C++ implementation should use to store temporary 34 * files. If files created by the C++ runtime in this directory are deleted, it will still 35 * function properly. 36 */ getCacheDir()37 String getCacheDir(); 38 39 /** 40 * Checks whether the device conditions - e.g. Network, Battery, Idleness - allow for running a 41 * federated computation. 42 */ trainingConditionsSatisfied()43 boolean trainingConditionsSatisfied(); 44 45 /** Returns an {@link JavaExampleIterator} object. */ createExampleIterator(byte[] exampleSelector)46 JavaExampleIterator createExampleIterator(byte[] exampleSelector); 47 48 /** Returns an {@link JavaExampleIterator} object. */ createExampleIteratorWithContext( byte[] exampleSelector, byte[] selectorContext)49 JavaExampleIterator createExampleIteratorWithContext( 50 byte[] exampleSelector, byte[] selectorContext); 51 } 52