How to retrieve exposed content providers of an installed application? - java

I am trying to extract all exported content providers from installed application using the following code. But for every application, this returns zero. Though, when I check the same with ADB, the application lists all exposed content providers and their URIs. Do I need any permission to extract? Could someone please guide me on this? I am quite new to android.
List<ProviderInfo> returnList = new ArrayList<ProviderInfo>();
ProviderInfo[] prov = getPackageManager().getPackageInfo(packageName, 0).providers;
if (prov != null)
{
returnList.addAll(Arrays.asList(prov));
}
int count1 = returnList.size();

Related

getWebDomain() function always returns null in Android AutoFill service

While implementing the Android AutoFill functionality for my password manager, I’m unable to get the domain name for the webpage with which the user is interacting. While testing other password managers, I see they are able to get the domain, because they are able to filter responses according to the domain stored on various records. For example, if I have 3 records that have “yahoo.com” as the domain and 6 other records with different domains, when I tap into the username field on Yahoo’s sign in form, I’m only presented with the 3 records with “yahoo.com” as the domain, which is the correct functionality. In my own app, when I tap into the username field, I’m presented with all 9 records. I’m not able to get the domain needed to filter the records appropriately.
I studied the documentation in detail and used an example from Google for development.
I did not find any mention there may be any difficulties with getting the domain, but I am not able to get the data I need. Below is an example of how I am trying to get the domain name on a page.
public void onFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) {
List<FillContext> context = request.getFillContexts();
AssistStructure structure = context.get(context.size() - 1).getStructure();
ArrayMap<String, AutofillId> fields = new ArrayMap<>();
int nodes = structure.getWindowNodeCount();
for (int i = 0; i < nodes; i++) {
AssistStructure.ViewNode node = structure.getWindowNodeAt(i).getRootViewNode();
String webDomain = node.getWebDomain();
if (webDomain != null){
Log.d(TAG,"domain: " + webDomain);
}
addAutofillableFields(fields, node);
}
FillResponse response = createResponse(this, fields);
callback.onSuccess(response);
}
I have not been able to get a real webDomain value. Only null…
It works fine in the apps due there I need only packageName for identifying the app. But for browser pages I need a page domain name.
I would be grateful if someone could tell me what I did wrong. The project is posted here -
Solved. web Domain name can be retrieved only from the one of the nodes from the node tree. I thought that it should be filled for each node.

Azure App Configuration Feature Management

I am looking for a solution using Maven and Java (Not Spring) where I can upload all my Key and labels and flag value by Json to deploy.
When I configure my project in Jenkins it should apply all the values which are changed.
Kindly provide me some directions, I tried lot with less material on this topic
I managed to workout the solution. Basically following this Microsoft Azure Link
, but not completely solved my problem by this link though. Below is the Code Snippet which solved my problem. Code is not testable or productionable , this is just for reference.
public void process() {
String value = "{\"id\": \"test\", \"description\": \"Sample Feature\",\"enabled\": false,\"conditions\": { \"client_filters\": []}}";
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.connectionString(END_POINT)
.buildClient();
final ConfigurationSetting configurationSetting = new ConfigurationSetting();
configurationSetting.setKey(format(".appconfig.abc/%s", "abc"));
configurationSetting.setLabel("lable");
configurationSetting.setContentType("application/vnd.microsoft.appconfig.ff+json;charset=utf-8");
configurationSetting.setValue(value);
configurationClient.addConfigurationSettingWithResponse(configurationSetting, NONE)
}
Key points here is ".appconfig.abc" , At this point of time we don't have direct call to Feature Management , but we can add Key and labels to configuration as I said in the code snippet but with the Key as ".appconfig.abc" which you can get this info from portal. And the value should be a Json object, how we make this Json is upto you really.
Overall so much of information around the sites but none of them are connected in Java world for Azure. May be helpful to any one.
End Point , one can get from the Configuration Access Keys.

Not able to reference Java class from my report in BIRT

