Add dummy SettingsApi

This commit is contained in:
Marvin W 2017-02-11 02:32:16 +01:00
parent aec1ad93b8
commit 7b897cd001
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
4 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2017 microG Project Team
*
* 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 org.microg.gms.common.api;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Result;
import com.google.android.gms.common.api.ResultCallback;
import java.util.concurrent.TimeUnit;
public class InstantPendingResult<R extends Result> implements PendingResult<R> {
R value;
public InstantPendingResult(R value) {
this.value = value;
}
@Override
public R await() {
return value;
}
@Override
public R await(long time, TimeUnit unit) {
return value;
}
@Override
public void cancel() {
}
@Override
public boolean isCanceled() {
return false;
}
@Override
public void setResultCallback(ResultCallback<R> callback, long time, TimeUnit unit) {
callback.onResult(value);
}
@Override
public void setResultCallback(ResultCallback<R> callback) {
callback.onResult(value);
}
}

View File

@ -17,16 +17,34 @@
package com.google.android.gms.location;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApiClient.Builder;
import org.microg.gms.location.FusedLocationProviderApiImpl;
import org.microg.gms.location.GeofencingApiImpl;
import org.microg.gms.location.LocationServicesApiBuilder;
import org.microg.gms.location.SettingsApiImpl;
/**
* The main entry point for location services integration.
*/
public class LocationServices {
/**
* Token to pass to {@link Builder#addApi(Api)} to enable LocationServices.
*/
public static final Api<Api.ApiOptions.NoOptions> API = new Api<Api.ApiOptions.NoOptions>(new LocationServicesApiBuilder());
/**
* Entry point to the fused location APIs.
*/
public static final FusedLocationProviderApi FusedLocationApi = new FusedLocationProviderApiImpl();
/**
* Entry point to the geofencing APIs.
*/
public static final GeofencingApi GeofencingApi = new GeofencingApiImpl();
/**
* Entry point to the location settings-enabler dialog APIs.
*/
public static final SettingsApi SettingsApi = new SettingsApiImpl();
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2017 microG Project Team
*
* 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.google.android.gms.location;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
/**
* The main entry point for interacting with the location settings-enabler APIs.
* <p>
* This API makes it easy for an app to ensure that the device's system settings are properly
* configured for the app's location needs.
*/
public interface SettingsApi {
/**
* Checks if the relevant system settings are enabled on the device to carry out the desired
* location requests.
*
* @param client an existing GoogleApiClient. It does not need to be connected
* at the time of this call, but the result will be delayed until
* the connection is complete.
* @param locationSettingsRequest an object that contains all the location requirements that the
* client is interested in.
* @return result containing the status of the request.
*/
PendingResult<LocationSettingsResult> checkLocationSettings(GoogleApiClient client, LocationSettingsRequest locationSettingsRequest);
}

View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2017 microG Project Team
*
* 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 org.microg.gms.location;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.SettingsApi;
import org.microg.gms.common.api.InstantPendingResult;
public class SettingsApiImpl implements SettingsApi {
@Override
public PendingResult<LocationSettingsResult> checkLocationSettings(GoogleApiClient client, LocationSettingsRequest locationSettingsRequest) {
return new InstantPendingResult<LocationSettingsResult>(new LocationSettingsResult(Status.CANCELED));
}
}