// Path: app/src/main/java/ooo/oxo/apps/earth/LegacyEarthSharedState.java
// public class LegacyEarthSharedState {
// 
//     @SuppressWarnings("unused")
//     private static final String TAG = "LegacyEarthSharedState";
// 
//     private final Context context;
//     private final SharedPreferences preferences;
// 
//     public LegacyEarthSharedState(Context context) {
//         this.context = context;
//         this.preferences = context.getSharedPreferences("earth", Context.MODE_PRIVATE);
//     }
// 
//     @Nullable
//     public String getLastEarth() {
//         return preferences.getString("last_earth", null);
//     }
// 
//     public long getInterval() {
//         return preferences.getLong("interval", TimeUnit.MINUTES.toMillis(10));
//     }
// 
//     public int getResolution() {
//         if (!BuildConfig.USE_OXO_SERVER) {
//             return 550;
//         }
// 
//         int resolution = preferences.getInt("resolution", 0);
// 
//         if (resolution == 0) {
//             DisplayMetrics metrics = context.getResources().getDisplayMetrics();
//             resolution = Resolutions.findBestResolution(metrics);
//         }
// 
//         return resolution;
//     }
// 
//     public boolean getWifiOnly() {
//         return preferences.getBoolean("wifi_only", true);
//     }
// 
// }
// 
// Path: wear/src/main/java/ooo/oxo/apps/earth/dao/Earth.java
// public class Earth {
// 
//     public String file;
// 
//     public Date fetchedAt = new Date();
// 
//     public Earth() {
//     }
// 
//     public Earth(String file) {
//         this.file = file;
//     }
// 
//     @Nullable
//     public static Earth fromCursor(@NonNull Cursor cursor) {
//         if (!cursor.moveToNext()) {
//             return null;
//         }
// 
//         Earth earth = new Earth();
//         earth.file = cursor.getString(cursor.getColumnIndexOrThrow(EarthsContract.Columns.FILE));
//         earth.fetchedAt = new Date(cursor.getLong(cursor.getColumnIndexOrThrow(EarthsContract.Columns.FETCHED_AT)));
// 
//         if (TextUtils.isEmpty(earth.file)) {
//             return null;
//         }
// 
//         return earth;
//     }
// 
//     public ContentValues toContentValues() {
//         ContentValues values = new ContentValues();
//         values.put(EarthsContract.Columns.FILE, file);
//         values.put(EarthsContract.Columns.FETCHED_AT, fetchedAt.getTime());
//         return values;
//     }
// 
// }


import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.concurrent.TimeUnit;
import ooo.oxo.apps.earth.LegacyEarthSharedState;
import ooo.oxo.apps.earth.dao.Earth;

    @Override
    public int update(@NonNull Uri uri, ContentValues values, String selection, String[]
            selectionArgs) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
        if (matcher.match(uri) != 4) {
            throw new UnsupportedOperationException();
        }

        final SQLiteDatabase db = dbHelper.getWritableDatabase();

        final long window = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(2);

        selection = EarthsContract.Columns.FETCHED_AT + " < ?";
        selectionArgs = new String[]{String.valueOf(window)};

        final SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
        builder.setTables(EarthsContract.TABLE);

        final Cursor cursor = builder.query(db, null, selection, selectionArgs, null, null, null, null);

        if (cursor == null) {
            return 0;
        }

        while (cursor.moveToNext()) {
// Path: app/src/main/java/ooo/oxo/apps/earth/LegacyEarthSharedState.java
// public class LegacyEarthSharedState {
// 
//     @SuppressWarnings("unused")
//     private static final String TAG = "LegacyEarthSharedState";
// 
//     private final Context context;
//     private final SharedPreferences preferences;
// 
//     public LegacyEarthSharedState(Context context) {
//         this.context = context;
//         this.preferences = context.getSharedPreferences("earth", Context.MODE_PRIVATE);
//     }
// 
//     @Nullable
//     public String getLastEarth() {
//         return preferences.getString("last_earth", null);
//     }
// 
//     public long getInterval() {
//         return preferences.getLong("interval", TimeUnit.MINUTES.toMillis(10));
//     }
// 
//     public int getResolution() {
//         if (!BuildConfig.USE_OXO_SERVER) {
//             return 550;
//         }
// 
//         int resolution = preferences.getInt("resolution", 0);
// 
//         if (resolution == 0) {
//             DisplayMetrics metrics = context.getResources().getDisplayMetrics();
//             resolution = Resolutions.findBestResolution(metrics);
//         }
// 
//         return resolution;
//     }
// 
//     public boolean getWifiOnly() {
//         return preferences.getBoolean("wifi_only", true);
//     }
// 
// }
// 
// Path: wear/src/main/java/ooo/oxo/apps/earth/dao/Earth.java
// public class Earth {
// 
//     public String file;
// 
//     public Date fetchedAt = new Date();
// 
//     public Earth() {
//     }
// 
//     public Earth(String file) {
//         this.file = file;
//     }
// 
//     @Nullable
//     public static Earth fromCursor(@NonNull Cursor cursor) {
//         if (!cursor.moveToNext()) {
//             return null;
//         }
// 
//         Earth earth = new Earth();
//         earth.file = cursor.getString(cursor.getColumnIndexOrThrow(EarthsContract.Columns.FILE));
//         earth.fetchedAt = new Date(cursor.getLong(cursor.getColumnIndexOrThrow(EarthsContract.Columns.FETCHED_AT)));
// 
//         if (TextUtils.isEmpty(earth.file)) {
//             return null;
//         }
// 
//         return earth;
//     }
// 
//     public ContentValues toContentValues() {
//         ContentValues values = new ContentValues();
//         values.put(EarthsContract.Columns.FILE, file);
//         values.put(EarthsContract.Columns.FETCHED_AT, fetchedAt.getTime());
//         return values;
//     }
// 
// }


// Path: app/src/main/java/ooo/oxo/apps/earth/provider/EarthsProvider.java
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.concurrent.TimeUnit;
import ooo.oxo.apps.earth.LegacyEarthSharedState;
import ooo.oxo.apps.earth.dao.Earth;


    @Override
    public int update(@NonNull Uri uri, ContentValues values, String selection, String[]
            selectionArgs) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
        if (matcher.match(uri) != 4) {
            throw new UnsupportedOperationException();
        }

        final SQLiteDatabase db = dbHelper.getWritableDatabase();

        final long window = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(2);

        selection = EarthsContract.Columns.FETCHED_AT + " < ?";
        selectionArgs = new String[]{String.valueOf(window)};

        final SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
        builder.setTables(EarthsContract.TABLE);

        final Cursor cursor = builder.query(db, null, selection, selectionArgs, null, null, null, null);

        if (cursor == null) {
            return 0;
        }

        while (cursor.moveToNext()) {
            final Earth earth = Earth.fromCursor(cursor);