So I have an SMS app and I'm sending MMS pictures. Pictures are resized before sending. I want to change maxImageWidth and maxImageHeight so the sent pictures will be bigger.
I have a class BugleCarrierConfigValuesLoader and a method inside:
/**
* Loading carrier config values
*
* #param subId which SIM to load for
* #param values the result to add to
* #return the source of the config, could be "resources" or "resources+system"
*/
private String loadLocked(final int subId, final Bundle values) {
// Load from resources in earlier platform
loadFromResources(subId, values);
if (OsUtil.isAtLeastL()) {
// Load from system to override if system API exists
loadFromSystem(subId, values);
return "resources+system";
}
return "resources";
}
This method loads values like maxImageWidth=640 or maxImageHeight=480.
I would like to understand why is it done like that. Why can't I just make final static int with maxImageWidth value. Why do I need to load these values from resources or system.
Related
On Keycloak I have several resources and I need to fetch all resources owned by me and "shared with me" by other users.
For example, this resource is owned by "test" user and it is shared with "test2" user:
So the idea is test2 will fetch resources shared with him.
But the only option I see is to find by Owner/Name/Uri: Keycloak docs
/**
* Query the server for any resource with the matching arguments.
*
* #param id the resource id
* #param name the resource name
* #param uri the resource uri
* #param owner the resource owner
* #param type the resource type
* #param scope the resource scope
* #param matchingUri the resource uri. Use this parameter to lookup a resource that best match the given uri
* #param exactName if the the {#code name} provided should have a exact match
* #param deep if the result should be a list of resource representations with details about the resource. If false, only ids are returned
* #param firstResult the position of the first resource to retrieve
* #param maxResult the maximum number of resources to retrieve
* #return a list of resource representations or an array of strings representing resource ids, depending on the generic type
*/
public <R> R find(final String id, final String name, final String uri, final String owner, final String type, final String scope, final boolean matchingUri, final boolean exactName, final boolean deep, final Integer firstResult, final Integer maxResult)
By other side, the keycloak account UI application seems to call to an
endpoint to fetch the resources shared-with-me
If you send an empty authorization request to Keycloak then it returns all allowed permissions with the associated resources. This list includes owned by you or sharing with you.
fun AuthzClient.findAllGrantedPermissions(accessToken: String): TokenIntrospectionResponse {
val request = AuthorizationRequest()
val rpt = this.authorization(accessToken).authorize(request).token
return this.protection().introspectRequestingPartyToken(rpt)
}
I couldn't find how to do this anywhere else online, though I'm sure it's really easy to do. I'm primarily self taught though, and I'd like to start learning to document my code properly. This "yellow box" that pops up in eclipse with information about the method - I want it to pop up on a custom object. For my example below I have a custom class called "System Properties" and a method called "getOs" but when I hover that option, no information comes up. How do I add information to my object?
This picture shows the yellow box
This picture shows the lack of a "yellow box" on my object
and then finally my custom objects code...
public class SystemProperties {
private String os;
public SystemProperties() {
this.os = setOs();
}
private String setOs() {
String osName = System.getProperty("os.name");
if(osName.toLowerCase().contains("window"))
return "Windows";
else if(osName.toLowerCase().contains("mac"))
return "Mac";
else
return "Linux";
}
/**
* Method to grab the OS the user is running from
* #return String - the os
*/
public String getOs() {
return this.os;
}
}
Thank you in advance for your time and knowledge. :)
EDIT:
When I import the project of the custom object, it works just fine. It only doesn't work when I export the project of the custom class to a jar file and then use that instead. Do I have to click an option on the export screen?
Eclipse take the info from the notes above the methods in the built in objects.
see this:
/**
* Returns <tt>true</tt> if this map contains a mapping for the specified
* key. More formally, returns <tt>true</tt> if and only if
* this map contains a mapping for a key <tt>k</tt> such that
* <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be
* at most one such mapping.)
*
* #param key key whose presence in this map is to be tested
* #return <tt>true</tt> if this map contains a mapping for the specified
* key
* #throws ClassCastException if the key is of an inappropriate type for
* this map
* (optional)
* #throws NullPointerException if the specified key is null and this map
* does not permit null keys
* (optional)
*/
boolean containsKey(Object key);
You can do the same to the methods of your own objects.
If I have the variable declaration:
/**
* The Resource folder for the program Information.
*/
public static final Path RESOURCE_FOLDER_PATH = Paths.get("", "Resources"),
/**
* The folder holding all faction information.
*/
FACTION_FOLDER_PATH = Paths.get(RESOURCE_FOLDER_PATH.toString(), "Faction Information");
The Javadoc will not document the latter Path variable. Does Javadoc support this type of documenting style or do I have to declare them separately?
No unfortunately you can't.
You need to do it in the following way which is clearer and neater:
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {#link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* #param url an absolute URL giving the base location of the image
* #param name the location of the image, relative to the url argument
* #return the image at the specified URL
* #see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
I have used the Java API for AWS for some time now but somehow I can't find how to delete a snapshot that was created with a CreateImage request.
This request will provide you with an Image containing an Image ID.
When you want to remove the image you can Deregister it given this ID.
But I can't find how to delete the snapshot that is being used by that Image.
Am I missing something here?
Thanks in advance,
Giriel
PS: Some code to show what I mean:
final CreateImageResult createAMIResult = AWS.ec2.createImage(new CreateImageRequest().withInstanceId(instanceID).withName(amiName).withNoReboot(noReboot));
final String imageId = createAMIResult.getImageId();
//After a while I want to remove it again
AWS.ec2.deregisterImage(new DeregisterImageRequest(imageId));
//TODO: How to remove the snapshot??
After having searched through the AWS Developer forums I found the solution to be quite disappointing.
You have to check the description of all your snapshots and delete the one that matches your image id.
The description has the following format when using CreateImage:
Created by CreateImage(i-xxxxxxxx) for ami-xxxxxxxx from vol-xxxxxxxx
So it is a matter of matching the ami-xxxxxxx part with your own image ID.
Edit
This solution does not work when you use the copy functionality provided by AWS.
My new solution is based upon the fact that an EBS volume is added to the ami as a blockingdevice and has access to the snapshot id!
Some code as illustration:
/**
* Removes an ami and its snapshot.
* #param amiID
* #param snapshotID
*/
public static void removeImage(final String amiID, final AmazonEC2 ec2) {
if (amiID != null) {
DescribeImagesResult result = ec2.describeImages(new DescribeImagesRequest().withImageIds(amiID).withOwners(owner));
if (!result.getImages().isEmpty()) {
ec2.deregisterImage(new DeregisterImageRequest(amiID));
for (BlockDeviceMapping blockingDevice : result.getImages().get(0).getBlockDeviceMappings()) {
if (blockingDevice.getEbs() != null) {
ec2.deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(blockingDevice.getEbs().getSnapshotId()));
}
}
}
}
}
I am new to android framework. I am working with USB Settings. I want to know where are USB settings stored in android.
I am having following problem :
when i connect my phone to Computer and select one of the option from mass storage, MTP,PTP and now if I switch off and then switch on the device my selection get cleared. I want the previous selection to be retained.
What should I do..??
Thanks in advance...
Edit : I discovered today that usb_device_manager.xml file should be created in /data/system folder but in my case it is not getting generated.
I am unable to find what is the reason behind this.
The file that creates this file is located at frameworks/base/services/java/com/android/server/usb/
Waiting for positive reply...
According to http://developer.android.com/reference/android/hardware/usb/UsbManager.html
You cannot find an open API for getting this information.
However, from the source code we can see this two functions:
/**
* Name of the MTP USB function.
* Used in extras for the {#link #ACTION_USB_STATE} broadcast
*
* {#hide}
*/
public static final String USB_FUNCTION_MTP = "mtp";
/**
* Name of the PTP USB function.
* Used in extras for the {#link #ACTION_USB_STATE} broadcast
*
* {#hide}
*/
public static final String USB_FUNCTION_PTP = "ptp";
/**
* Returns the current default USB function.
*
* #return name of the default function.
*
* {#hide}
*/
public String getDefaultFunction() {
String functions = SystemProperties.get("persist.sys.usb.config", "");
int commaIndex = functions.indexOf(',');
if (commaIndex > 0) {
return functions.substring(0, commaIndex);
} else {
return functions;
}
}
/**
* Sets the current USB function.
* If function is null, then the current function is set to the default function.
*
* #param function name of the USB function, or null to restore the default function
* #param makeDefault true if the function should be set as the new default function
*
* {#hide}
*/
public void setCurrentFunction(String function, boolean makeDefault) {
try {
mService.setCurrentFunction(function, makeDefault);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in setCurrentFunction", e);
}
}
It is not recommended to use hidden APIs, but this might solve your problem.
If you wants to know how to use the hidden APIs, refer to this link:
http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/