mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1283881 - Add PartnerBrowserCustomizationsClient for reading customizations from Android's "partner browser customizations" content provider. r=grisha
MozReview-Commit-ID: 3qVXGHC6LfE --HG-- extra : rebase_source : 29d545e4e6ac606558a4f4cdf3f8f474d0606af0
This commit is contained in:
parent
c9b2e89a26
commit
7544d420b6
@ -0,0 +1,43 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.distribution;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
||||
/**
|
||||
* Client for accessing data from Android's "partner browser customizations" content provider.
|
||||
*/
|
||||
public class PartnerBrowserCustomizationsClient {
|
||||
private static final Uri CONTENT_URI = Uri.parse("content://com.android.partnerbrowsercustomizations");
|
||||
|
||||
private static final Uri HOMEPAGE_URI = CONTENT_URI.buildUpon().path("homepage").build();
|
||||
|
||||
private static final String COLUMN_HOMEPAGE = "homepage";
|
||||
|
||||
/**
|
||||
* Returns the partner homepage or null if it could not be read from the content provider.
|
||||
*/
|
||||
public static String getHomepage(Context context) {
|
||||
Cursor cursor = context.getContentResolver().query(
|
||||
HOMEPAGE_URI, new String[] { COLUMN_HOMEPAGE }, null, null, null);
|
||||
|
||||
if (cursor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!cursor.moveToFirst()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_HOMEPAGE));
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -268,6 +268,7 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
||||
'DevToolsAuthHelper.java',
|
||||
'distribution/Distribution.java',
|
||||
'distribution/DistributionStoreCallback.java',
|
||||
'distribution/PartnerBrowserCustomizationsClient.java',
|
||||
'distribution/ReferrerDescriptor.java',
|
||||
'distribution/ReferrerReceiver.java',
|
||||
'dlc/BaseAction.java',
|
||||
|
Loading…
Reference in New Issue
Block a user