Add selectProfile method to aidl
This commit is contained in:
parent
1fd01594a0
commit
946a60a668
5 changed files with 75 additions and 0 deletions
|
@ -78,6 +78,7 @@ import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
|||
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
||||
import net.osmand.aidlapi.customization.MapMarginsParams;
|
||||
import net.osmand.aidlapi.customization.CustomPluginParams;
|
||||
import net.osmand.aidlapi.customization.SelectProfileParams;
|
||||
|
||||
import net.osmand.aidlapi.gpx.AGpxFile;
|
||||
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
||||
|
@ -886,4 +887,6 @@ interface IOsmAndAidlInterface {
|
|||
boolean isMenuOpen();
|
||||
|
||||
int getPluginVersion(in CustomPluginParams params);
|
||||
|
||||
boolean selectProfile(in SelectProfileParams params);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidlapi.customization;
|
||||
|
||||
parcelable SelectProfileParams;
|
|
@ -0,0 +1,47 @@
|
|||
package net.osmand.aidlapi.customization;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import net.osmand.aidlapi.AidlParams;
|
||||
|
||||
public class SelectProfileParams extends AidlParams {
|
||||
|
||||
public static final String PROFILE_ID_KEY = "profile_id";
|
||||
|
||||
private String appModeKey;
|
||||
|
||||
public SelectProfileParams(String appModeKey) {
|
||||
this.appModeKey = appModeKey;
|
||||
}
|
||||
|
||||
public SelectProfileParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<SelectProfileParams> CREATOR = new Creator<SelectProfileParams>() {
|
||||
@Override
|
||||
public SelectProfileParams createFromParcel(Parcel in) {
|
||||
return new SelectProfileParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectProfileParams[] newArray(int size) {
|
||||
return new SelectProfileParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String getAppModeKey() {
|
||||
return appModeKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToBundle(Bundle bundle) {
|
||||
bundle.putString(PROFILE_ID_KEY, appModeKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromBundle(Bundle bundle) {
|
||||
appModeKey = bundle.getString(PROFILE_ID_KEY);
|
||||
}
|
||||
}
|
|
@ -2337,6 +2337,16 @@ public class OsmandAidlApi {
|
|||
return CANNOT_ACCESS_API_ERROR;
|
||||
}
|
||||
|
||||
public boolean selectProfile(String appModeKey) {
|
||||
ApplicationMode appMode = ApplicationMode.valueOfStringKey(appModeKey, null);
|
||||
if (appMode != null) {
|
||||
// ApplicationMode.changeProfileAvailability(appMode, true, app);
|
||||
app.getSettings().APPLICATION_MODE.set(appMode);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class FileCopyInfo {
|
||||
long startTime;
|
||||
long lastAccessTime;
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.osmand.aidlapi.customization.MapMarginsParams;
|
|||
import net.osmand.aidlapi.customization.OsmandSettingsInfoParams;
|
||||
import net.osmand.aidlapi.customization.OsmandSettingsParams;
|
||||
import net.osmand.aidlapi.customization.ProfileSettingsParams;
|
||||
import net.osmand.aidlapi.customization.SelectProfileParams;
|
||||
import net.osmand.aidlapi.customization.SetWidgetsParams;
|
||||
import net.osmand.aidlapi.events.AKeyEventsParams;
|
||||
import net.osmand.aidlapi.favorite.AFavorite;
|
||||
|
@ -1372,6 +1373,17 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
|||
}
|
||||
return CANNOT_ACCESS_API_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectProfile(SelectProfileParams params) {
|
||||
try {
|
||||
OsmandAidlApi api = getApi("selectProfile");
|
||||
return api != null && api.selectProfile(params.getAppModeKey());
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||
|
|
Loading…
Reference in a new issue