I am very new to BIRT. I am wokring on a BIRT project where I am trying to reference Java class inside script 'open' section but am unable to do so.
I do not get any errors but I am not able to see any data in my dataset preview.
Script - open
count = 0;
// create instance of
// the GetStockHistory class
gsh = new Packages.de.vogella.birt.stocks.daomock.StockDaoMock(); //cause of error somehow
//Load the List
stock = gsh.getStockValues("Java");
Script-Fetch
if(count < stock.size()){
row["columnDate"] = stock.get(count).getDate();
row["columnOpen"] = stock.get(count).getOpen();
row["columnHigh"] = stock.get(count).getHigh();
row["columnLow"] = stock.get(count).getLow();
row["columnClose"] = stock.get(count).getClose();
row["columnVolume"] = stock.get(count).getVolume();
count++;
return true;
}
return false;
StockDaoMock is a class which returns a dummy list of values.
Referring this blog BIRT sample app
Can anyone please help me here and let me know what am I doing wrong ?
Why can't I see any data in preview dataset. Is there a specific way in which I need to make reference to java classes because I am sure the error is somewhere in that part only. If I remove the reference part and just hardcode a string, then it is working fine and I can see it in the preview. Things mess up as soon as I refer a java class by importing it.
BIRT-4.8
EDIT---
even this inside my Script 'open' doesn't work
importPackage(Packages.de.vogella.birt.stocks.daomock);
gsh = new StockDaoMock();
BIRT does not use the java sources directly. You have to generate a JAR from your classes and add that JAR to your BIRT class path (Window / Preferences / Report Design / Classpath).

Android Java: Get Open WiFi-Networks

I want to make an app that is automatically connecting to Open Networks (so no password). I know you can scan with wifi.startScan() and wifi.getScanResults. But how can I save all these Network Names?
So I can connect to them with:
String networkSSID = "test";
String networkPass = "pass";
WifiConfiguration conf = new WifiConfiguration();
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
Sorry, I'm really a nooby.
Do you mean that you just want to store the strings for the SSID and keys so that you can easily restore and connect later?
The easiest way is to use SharedPreferences to store any data.
Here is a a tutorial by slidenerd that is very easy to follow.
https://www.youtube.com/watch?v=riyMQiHY3V4
I'm a noob too, so whenever I have questions, I head straight to slidenerd or thenewboston on youtube and then start digging through tech documentation once I have a basic understanding.
Filter out the Open networks.
Use this method to check if a network is open or not
private boolean isProtectedNetwork(String capability){
return (capability.contains("WPA") ||
capability.contains("WEP") ||
capability.contains("WPS")
);
}
Then iterate through all the network lists and get the all open networks.
private void getAllOpenNetworks(List<ScanResult> allNetworks){
List<ScanResult>openNetworks = new ArrayList<ScanResult>();
for(ScanResult network : allNetworks){
if(!isProtectedNetwork(network.capabilities)){
openNetworks.add(network);
}
}
}
Useful Resource:
You can find more related solutions on My Github Repository

Reading Gmail mails using android SDK

I want to read Gmail mails in my own android app. Is there anyway to do it using android sdk? If not, what are the other options? parsing gmail atom?
I ask and answer that question here.
You need Gmail.java code (in the question there are a link) and you must understand that you shouldn't use that undocumented provider
Are there any good short code examples that simply read a new gmail message?
It's possible using the GMail API, here are some steps I found helpful.
Start with the official sample to get the GMailAPI started, see here
When following the instructions I found it helpful to read about the app signing here in order to get Step1+2 in the sample right.
With the sample running you can use the information here to access messages. You can e.g. replace the implementation in MakeRequestTask.getDataFromApi
Be sure to add at least the read-only scope for proper permissions. In the sample the scopes are defined in an array:
private static final String[] SCOPES = { GmailScopes.GMAIL_LABELS, mailScopes.GMAIL_READONLY };
My intention was to read all subjects. I used the following code (which is the adapted getDataFromApi method from the official sample):
private List<String> getDataFromApi() throws IOException {
// Get the labels in the user's account. "me" referes to the authentized user.
String user = "me";
List<String> labels = new ArrayList<String>();
ListMessagesResponse response = mService.users().messages().list(user).execute();
for (Message message : response.getMessages()) {
Message readableMessage = mService.users().messages().get(user, message.getId()).execute();
if (readableMessage.getPayload() != null) {
for (MessagePartHeader header : readableMessage.getPayload().getHeaders()) {
if (header.getName().compareToIgnoreCase("Subject") == 0) {
labels.add(header.getValue());
}
}
}
}
return labels;
}

Categories

Resources