summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml10
-rw-r--r--res/layout-watch/settings_internal.xml41
-rw-r--r--src/com/android/packageinstaller/permission/model/AppPermissionGroup.java4
-rw-r--r--src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java23
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java18
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/TitledSettingsFragment.java21
-rw-r--r--src/com/android/packageinstaller/wear/WearPackageArgs.java14
-rw-r--r--src/com/android/packageinstaller/wear/WearPackageInstallerService.java61
-rw-r--r--src/com/android/packageinstaller/wear/WearPackageUtil.java13
9 files changed, 140 insertions, 65 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7bc39a1..a750491 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -125,15 +125,7 @@
<!-- Wearable Components -->
<service android:name=".wear.WearPackageInstallerService"
android:permission="com.google.android.permission.INSTALL_WEARABLE_PACKAGES"
- android:exported="true">
- <intent-filter>
- <action android:name="com.android.packageinstaller.wear.INSTALL_PACKAGE"/>
- <data android:scheme="content" android:mimeType="vnd.android.cursor.item/*"/>
- </intent-filter>
- <intent-filter>
- <action android:name="com.android.packageinstaller.wear.UNINSTALL_PACKAGE"/>
- </intent-filter>
- </service>
+ android:exported="true"/>
<provider android:name=".wear.WearPackageIconProvider"
android:authorities="com.google.android.packageinstaller.wear.provider"
diff --git a/res/layout-watch/settings_internal.xml b/res/layout-watch/settings_internal.xml
index fdd21ce..e1947aa 100644
--- a/res/layout-watch/settings_internal.xml
+++ b/res/layout-watch/settings_internal.xml
@@ -14,19 +14,38 @@
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
- <TextView
- android:id="@+id/header"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="@dimen/settings_header_base_height"
- android:layout_marginLeft="16dp"
- android:layout_marginTop="@dimen/settings_header_top_margin"
- android:textSize="@dimen/setting_short_header_text_size"
- android:maxLines="2"
- android:ellipsize="end"
- android:textColor="#9E9E9E"
- android:fontFamily="sans-serif-condensed-light"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/settings_header_base_height"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="@dimen/settings_header_top_margin"
+ android:textSize="@dimen/setting_short_header_text_size"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:textColor="#9E9E9E"
+ android:fontFamily="sans-serif-condensed-light"
+ />
+
+ <TextView
+ android:id="@+id/details"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/settings_header_base_height"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="@dimen/settings_header_top_margin"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:textColor="@color/permissions_settings_item_color"
+ android:textSize="14sp"
+ android:visibility="gone"
/>
+ </LinearLayout>
<android.support.wearable.view.WearableListView
xmlns:android="http://schemas.android.com/apk/res/android"
diff --git a/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java b/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
index 0771a0f..fdb7793 100644
--- a/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
+++ b/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
@@ -162,6 +162,10 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>
group.addPermission(permission);
}
+ if (group.getPermissions().isEmpty()) {
+ return null;
+ }
+
return group;
}
diff --git a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
index 38080e6..f31d618 100644
--- a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
+++ b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
@@ -120,13 +120,18 @@ public final class ReviewPermissionsActivity extends Activity
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+
PackageInfo packageInfo = getArguments().getParcelable(EXTRA_PACKAGE_INFO);
if (packageInfo == null) {
- getActivity().finish();
+ activity.finish();
return;
}
- mAppPermissions = new AppPermissions(getActivity(), packageInfo, null, false,
+ mAppPermissions = new AppPermissions(activity, packageInfo, null, false,
new Runnable() {
@Override
public void run() {
@@ -135,7 +140,7 @@ public final class ReviewPermissionsActivity extends Activity
});
if (mAppPermissions.getPermissionGroups().isEmpty()) {
- getActivity().finish();
+ activity.finish();
return;
}
@@ -148,7 +153,7 @@ public final class ReviewPermissionsActivity extends Activity
}
if (!reviewRequired) {
- getActivity().finish();
+ activity.finish();
}
}
@@ -166,14 +171,18 @@ public final class ReviewPermissionsActivity extends Activity
@Override
public void onClick(View view) {
+ Activity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
if (view == mContinueButton) {
confirmPermissionsReview();
executeCallback(true);
} else if (view == mCancelButton) {
executeCallback(false);
- getActivity().setResult(Activity.RESULT_CANCELED);
+ activity.setResult(Activity.RESULT_CANCELED);
}
- getActivity().finish();
+ activity.finish();
}
@Override
@@ -185,6 +194,8 @@ public final class ReviewPermissionsActivity extends Activity
SwitchPreference switchPreference = (SwitchPreference) preference;
if (switchPreference.isChecked()) {
showWarnRevokeDialog(switchPreference.getKey());
+ } else {
+ return true;
}
}
return false;
diff --git a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
index 13a16d6..4b621a6 100644
--- a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
+++ b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
@@ -123,18 +123,18 @@ public final class AppPermissionsFragmentWear extends TitledSettingsFragment {
super.onViewCreated(view, savedInstanceState);
if (mAppPermissions != null) {
initializeLayout(mAdapter);
- bindHeader(mAppPermissions.getPackageInfo());
+ mHeader.setText(R.string.app_permissions);
+ mDetails.setText(R.string.no_permissions);
+ if (mAdapter.getItemCount() == 0) {
+ mDetails.setVisibility(View.VISIBLE);
+ mWheel.setVisibility(View.GONE);
+ } else {
+ mDetails.setVisibility(View.GONE);
+ mWheel.setVisibility(View.VISIBLE);
+ }
}
}
- private void bindHeader(PackageInfo packageInfo) {
- Activity activity = getActivity();
- PackageManager pm = activity.getPackageManager();
- ApplicationInfo appInfo = packageInfo.applicationInfo;
- CharSequence label = appInfo.loadLabel(pm);
- mHeader.setText(label);
- }
-
private void initializePermissionGroupList() {
final String packageName = mAppPermissions.getPackageInfo().packageName;
List<AppPermissionGroup> groups = mAppPermissions.getPermissionGroups();
diff --git a/src/com/android/packageinstaller/permission/ui/wear/TitledSettingsFragment.java b/src/com/android/packageinstaller/permission/ui/wear/TitledSettingsFragment.java
index ef7efb2..b673a49 100644
--- a/src/com/android/packageinstaller/permission/ui/wear/TitledSettingsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/wear/TitledSettingsFragment.java
@@ -28,7 +28,7 @@ import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
-import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.packageinstaller.permission.ui.wear.settings.ViewUtils;
@@ -46,6 +46,7 @@ public abstract class TitledSettingsFragment extends Fragment implements
private int mInitialHeaderHeight;
protected TextView mHeader;
+ protected TextView mDetails;
protected WearableListView mWheel;
private int mCharLimitShortTitle;
@@ -114,6 +115,9 @@ public abstract class TitledSettingsFragment extends Fragment implements
mHeader.addOnLayoutChangeListener(this);
mHeader.addTextChangedListener(mHeaderTextWatcher);
+ mDetails = (TextView) v.findViewById(R.id.details);
+ mDetails.addOnLayoutChangeListener(this);
+
mWheel.setAdapter(adapter);
mWheel.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
@@ -134,13 +138,14 @@ public abstract class TitledSettingsFragment extends Fragment implements
adjustHeaderSize();
- positionOnCircular(getContext(), mHeader, mWheel);
+ positionOnCircular(getContext(), mHeader, mDetails, mWheel);
}
- public void positionOnCircular(Context context, View header, final ViewGroup wheel) {
+ public void positionOnCircular(Context context, View header, View details,
+ final ViewGroup wheel) {
if (ViewUtils.getIsCircular(context)) {
- FrameLayout.LayoutParams params =
- (FrameLayout.LayoutParams) header.getLayoutParams();
+ LinearLayout.LayoutParams params =
+ (LinearLayout.LayoutParams) header.getLayoutParams();
params.topMargin = (int) context.getResources().getDimension(
R.dimen.settings_header_top_margin_circular);
// Note that the margins are made symmetrical here. Since they're symmetrical we choose
@@ -152,10 +157,14 @@ public abstract class TitledSettingsFragment extends Fragment implements
params.rightMargin = margin;
params.gravity = Gravity.CENTER_HORIZONTAL;
header.setLayoutParams(params);
+ details.setLayoutParams(params);
if (header instanceof TextView) {
((TextView) header).setGravity(Gravity.CENTER);
}
+ if (details instanceof TextView) {
+ ((TextView) details).setGravity(Gravity.CENTER);
+ }
final int leftPadding = (int) context.getResources().getDimension(
R.dimen.round_content_padding_left);
@@ -209,7 +218,7 @@ public abstract class TitledSettingsFragment extends Fragment implements
}
mHeader.setMinHeight((int) height);
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mHeader.getLayoutParams();
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mHeader.getLayoutParams();
final Context context = getContext();
if (!singleLine) {
// Make the top margin a little bit smaller so there is more space for the title.
diff --git a/src/com/android/packageinstaller/wear/WearPackageArgs.java b/src/com/android/packageinstaller/wear/WearPackageArgs.java
index 67051da..da49192 100644
--- a/src/com/android/packageinstaller/wear/WearPackageArgs.java
+++ b/src/com/android/packageinstaller/wear/WearPackageArgs.java
@@ -25,6 +25,8 @@ import android.os.Bundle;
* installing/uninstalling.
*/
public class WearPackageArgs {
+ private static final String KEY_PACKAGE_NAME =
+ "com.google.android.clockwork.EXTRA_PACKAGE_NAME";
private static final String KEY_ASSET_URI =
"com.google.android.clockwork.EXTRA_ASSET_URI";
private static final String KEY_START_ID =
@@ -45,16 +47,16 @@ public class WearPackageArgs {
"com.google.android.clockwork.EXTRA_KEY_SHOULD_CHECK_GMS_DEPENDENCY";
public static String getPackageName(Bundle b) {
- return b.getString(Intent.EXTRA_INSTALLER_PACKAGE_NAME);
+ return b.getString(KEY_PACKAGE_NAME);
}
- public static Uri getAssetUri(Bundle b) {
- return b.getParcelable(KEY_ASSET_URI);
+ public static Bundle setPackageName(Bundle b, String packageName) {
+ b.putString(KEY_PACKAGE_NAME, packageName);
+ return b;
}
- public static Bundle setAssetUri(Bundle b, Uri assetUri) {
- b.putParcelable(KEY_ASSET_URI, assetUri);
- return b;
+ public static Uri getAssetUri(Bundle b) {
+ return b.getParcelable(KEY_ASSET_URI);
}
public static Uri getPermUri(Bundle b) {
diff --git a/src/com/android/packageinstaller/wear/WearPackageInstallerService.java b/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
index 3874c0a..7387ed2 100644
--- a/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
+++ b/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
@@ -66,13 +66,18 @@ import java.util.Set;
*
* Install Action example:
* adb shell am startservice -a com.android.packageinstaller.wear.INSTALL_PACKAGE \
- * -t vnd.android.cursor.item/wearable_apk \
- * -d content://com.google.android.clockwork.home.provider/host/com.google.android.wearable.app/wearable/com.google.android.gms/apk \
+ * -d package://com.google.android.gms \
+ * --eu com.google.android.clockwork.EXTRA_ASSET_URI content://com.google.android.clockwork.home.provider/host/com.google.android.wearable.app/wearable/com.google.android.gms/apk \
* --es android.intent.extra.INSTALLER_PACKAGE_NAME com.google.android.gms \
* --ez com.google.android.clockwork.EXTRA_CHECK_PERMS false \
* --eu com.google.android.clockwork.EXTRA_PERM_URI content://com.google.android.clockwork.home.provider/host/com.google.android.wearable.app/permissions \
* com.android.packageinstaller/com.android.packageinstaller.wear.WearPackageInstallerService
*
+ * Uninstall Action example:
+ * adb shell am startservice -a com.android.packageinstaller.wear.UNINSTALL_PACKAGE \
+ * -d package://com.google.android.gms \
+ * com.android.packageinstaller/com.android.packageinstaller.wear.WearPackageInstallerService
+ *
* Retry GMS:
* adb shell am startservice -a com.android.packageinstaller.wear.RETRY_GMS \
* com.android.packageinstaller/com.android.packageinstaller.wear.WearPackageInstallerService
@@ -141,29 +146,49 @@ public class WearPackageInstallerService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!DeviceUtils.isWear(this)) {
- Log.w(TAG, "Not running on wearable");
+ Log.w(TAG, "Not running on wearable.");
+ return START_NOT_STICKY;
+ }
+
+ if (intent == null) {
+ Log.w(TAG, "Got null intent.");
return START_NOT_STICKY;
}
+
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Got install/uninstall request " + intent);
+ }
+
+ Uri packageUri = intent.getData();
+ if (packageUri == null) {
+ Log.e(TAG, "No package URI in intent");
+ return START_NOT_STICKY;
+ }
+ final String packageName = WearPackageUtil.getSanitizedPackageName(packageUri);
+ if (packageName == null) {
+ Log.e(TAG, "Invalid package name in URI (expected package:<pkgName>): " + packageUri);
+ return START_NOT_STICKY;
+ }
+
PowerManager.WakeLock lock = getLock(this.getApplicationContext());
if (!lock.isHeld()) {
lock.acquire();
}
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Got install/uninstall request " + intent);
+
+ Bundle intentBundle = intent.getExtras();
+ if (intentBundle == null) {
+ intentBundle = new Bundle();
}
- if (intent != null) {
- Bundle intentBundle = intent.getExtras();
- WearPackageArgs.setStartId(intentBundle, startId);
- if (Intent.ACTION_INSTALL_PACKAGE.equals(intent.getAction())) {
- final Message msg = mServiceHandler.obtainMessage(START_INSTALL);
- WearPackageArgs.setAssetUri(intentBundle, intent.getData());
- msg.setData(intentBundle);
- mServiceHandler.sendMessage(msg);
- } else if (Intent.ACTION_UNINSTALL_PACKAGE.equals(intent.getAction())) {
- Message msg = mServiceHandler.obtainMessage(START_UNINSTALL);
- msg.setData(intentBundle);
- mServiceHandler.sendMessage(msg);
- }
+ WearPackageArgs.setStartId(intentBundle, startId);
+ WearPackageArgs.setPackageName(intentBundle, packageName);
+ if (Intent.ACTION_INSTALL_PACKAGE.equals(intent.getAction())) {
+ Message msg = mServiceHandler.obtainMessage(START_INSTALL);
+ msg.setData(intentBundle);
+ mServiceHandler.sendMessage(msg);
+ } else if (Intent.ACTION_UNINSTALL_PACKAGE.equals(intent.getAction())) {
+ Message msg = mServiceHandler.obtainMessage(START_UNINSTALL);
+ msg.setData(intentBundle);
+ mServiceHandler.sendMessage(msg);
}
return START_NOT_STICKY;
}
diff --git a/src/com/android/packageinstaller/wear/WearPackageUtil.java b/src/com/android/packageinstaller/wear/WearPackageUtil.java
index 688d616..c351277 100644
--- a/src/com/android/packageinstaller/wear/WearPackageUtil.java
+++ b/src/com/android/packageinstaller/wear/WearPackageUtil.java
@@ -21,6 +21,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageParser;
+import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
@@ -164,4 +165,16 @@ public class WearPackageUtil {
+ " for " + wearablePackageName);
context.startService(newIntent);
}
+
+ /**
+ * @return com.google.com from expected formats like
+ * Uri: package:com.google.com, package:/com.google.com, package://com.google.com
+ */
+ public static String getSanitizedPackageName(Uri packageUri) {
+ String packageName = packageUri.getEncodedSchemeSpecificPart();
+ if (packageName != null) {
+ return packageName.replaceAll("^/+", "");
+ }
+ return packageName;
+ }
}