| Index: webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java
|
| diff --git a/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java b/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java
|
| deleted file mode 100644
|
| index 2af8bae5f6c2e85d74e145be1bbb26176623ccc7..0000000000000000000000000000000000000000
|
| --- a/webapk/libs/runtime_library/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImpl.java
|
| +++ /dev/null
|
| @@ -1,98 +0,0 @@
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -package org.chromium.webapk.lib.runtime_library;
|
| -
|
| -import android.app.Notification;
|
| -import android.app.NotificationManager;
|
| -import android.app.PendingIntent;
|
| -import android.content.Context;
|
| -import android.content.Intent;
|
| -import android.content.pm.PackageManager;
|
| -import android.os.Binder;
|
| -import android.os.Bundle;
|
| -import android.os.Parcel;
|
| -import android.os.RemoteException;
|
| -import android.util.Log;
|
| -
|
| -import java.util.Arrays;
|
| -import java.util.HashSet;
|
| -import java.util.Set;
|
| -
|
| -/**
|
| - * Implements services offered by the minted APK to chrome.
|
| - */
|
| -public class WebApkServiceImpl extends IWebApkApi.Stub {
|
| - public static final String KEY_APP_ICON_ID = "app_icon_id";
|
| - public static final String KEY_EXPECTED_HOST_BROWSER = "expected_host_browser";
|
| - private static final String TAG = "WebApkServiceImpl";
|
| -
|
| - private final Context mContext;
|
| - // TODO(hanxi): Removes when org.chromium.webapk.R.java is in the web_apk.dex.
|
| - private final int mAppIcon;
|
| - private final String mExpectedHostPackage;
|
| - private final Set<Integer> mAuthorizedUids = new HashSet<>();
|
| -
|
| - public WebApkServiceImpl(Context context, Bundle bundle) {
|
| - mContext = context;
|
| - mAppIcon = bundle.getInt(KEY_APP_ICON_ID);
|
| - mExpectedHostPackage = bundle.getString(KEY_EXPECTED_HOST_BROWSER);
|
| - }
|
| -
|
| - boolean checkHasAccess(int uid, PackageManager packageManager) {
|
| - String[] callingPackageNames = packageManager.getPackagesForUid(uid);
|
| - Log.d(TAG, "Verifying bind request from: " + Arrays.toString(callingPackageNames));
|
| - if (callingPackageNames == null) {
|
| - return false;
|
| - }
|
| -
|
| - for (String packageName : callingPackageNames) {
|
| - if (packageName.equals(mExpectedHostPackage)) {
|
| - return true;
|
| - }
|
| - }
|
| -
|
| - Log.e(TAG, "Unauthorized request from uid: " + uid);
|
| - return false;
|
| - }
|
| -
|
| - @Override
|
| - public boolean onTransact(int arg0, Parcel arg1, Parcel arg2, int arg3) throws RemoteException {
|
| - int callingUid = Binder.getCallingUid();
|
| - if (mExpectedHostPackage != null && !mAuthorizedUids.contains(Binder.getCallingUid())) {
|
| - if (checkHasAccess(callingUid, mContext.getPackageManager())) {
|
| - mAuthorizedUids.add(callingUid);
|
| - } else {
|
| - throw new RemoteException("Unauthorized caller " + callingUid
|
| - + " does not match expected host=" + mExpectedHostPackage);
|
| - }
|
| - }
|
| - return super.onTransact(arg0, arg1, arg2, arg3);
|
| - }
|
| -
|
| - @Override
|
| - public PendingIntent getBroadcastPendingIntent(int requestCode, Intent intent, int flags) {
|
| - return PendingIntent.getBroadcast(
|
| - mContext.getApplicationContext(), requestCode, intent, flags);
|
| - }
|
| -
|
| - @Override
|
| - public int getSmallIconId() {
|
| - return mAppIcon;
|
| - }
|
| -
|
| - @Override
|
| - public void displayNotification(String platformTag, int platformID, Notification notification) {
|
| - getNotificationManager().notify(platformTag, platformID, notification);
|
| - }
|
| -
|
| - @Override
|
| - public void closeNotification(String platformTag, int platformID) {
|
| - getNotificationManager().cancel(platformTag, platformID);
|
| - }
|
| -
|
| - private NotificationManager getNotificationManager() {
|
| - return (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
| - }
|
| -}
|
|
|